arch_interface: remove unnecessary params

arch_new_thread() passes along the thread priority and option
flags, but these are already initialized in thread->base and
can be accessed there if needed.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
This commit is contained in:
Andrew Boie 2020-04-23 11:17:14 -07:00 committed by Anas Nashif
commit 62eb7d99dc
11 changed files with 20 additions and 36 deletions

View file

@ -45,23 +45,18 @@ struct init_stack_frame {
* z_thread_entry() return address, that points at z_thread_entry() * z_thread_entry() return address, that points at z_thread_entry()
* and status register. * and status register.
* *
* <options> is currently unused.
*
* @param pStackmem the pointer to aligned stack memory * @param pStackmem the pointer to aligned stack memory
* @param stackSize the stack size in bytes * @param stackSize the stack size in bytes
* @param pEntry thread entry point routine * @param pEntry thread entry point routine
* @param parameter1 first param to entry point * @param parameter1 first param to entry point
* @param parameter2 second param to entry point * @param parameter2 second param to entry point
* @param parameter3 third param to entry point * @param parameter3 third param to entry point
* @param priority thread priority
* @param options thread options: K_ESSENTIAL
* *
* @return N/A * @return N/A
*/ */
void arch_new_thread(struct k_thread *thread, k_thread_stack_t *stack, void arch_new_thread(struct k_thread *thread, k_thread_stack_t *stack,
size_t stackSize, k_thread_entry_t pEntry, size_t stackSize, k_thread_entry_t pEntry,
void *parameter1, void *parameter2, void *parameter3, void *parameter1, void *parameter2, void *parameter3)
int priority, unsigned int options)
{ {
char *pStackMem = Z_THREAD_STACK_BUFFER(stack); char *pStackMem = Z_THREAD_STACK_BUFFER(stack);
@ -73,6 +68,7 @@ void arch_new_thread(struct k_thread *thread, k_thread_stack_t *stack,
size_t stackAdjSize; size_t stackAdjSize;
size_t offset = 0; size_t offset = 0;
bool is_user = (thread->base.user_options & K_USER) != 0;
stackAdjSize = Z_ARC_MPU_SIZE_ALIGN(stackSize); stackAdjSize = Z_ARC_MPU_SIZE_ALIGN(stackSize);
@ -83,7 +79,7 @@ void arch_new_thread(struct k_thread *thread, k_thread_stack_t *stack,
offset = stackAdjSize - stackSize; offset = stackAdjSize - stackSize;
#endif #endif
if (options & K_USER) { if (is_user) {
#ifdef CONFIG_GEN_PRIV_STACKS #ifdef CONFIG_GEN_PRIV_STACKS
thread->arch.priv_stack_start = thread->arch.priv_stack_start =
(uint32_t)z_priv_stack_find(thread->stack_obj); (uint32_t)z_priv_stack_find(thread->stack_obj);
@ -138,7 +134,7 @@ void arch_new_thread(struct k_thread *thread, k_thread_stack_t *stack,
/* fill init context */ /* fill init context */
pInitCtx->status32 = 0U; pInitCtx->status32 = 0U;
if (options & K_USER) { if (is_user) {
pInitCtx->pc = ((uint32_t)z_user_thread_entry_wrapper); pInitCtx->pc = ((uint32_t)z_user_thread_entry_wrapper);
} else { } else {
pInitCtx->pc = ((uint32_t)z_thread_entry_wrapper); pInitCtx->pc = ((uint32_t)z_thread_entry_wrapper);
@ -185,7 +181,7 @@ void arch_new_thread(struct k_thread *thread, k_thread_stack_t *stack,
pInitCtx->status32 |= _ARC_V2_STATUS32_SC; pInitCtx->status32 |= _ARC_V2_STATUS32_SC;
#endif #endif
#ifdef CONFIG_USERSPACE #ifdef CONFIG_USERSPACE
if (options & K_USER) { if (is_user) {
thread->arch.u_stack_top = (uint32_t)pStackMem; thread->arch.u_stack_top = (uint32_t)pStackMem;
thread->arch.u_stack_base = (uint32_t)stackEnd; thread->arch.u_stack_base = (uint32_t)stackEnd;
thread->arch.k_stack_top = thread->arch.k_stack_top =

View file

@ -30,8 +30,7 @@
*/ */
void arch_new_thread(struct k_thread *thread, k_thread_stack_t *stack, void arch_new_thread(struct k_thread *thread, k_thread_stack_t *stack,
size_t stackSize, k_thread_entry_t pEntry, size_t stackSize, k_thread_entry_t pEntry,
void *parameter1, void *parameter2, void *parameter3, void *parameter1, void *parameter2, void *parameter3)
int priority, unsigned int options)
{ {
char *pStackMem = Z_THREAD_STACK_BUFFER(stack); char *pStackMem = Z_THREAD_STACK_BUFFER(stack);
char *stackEnd; char *stackEnd;
@ -81,7 +80,7 @@ void arch_new_thread(struct k_thread *thread, k_thread_stack_t *stack,
* .start and .size. * .start and .size.
* *
*/ */
if ((options & K_FP_REGS) != 0) { if ((thread->base.user_options & K_FP_REGS) != 0) {
pStackMem += MPU_GUARD_ALIGN_AND_SIZE_FLOAT pStackMem += MPU_GUARD_ALIGN_AND_SIZE_FLOAT
- MPU_GUARD_ALIGN_AND_SIZE; - MPU_GUARD_ALIGN_AND_SIZE;
stackSize -= MPU_GUARD_ALIGN_AND_SIZE_FLOAT stackSize -= MPU_GUARD_ALIGN_AND_SIZE_FLOAT
@ -104,7 +103,7 @@ void arch_new_thread(struct k_thread *thread, k_thread_stack_t *stack,
(char *)top_of_stack_offset - sizeof(struct __basic_sf))); (char *)top_of_stack_offset - sizeof(struct __basic_sf)));
#if defined(CONFIG_USERSPACE) #if defined(CONFIG_USERSPACE)
if ((options & K_USER) != 0) { if ((thread->base.user_options & K_USER) != 0) {
pInitCtx->basic.pc = (uint32_t)arch_user_mode_enter; pInitCtx->basic.pc = (uint32_t)arch_user_mode_enter;
} else { } else {
pInitCtx->basic.pc = (uint32_t)z_thread_entry; pInitCtx->basic.pc = (uint32_t)z_thread_entry;

View file

@ -33,8 +33,6 @@
* @param parameter1 entry point to the first param * @param parameter1 entry point to the first param
* @param parameter2 entry point to the second param * @param parameter2 entry point to the second param
* @param parameter3 entry point to the third param * @param parameter3 entry point to the third param
* @param priority thread priority
* @param options thread options: K_ESSENTIAL, K_FP_REGS
* *
* @return N/A * @return N/A
*/ */
@ -62,8 +60,7 @@ struct init_stack_frame {
void arch_new_thread(struct k_thread *thread, k_thread_stack_t *stack, void arch_new_thread(struct k_thread *thread, k_thread_stack_t *stack,
size_t stackSize, k_thread_entry_t pEntry, size_t stackSize, k_thread_entry_t pEntry,
void *parameter1, void *parameter2, void *parameter3, void *parameter1, void *parameter2, void *parameter3)
int priority, unsigned int options)
{ {
char *pStackMem = Z_THREAD_STACK_BUFFER(stack); char *pStackMem = Z_THREAD_STACK_BUFFER(stack);
char *stackEnd; char *stackEnd;

View file

@ -30,8 +30,7 @@ struct init_stack_frame {
void arch_new_thread(struct k_thread *thread, k_thread_stack_t *stack, void arch_new_thread(struct k_thread *thread, k_thread_stack_t *stack,
size_t stack_size, k_thread_entry_t thread_func, size_t stack_size, k_thread_entry_t thread_func,
void *arg1, void *arg2, void *arg3, void *arg1, void *arg2, void *arg3)
int priority, unsigned int options)
{ {
char *stack_memory = Z_THREAD_STACK_BUFFER(stack); char *stack_memory = Z_THREAD_STACK_BUFFER(stack);
struct init_stack_frame *iframe; struct init_stack_frame *iframe;

View file

@ -26,8 +26,7 @@
*/ */
void arch_new_thread(struct k_thread *thread, k_thread_stack_t *stack, void arch_new_thread(struct k_thread *thread, k_thread_stack_t *stack,
size_t stack_size, k_thread_entry_t thread_func, size_t stack_size, k_thread_entry_t thread_func,
void *arg1, void *arg2, void *arg3, void *arg1, void *arg2, void *arg3)
int priority, unsigned int options)
{ {
char *stack_memory = Z_THREAD_STACK_BUFFER(stack); char *stack_memory = Z_THREAD_STACK_BUFFER(stack);

View file

@ -14,8 +14,7 @@ void z_thread_entry_wrapper(k_thread_entry_t thread,
void arch_new_thread(struct k_thread *thread, k_thread_stack_t *stack, void arch_new_thread(struct k_thread *thread, k_thread_stack_t *stack,
size_t stack_size, k_thread_entry_t thread_func, size_t stack_size, k_thread_entry_t thread_func,
void *arg1, void *arg2, void *arg3, void *arg1, void *arg2, void *arg3)
int priority, unsigned int options)
{ {
char *stack_memory = Z_THREAD_STACK_BUFFER(stack); char *stack_memory = Z_THREAD_STACK_BUFFER(stack);

View file

@ -62,8 +62,7 @@ int arch_float_disable(struct k_thread *thread)
void arch_new_thread(struct k_thread *thread, k_thread_stack_t *stack, void arch_new_thread(struct k_thread *thread, k_thread_stack_t *stack,
size_t stack_size, k_thread_entry_t entry, size_t stack_size, k_thread_entry_t entry,
void *parameter1, void *parameter2, void *parameter3, void *parameter1, void *parameter2, void *parameter3)
int priority, unsigned int options)
{ {
char *stack_buf; char *stack_buf;
char *stack_high; char *stack_high;

View file

@ -13,8 +13,7 @@ extern void x86_sse_init(struct k_thread *); /* in locore.S */
void arch_new_thread(struct k_thread *thread, k_thread_stack_t *stack, void arch_new_thread(struct k_thread *thread, k_thread_stack_t *stack,
size_t stack_size, k_thread_entry_t entry, size_t stack_size, k_thread_entry_t entry,
void *parameter1, void *parameter2, void *parameter3, void *parameter1, void *parameter2, void *parameter3)
int priority, unsigned int options)
{ {
void *switch_entry; void *switch_entry;

View file

@ -58,8 +58,7 @@ void *xtensa_init_stack(int *stack_top,
void arch_new_thread(struct k_thread *thread, k_thread_stack_t *stack, void arch_new_thread(struct k_thread *thread, k_thread_stack_t *stack,
size_t sz, k_thread_entry_t entry, size_t sz, k_thread_entry_t entry,
void *p1, void *p2, void *p3, void *p1, void *p2, void *p3)
int prio, unsigned int opts)
{ {
char *base = Z_THREAD_STACK_BUFFER(stack); char *base = Z_THREAD_STACK_BUFFER(stack);
char *top = base + sz; char *top = base + sz;

View file

@ -58,6 +58,8 @@ void arch_busy_wait(uint32_t usec_to_wait);
* be called with the true bounds of the available stack buffer within the * be called with the true bounds of the available stack buffer within the
* thread's stack object. * thread's stack object.
* *
* Fields in thread->base will be initialized when this is called.
*
* @param thread Pointer to uninitialized struct k_thread * @param thread Pointer to uninitialized struct k_thread
* @param pStack Pointer to the stack space. * @param pStack Pointer to the stack space.
* @param stackSize Stack size in bytes. * @param stackSize Stack size in bytes.
@ -65,13 +67,10 @@ void arch_busy_wait(uint32_t usec_to_wait);
* @param p1 1st entry point parameter. * @param p1 1st entry point parameter.
* @param p2 2nd entry point parameter. * @param p2 2nd entry point parameter.
* @param p3 3rd entry point parameter. * @param p3 3rd entry point parameter.
* @param prio Thread priority.
* @param options Thread options.
*/ */
void arch_new_thread(struct k_thread *thread, k_thread_stack_t *pStack, void arch_new_thread(struct k_thread *thread, k_thread_stack_t *pStack,
size_t stackSize, k_thread_entry_t entry, size_t stackSize, k_thread_entry_t entry,
void *p1, void *p2, void *p3, void *p1, void *p2, void *p3);
int prio, unsigned int options);
#ifdef CONFIG_USE_SWITCH #ifdef CONFIG_USE_SWITCH
/** /**

View file

@ -484,8 +484,7 @@ void z_setup_new_thread(struct k_thread *new_thread,
/* Initialize various struct k_thread members */ /* Initialize various struct k_thread members */
z_init_thread_base(&new_thread->base, prio, _THREAD_PRESTART, options); z_init_thread_base(&new_thread->base, prio, _THREAD_PRESTART, options);
arch_new_thread(new_thread, stack, stack_size, entry, p1, p2, p3, arch_new_thread(new_thread, stack, stack_size, entry, p1, p2, p3);
prio, options);
/* static threads overwrite it afterwards with real value */ /* static threads overwrite it afterwards with real value */
new_thread->init_data = NULL; new_thread->init_data = NULL;
new_thread->fn_abort = NULL; new_thread->fn_abort = NULL;