[rtems commit] or1k fix bug: Initialize thread context with higher stack address.

Joel Sherrill joel at rtems.org
Mon Sep 29 19:28:38 UTC 2014


Module:    rtems
Branch:    master
Commit:    5464752f79983a84d81ba9022da1ee588a2f839c
Changeset: http://git.rtems.org/rtems/commit/?id=5464752f79983a84d81ba9022da1ee588a2f839c

Author:    Hesham ALMatary <heshamelmatary at gmail.com>
Date:      Fri Sep 19 09:55:09 2014 -0500

or1k fix bug: Initialize thread context with higher stack address.

Since or1k architecture stack grows down, threads should be initialized
with high stack addresses instead of lower ones. This is done in
_CPU_Context_Initialize function.

---

 cpukit/score/cpu/or1k/or1k-context-initialize.c |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/cpukit/score/cpu/or1k/or1k-context-initialize.c b/cpukit/score/cpu/or1k/or1k-context-initialize.c
index 1c9cdd7..a7205e3 100644
--- a/cpukit/score/cpu/or1k/or1k-context-initialize.c
+++ b/cpukit/score/cpu/or1k/or1k-context-initialize.c
@@ -32,13 +32,14 @@ void _CPU_Context_Initialize(
   /* Decrement 200 byte to account for red-zone */
   uint32_t stack = ((uint32_t) stack_area_begin) - 200;
   uint32_t sr;
+  uint32_t stack_high = stack + stack_area_size;
 
   sr = _OR1K_mfspr(CPU_OR1K_SPR_SR);
 
   memset(context, 0, sizeof(*context));
 
-  context->r1 = stack;
-  context->r2 = stack;
+  context->r1 = stack_high;
+  context->r2 = stack_high;
   context->r9 = (uint32_t) entry_point;
   context->sr = sr;
 }



More information about the vc mailing list