* \author Andrea Righi <arighi@develer.com>
*/
+#define CONTROL_UNPRIVILEGED 1
+#define CONTROL_PSP 2
+
.syntax unified
.thumb
.section .init, "ax", %progbits
__init0:
/* Disable IRQs */
cpsid i
+ /*
+ * Initialize process stack pointer.
+ */
+ ldr r0, =__psp_end
+ msr psp, r0
/* Call the early hardware initialization routine */
bl __init1
strlo r0, [r1], #4
blo bss_loop
+ /* Switch to the process stack */
+ movs r0, CONTROL_PSP
+ msr control, r0
+ isb
+
/* Call the hardware initialization routine */
bl __init2
/* Call the application's entry point */
+ cpsie i
+ mov r0, #0
+ mov r1, #0
bl main
end:
wfi
* \author Andrea Righi <arighi@develer.com>
*/
+#include <cfg/cfg_proc.h>
+
.syntax unified
+#if !CONFIG_KERN_PREEMPT
/* void asm_switch_context(void **new_sp [r0], void **save_sp [r1]) */
.global asm_switch_context
.thumb_func
asm_switch_context:
- mrs r12, msp
+ mrs ip, psp
/* Save registers */
- stmdb r12!, {r4-r11, lr}
+ stmdb ip!, {r4-r11, lr}
/* Save old stack pointer */
- str r12, [r1]
+ str ip, [r1]
/* Load new stack pointer */
- ldr r12, [r0]
+ ldr ip, [r0]
/* Load new registers */
- ldmia r12!, {r4-r11, lr}
- msr msp, r12
+ ldmia ip!, {r4-r11, lr}
+ msr psp, ip
bx lr
+#endif /* CONFIG_KERN_PREEMPT */
/*
* Define stack size here
*/
-MAIN_STACK_SIZE = 0x0400;
+STACK_SIZE = 0x1000;
/*
* Allocate section memory
* Allocated stack at the end of bss section.
* Data heap is allocate at end of stack.
*/
- PROVIDE (__stack_start = .);
+ PROVIDE (__msp_start = .);
. = ALIGN(4);
- . += MAIN_STACK_SIZE;
- PROVIDE (__stack_end = .);
+ . += STACK_SIZE;
+ PROVIDE (__msp_end = .);
+
+ PROVIDE (__psp_start = .);
+ . = ALIGN(4);
+ . += STACK_SIZE;
+ PROVIDE (__psp_end = .);
PROVIDE (__heap_start = .);
. = ALIGN(4);