diff --git a/src/arch/x86/c_start.S b/src/arch/x86/c_start.S index 3ef03b3346..34ed4e3665 100644 --- a/src/arch/x86/c_start.S +++ b/src/arch/x86/c_start.S @@ -17,11 +17,6 @@ _stack: .space (CONFIG_MAX_CPUS+1)*CONFIG_STACK_SIZE _estack: .set _stack_size, _estack - _stack -#if CONFIG(COOP_MULTITASKING) -.global thread_stacks -thread_stacks: -.space CONFIG_STACK_SIZE*CONFIG_NUM_THREADS -#endif .section ".text._start", "ax", @progbits #if ENV_X86_64 diff --git a/src/arch/x86/thread.c b/src/arch/x86/thread.c index 3d12bf8d5c..a9fda66245 100644 --- a/src/arch/x86/thread.c +++ b/src/arch/x86/thread.c @@ -39,10 +39,3 @@ void arch_prepare_thread(struct thread *t, t->stack_current = stack; } - -void *arch_get_thread_stackbase(void) -{ - /* defined in c_start.S */ - extern u8 thread_stacks[]; - return &thread_stacks[0]; -} diff --git a/src/include/thread.h b/src/include/thread.h index fed0bfb964..ce250b8520 100644 --- a/src/include/thread.h +++ b/src/include/thread.h @@ -52,11 +52,6 @@ struct thread { }; void threads_initialize(void); -/* Get the base of the thread stacks. - * Returns pointer to CONFIG_NUM_THREADS*CONFIG_STACK_SIZE contiguous bytes - * aligned to CONFIG_STACK_SIZE, or NULL. - */ -void *arch_get_thread_stackbase(void); /* Return 0 on successful yield, < 0 when thread did not yield. */ int thread_yield(void); diff --git a/src/lib/thread.c b/src/lib/thread.c index 262cfa53bd..413e5b4bec 100644 --- a/src/lib/thread.c +++ b/src/lib/thread.c @@ -15,6 +15,12 @@ _Static_assert((CONFIG_STACK_SIZE & (CONFIG_STACK_SIZE - 1)) == 0, "`cpu_info()` requires the stack size to be a power of 2"); +/* + * struct cpu_info lives at the top of each thread's stack. `cpu_info()` locates this struct by + * taking the current stack pointer and masking off CONFIG_STACK_SIZE. This requires the stack + * to be STACK_SIZE aligned. + */ +static u8 thread_stacks[CONFIG_STACK_SIZE * CONFIG_NUM_THREADS] __aligned(CONFIG_STACK_SIZE); static bool initialized; static void idle_thread_init(void); @@ -257,9 +263,6 @@ void threads_initialize(void) struct thread *t; u8 *stack_top; struct cpu_info *ci; - u8 *thread_stacks; - - thread_stacks = arch_get_thread_stackbase(); /* `cpu_info()` requires the stacks to be STACK_SIZE aligned */ assert(IS_ALIGNED((uintptr_t)thread_stacks, CONFIG_STACK_SIZE));