Optimization: Use a trampoline to start ARM processes instead of wasting one stack...
[bertos.git] / bertos / cpu / arm / hw / switch_ctx_arm.S
index bde843cda734cd14ed7066fcb69dfa096dc2c4b2..e610ac97c535073bb3cbbcc798299c792aaced57 100644 (file)
@@ -42,6 +42,7 @@
 .globl asm_switch_context
 asm_switch_context:
        mrs     r2, cpsr               /* Save status. */
+
        stmfd   sp!, {r2, r4-r11, lr}  /* Save registers. */
 
        str     sp, [r1]               /* Save old stack pointer. */
@@ -51,3 +52,14 @@ asm_switch_context:
        msr     cpsr, r2               /* restore flags reg. */
 
        mov     pc, lr
+
+
+/* proc_entry trampoline needed because ARM does not pop return addresses
+from the stack, but uses lr instead.*/
+.globl asm_proc_entry
+asm_proc_entry:
+       mov     lr, pc
+       /* In r11 we have the real process entry point as set up by CPU_CREATE_NEW_STACK */
+       bx      r11
+       bl      proc_exit
+