diff options
-rw-r--r-- | src/arch/x86/lib/thread.c | 7 | ||||
-rw-r--r-- | src/include/thread.h | 5 | ||||
-rw-r--r-- | src/lib/thread.c | 6 |
3 files changed, 16 insertions, 2 deletions
diff --git a/src/arch/x86/lib/thread.c b/src/arch/x86/lib/thread.c index 06f8a154e2..b1549b5e32 100644 --- a/src/arch/x86/lib/thread.c +++ b/src/arch/x86/lib/thread.c @@ -56,3 +56,10 @@ 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 0522337429..306aad670b 100644 --- a/src/include/thread.h +++ b/src/include/thread.h @@ -38,6 +38,11 @@ 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); /* Run func(arrg) on a new thread. Return 0 on successful start of thread, < 0 * when thread could not be started. Note that the thread will block the * current state in the boot state machine until it is complete. */ diff --git a/src/lib/thread.c b/src/lib/thread.c index 6508bfad14..089ae3f04a 100644 --- a/src/lib/thread.c +++ b/src/lib/thread.c @@ -28,7 +28,6 @@ static void idle_thread_init(void); /* There needs to be at least one thread to run the ramstate state machine. */ #define TOTAL_NUM_THREADS (CONFIG_NUM_THREADS + 1) -extern char thread_stacks[CONFIG_NUM_THREADS*CONFIG_STACK_SIZE]; /* Storage space for the thread structs .*/ static struct thread all_threads[TOTAL_NUM_THREADS]; @@ -259,8 +258,11 @@ void threads_initialize(void) { int i; struct thread *t; - char *stack_top; + u8 *stack_top; struct cpu_info *ci; + u8 *thread_stacks; + + thread_stacks = arch_get_thread_stackbase(); /* Initialize the BSP thread first. The cpu_info structure is assumed * to be just under the top of the stack. */ |