kernel: declare main and idle stack as globals

Renamed main_stack and idle_stack, to _main_stack and
_idle_stack, respectively, and made them globals. This does
not affect performance. They are still kept kernel private
symbols and not part of kernel API.

This will allow these symbols to be referenced in calls to
stack_analyse misc functions to profile stack usage in
applications.

Change-id: Id6b746c5cfda617c26901c6e62c3e17114471f57
Signed-off-by: Vinayak Chettimada <vinayak.kariappa.chettimada@nordicsemi.no>
This commit is contained in:
Vinayak Chettimada 2016-11-18 17:55:16 +01:00 committed by Anas Nashif
commit 09ba96d856

View file

@ -94,11 +94,11 @@ uint64_t __noinit __idle_tsc; /* timestamp when CPU goes idle */
#define MAIN_STACK_SIZE CONFIG_MAIN_STACK_SIZE
#endif
static char __noinit __stack main_stack[MAIN_STACK_SIZE];
static char __noinit __stack idle_stack[IDLE_STACK_SIZE];
char __noinit __stack _main_stack[MAIN_STACK_SIZE];
char __noinit __stack _idle_stack[IDLE_STACK_SIZE];
k_tid_t const _main_thread = (k_tid_t)main_stack;
k_tid_t const _idle_thread = (k_tid_t)idle_stack;
k_tid_t const _main_thread = (k_tid_t)_main_stack;
k_tid_t const _idle_thread = (k_tid_t)_idle_stack;
/*
* storage space for the interrupt stack
@ -281,13 +281,13 @@ static void prepare_multithreading(struct k_thread *dummy_thread)
sys_dlist_init(&_ready_q.q[ii]);
}
_new_thread(main_stack, MAIN_STACK_SIZE,
_new_thread(_main_stack, MAIN_STACK_SIZE,
_main, NULL, NULL, NULL,
CONFIG_MAIN_THREAD_PRIORITY, K_ESSENTIAL);
_mark_thread_as_started(_main_thread);
_add_thread_to_ready_q(_main_thread);
_new_thread(idle_stack, IDLE_STACK_SIZE,
_new_thread(_idle_stack, IDLE_STACK_SIZE,
idle, NULL, NULL, NULL,
K_LOWEST_THREAD_PRIO, K_ESSENTIAL);
_mark_thread_as_started(_idle_thread);
@ -303,7 +303,7 @@ static void prepare_multithreading(struct k_thread *dummy_thread)
static void switch_to_main_thread(void)
{
#ifdef CONFIG_ARCH_HAS_CUSTOM_SWAP_TO_MAIN
_arch_switch_to_main_thread(main_stack, MAIN_STACK_SIZE, _main);
_arch_switch_to_main_thread(_main_stack, MAIN_STACK_SIZE, _main);
#else
/*
* Context switch to main task (entry function is _main()): the