diff options
author | Keith Packard <keithp@keithp.com> | 2013-04-30 19:04:26 -0700 |
---|---|---|
committer | Keith Packard <keithp@keithp.com> | 2013-04-30 19:04:26 -0700 |
commit | 38d7a68d9edf1e8ea6e7ed72b41705a2a5882435 (patch) | |
tree | fc460bc23991f4275de7a3f8a7b723dcb31fdbe1 /src/stm/ao_arch_funcs.h | |
parent | 9fad3457a4977158697eeca8b6ea7516cc59a6c8 (diff) |
altos: Use separate exception stack on STM32L
This reserves 512 bytes of memory for a stack, then makes sure that
exceptions continue to use that stack while processes use the per-task
stack.
Signed-off-by: Keith Packard <keithp@keithp.com>
Diffstat (limited to 'src/stm/ao_arch_funcs.h')
-rw-r--r-- | src/stm/ao_arch_funcs.h | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/stm/ao_arch_funcs.h b/src/stm/ao_arch_funcs.h index e152440a..0d63b396 100644 --- a/src/stm/ao_arch_funcs.h +++ b/src/stm/ao_arch_funcs.h @@ -334,6 +334,20 @@ static inline void ao_arch_restore_stack(void) { /* Return to calling function */ asm("bx lr"); } + +#define HAS_ARCH_START_SCHEDULER 1 + +static inline void ao_arch_start_scheduler(void) { + uint32_t sp; + uint32_t control; + + asm("mrs %0,msp" : "=&r" (sp)); + asm("msr psp,%0" : : "r" (sp)); + asm("mrs %0,control" : "=&r" (control)); + control |= (1 << 1); + asm("msr control,%0" : : "r" (control)); +} + #endif #define ao_arch_isr_stack() |