diff --git a/arch/arc/core/context.c b/arch/arc/core/context.c index 773e918485f..ef9d97cd210 100644 --- a/arch/arc/core/context.c +++ b/arch/arc/core/context.c @@ -108,7 +108,7 @@ static ALWAYS_INLINE void context_monitor_init(struct s_CCS *pCcs /* context */ * RETURNS: N/A */ -void *_NewContext( +void _NewContext( char *pStackMem, /* pointer to aligned stack memory */ unsigned stackSize, /* stack size in bytes */ _ContextEntry pEntry, /* context (thread) entry point routine */ @@ -166,6 +166,4 @@ void *_NewContext( /* initial values in all other registers/CCS entries are irrelevant */ CONTEXT_MONITOR_INIT(pCcs); - - return pCcs; } diff --git a/arch/arc/include/nanok.h b/arch/arc/include/nanok.h index 4847f23d128..cd0d2c9f5ce 100644 --- a/arch/arc/include/nanok.h +++ b/arch/arc/include/nanok.h @@ -265,9 +265,9 @@ static ALWAYS_INLINE int _IS_IN_ISR(void) } extern void _insert_ccs(tCCS **, tCCS *); -extern void *_NewContext(char *, unsigned, _ContextEntry, - _ContextArg, _ContextArg, _ContextArg, - int, unsigned); +extern void _NewContext(char *, unsigned, _ContextEntry, + _ContextArg, _ContextArg, _ContextArg, + int, unsigned); extern unsigned int _Swap(unsigned int); extern void nanoCpuAtomicIdle(unsigned int); diff --git a/arch/arm/core/nanocontext.c b/arch/arm/core/nanocontext.c index c3781fa1af1..ec00f13d80f 100644 --- a/arch/arm/core/nanocontext.c +++ b/arch/arm/core/nanocontext.c @@ -102,7 +102,7 @@ static ALWAYS_INLINE void _context_monitor_init(struct s_CCS *pCcs /* context */ * RETURNS: N/A */ -void *_NewContext( +void _NewContext( char *pStackMem, /* aligned stack memory */ unsigned stackSize, /* stack size in bytes */ _ContextEntry pEntry, /* entry point */ @@ -146,6 +146,4 @@ void *_NewContext( /* initial values in all other registers/CCS entries are irrelevant */ CONTEXT_MONITOR_INIT(pCcs); - - return pCcs; } diff --git a/arch/arm/include/nanok.h b/arch/arm/include/nanok.h index 22f650752d0..5323f29b950 100644 --- a/arch/arm/include/nanok.h +++ b/arch/arm/include/nanok.h @@ -199,7 +199,7 @@ static ALWAYS_INLINE void fiberRtnValueSet( } extern void _insert_ccs(tCCS **, tCCS *); -extern void *_NewContext(char *, +extern void _NewContext(char *, unsigned, _ContextEntry, _ContextArg, diff --git a/arch/x86/core/nanocontext.c b/arch/x86/core/nanocontext.c index 0761a84d8c2..86b32466dce 100644 --- a/arch/x86/core/nanocontext.c +++ b/arch/x86/core/nanocontext.c @@ -75,7 +75,6 @@ void _ContextEntryWrapper(_ContextEntry, _ContextArg, _ContextArg, _ContextArg); */ static void _NewContextInternal( - tCCS *ccs, /* pointer to the new task's ccs */ char *pStackMem, /* pointer to context stack memory */ unsigned stackSize, /* size of stack in bytes */ int priority, /* context priority */ @@ -83,6 +82,7 @@ static void _NewContextInternal( ) { unsigned long *pInitialCtx; + tCCS *ccs = (tCCS *) pStackMem; /* pointer to the new task's ccs */ #ifndef CONFIG_FP_SHARING ARG_UNUSED(options); @@ -288,7 +288,7 @@ __asm__("\t.globl _context_entry\n" * \NOMANUAL */ -void *_NewContext( +void _NewContext( char *pStackMem, /* pointer to aligned stack memory */ unsigned stackSize, /* size of stack in bytes */ _ContextEntry pEntry, /* context entry point function */ @@ -299,7 +299,6 @@ void *_NewContext( unsigned options /* context options: USE_FP, USE_SSE */ ) { - tCCS *ccs; unsigned long *pInitialContext; /* carve the context entry struct from the "base" of the stack */ @@ -354,10 +353,5 @@ void *_NewContext( * stack */ - ccs = (tCCS *) pStackMem; - - _NewContextInternal(ccs, pStackMem, stackSize, priority, options); - - - return ((void *)ccs); + _NewContextInternal(pStackMem, stackSize, priority, options); } diff --git a/arch/x86/include/nanok.h b/arch/x86/include/nanok.h index 00ff5373a7f..8bf0140dcf9 100644 --- a/arch/x86/include/nanok.h +++ b/arch/x86/include/nanok.h @@ -865,7 +865,7 @@ extern void nano_cpu_atomic_idle(unsigned int imask); extern unsigned _Swap(unsigned int mask); extern void _insert_ccs(tCCS **queue, tCCS *ccs); -extern void *_NewContext(char *pStack, +extern void _NewContext(char *pStack, unsigned stackSize, _ContextEntry pEntry, _ContextArg arg1, diff --git a/kernel/microkernel/k_task.c b/kernel/microkernel/k_task.c index 09a0402862e..92ba6de3c27 100644 --- a/kernel/microkernel/k_task.c +++ b/kernel/microkernel/k_task.c @@ -205,7 +205,6 @@ void start_task(struct k_proc *X, /* ptr to task control block */ ) { unsigned int contextOptions; - void *pNewContext; /* Note: the field X->worksize now represents the task size in bytes */ @@ -225,17 +224,16 @@ void start_task(struct k_proc *X, /* ptr to task control block */ * the context is a task, rather than a fiber. */ - pNewContext = (tCCS *)_NewContext((char *)X->workspace, /* pStackMem */ - X->worksize, /* stackSize */ - (_ContextEntry)func, /* pEntry */ - (void *)0, /* parameter1 */ - (void *)0, /* parameter2 */ - (void *)0, /* parameter3 */ - -1, /* priority */ - contextOptions /* options */ - ); + _NewContext((char *)X->workspace, /* pStackMem */ + X->worksize, /* stackSize */ + (_ContextEntry)func, /* pEntry */ + (void *)0, /* parameter1 */ + (void *)0, /* parameter2 */ + (void *)0, /* parameter3 */ + -1, /* priority */ + contextOptions /* options */ + ); - X->workspace = (char *)pNewContext; X->fabort = NULL; reset_state_bit(X, TF_STOP | TF_TERM); diff --git a/kernel/nanokernel/nano_fiber.c b/kernel/nanokernel/nano_fiber.c index acbaadee35c..ad679fa3a30 100644 --- a/kernel/nanokernel/nano_fiber.c +++ b/kernel/nanokernel/nano_fiber.c @@ -83,7 +83,8 @@ void _fiber_start(char *pStack, memset((char *)pStack, 0xaa, stackSize); #endif - ccs = _NewContext((char *)pStack, + ccs = (tCCS *) pStack; + _NewContext(pStack, stackSize, (_ContextEntry)pEntry, (void *)parameter1, diff --git a/kernel/nanokernel/nano_init.c b/kernel/nanokernel/nano_init.c index 0e1004668d5..ec8ed293ddc 100644 --- a/kernel/nanokernel/nano_init.c +++ b/kernel/nanokernel/nano_init.c @@ -152,8 +152,9 @@ static void nano_init(tCCS *dummyOutContext) * (or idle task). The entry point for this context is 'main'. */ - _nanokernel.task = - _NewContext(main_task_stack, /* pStackMem */ + _nanokernel.task = (tCCS *) main_task_stack; + + _NewContext(main_task_stack, /* pStackMem */ CONFIG_MAIN_STACK_SIZE, /* stackSize */ (_ContextEntry)main, /* pEntry */ (_ContextArg)0, /* parameter1 */