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

Hesham ALMatary heshamelmatary at gmail.com
Fri Sep 19 14:55:09 UTC 2014


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 file 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;
 }
-- 
1.9.3



More information about the devel mailing list