From d6c3c3618a708d2a1a7948454710e6ae21c2a426 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Mon, 4 Feb 2019 22:38:23 -0800 Subject: altos: Declare task stack as union of uint8_t and uint32_t Support -Wcast-align and -Wpointer-arith while still allowing architectures to pick whether they want an 8-bit or 32-bit stack. Signed-off-by: Keith Packard --- src/lpc/ao_arch.h | 3 --- src/lpc/ao_arch_funcs.h | 13 +++++-------- 2 files changed, 5 insertions(+), 11 deletions(-) (limited to 'src/lpc') diff --git a/src/lpc/ao_arch.h b/src/lpc/ao_arch.h index 35dcc9de..7821839e 100644 --- a/src/lpc/ao_arch.h +++ b/src/lpc/ao_arch.h @@ -60,9 +60,6 @@ #define AO_ROMCONFIG_SYMBOL __attribute__((section(".romconfig"))) const -#define ao_arch_task_members\ - uint32_t *sp; /* saved stack pointer */ - #define ao_arch_block_interrupts() asm("cpsid i") #define ao_arch_release_interrupts() asm("cpsie i") diff --git a/src/lpc/ao_arch_funcs.h b/src/lpc/ao_arch_funcs.h index 345108ae..1368f7e5 100644 --- a/src/lpc/ao_arch_funcs.h +++ b/src/lpc/ao_arch_funcs.h @@ -109,7 +109,7 @@ ao_arch_memory_barrier(void) { static inline void ao_arch_init_stack(struct ao_task *task, void *start) { - uint32_t *sp = (uint32_t *) (void *) (task->stack + AO_STACK_SIZE); + uint32_t *sp = &task->stack32[AO_STACK_SIZE >> 2]; uint32_t a = (uint32_t) start; int i; @@ -127,7 +127,7 @@ ao_arch_init_stack(struct ao_task *task, void *start) /* PRIMASK with interrupts enabled */ ARM_PUSH32(sp, 0); - task->sp = sp; + task->sp32 = sp; } static inline void ao_arch_save_regs(void) { @@ -146,17 +146,14 @@ static inline void ao_arch_save_regs(void) { static inline void ao_arch_save_stack(void) { uint32_t *sp; asm("mov %0,sp" : "=&r" (sp) ); - ao_cur_task->sp = (sp); - if ((uint8_t *) sp < &ao_cur_task->stack[0]) + ao_cur_task->sp32 = (sp); + if (sp < &ao_cur_task->stack32[0]) ao_panic (AO_PANIC_STACK); } static inline void ao_arch_restore_stack(void) { - uint32_t sp; - sp = (uint32_t) ao_cur_task->sp; - /* Switch stacks */ - asm("mov sp, %0" : : "r" (sp) ); + asm("mov sp, %0" : : "r" (ao_cur_task->sp32) ); /* Restore PRIMASK */ asm("pop {r0}"); -- cgit v1.2.3