Optimization: Use a trampoline to start ARM processes instead of wasting one stack...
[bertos.git] / bertos / cpu / frame.h
index 2244b3b1bf85a243ca1d1f407a365fd1bc99cf24..8cb7a813d5a2192c9afe1c47dda4616042008ed4 100644 (file)
@@ -62,6 +62,8 @@
        #define CPU_STACK_GROWS_UPWARD 0
        #define CPU_SP_ON_EMPTY_SLOT   0
 
+
+       EXTERN_C void asm_proc_entry(void);
        /**
         * Initialization value for registers in stack frame.
         * For the CPSR register, the initial value is set to:
         */
        #define CPU_CREATE_NEW_STACK(stack, entry, exit) \
        do { \
-               /* Process entry point */ \
+               /* LR (asm proc_entry trampoline) */ \
+               CPU_PUSH_CALL_FRAME(stack, asm_proc_entry); \
+               /* R11 (Process entry point) DO NOT CHANGE: asm_proc_entry expects \
+                * to find the actual process entry point in R11 */ \
                CPU_PUSH_CALL_FRAME(stack, entry); \
-               /* LR (proc_exit) */ \
-               CPU_PUSH_CALL_FRAME(stack, exit); \
-               /* R11 */ \
-               CPU_PUSH_WORD(stack, 0x11111111); \
                /* R10 */ \
                CPU_PUSH_WORD(stack, 0x10101010); \
                /* R9 */ \
 
 /**
  * Default macro for creating a new Process stack
- */ 
+ */
 #ifndef CPU_CREATE_NEW_STACK
 
        #define CPU_CREATE_NEW_STACK(stack, entry, exit) \