summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--c/src/lib/libbsp/or1k/or1ksim/start/start.S2
-rw-r--r--cpukit/score/cpu/or1k/or1k-context-initialize.c3
-rw-r--r--cpukit/score/cpu/or1k/or1k-exception-handler-low.S38
3 files changed, 23 insertions, 20 deletions
diff --git a/c/src/lib/libbsp/or1k/or1ksim/start/start.S b/c/src/lib/libbsp/or1k/or1ksim/start/start.S
index 6942b5217f..4d911d4a41 100644
--- a/c/src/lib/libbsp/or1k/or1ksim/start/start.S
+++ b/c/src/lib/libbsp/or1k/or1ksim/start/start.S
@@ -16,7 +16,7 @@
*/
#define EXCEPTION_SETUP(vector) \
l.nop ;\
- l.addi r1, r1, -4 ;\
+ l.addi r1, r1, -200 ;\
l.sw 0(r1), r3; \
l.addi r3, r0, vector; \
l.j _ISR_Handler; \
diff --git a/cpukit/score/cpu/or1k/or1k-context-initialize.c b/cpukit/score/cpu/or1k/or1k-context-initialize.c
index 7ac2875ce7..1c9cdd7b5e 100644
--- a/cpukit/score/cpu/or1k/or1k-context-initialize.c
+++ b/cpukit/score/cpu/or1k/or1k-context-initialize.c
@@ -29,7 +29,8 @@ void _CPU_Context_Initialize(
void *tls_area
)
{
- uint32_t stack = (uint32_t) stack_area_begin;
+ /* Decrement 200 byte to account for red-zone */
+ uint32_t stack = ((uint32_t) stack_area_begin) - 200;
uint32_t sr;
sr = _OR1K_mfspr(CPU_OR1K_SPR_SR);
diff --git a/cpukit/score/cpu/or1k/or1k-exception-handler-low.S b/cpukit/score/cpu/or1k/or1k-exception-handler-low.S
index 7108ff65b5..3a0425b6d5 100644
--- a/cpukit/score/cpu/or1k/or1k-exception-handler-low.S
+++ b/cpukit/score/cpu/or1k/or1k-exception-handler-low.S
@@ -93,7 +93,7 @@ PUBLIC(_ISR_Handler)
l.sw 0(r8), r7
/* Save interrupted task stack pointer */
- l.addi r4, r1, 144
+ l.addi r4, r1, 340
l.sw 4(r1), r4
/* Save interrupted task r3 (first arg) value */
@@ -118,7 +118,7 @@ PUBLIC(_ISR_Handler)
/* Do not switch stacks if we are in a nested interrupt. At
* this point r5 should be holding ISR_NEST_LEVEL value.
*/
- l.sfgtui r5, 2
+ l.sfgtui r5, 1
l.bf jump_to_c_handler
l.nop
@@ -134,6 +134,21 @@ jump_to_c_handler:
/* Switch back to the interrupted task stack */
l.add r1, r14, r0
+ /* Decrement nesting level */
+ l.movhi r6, hi(ISR_NEST_LEVEL)
+ l.ori r6, r6, lo(ISR_NEST_LEVEL)
+
+ /* Enable multitasking */
+ l.movhi r8, hi(THREAD_DISPATCH_DISABLE_LEVEL)
+ l.ori r8, r8, lo(THREAD_DISPATCH_DISABLE_LEVEL)
+
+ l.lwz r5, 0(r6)
+ l.lwz r7, 0(r8)
+ l.addi r5, r5, -1
+ l.addi r7, r7, -1
+ l.sw 0(r6), r5
+ l.sw 0(r8), r7
+
/* Check if dispatch needed */
l.movhi r31, hi(DISPATCH_NEEDED)
l.ori r31, r31, lo(DISPATCH_NEEDED)
@@ -163,21 +178,6 @@ jump_to_c_handler:
l.lwz r13, 136(r1)
l.mtspr r0, r13, CPU_OR1K_SPR_ESR0
- /* Increment nesting level */
- l.movhi r6, hi(ISR_NEST_LEVEL)
- l.ori r6, r6, lo(ISR_NEST_LEVEL)
-
- /* Disable multitasking */
- l.movhi r8, hi(THREAD_DISPATCH_DISABLE_LEVEL)
- l.ori r8, r8, lo(THREAD_DISPATCH_DISABLE_LEVEL)
-
- l.lwz r5, 0(r6)
- l.lwz r7, 0(r8)
- l.addi r5, r5, -1
- l.addi r7, r7, -1
- l.sw 0(r6), r5
- l.sw 0(r8), r7
-
l.lwz r2, 8(r1)
l.lwz r3, 12(r1)
l.lwz r4, 16(r1)
@@ -209,9 +209,11 @@ jump_to_c_handler:
l.lwz r30, 120(r1)
l.lwz r31, 124(r1)
+ /* Unwind exception frame */
l.addi r1, r1, 140
- l.addi r1, r1, 4
+ /* Red-zone */
+ l.addi r1, r1, 200
l.rfe
l.nop