kernel: Refactor common _new_thread init code

We do a bit of the same stuff on all the arch's to setup a new thread.
So lets put that code in a common place so we unify it for everyone and
reduce some duplicated code.

Change-Id: Ic04121bfd6846aece16aa7ffd4382bdcdb6136e3
Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
This commit is contained in:
Kumar Gala 2017-04-21 09:07:34 -05:00 committed by Andrew Boie
commit b8823c4efd
7 changed files with 44 additions and 95 deletions

View file

@ -83,9 +83,7 @@ void _new_thread(char *pStackMem, size_t stackSize,
struct __esf *pInitCtx;
struct k_thread *thread = (struct k_thread *) pStackMem;
#ifdef CONFIG_INIT_STACKS
memset(pStackMem, 0xaa, stackSize);
#endif
thread = _new_thread_init(pStackMem, stackSize, priority, options);
/* carve the thread entry struct from the "base" of the stack */
@ -100,18 +98,6 @@ void _new_thread(char *pStackMem, size_t stackSize,
pInitCtx->xpsr =
0x01000000UL; /* clear all, thumb bit is 1, even if RO */
_init_thread_base(&thread->base, priority, _THREAD_PRESTART, options);
/* static threads overwrite it afterwards with real value */
thread->init_data = NULL;
thread->fn_abort = NULL;
#ifdef CONFIG_THREAD_CUSTOM_DATA
/* Initialize custom data field (value is opaque to kernel) */
thread->custom_data = NULL;
#endif
#ifdef CONFIG_THREAD_MONITOR
/*
* In debug mode thread->entry give direct access to the thread entry