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,11 +83,9 @@ void _new_thread(char *pStackMem, size_t stackSize,
char *stackEnd = pStackMem + stackSize;
struct init_stack_frame *pInitCtx;
struct k_thread *thread = (struct k_thread *) pStackMem;
struct k_thread *thread;
#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 */
@ -113,18 +111,6 @@ void _new_thread(char *pStackMem, size_t stackSize,
pInitCtx->status32 = _ARC_V2_STATUS32_E(_ARC_V2_DEF_IRQ_LEVEL);
#endif
_init_thread_base(&thread->base, priority, _THREAD_PRESTART, options);
/* static threads overwrite them afterwards with real values */
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