X-Git-Url: https://codewiz.org/gitweb?a=blobdiff_plain;f=bertos%2Fcpu%2Fcortex-m3%2Fhw%2Fcrt_cm3.S;h=c23d83741c0ee16421a682da411a33adde718386;hb=b12629e93f75e4d8d0d750452d96d803f54489be;hp=a442bc59e0a07c12a665136c4778870140ecb5a6;hpb=a61181f8614fe8257dc21bf1762a380165932348;p=bertos.git diff --git a/bertos/cpu/cortex-m3/hw/crt_cm3.S b/bertos/cpu/cortex-m3/hw/crt_cm3.S index a442bc59..c23d8374 100644 --- a/bertos/cpu/cortex-m3/hw/crt_cm3.S +++ b/bertos/cpu/cortex-m3/hw/crt_cm3.S @@ -35,6 +35,9 @@ * \author Andrea Righi */ +#define CONTROL_UNPRIVILEGED 1 +#define CONTROL_PSP 2 + .syntax unified .thumb .section .init, "ax", %progbits @@ -61,6 +64,11 @@ __dummy_init: __init0: /* Disable IRQs */ cpsid i + /* + * Initialize process stack pointer. + */ + ldr r0, =__psp_end + msr psp, r0 /* Call the early hardware initialization routine */ bl __init1 @@ -86,10 +94,18 @@ bss_loop: 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