arch/ceva: Move the idle stack initialization to up_initial_state

to follow other arch's implementation

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
This commit is contained in:
Xiang Xiao 2022-03-12 23:46:52 +08:00 committed by Petro Karashchenko
parent 4cc28882f9
commit f94093bc2e
6 changed files with 46 additions and 17 deletions

View File

@ -30,6 +30,8 @@
****************************************************************************/
#include <nuttx/config.h>
#include <arch/irq.h>
#include <arch/chip/chip.h>
/****************************************************************************

View File

@ -230,8 +230,12 @@ int up_create_stack(FAR struct tcb_s *tcb, size_t stack_size, uint8_t ttype)
#ifdef CONFIG_STACK_COLORATION
void up_stack_color(FAR void *stackbase, size_t nbytes)
{
uint32_t *stkptr = stackbase;
size_t nwords = nbytes / sizeof(uint32_t);
/* Take extra care that we do not write outsize the stack boundaries */
uint32_t *stkptr = (uint32_t *)(((uintptr_t)stackbase + 3) & ~3);
uintptr_t stkend = nbytes ? (((uintptr_t)stackbase + nbytes) & ~3) :
up_getsp(); /* 0: colorize the running stack */
size_t nwords = (stkend - (uintptr_t)stackbase) >> 2;
/* Set the entire stack to the coloration value */

View File

@ -47,8 +47,6 @@
#include "up_internal.h"
#include "chip.h"
#include "sched/sched.h"
/****************************************************************************
* Private Functions
****************************************************************************/
@ -98,19 +96,10 @@ static inline void up_color_intstack(void)
void up_initialize(void)
{
struct tcb_s *idle;
/* Initialize global variables */
CURRENT_REGS = NULL;
/* Initialize the idle task stack info */
idle = this_task(); /* It should be idle task */
idle->stack_alloc_ptr = g_idle_basestack;
idle->stack_base_ptr = g_idle_topstack;
idle->adj_stack_size = g_idle_topstack - g_idle_basestack;
/* Colorize the interrupt stack */
up_color_intstack();

View File

@ -243,10 +243,6 @@ static void init_kernelspace(void)
mpu_priv_data(g_idle_basestack,
g_idle_topstack - g_idle_basestack);
#ifdef CONFIG_STACK_COLORATION
up_stack_color(g_idle_basestack,
g_idle_topstack - g_idle_basestack - 256);
#endif
}
#ifdef CONFIG_BUILD_PROTECTED

View File

@ -29,6 +29,8 @@
#include <nuttx/arch.h>
#include <nuttx/irq.h>
#include "up_internal.h"
/****************************************************************************
* Public Functions
****************************************************************************/
@ -51,6 +53,23 @@ void up_initial_state(struct tcb_s *tcb)
{
struct xcptcontext *xcp = &tcb->xcp;
/* Initialize the idle thread stack */
if (tcb->pid == 0)
{
tcb->stack_alloc_ptr = g_idle_basestack;
tcb->stack_base_ptr = tcb->stack_alloc_ptr;
tcb->adj_stack_size = g_idle_topstack - g_idle_basestack;
#ifdef CONFIG_STACK_COLORATION
/* If stack debug is enabled, then fill the stack with a
* recognizable value that we can use later to test for high
* water marks.
*/
up_stack_color(tcb->stack_alloc_ptr, 0);
#endif /* CONFIG_STACK_COLORATION */
}
/* Initialize the initial exception register context structure */
memset(xcp, 0, sizeof(struct xcptcontext));

View File

@ -29,6 +29,8 @@
#include <nuttx/arch.h>
#include <nuttx/irq.h>
#include "up_internal.h"
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
@ -57,6 +59,23 @@ void up_initial_state(struct tcb_s *tcb)
{
struct xcptcontext *xcp = &tcb->xcp;
/* Initialize the idle thread stack */
if (tcb->pid == 0)
{
tcb->stack_alloc_ptr = g_idle_basestack;
tcb->stack_base_ptr = tcb->stack_alloc_ptr;
tcb->adj_stack_size = g_idle_topstack - g_idle_basestack;
#ifdef CONFIG_STACK_COLORATION
/* If stack debug is enabled, then fill the stack with a
* recognizable value that we can use later to test for high
* water marks.
*/
up_stack_color(tcb->stack_alloc_ptr, 0);
#endif /* CONFIG_STACK_COLORATION */
}
/* Initialize the initial exception register context structure */
memset(xcp, 0, sizeof(struct xcptcontext));