diff options
| author | Keith Packard <keithp@keithp.com> | 2013-04-30 19:04:26 -0700 | 
|---|---|---|
| committer | Keith Packard <keithp@keithp.com> | 2013-05-07 20:08:00 -0700 | 
| commit | 1e9b405e939136d25d937334d1f14f06c7d6127b (patch) | |
| tree | 41231eaa27550b5a5f0fd43022c5a4ef3c37cb15 | |
| parent | ac72d1c298fc553808a8e04a65482d4990f177d7 (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>
| -rw-r--r-- | src/core/ao_task.c | 3 | ||||
| -rw-r--r-- | src/stm/altos.ld | 6 | ||||
| -rw-r--r-- | src/stm/ao_arch_funcs.h | 13 | 
3 files changed, 20 insertions, 2 deletions
| diff --git a/src/core/ao_task.c b/src/core/ao_task.c index 9cb074b5..c24c9929 100644 --- a/src/core/ao_task.c +++ b/src/core/ao_task.c @@ -536,5 +536,8 @@ ao_start_scheduler(void)  	ao_cur_task_index = AO_NO_TASK_INDEX;  #endif  	ao_cur_task = NULL; +#if HAS_ARCH_START_SCHEDULER +	ao_arch_start_scheduler(); +#endif  	ao_yield();  } diff --git a/src/stm/altos.ld b/src/stm/altos.ld index f78a45d6..d218e992 100644 --- a/src/stm/altos.ld +++ b/src/stm/altos.ld @@ -17,7 +17,8 @@  MEMORY {  	rom (rx) : ORIGIN = 0x08000000, LENGTH = 128K -	ram (!w) : ORIGIN = 0x20000000, LENGTH = 16K +	ram (!w) : ORIGIN = 0x20000000, LENGTH = 15872 +	stack (!w) : ORIGIN = 0x20003e00, LENGTH = 512  }  INCLUDE registers.ld @@ -63,8 +64,9 @@ SECTIONS {  		__bss_end__ = .;  	} >ram -	PROVIDE(__stack__ = ORIGIN(ram) + LENGTH(ram));  	PROVIDE(end = .); + +	PROVIDE(__stack__ = ORIGIN(stack) + LENGTH(stack));  }  ENTRY(start); diff --git a/src/stm/ao_arch_funcs.h b/src/stm/ao_arch_funcs.h index d1779307..f3d68202 100644 --- a/src/stm/ao_arch_funcs.h +++ b/src/stm/ao_arch_funcs.h @@ -317,6 +317,19 @@ static inline void ao_arch_restore_stack(void) {  	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)); +} +  #define ao_arch_isr_stack()  #define ao_arch_wait_interrupt() do {			\ | 
