Skip to content

Arch arm main thread init cleanup #16382

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 1 addition & 7 deletions arch/arm/include/kernel_arch_func.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,15 +74,9 @@ z_arch_switch_to_main_thread(struct k_thread *main_thread,
/* get high address of the stack, i.e. its start (stack grows down) */
char *start_of_main_stack;

#if defined(CONFIG_MPU_REQUIRES_POWER_OF_TWO_ALIGNMENT) && \
defined(CONFIG_USERSPACE)
start_of_main_stack =
Z_THREAD_STACK_BUFFER(main_stack) + main_stack_size -
MPU_GUARD_ALIGN_AND_SIZE;
#else
start_of_main_stack =
Z_THREAD_STACK_BUFFER(main_stack) + main_stack_size;
#endif

start_of_main_stack = (char *)STACK_ROUND_DOWN(start_of_main_stack);

#ifdef CONFIG_TRACING
Expand Down
9 changes: 4 additions & 5 deletions kernel/init.c
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ static void init_idle_thread(struct k_thread *thr, k_thread_stack_t *stack)
K_LOWEST_THREAD_PRIO, K_ESSENTIAL, IDLE_THREAD_NAME);
z_mark_thread_as_started(thr);
}
#endif
#endif /* CONFIG_MULTITHREADING */

/**
*
Expand Down Expand Up @@ -347,7 +347,7 @@ static void prepare_multithreading(struct k_thread *dummy_thread)
#ifdef CONFIG_USERSPACE
dummy_thread->mem_domain_info.mem_domain = 0;
#endif
#endif
#endif /* CONFIG_ARCH_HAS_CUSTOM_SWAP_TO_MAIN */

/* _kernel.ready_q is all zeroes */
z_sched_init();
Expand All @@ -374,11 +374,9 @@ static void prepare_multithreading(struct k_thread *dummy_thread)
z_mark_thread_as_started(_main_thread);
z_ready_thread(_main_thread);

#ifdef CONFIG_MULTITHREADING
init_idle_thread(_idle_thread, _idle_stack);
_kernel.cpus[0].idle_thread = _idle_thread;
sys_trace_thread_create(_idle_thread);
#endif

#if defined(CONFIG_SMP) && CONFIG_MP_NUM_CPUS > 1
init_idle_thread(_idle_thread1, _idle_stack1);
Expand Down Expand Up @@ -411,7 +409,8 @@ static void prepare_multithreading(struct k_thread *dummy_thread)
static void switch_to_main_thread(void)
{
#ifdef CONFIG_ARCH_HAS_CUSTOM_SWAP_TO_MAIN
z_arch_switch_to_main_thread(_main_thread, _main_stack, MAIN_STACK_SIZE,
z_arch_switch_to_main_thread(_main_thread, _main_stack,
K_THREAD_STACK_SIZEOF(_main_stack),
bg_thread_main);
#else
/*
Expand Down