diff --git a/TODO b/TODO index 8fd88f06979..e03e408cfb7 100644 --- a/TODO +++ b/TODO @@ -1,4 +1,4 @@ -NuttX TODO List (Last updated July 2, 2020) +NuttX TODO List (Last updated July 19, 2020) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ This file summarizes known NuttX bugs, limitations, inconsistencies with @@ -295,49 +295,10 @@ o Task/Scheduler (sched/) Task: IDLE THREAD TCB SETUP Description: There are issues with setting IDLE thread stacks: - 1. One problem is stack-related data in the IDLE threads TCB. - A solution might be to standardize the use of g_idle_topstack. - That you could add initialization like this in nx_start: - - @@ -344,6 +347,11 @@ void nx_start(void) - g_idleargv[1] = NULL; - g_idletcb.argv = g_idleargv; - - + /* Set the IDLE task stack size */ - + - + g_idletcb.cmn.adj_stack_size = CONFIG_IDLETHREAD_STACKSIZE; - + g_idletcb.cmn.stack_alloc_ptr = (void *)(g_idle_topstack - CONFIG_IDLETHREAD_STACKSIZE); - + - /* Then add the idle task's TCB to the head of the ready to run list */ - - dq_addfirst((FAR dq_entry_t *)&g_idletcb, (FAR dq_queue_t *)&g_readytorun); - - The g_idle_topstack variable is available for almost all architectures: - - $ find . -name *.h | xargs grep g_idle_top - ./arm/src/common/up_internal.h:EXTERN const uint32_t g_idle_topstack; - ./avr/src/avr/avr.h:extern uint16_t g_idle_topstack; - ./avr/src/avr32/avr32.h:extern uint32_t g_idle_topstack; - ./hc/src/common/up_internal.h:extern uint16_t g_idle_topstack; - ./mips/src/common/up_internal.h:extern uint32_t g_idle_topstack; - ./misoc/src/lm32/lm32.h:extern uint32_t g_idle_topstack; - ./renesas/src/common/up_internal.h:extern uint32_t g_idle_topstack; - ./renesas/src/m16c/chip.h:extern uint32_t g_idle_topstack; /* Start of the heap */ - ./risc-v/src/common/up_internal.h:EXTERN uint32_t g_idle_topstack; - ./x86/src/common/up_internal.h:extern uint32_t g_idle_topstack; - - That omits these architectures: sh1, sim, xtensa, z16, z80, - ez80, and z8. All would have to support this common - global variable. - - Also, the stack itself may be 8-, 16-, or 32-bits wide, - depending upon the architecture and do have differing - alignment requirements. - - 2. Another problem is colorizing that stack to use with - stack usage monitoring logic. There is logic in some - start functions to do this in a function called go_nx_start. - It is available in these architectures: + The problem is colorizing that stack to use with stack usage + monitoring logic. There is logic in some start functions to + do this in a function called go_nx_start. + It is available in these architectures: ./arm/src/efm32/efm32_start.c:static void go_nx_start(void *pv, unsigned int nbytes) ./arm/src/kinetis/kinetis_start.c:static void go_nx_start(void *pv, unsigned int nbytes) @@ -349,9 +310,9 @@ o Task/Scheduler (sched/) ./arm/src/tms570/tms570_boot.c:static void go_nx_start(void *pv, unsigned int nbytes) ./arm/src/xmc4/xmc4_start.c:static void go_nx_start(void *pv, unsigned int nbytes) - But no others. - Status: Open - Priority: Low, only needed for more complete debug. + But no others. + Status: Open + Priority: Low, only needed for more complete debug. Title: PRIORITY INHERITANCE WITH SPORADIC SCHEDULER Description: The sporadic scheduler manages CPU utilization by a task by diff --git a/arch/arm/src/arm/arm_assert.c b/arch/arm/src/arm/arm_assert.c index 71e1512aa0c..e4f445bb806 100644 --- a/arch/arm/src/arm/arm_assert.c +++ b/arch/arm/src/arm/arm_assert.c @@ -187,16 +187,8 @@ static void up_dumpstate(void) /* Get the limits on the user stack memory */ - if (rtcb->pid == 0) /* Check for CPU0 IDLE thread */ - { - ustackbase = g_idle_topstack - 4; - ustacksize = CONFIG_IDLETHREAD_STACKSIZE; - } - else - { - ustackbase = (uint32_t)rtcb->adj_stack_ptr; - ustacksize = (uint32_t)rtcb->adj_stack_size; - } + ustackbase = (uint32_t)rtcb->adj_stack_ptr; + ustacksize = (uint32_t)rtcb->adj_stack_size; /* Get the limits on the interrupt stack memory */ diff --git a/arch/arm/src/arm/arm_initialstate.c b/arch/arm/src/arm/arm_initialstate.c index d18aa6bf506..13c9c928891 100644 --- a/arch/arm/src/arm/arm_initialstate.c +++ b/arch/arm/src/arm/arm_initialstate.c @@ -48,18 +48,6 @@ #include "arm_internal.h" #include "arm_arch.h" -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - -/**************************************************************************** - * Private Data - ****************************************************************************/ - -/**************************************************************************** - * Private Functions - ****************************************************************************/ - /**************************************************************************** * Public Functions ****************************************************************************/ @@ -83,6 +71,14 @@ void up_initial_state(struct tcb_s *tcb) struct xcptcontext *xcp = &tcb->xcp; uint32_t cpsr; + /* Initialize the idle thread stack */ + + if (tcb->pid == 0) + { + up_use_stack(tcb, (void *)(g_idle_topstack - + CONFIG_IDLETHREAD_STACKSIZE), CONFIG_IDLETHREAD_STACKSIZE); + } + /* Initialize the initial exception register context structure */ memset(xcp, 0, sizeof(struct xcptcontext)); diff --git a/arch/arm/src/armv6-m/arm_assert.c b/arch/arm/src/armv6-m/arm_assert.c index bbc1e413560..382a039a394 100644 --- a/arch/arm/src/armv6-m/arm_assert.c +++ b/arch/arm/src/armv6-m/arm_assert.c @@ -224,16 +224,8 @@ static void up_dumpstate(void) /* Get the limits on the user stack memory */ - if (rtcb->pid == 0) /* Check for CPU0 IDLE thread */ - { - ustackbase = g_idle_topstack - 4; - ustacksize = CONFIG_IDLETHREAD_STACKSIZE; - } - else - { - ustackbase = (uint32_t)rtcb->adj_stack_ptr; - ustacksize = (uint32_t)rtcb->adj_stack_size; - } + ustackbase = (uint32_t)rtcb->adj_stack_ptr; + ustacksize = (uint32_t)rtcb->adj_stack_size; /* Get the limits on the interrupt stack memory */ diff --git a/arch/arm/src/armv6-m/arm_initialstate.c b/arch/arm/src/armv6-m/arm_initialstate.c index 263d502933f..25ccafa5de7 100644 --- a/arch/arm/src/armv6-m/arm_initialstate.c +++ b/arch/arm/src/armv6-m/arm_initialstate.c @@ -51,18 +51,6 @@ #include "psr.h" #include "exc_return.h" -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - -/**************************************************************************** - * Private Data - ****************************************************************************/ - -/**************************************************************************** - * Private Functions - ****************************************************************************/ - /**************************************************************************** * Public Functions ****************************************************************************/ @@ -85,6 +73,14 @@ void up_initial_state(struct tcb_s *tcb) { struct xcptcontext *xcp = &tcb->xcp; + /* Initialize the idle thread stack */ + + if (tcb->pid == 0) + { + up_use_stack(tcb, (void *)(g_idle_topstack - + CONFIG_IDLETHREAD_STACKSIZE), CONFIG_IDLETHREAD_STACKSIZE); + } + /* Initialize the initial exception register context structure */ memset(xcp, 0, sizeof(struct xcptcontext)); diff --git a/arch/arm/src/armv7-a/arm_assert.c b/arch/arm/src/armv7-a/arm_assert.c index 3e5e48acd6f..683264eba24 100644 --- a/arch/arm/src/armv7-a/arm_assert.c +++ b/arch/arm/src/armv7-a/arm_assert.c @@ -212,16 +212,8 @@ static void up_dumpstate(void) /* Get the limits on the user stack memory */ - if (rtcb->pid == 0) /* Check for CPU0 IDLE thread */ - { - ustackbase = g_idle_topstack - 4; - ustacksize = CONFIG_IDLETHREAD_STACKSIZE; - } - else - { - ustackbase = (uint32_t)rtcb->adj_stack_ptr; - ustacksize = (uint32_t)rtcb->adj_stack_size; - } + ustackbase = (uint32_t)rtcb->adj_stack_ptr; + ustacksize = (uint32_t)rtcb->adj_stack_size; _alert("Current sp: %08x\n", sp); diff --git a/arch/arm/src/armv7-a/arm_initialstate.c b/arch/arm/src/armv7-a/arm_initialstate.c index 97b3c0a0ec1..65af4b00422 100644 --- a/arch/arm/src/armv7-a/arm_initialstate.c +++ b/arch/arm/src/armv7-a/arm_initialstate.c @@ -71,6 +71,14 @@ void up_initial_state(struct tcb_s *tcb) struct xcptcontext *xcp = &tcb->xcp; uint32_t cpsr; + /* Initialize the idle thread stack */ + + if (tcb->pid == 0) + { + up_use_stack(tcb, (void *)(g_idle_topstack - + CONFIG_IDLETHREAD_STACKSIZE), CONFIG_IDLETHREAD_STACKSIZE); + } + /* Initialize the initial exception register context structure */ memset(xcp, 0, sizeof(struct xcptcontext)); diff --git a/arch/arm/src/armv7-m/arm_assert.c b/arch/arm/src/armv7-m/arm_assert.c index aae1da418b7..382297f202b 100644 --- a/arch/arm/src/armv7-m/arm_assert.c +++ b/arch/arm/src/armv7-m/arm_assert.c @@ -217,16 +217,8 @@ static void up_dumpstate(void) /* Get the limits on the user stack memory */ - if (rtcb->pid == 0) /* Check for CPU0 IDLE thread */ - { - ustackbase = g_idle_topstack - 4; - ustacksize = CONFIG_IDLETHREAD_STACKSIZE; - } - else - { - ustackbase = (uint32_t)rtcb->adj_stack_ptr; - ustacksize = (uint32_t)rtcb->adj_stack_size; - } + ustackbase = (uint32_t)rtcb->adj_stack_ptr; + ustacksize = (uint32_t)rtcb->adj_stack_size; #if CONFIG_ARCH_INTERRUPTSTACK > 7 /* Get the limits on the interrupt stack memory */ diff --git a/arch/arm/src/armv7-m/arm_initialstate.c b/arch/arm/src/armv7-m/arm_initialstate.c index b014b18beb2..0a02a4c9a1a 100644 --- a/arch/arm/src/armv7-m/arm_initialstate.c +++ b/arch/arm/src/armv7-m/arm_initialstate.c @@ -59,6 +59,14 @@ void up_initial_state(struct tcb_s *tcb) { struct xcptcontext *xcp = &tcb->xcp; + /* Initialize the idle thread stack */ + + if (tcb->pid == 0) + { + up_use_stack(tcb, (void *)(g_idle_topstack - + CONFIG_IDLETHREAD_STACKSIZE), CONFIG_IDLETHREAD_STACKSIZE); + } + /* Initialize the initial exception register context structure */ memset(xcp, 0, sizeof(struct xcptcontext)); diff --git a/arch/arm/src/armv7-r/arm_assert.c b/arch/arm/src/armv7-r/arm_assert.c index ae4c71947a6..4c65ad5316c 100644 --- a/arch/arm/src/armv7-r/arm_assert.c +++ b/arch/arm/src/armv7-r/arm_assert.c @@ -209,16 +209,8 @@ static void up_dumpstate(void) /* Get the limits on the user stack memory */ - if (rtcb->pid == 0) /* Check for CPU0 IDLE thread */ - { - ustackbase = g_idle_topstack - 4; - ustacksize = CONFIG_IDLETHREAD_STACKSIZE; - } - else - { - ustackbase = (uint32_t)rtcb->adj_stack_ptr; - ustacksize = (uint32_t)rtcb->adj_stack_size; - } + ustackbase = (uint32_t)rtcb->adj_stack_ptr; + ustacksize = (uint32_t)rtcb->adj_stack_size; _alert("Current sp: %08x\n", sp); diff --git a/arch/arm/src/armv7-r/arm_initialstate.c b/arch/arm/src/armv7-r/arm_initialstate.c index edd7c6da3df..edbf8118592 100644 --- a/arch/arm/src/armv7-r/arm_initialstate.c +++ b/arch/arm/src/armv7-r/arm_initialstate.c @@ -48,18 +48,6 @@ #include "arm_internal.h" #include "arm_arch.h" -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - -/**************************************************************************** - * Private Data - ****************************************************************************/ - -/**************************************************************************** - * Private Functions - ****************************************************************************/ - /**************************************************************************** * Public Functions ****************************************************************************/ @@ -83,6 +71,14 @@ void up_initial_state(struct tcb_s *tcb) struct xcptcontext *xcp = &tcb->xcp; uint32_t cpsr; + /* Initialize the idle thread stack */ + + if (tcb->pid == 0) + { + up_use_stack(tcb, (void *)(g_idle_topstack - + CONFIG_IDLETHREAD_STACKSIZE), CONFIG_IDLETHREAD_STACKSIZE); + } + /* Initialize the initial exception register context structure */ memset(xcp, 0, sizeof(struct xcptcontext)); diff --git a/arch/arm/src/armv8-m/arm_assert.c b/arch/arm/src/armv8-m/arm_assert.c index 4477964914c..ac0b9b72151 100644 --- a/arch/arm/src/armv8-m/arm_assert.c +++ b/arch/arm/src/armv8-m/arm_assert.c @@ -217,16 +217,8 @@ static void up_dumpstate(void) /* Get the limits on the user stack memory */ - if (rtcb->pid == 0) /* Check for CPU0 IDLE thread */ - { - ustackbase = g_idle_topstack - 4; - ustacksize = CONFIG_IDLETHREAD_STACKSIZE; - } - else - { - ustackbase = (uint32_t)rtcb->adj_stack_ptr; - ustacksize = (uint32_t)rtcb->adj_stack_size; - } + ustackbase = (uint32_t)rtcb->adj_stack_ptr; + ustacksize = (uint32_t)rtcb->adj_stack_size; #if CONFIG_ARCH_INTERRUPTSTACK > 7 /* Get the limits on the interrupt stack memory */ diff --git a/arch/arm/src/armv8-m/arm_initialstate.c b/arch/arm/src/armv8-m/arm_initialstate.c index 969c9bec32c..459303990ea 100644 --- a/arch/arm/src/armv8-m/arm_initialstate.c +++ b/arch/arm/src/armv8-m/arm_initialstate.c @@ -59,6 +59,14 @@ void up_initial_state(struct tcb_s *tcb) { struct xcptcontext *xcp = &tcb->xcp; + /* Initialize the idle thread stack */ + + if (tcb->pid == 0) + { + up_use_stack(tcb, (void *)(g_idle_topstack - + CONFIG_IDLETHREAD_STACKSIZE), CONFIG_IDLETHREAD_STACKSIZE); + } + /* Initialize the initial exception register context structure */ memset(xcp, 0, sizeof(struct xcptcontext)); diff --git a/arch/arm/src/common/arm_usestack.c b/arch/arm/src/common/arm_usestack.c index 2fda891e935..e0e03b4668d 100644 --- a/arch/arm/src/common/arm_usestack.c +++ b/arch/arm/src/common/arm_usestack.c @@ -146,8 +146,11 @@ int up_use_stack(struct tcb_s *tcb, void *stack, size_t stack_size) * water marks. */ - arm_stack_color((FAR void *)((uintptr_t)tcb->adj_stack_ptr - - tcb->adj_stack_size), tcb->adj_stack_size); + if (tcb->pid != 0) + { + arm_stack_color((FAR void *)((uintptr_t)tcb->adj_stack_ptr - + tcb->adj_stack_size), tcb->adj_stack_size); + } #endif /* CONFIG_STACK_COLORATION */ return OK; diff --git a/arch/arm/src/efm32/efm32_start.h b/arch/arm/src/efm32/efm32_start.h index f63ff36d00e..693f3a40eec 100644 --- a/arch/arm/src/efm32/efm32_start.h +++ b/arch/arm/src/efm32/efm32_start.h @@ -42,22 +42,6 @@ #include -/**************************************************************************** - * Public Data - ****************************************************************************/ - -/* g_idle_topstack: _sbss is the start of the BSS region as defined by the - * linker script. _ebss lies at the end of the BSS region. The idle task - * stack starts at the end of BSS and is of size CONFIG_IDLETHREAD_STACKSIZE. - * The IDLE thread is the thread that the system boots on and, eventually, - * becomes the IDLE, do nothing task that runs only when there is nothing - * else to run. The heap continues from there until the end of memory. - * g_idle_topstack is a read-only variable the provides this computed - * address. - */ - -extern const uintptr_t g_idle_topstack; - /**************************************************************************** * Public Functions ****************************************************************************/ diff --git a/arch/arm/src/imxrt/imxrt_start.h b/arch/arm/src/imxrt/imxrt_start.h index b8e0b51c5f3..59e19af050f 100644 --- a/arch/arm/src/imxrt/imxrt_start.h +++ b/arch/arm/src/imxrt/imxrt_start.h @@ -77,17 +77,6 @@ extern "C" #define EXTERN extern #endif -/* g_idle_topstack: _sbss is the start of the BSS region as defined by the linker - * script. _ebss lies at the end of the BSS region. The idle task stack starts at - * the end of BSS and is of size CONFIG_IDLETHREAD_STACKSIZE. The IDLE thread is - * the thread that the system boots on and, eventually, becomes the IDLE, do - * nothing task that runs only when there is nothing else to run. The heap - * continues from there until the end of memory. g_idle_topstack is a read-only - * variable the provides this computed address. - */ - -EXTERN const uintptr_t g_idle_topstack; - /************************************************************************************ * Public Function Prototypes ************************************************************************************/ diff --git a/arch/arm/src/kinetis/kinetis_start.h b/arch/arm/src/kinetis/kinetis_start.h index e37361bcd82..6c2eb7bb84e 100644 --- a/arch/arm/src/kinetis/kinetis_start.h +++ b/arch/arm/src/kinetis/kinetis_start.h @@ -42,22 +42,6 @@ #include -/************************************************************************************ - * Public Data - ************************************************************************************/ - -/* g_idle_topstack: _sbss is the start of the BSS region as defined by the - * linker script. _ebss lies at the end of the BSS region. The idle task - * stack starts at the end of BSS and is of size CONFIG_IDLETHREAD_STACKSIZE. - * The IDLE thread is the thread that the system boots on and, eventually, - * becomes the IDLE, do nothing task that runs only when there is nothing - * else to run. The heap continues from there until the end of memory. - * g_idle_topstack is a read-only variable the provides this computed - * address. - */ - -extern const uintptr_t g_idle_topstack; - /************************************************************************************ * Public Function Prototypes ************************************************************************************/ diff --git a/arch/arm/src/lc823450/lc823450_start.h b/arch/arm/src/lc823450/lc823450_start.h index a3836c851ed..9f7d2d2b476 100644 --- a/arch/arm/src/lc823450/lc823450_start.h +++ b/arch/arm/src/lc823450/lc823450_start.h @@ -42,22 +42,6 @@ #include -/************************************************************************************ - * Public Data - ************************************************************************************/ - -/* g_idle_topstack: _sbss is the start of the BSS region as defined by the - * linker script. _ebss lies at the end of the BSS region. The idle task - * stack starts at the end of BSS and is of size CONFIG_IDLETHREAD_STACKSIZE. - * The IDLE thread is the thread that the system boots on and, eventually, - * becomes the IDLE, do nothing task that runs only when there is nothing - * else to run. The heap continues from there until the end of memory. - * g_idle_topstack is a read-only variable the provides this computed - * address. - */ - -extern const uintptr_t g_idle_topstack; - /************************************************************************************ * Public Function Prototypes ************************************************************************************/ diff --git a/arch/arm/src/lpc17xx_40xx/lpc17_40_start.h b/arch/arm/src/lpc17xx_40xx/lpc17_40_start.h index 3bcbf3a1c8d..94f29aa7387 100644 --- a/arch/arm/src/lpc17xx_40xx/lpc17_40_start.h +++ b/arch/arm/src/lpc17xx_40xx/lpc17_40_start.h @@ -42,22 +42,6 @@ #include -/************************************************************************************ - * Public Data - ************************************************************************************/ - -/* g_idle_topstack: _sbss is the start of the BSS region as defined by the - * linker script. _ebss lies at the end of the BSS region. The idle task - * stack starts at the end of BSS and is of size CONFIG_IDLETHREAD_STACKSIZE. - * The IDLE thread is the thread that the system boots on and, eventually, - * becomes the IDLE, do nothing task that runs only when there is nothing - * else to run. The heap continues from there until the end of memory. - * g_idle_topstack is a read-only variable the provides this computed - * address. - */ - -extern const uintptr_t g_idle_topstack; - /************************************************************************************ * Public Function Prototypes ************************************************************************************/ diff --git a/arch/arm/src/lpc54xx/lpc54_start.h b/arch/arm/src/lpc54xx/lpc54_start.h index 00e0cfac03d..593320552c9 100644 --- a/arch/arm/src/lpc54xx/lpc54_start.h +++ b/arch/arm/src/lpc54xx/lpc54_start.h @@ -50,23 +50,8 @@ #include "arm_internal.h" #include "chip.h" -/************************************************************************************ - * Public Data - ************************************************************************************/ - #ifndef __ASSEMBLY__ -/* g_idle_topstack: _sbss is the start of the BSS region as defined by the linker - * script. _ebss lies at the end of the BSS region. The idle task stack starts at - * the end of BSS and is of size CONFIG_IDLETHREAD_STACKSIZE. The IDLE thread is - * the thread that the system boots on and, eventually, becomes the IDLE, do - * nothing task that runs only when there is nothing else to run. The heap - * continues from there until the end of memory. g_idle_topstack is a read-only - * variable the provides this computed address. - */ - -extern const uintptr_t g_idle_topstack; - /************************************************************************************ * Public Function Prototypes ************************************************************************************/ diff --git a/arch/arm/src/max326xx/max326_start.h b/arch/arm/src/max326xx/max326_start.h index feb0be78f23..0c2c297871e 100644 --- a/arch/arm/src/max326xx/max326_start.h +++ b/arch/arm/src/max326xx/max326_start.h @@ -50,23 +50,8 @@ #include "arm_internal.h" #include "chip.h" -/************************************************************************************ - * Public Data - ************************************************************************************/ - #ifndef __ASSEMBLY__ -/* g_idle_topstack: _sbss is the start of the BSS region as defined by the linker - * script. _ebss lies at the end of the BSS region. The idle task stack starts at - * the end of BSS and is of size CONFIG_IDLETHREAD_STACKSIZE. The IDLE thread is - * the thread that the system boots on and, eventually, becomes the IDLE, do - * nothing task that runs only when there is nothing else to run. The heap - * continues from there until the end of memory. g_idle_topstack is a read-only - * variable the provides this computed address. - */ - -extern const uintptr_t g_idle_topstack; - /************************************************************************************ * Public Function Prototypes ************************************************************************************/ diff --git a/arch/arm/src/nrf52/nrf52_start.h b/arch/arm/src/nrf52/nrf52_start.h index 4b26bdcb0dc..519a3af49b8 100644 --- a/arch/arm/src/nrf52/nrf52_start.h +++ b/arch/arm/src/nrf52/nrf52_start.h @@ -50,23 +50,8 @@ #include "arm_internal.h" #include "chip.h" -/************************************************************************************ - * Public Data - ************************************************************************************/ - #ifndef __ASSEMBLY__ -/* g_idle_topstack: _sbss is the start of the BSS region as defined by the linker - * script. _ebss lies at the end of the BSS region. The idle task stack starts at - * the end of BSS and is of size CONFIG_IDLETHREAD_STACKSIZE. The IDLE thread is - * the thread that the system boots on and, eventually, becomes the IDLE, do - * nothing task that runs only when there is nothing else to run. The heap - * continues from there until the end of memory. g_idle_topstack is a read-only - * variable the provides this computed address. - */ - -extern const uintptr_t g_idle_topstack; - /************************************************************************************ * Public Function Prototypes ************************************************************************************/ diff --git a/arch/arm/src/s32k1xx/s32k1xx_start.h b/arch/arm/src/s32k1xx/s32k1xx_start.h index cc708d76fd4..45d212eb7f0 100644 --- a/arch/arm/src/s32k1xx/s32k1xx_start.h +++ b/arch/arm/src/s32k1xx/s32k1xx_start.h @@ -56,17 +56,6 @@ #ifndef __ASSEMBLY__ -/* g_idle_topstack: _sbss is the start of the BSS region as defined by the linker - * script. _ebss lies at the end of the BSS region. The idle task stack starts at - * the end of BSS and is of size CONFIG_IDLETHREAD_STACKSIZE. The IDLE thread is - * the thread that the system boots on and, eventually, becomes the IDLE, do - * nothing task that runs only when there is nothing else to run. The heap - * continues from there until the end of memory. g_idle_topstack is a read-only - * variable the provides this computed address. - */ - -extern const uintptr_t g_idle_topstack; - /* Each S32K1xx board must provide the following initialized structure. This is * needed to establish the initial board clocking. */ diff --git a/arch/arm/src/sam34/sam_start.h b/arch/arm/src/sam34/sam_start.h index 05644ef3b5e..b39cbbb5470 100644 --- a/arch/arm/src/sam34/sam_start.h +++ b/arch/arm/src/sam34/sam_start.h @@ -42,22 +42,6 @@ #include -/************************************************************************************ - * Public Data - ************************************************************************************/ - -/* g_idle_topstack: _sbss is the start of the BSS region as defined by the - * linker script. _ebss lies at the end of the BSS region. The idle task - * stack starts at the end of BSS and is of size CONFIG_IDLETHREAD_STACKSIZE. - * The IDLE thread is the thread that the system boots on and, eventually, - * becomes the IDLE, do nothing task that runs only when there is nothing - * else to run. The heap continues from there until the end of memory. - * g_idle_topstack is a read-only variable the provides this computed - * address. - */ - -extern const uintptr_t g_idle_topstack; - /************************************************************************************ * Public Function Prototypes ************************************************************************************/ diff --git a/arch/arm/src/samd5e5/sam_start.h b/arch/arm/src/samd5e5/sam_start.h index 3e44fb3d282..96ed7acae8a 100644 --- a/arch/arm/src/samd5e5/sam_start.h +++ b/arch/arm/src/samd5e5/sam_start.h @@ -42,22 +42,6 @@ #include -/************************************************************************************ - * Public Data - ************************************************************************************/ - -/* g_idle_topstack: _sbss is the start of the BSS region as defined by the - * linker script. _ebss lies at the end of the BSS region. The idle task - * stack starts at the end of BSS and is of size CONFIG_IDLETHREAD_STACKSIZE. - * The IDLE thread is the thread that the system boots on and, eventually, - * becomes the IDLE, do nothing task that runs only when there is nothing - * else to run. The heap continues from there until the end of memory. - * g_idle_topstack is a read-only variable the provides this computed - * address. - */ - -extern const uintptr_t g_idle_topstack; - /************************************************************************************ * Public Function Prototypes ************************************************************************************/ diff --git a/arch/arm/src/samv7/sam_start.h b/arch/arm/src/samv7/sam_start.h index 2ca8804ea3b..4a33cf4e47b 100644 --- a/arch/arm/src/samv7/sam_start.h +++ b/arch/arm/src/samv7/sam_start.h @@ -50,24 +50,8 @@ #include "arm_internal.h" #include "chip.h" -/************************************************************************************ - * Pre-processor Definitions - ************************************************************************************/ - -/************************************************************************************ - * Public Types - ************************************************************************************/ - -/************************************************************************************ - * Inline Functions - ************************************************************************************/ - #ifndef __ASSEMBLY__ -/************************************************************************************ - * Public Data - ************************************************************************************/ - #undef EXTERN #if defined(__cplusplus) #define EXTERN extern "C" @@ -77,17 +61,6 @@ extern "C" #define EXTERN extern #endif -/* g_idle_topstack: _sbss is the start of the BSS region as defined by the linker - * script. _ebss lies at the end of the BSS region. The idle task stack starts at - * the end of BSS and is of size CONFIG_IDLETHREAD_STACKSIZE. The IDLE thread is - * the thread that the system boots on and, eventually, becomes the IDLE, do - * nothing task that runs only when there is nothing else to run. The heap - * continues from there until the end of memory. g_idle_topstack is a read-only - * variable the provides this computed address. - */ - -EXTERN const uintptr_t g_idle_topstack; - /************************************************************************************ * Public Function Prototypes ************************************************************************************/ diff --git a/arch/arm/src/stm32/stm32_start.h b/arch/arm/src/stm32/stm32_start.h index ac6b90b6af3..9111426965b 100644 --- a/arch/arm/src/stm32/stm32_start.h +++ b/arch/arm/src/stm32/stm32_start.h @@ -42,22 +42,6 @@ #include -/************************************************************************************ - * Public Data - ************************************************************************************/ - -/* g_idle_topstack: _sbss is the start of the BSS region as defined by the - * linker script. _ebss lies at the end of the BSS region. The idle task - * stack starts at the end of BSS and is of size CONFIG_IDLETHREAD_STACKSIZE. - * The IDLE thread is the thread that the system boots on and, eventually, - * becomes the IDLE, do nothing task that runs only when there is nothing - * else to run. The heap continues from there until the end of memory. - * g_idle_topstack is a read-only variable the provides this computed - * address. - */ - -extern const uintptr_t g_idle_topstack; - /************************************************************************************ * Public Function Prototypes ************************************************************************************/ diff --git a/arch/arm/src/stm32f7/stm32_start.h b/arch/arm/src/stm32f7/stm32_start.h index df85f59840c..35c28029b4e 100644 --- a/arch/arm/src/stm32f7/stm32_start.h +++ b/arch/arm/src/stm32f7/stm32_start.h @@ -50,10 +50,6 @@ #include "arm_internal.h" #include "chip.h" -/************************************************************************************ - * Public Data - ************************************************************************************/ - #ifndef __ASSEMBLY__ #undef EXTERN @@ -65,17 +61,6 @@ extern "C" #define EXTERN extern #endif -/* g_idle_topstack: _sbss is the start of the BSS region as defined by the linker - * script. _ebss lies at the end of the BSS region. The idle task stack starts at - * the end of BSS and is of size CONFIG_IDLETHREAD_STACKSIZE. The IDLE thread is - * the thread that the system boots on and, eventually, becomes the IDLE, do - * nothing task that runs only when there is nothing else to run. The heap - * continues from there until the end of memory. g_idle_topstack is a read-only - * variable the provides this computed address. - */ - -EXTERN const uintptr_t g_idle_topstack; - /************************************************************************************ * Public Function Prototypes ************************************************************************************/ diff --git a/arch/arm/src/stm32h7/stm32_start.h b/arch/arm/src/stm32h7/stm32_start.h index afae133d550..79725868e93 100644 --- a/arch/arm/src/stm32h7/stm32_start.h +++ b/arch/arm/src/stm32h7/stm32_start.h @@ -50,10 +50,6 @@ #include "arm_internal.h" #include "chip.h" -/************************************************************************************ - * Public Data - ************************************************************************************/ - #ifndef __ASSEMBLY__ #undef EXTERN @@ -65,17 +61,6 @@ extern "C" #define EXTERN extern #endif -/* g_idle_topstack: _sbss is the start of the BSS region as defined by the linker - * script. _ebss lies at the end of the BSS region. The idle task stack starts at - * the end of BSS and is of size CONFIG_IDLETHREAD_STACKSIZE. The IDLE thread is - * the thread that the system boots on and, eventually, becomes the IDLE, do - * nothing task that runs only when there is nothing else to run. The heap - * continues from there until the end of memory. g_idle_topstack is a read-only - * variable the provides this computed address. - */ - -EXTERN const uintptr_t g_idle_topstack; - /************************************************************************************ * Public Function Prototypes ************************************************************************************/ diff --git a/arch/arm/src/tiva/tiva_start.h b/arch/arm/src/tiva/tiva_start.h index 64c449db3de..1a2bb839e5f 100644 --- a/arch/arm/src/tiva/tiva_start.h +++ b/arch/arm/src/tiva/tiva_start.h @@ -42,22 +42,6 @@ #include -/**************************************************************************** - * Public Data - ****************************************************************************/ - -/* g_idle_topstack: _sbss is the start of the BSS region as defined by the - * linker script. _ebss lies at the end of the BSS region. The idle task - * stack starts at the end of BSS and is of size CONFIG_IDLETHREAD_STACKSIZE. - * The IDLE thread is the thread that the system boots on and, eventually, - * becomes the IDLE, do nothing task that runs only when there is nothing - * else to run. The heap continues from there until the end of memory. - * g_idle_topstack is a read-only variable the provides this computed - * address. - */ - -extern const uintptr_t g_idle_topstack; - /**************************************************************************** * Public Functions ****************************************************************************/ diff --git a/arch/arm/src/tms570/tms570_boot.h b/arch/arm/src/tms570/tms570_boot.h index 83ead3dc4c9..9f4307cc8cc 100644 --- a/arch/arm/src/tms570/tms570_boot.h +++ b/arch/arm/src/tms570/tms570_boot.h @@ -50,24 +50,8 @@ #include "arm_internal.h" #include "chip.h" -/************************************************************************************ - * Pre-processor Definitions - ************************************************************************************/ - -/************************************************************************************ - * Public Types - ************************************************************************************/ - -/************************************************************************************ - * Inline Functions - ************************************************************************************/ - #ifndef __ASSEMBLY__ -/************************************************************************************ - * Public Data - ************************************************************************************/ - #undef EXTERN #if defined(__cplusplus) #define EXTERN extern "C" @@ -77,17 +61,6 @@ extern "C" #define EXTERN extern #endif -/* g_idle_topstack: _sbss is the start of the BSS region as defined by the linker - * script. _ebss lies at the end of the BSS region. The idle task stack starts at - * the end of BSS and is of size CONFIG_IDLETHREAD_STACKSIZE. The IDLE thread is - * the thread that the system boots on and, eventually, becomes the IDLE, do - * nothing task that runs only when there is nothing else to run. The heap - * continues from there until the end of memory. g_idle_topstack is a read-only - * variable the provides this computed address. - */ - -EXTERN const uintptr_t g_idle_topstack; - /************************************************************************************ * Public Function Prototypes ************************************************************************************/ diff --git a/arch/avr/src/avr/up_dumpstate.c b/arch/avr/src/avr/up_dumpstate.c index 0dc4c69c2d6..def469988c3 100644 --- a/arch/avr/src/avr/up_dumpstate.c +++ b/arch/avr/src/avr/up_dumpstate.c @@ -154,16 +154,8 @@ void up_dumpstate(void) /* Get the limits on the user stack memory */ - if (rtcb->pid == 0) /* Check for CPU0 IDLE thread */ - { - ustackbase = g_idle_topstack - 1; - ustacksize = CONFIG_IDLETHREAD_STACKSIZE; - } - else - { - ustackbase = (uint16_t)rtcb->adj_stack_ptr; - ustacksize = (uint16_t)rtcb->adj_stack_size; - } + ustackbase = (uint16_t)rtcb->adj_stack_ptr; + ustacksize = (uint16_t)rtcb->adj_stack_size; /* Get the limits on the interrupt stack memory */ diff --git a/arch/avr/src/avr/up_initialstate.c b/arch/avr/src/avr/up_initialstate.c index 5c63f239e00..9f975138800 100644 --- a/arch/avr/src/avr/up_initialstate.c +++ b/arch/avr/src/avr/up_initialstate.c @@ -71,6 +71,14 @@ void up_initial_state(struct tcb_s *tcb) { struct xcptcontext *xcp = &tcb->xcp; + /* Initialize the idle thread stack */ + + if (tcb->pid == 0) + { + up_use_stack(tcb, (void *)(g_idle_topstack - + CONFIG_IDLETHREAD_STACKSIZE), CONFIG_IDLETHREAD_STACKSIZE); + } + /* Initialize the initial exception register context structure. Zeroing * all registers is a good debug helper, but should not be necessary. */ diff --git a/arch/avr/src/avr/up_usestack.c b/arch/avr/src/avr/up_usestack.c index 0721160098c..6a4eee6a302 100644 --- a/arch/avr/src/avr/up_usestack.c +++ b/arch/avr/src/avr/up_usestack.c @@ -51,14 +51,6 @@ #include "up_internal.h" -/**************************************************************************** - * Private Types - ****************************************************************************/ - -/**************************************************************************** - * Private Function Prototypes - ****************************************************************************/ - /**************************************************************************** * Public Functions ****************************************************************************/ @@ -119,7 +111,10 @@ int up_use_stack(struct tcb_s *tcb, void *stack, size_t stack_size) */ #ifdef CONFIG_STACK_COLORATION - memset(tcb->stack_alloc_ptr, STACK_COLOR, stack_size); + if (tcb->pid != 0) + { + memset(tcb->stack_alloc_ptr, STACK_COLOR, stack_size); + } #endif /* The AVR uses a push-down stack: the stack grows toward loweraddresses diff --git a/arch/avr/src/avr32/up_dumpstate.c b/arch/avr/src/avr32/up_dumpstate.c index f818041db06..c98d912e084 100644 --- a/arch/avr/src/avr32/up_dumpstate.c +++ b/arch/avr/src/avr32/up_dumpstate.c @@ -124,16 +124,8 @@ void up_dumpstate(void) /* Get the limits on the user stack memory */ - if (rtcb->pid == 0) /* Check for CPU0 IDLE thread */ - { - ustackbase = g_idle_topstack - 4; - ustacksize = CONFIG_IDLETHREAD_STACKSIZE; - } - else - { - ustackbase = (uint32_t)rtcb->adj_stack_ptr; - ustacksize = (uint32_t)rtcb->adj_stack_size; - } + ustackbase = (uint32_t)rtcb->adj_stack_ptr; + ustacksize = (uint32_t)rtcb->adj_stack_size; /* Get the limits on the interrupt stack memory */ diff --git a/arch/avr/src/avr32/up_initialstate.c b/arch/avr/src/avr32/up_initialstate.c index 2d473828e27..4383a2f11fe 100644 --- a/arch/avr/src/avr32/up_initialstate.c +++ b/arch/avr/src/avr32/up_initialstate.c @@ -48,18 +48,6 @@ #include "up_internal.h" #include "up_arch.h" -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - -/**************************************************************************** - * Private Data - ****************************************************************************/ - -/**************************************************************************** - * Private Functions - ****************************************************************************/ - /**************************************************************************** * Public Functions ****************************************************************************/ @@ -81,6 +69,14 @@ void up_initial_state(struct tcb_s *tcb) { struct xcptcontext *xcp = &tcb->xcp; + /* Initialize the idle thread stack */ + + if (tcb->pid == 0) + { + up_use_stack(tcb, (void *)(g_idle_topstack - + CONFIG_IDLETHREAD_STACKSIZE), CONFIG_IDLETHREAD_STACKSIZE); + } + /* Initialize the initial exception register context structure. Zeroing * all registers is a good debug helper, but should not be necessary. */ diff --git a/arch/avr/src/avr32/up_usestack.c b/arch/avr/src/avr32/up_usestack.c index 19d81375839..c30163e60dc 100644 --- a/arch/avr/src/avr32/up_usestack.c +++ b/arch/avr/src/avr32/up_usestack.c @@ -50,14 +50,6 @@ #include "up_internal.h" -/**************************************************************************** - * Private Types - ****************************************************************************/ - -/**************************************************************************** - * Private Function Prototypes - ****************************************************************************/ - /**************************************************************************** * Public Functions ****************************************************************************/ @@ -119,7 +111,10 @@ int up_use_stack(struct tcb_s *tcb, void *stack, size_t stack_size) */ #ifdef CONFIG_STACK_COLORATION - memset(tcb->stack_alloc_ptr, STACK_COLOR, stack_size); + if (tcb->pid != 0) + { + memset(tcb->stack_alloc_ptr, STACK_COLOR, stack_size); + } #endif /* The AVR32 uses a push-down stack: the stack grows diff --git a/arch/hc/src/common/up_usestack.c b/arch/hc/src/common/up_usestack.c index 59b01881b15..beaf299bff7 100644 --- a/arch/hc/src/common/up_usestack.c +++ b/arch/hc/src/common/up_usestack.c @@ -49,14 +49,6 @@ #include "up_internal.h" -/**************************************************************************** - * Private Types - ****************************************************************************/ - -/**************************************************************************** - * Private Function Prototypes - ****************************************************************************/ - /**************************************************************************** * Public Functions ****************************************************************************/ @@ -113,6 +105,17 @@ int up_use_stack(struct tcb_s *tcb, void *stack, size_t stack_size) tcb->stack_alloc_ptr = stack; + /* If stack debug is enabled, then fill the stack with a recognizable value + * that we can use later to test for high water marks. + */ + +#ifdef CONFIG_STACK_COLORATION + if (tcb->pid != 0) + { + memset(tcb->stack_alloc_ptr, 0xaa, stack_size); + } +#endif + /* The CPU12 uses a push-down stack: the stack grows * toward lower addresses in memory. Because the CPU12 stack * operates as a decrement then store stack, the value assigned diff --git a/arch/hc/src/m9s12/m9s12_assert.c b/arch/hc/src/m9s12/m9s12_assert.c index 487031c194b..7e1696bda41 100644 --- a/arch/hc/src/m9s12/m9s12_assert.c +++ b/arch/hc/src/m9s12/m9s12_assert.c @@ -199,16 +199,8 @@ static void up_dumpstate(void) /* Get the limits on the user stack memory */ - if (rtcb->pid == 0) /* Check for CPU0 IDLE thread */ - { - ustackbase = g_idle_topstack - 4; - ustacksize = CONFIG_IDLETHREAD_STACKSIZE; - } - else - { - ustackbase = (uint16_t)rtcb->adj_stack_ptr; - ustacksize = (uint16_t)rtcb->adj_stack_size; - } + ustackbase = (uint16_t)rtcb->adj_stack_ptr; + ustacksize = (uint16_t)rtcb->adj_stack_size; /* Get the limits on the interrupt stack memory */ diff --git a/arch/hc/src/m9s12/m9s12_initialstate.c b/arch/hc/src/m9s12/m9s12_initialstate.c index 89e2ac9a27d..2bd6931ab1d 100644 --- a/arch/hc/src/m9s12/m9s12_initialstate.c +++ b/arch/hc/src/m9s12/m9s12_initialstate.c @@ -46,18 +46,6 @@ #include "up_internal.h" -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - -/**************************************************************************** - * Private Data - ****************************************************************************/ - -/**************************************************************************** - * Private Functions - ****************************************************************************/ - /**************************************************************************** * Public Functions ****************************************************************************/ @@ -80,6 +68,14 @@ void up_initial_state(struct tcb_s *tcb) { struct xcptcontext *xcp = &tcb->xcp; + /* Initialize the idle thread stack */ + + if (tcb->pid == 0) + { + up_use_stack(tcb, (void *)(g_idle_topstack - + CONFIG_IDLETHREAD_STACKSIZE), CONFIG_IDLETHREAD_STACKSIZE); + } + /* Initialize the initial exception register context structure */ memset(xcp, 0, sizeof(struct xcptcontext)); diff --git a/arch/mips/src/common/mips_usestack.c b/arch/mips/src/common/mips_usestack.c index 30a6a7e5c0b..aa7071df37a 100644 --- a/arch/mips/src/common/mips_usestack.c +++ b/arch/mips/src/common/mips_usestack.c @@ -70,14 +70,6 @@ #define STACK_ALIGN_DOWN(a) ((a) & ~STACK_ALIGN_MASK) #define STACK_ALIGN_UP(a) (((a) + STACK_ALIGN_MASK) & ~STACK_ALIGN_MASK) -/**************************************************************************** - * Private Types - ****************************************************************************/ - -/**************************************************************************** - * Private Function Prototypes - ****************************************************************************/ - /**************************************************************************** * Public Functions ****************************************************************************/ @@ -134,6 +126,17 @@ int up_use_stack(struct tcb_s *tcb, void *stack, size_t stack_size) tcb->stack_alloc_ptr = stack; + /* If stack debug is enabled, then fill the stack with a recognizable value + * that we can use later to test for high water marks. + */ + +#ifdef CONFIG_STACK_COLORATION + if (tcb->pid != 0) + { + memset(tcb->stack_alloc_ptr, 0xaa, stack_size); + } +#endif + /* MIPS uses a push-down stack: the stack grows toward loweraddresses in * memory. The stack pointer register, points to the lowest, valid work * address (the "top" of the stack). Items on the stack are referenced diff --git a/arch/mips/src/mips32/mips_dumpstate.c b/arch/mips/src/mips32/mips_dumpstate.c index 58c3da64717..9005001afd7 100644 --- a/arch/mips/src/mips32/mips_dumpstate.c +++ b/arch/mips/src/mips32/mips_dumpstate.c @@ -144,16 +144,8 @@ void up_dumpstate(void) /* Get the limits on the user stack memory */ - if (rtcb->pid == 0) /* Check for CPU0 IDLE thread */ - { - ustackbase = g_idle_topstack - 4; - ustacksize = CONFIG_IDLETHREAD_STACKSIZE; - } - else - { - ustackbase = (uint32_t)rtcb->adj_stack_ptr; - ustacksize = (uint32_t)rtcb->adj_stack_size; - } + ustackbase = (uint32_t)rtcb->adj_stack_ptr; + ustacksize = (uint32_t)rtcb->adj_stack_size; /* Get the limits on the interrupt stack memory */ diff --git a/arch/mips/src/mips32/mips_initialstate.c b/arch/mips/src/mips32/mips_initialstate.c index 7a7c242f0f6..9b02f5b94fe 100644 --- a/arch/mips/src/mips32/mips_initialstate.c +++ b/arch/mips/src/mips32/mips_initialstate.c @@ -73,6 +73,14 @@ void up_initial_state(struct tcb_s *tcb) struct xcptcontext *xcp = &tcb->xcp; uint32_t regval; + /* Initialize the idle thread stack */ + + if (tcb->pid == 0) + { + up_use_stack(tcb, (void *)(g_idle_topstack - + CONFIG_IDLETHREAD_STACKSIZE), CONFIG_IDLETHREAD_STACKSIZE); + } + /* Initialize the initial exception register context structure */ memset(xcp, 0, sizeof(struct xcptcontext)); diff --git a/arch/misoc/src/lm32/Make.defs b/arch/misoc/src/lm32/Make.defs index b8f21a054a2..15ec51f6368 100644 --- a/arch/misoc/src/lm32/Make.defs +++ b/arch/misoc/src/lm32/Make.defs @@ -50,4 +50,4 @@ CHIP_CSRCS += lm32_initialize.c lm32_initialstate.c lm32_interruptcontext.c CHIP_CSRCS += lm32_irq.c lm32_releasepending.c lm32_releasestack.c CHIP_CSRCS += lm32_stackframe.c lm32_swint.c lm32_unblocktask.c CHIP_CSRCS += lm32_reprioritizertr.c lm32_schedulesigaction.c lm32_sigdeliver.c -CHIP_CSRCS += lm32_flushcache.c +CHIP_CSRCS += lm32_flushcache.c lm32_usetack.c diff --git a/arch/misoc/src/lm32/lm32_dumpstate.c b/arch/misoc/src/lm32/lm32_dumpstate.c index f6ff679700e..9274b2a7add 100644 --- a/arch/misoc/src/lm32/lm32_dumpstate.c +++ b/arch/misoc/src/lm32/lm32_dumpstate.c @@ -141,16 +141,8 @@ void lm32_dumpstate(void) /* Get the limits on the user stack memory */ - if (rtcb->pid == 0) /* Check for CPU0 IDLE thread */ - { - ustackbase = g_idle_topstack - 4; - ustacksize = CONFIG_IDLETHREAD_STACKSIZE; - } - else - { - ustackbase = (uint32_t)rtcb->adj_stack_ptr; - ustacksize = (uint32_t)rtcb->adj_stack_size; - } + ustackbase = (uint32_t)rtcb->adj_stack_ptr; + ustacksize = (uint32_t)rtcb->adj_stack_size; /* Get the limits on the interrupt stack memory */ diff --git a/arch/misoc/src/lm32/lm32_initialstate.c b/arch/misoc/src/lm32/lm32_initialstate.c index f76c82e6ea3..9a9c000a141 100644 --- a/arch/misoc/src/lm32/lm32_initialstate.c +++ b/arch/misoc/src/lm32/lm32_initialstate.c @@ -49,18 +49,6 @@ #include "lm32.h" -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - -/**************************************************************************** - * Private Data - ****************************************************************************/ - -/**************************************************************************** - * Private Functions - ****************************************************************************/ - /**************************************************************************** * Public Functions ****************************************************************************/ @@ -83,6 +71,14 @@ void up_initial_state(struct tcb_s *tcb) { struct xcptcontext *xcp = &tcb->xcp; + /* Initialize the idle thread stack */ + + if (tcb->pid == 0) + { + up_use_stack(tcb, (void *)(g_idle_topstack - + CONFIG_IDLETHREAD_STACKSIZE), CONFIG_IDLETHREAD_STACKSIZE); + } + /* Initialize the initial exception register context structure */ memset(xcp, 0, sizeof(struct xcptcontext)); diff --git a/arch/misoc/src/lm32/lm32_usestack.c b/arch/misoc/src/lm32/lm32_usestack.c new file mode 100644 index 00000000000..ee4189cff44 --- /dev/null +++ b/arch/misoc/src/lm32/lm32_usestack.c @@ -0,0 +1,128 @@ +/**************************************************************************** + * arch/misoc/src/lm32/lm32_usestack.c + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include +#include +#include +#include + +#include +#include +#include + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: up_use_stack + * + * Description: + * Setup up stack-related information in the TCB using pre-allocated stack + * memory. This function is called only from nxtask_init() when a task or + * kernel thread is started (never for pthreads). + * + * The following TCB fields must be initialized: + * + * - adj_stack_size: Stack size after adjustment for hardware, + * processor, etc. This value is retained only for debug + * purposes. + * - stack_alloc_ptr: Pointer to allocated stack + * - adj_stack_ptr: Adjusted stack_alloc_ptr for HW. The + * initial value of the stack pointer. + * + * Input Parameters: + * - tcb: The TCB of new task + * - stack_size: The allocated stack size. + * + * NOTE: Unlike up_stack_create() and up_stack_release, this function + * does not require the task type (ttype) parameter. The TCB flags will + * always be set to provide the task type to up_use_stack() if it needs + * that information. + * + ****************************************************************************/ + +int up_use_stack(struct tcb_s *tcb, void *stack, size_t stack_size) +{ + size_t top_of_stack; + size_t size_of_stack; + +#ifdef CONFIG_TLS_ALIGNED + /* Make certain that the user provided stack is properly aligned */ + + DEBUGASSERT(((uintptr_t)stack & TLS_STACK_MASK) == 0); +#endif + + /* Is there already a stack allocated? */ + + if (tcb->stack_alloc_ptr) + { + /* Yes.. Release the old stack allocation */ + + up_release_stack(tcb, tcb->flags & TCB_FLAG_TTYPE_MASK); + } + + /* Save the new stack allocation */ + + tcb->stack_alloc_ptr = stack; + + /* If stack debug is enabled, then fill the stack with a recognizable value + * that we can use later to test for high water marks. + */ + +#ifdef CONFIG_STACK_COLORATION + if (tcb->pid != 0) + { + memset(tcb->stack_alloc_ptr, 0xaa, stack_size); + } +#endif + + /* The i486 uses a push-down stack: the stack grows toward loweraddresses + * in memory. The stack pointer register, points to the lowest, valid work + * address (the "top" of the stack). Items on the stack are referenced as + * positive word offsets from sp. + */ + + top_of_stack = (uint32_t)tcb->stack_alloc_ptr + stack_size - 4; + + /* The i486 stack must be aligned at word (4 byte) boundaries. If necessary + * top_of_stack must be rounded down to the next boundary + */ + + top_of_stack &= ~3; + size_of_stack = top_of_stack - (uint32_t)tcb->stack_alloc_ptr + 4; + + /* Save the adjusted stack values in the struct tcb_s */ + + tcb->adj_stack_ptr = (uint32_t *)top_of_stack; + tcb->adj_stack_size = size_of_stack; + + /* Initialize the TLS data structure */ + + memset(tcb->stack_alloc_ptr, 0, sizeof(struct tls_info_s)); + + return OK; +} diff --git a/arch/misoc/src/minerva/Make.defs b/arch/misoc/src/minerva/Make.defs index ed7fdcf62b3..dd80adff4e0 100644 --- a/arch/misoc/src/minerva/Make.defs +++ b/arch/misoc/src/minerva/Make.defs @@ -50,4 +50,4 @@ CHIP_CSRCS += minerva_initialize.c minerva_initialstate.c minerva_interruptconte CHIP_CSRCS += minerva_irq.c minerva_releasepending.c minerva_releasestack.c CHIP_CSRCS += minerva_stackframe.c minerva_swint.c minerva_unblocktask.c CHIP_CSRCS += minerva_reprioritizertr.c minerva_schedulesigaction.c minerva_sigdeliver.c -CHIP_CSRCS += minerva_flushcache.c minerva_doexceptions.c +CHIP_CSRCS += minerva_flushcache.c minerva_doexceptions.c minerva_usetack.c diff --git a/arch/misoc/src/minerva/minerva_dumpstate.c b/arch/misoc/src/minerva/minerva_dumpstate.c index 6bd55487afe..99228e71d58 100644 --- a/arch/misoc/src/minerva/minerva_dumpstate.c +++ b/arch/misoc/src/minerva/minerva_dumpstate.c @@ -148,16 +148,8 @@ void minerva_dumpstate(void) * == NULL) */ - if (rtcb->flink == NULL) - { - ustackbase = g_idle_topstack - 4; - ustacksize = CONFIG_IDLETHREAD_STACKSIZE; - } - else - { - ustackbase = (uint32_t) rtcb->adj_stack_ptr; - ustacksize = (uint32_t) rtcb->adj_stack_size; - } + ustackbase = (uint32_t) rtcb->adj_stack_ptr; + ustacksize = (uint32_t) rtcb->adj_stack_size; /* Get the limits on the interrupt stack memory */ diff --git a/arch/misoc/src/minerva/minerva_initialstate.c b/arch/misoc/src/minerva/minerva_initialstate.c index b4ae0974967..bcc0621f779 100644 --- a/arch/misoc/src/minerva/minerva_initialstate.c +++ b/arch/misoc/src/minerva/minerva_initialstate.c @@ -75,6 +75,14 @@ void up_initial_state(struct tcb_s *tcb) uint32_t regval; struct xcptcontext *xcp = &tcb->xcp; + /* Initialize the idle thread stack */ + + if (tcb->pid == 0) + { + up_use_stack(tcb, (void *)(g_idle_topstack - + CONFIG_IDLETHREAD_STACKSIZE), CONFIG_IDLETHREAD_STACKSIZE); + } + /* Initialize the initial exception register context structure */ memset(xcp, 0, sizeof(struct xcptcontext)); diff --git a/arch/misoc/src/minerva/minerva_usestack.c b/arch/misoc/src/minerva/minerva_usestack.c new file mode 100644 index 00000000000..782177defc0 --- /dev/null +++ b/arch/misoc/src/minerva/minerva_usestack.c @@ -0,0 +1,128 @@ +/**************************************************************************** + * arch/misoc/src/minerva/minerva_usestack.c + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include +#include +#include +#include + +#include +#include +#include + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: up_use_stack + * + * Description: + * Setup up stack-related information in the TCB using pre-allocated stack + * memory. This function is called only from nxtask_init() when a task or + * kernel thread is started (never for pthreads). + * + * The following TCB fields must be initialized: + * + * - adj_stack_size: Stack size after adjustment for hardware, + * processor, etc. This value is retained only for debug + * purposes. + * - stack_alloc_ptr: Pointer to allocated stack + * - adj_stack_ptr: Adjusted stack_alloc_ptr for HW. The + * initial value of the stack pointer. + * + * Input Parameters: + * - tcb: The TCB of new task + * - stack_size: The allocated stack size. + * + * NOTE: Unlike up_stack_create() and up_stack_release, this function + * does not require the task type (ttype) parameter. The TCB flags will + * always be set to provide the task type to up_use_stack() if it needs + * that information. + * + ****************************************************************************/ + +int up_use_stack(struct tcb_s *tcb, void *stack, size_t stack_size) +{ + size_t top_of_stack; + size_t size_of_stack; + +#ifdef CONFIG_TLS_ALIGNED + /* Make certain that the user provided stack is properly aligned */ + + DEBUGASSERT(((uintptr_t)stack & TLS_STACK_MASK) == 0); +#endif + + /* Is there already a stack allocated? */ + + if (tcb->stack_alloc_ptr) + { + /* Yes.. Release the old stack allocation */ + + up_release_stack(tcb, tcb->flags & TCB_FLAG_TTYPE_MASK); + } + + /* Save the new stack allocation */ + + tcb->stack_alloc_ptr = stack; + + /* If stack debug is enabled, then fill the stack with a recognizable value + * that we can use later to test for high water marks. + */ + +#ifdef CONFIG_STACK_COLORATION + if (tcb->pid != 0) + { + memset(tcb->stack_alloc_ptr, 0xaa, stack_size); + } +#endif + + /* The i486 uses a push-down stack: the stack grows toward loweraddresses + * in memory. The stack pointer register, points to the lowest, valid work + * address (the "top" of the stack). Items on the stack are referenced as + * positive word offsets from sp. + */ + + top_of_stack = (uint32_t)tcb->stack_alloc_ptr + stack_size - 4; + + /* The i486 stack must be aligned at word (4 byte) boundaries. If necessary + * top_of_stack must be rounded down to the next boundary + */ + + top_of_stack &= ~3; + size_of_stack = top_of_stack - (uint32_t)tcb->stack_alloc_ptr + 4; + + /* Save the adjusted stack values in the struct tcb_s */ + + tcb->adj_stack_ptr = (uint32_t *)top_of_stack; + tcb->adj_stack_size = size_of_stack; + + /* Initialize the TLS data structure */ + + memset(tcb->stack_alloc_ptr, 0, sizeof(struct tls_info_s)); + + return OK; +} diff --git a/arch/or1k/src/common/up_assert.c b/arch/or1k/src/common/up_assert.c index d7abb508048..6a81ae8f679 100644 --- a/arch/or1k/src/common/up_assert.c +++ b/arch/or1k/src/common/up_assert.c @@ -224,16 +224,8 @@ static void up_dumpstate(void) /* Get the limits on the user stack memory */ - if (rtcb->pid == 0) /* Check for CPU0 IDLE thread */ - { - ustackbase = g_idle_topstack - 4; - ustacksize = CONFIG_IDLETHREAD_STACKSIZE; - } - else - { - ustackbase = (uint32_t)rtcb->adj_stack_ptr; - ustacksize = (uint32_t)rtcb->adj_stack_size; - } + ustackbase = (uint32_t)rtcb->adj_stack_ptr; + ustacksize = (uint32_t)rtcb->adj_stack_size; /* Get the limits on the interrupt stack memory */ diff --git a/arch/or1k/src/common/up_initialstate.c b/arch/or1k/src/common/up_initialstate.c index 8754b3f0138..667a7cf4f5d 100644 --- a/arch/or1k/src/common/up_initialstate.c +++ b/arch/or1k/src/common/up_initialstate.c @@ -73,6 +73,14 @@ void up_initial_state(struct tcb_s *tcb) struct xcptcontext *xcp = &tcb->xcp; uint32_t sr; + /* Initialize the idle thread stack */ + + if (tcb->pid == 0) + { + up_use_stack(tcb, (void *)(g_idle_topstack - + CONFIG_IDLETHREAD_STACKSIZE), CONFIG_IDLETHREAD_STACKSIZE); + } + /* Initialize the initial exception register context structure */ memset(xcp, 0, sizeof(struct xcptcontext)); diff --git a/arch/or1k/src/common/up_usestack.c b/arch/or1k/src/common/up_usestack.c new file mode 100644 index 00000000000..782177defc0 --- /dev/null +++ b/arch/or1k/src/common/up_usestack.c @@ -0,0 +1,128 @@ +/**************************************************************************** + * arch/misoc/src/minerva/minerva_usestack.c + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include +#include +#include +#include + +#include +#include +#include + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: up_use_stack + * + * Description: + * Setup up stack-related information in the TCB using pre-allocated stack + * memory. This function is called only from nxtask_init() when a task or + * kernel thread is started (never for pthreads). + * + * The following TCB fields must be initialized: + * + * - adj_stack_size: Stack size after adjustment for hardware, + * processor, etc. This value is retained only for debug + * purposes. + * - stack_alloc_ptr: Pointer to allocated stack + * - adj_stack_ptr: Adjusted stack_alloc_ptr for HW. The + * initial value of the stack pointer. + * + * Input Parameters: + * - tcb: The TCB of new task + * - stack_size: The allocated stack size. + * + * NOTE: Unlike up_stack_create() and up_stack_release, this function + * does not require the task type (ttype) parameter. The TCB flags will + * always be set to provide the task type to up_use_stack() if it needs + * that information. + * + ****************************************************************************/ + +int up_use_stack(struct tcb_s *tcb, void *stack, size_t stack_size) +{ + size_t top_of_stack; + size_t size_of_stack; + +#ifdef CONFIG_TLS_ALIGNED + /* Make certain that the user provided stack is properly aligned */ + + DEBUGASSERT(((uintptr_t)stack & TLS_STACK_MASK) == 0); +#endif + + /* Is there already a stack allocated? */ + + if (tcb->stack_alloc_ptr) + { + /* Yes.. Release the old stack allocation */ + + up_release_stack(tcb, tcb->flags & TCB_FLAG_TTYPE_MASK); + } + + /* Save the new stack allocation */ + + tcb->stack_alloc_ptr = stack; + + /* If stack debug is enabled, then fill the stack with a recognizable value + * that we can use later to test for high water marks. + */ + +#ifdef CONFIG_STACK_COLORATION + if (tcb->pid != 0) + { + memset(tcb->stack_alloc_ptr, 0xaa, stack_size); + } +#endif + + /* The i486 uses a push-down stack: the stack grows toward loweraddresses + * in memory. The stack pointer register, points to the lowest, valid work + * address (the "top" of the stack). Items on the stack are referenced as + * positive word offsets from sp. + */ + + top_of_stack = (uint32_t)tcb->stack_alloc_ptr + stack_size - 4; + + /* The i486 stack must be aligned at word (4 byte) boundaries. If necessary + * top_of_stack must be rounded down to the next boundary + */ + + top_of_stack &= ~3; + size_of_stack = top_of_stack - (uint32_t)tcb->stack_alloc_ptr + 4; + + /* Save the adjusted stack values in the struct tcb_s */ + + tcb->adj_stack_ptr = (uint32_t *)top_of_stack; + tcb->adj_stack_size = size_of_stack; + + /* Initialize the TLS data structure */ + + memset(tcb->stack_alloc_ptr, 0, sizeof(struct tls_info_s)); + + return OK; +} diff --git a/arch/or1k/src/mor1kx/Make.defs b/arch/or1k/src/mor1kx/Make.defs index 1210b5314f3..d272b4d17b8 100644 --- a/arch/or1k/src/mor1kx/Make.defs +++ b/arch/or1k/src/mor1kx/Make.defs @@ -41,6 +41,7 @@ CMN_CSRCS = up_initialize.c \ up_interruptcontext.c \ up_allocateheap.c \ up_createstack.c \ + up_usestack.c \ up_releasestack.c \ up_stackframe.c \ up_initialstate.c \ diff --git a/arch/renesas/src/common/up_usestack.c b/arch/renesas/src/common/up_usestack.c index aa44e618acc..e11f7cc5fb2 100644 --- a/arch/renesas/src/common/up_usestack.c +++ b/arch/renesas/src/common/up_usestack.c @@ -50,14 +50,6 @@ #include "up_internal.h" -/**************************************************************************** - * Private Types - ****************************************************************************/ - -/**************************************************************************** - * Private Function Prototypes - ****************************************************************************/ - /**************************************************************************** * Public Functions ****************************************************************************/ @@ -114,6 +106,17 @@ int up_use_stack(struct tcb_s *tcb, void *stack, size_t stack_size) tcb->stack_alloc_ptr = stack; + /* If stack debug is enabled, then fill the stack with a recognizable value + * that we can use later to test for high water marks. + */ + +#ifdef CONFIG_STACK_COLORATION + if (tcb->pid != 0) + { + memset(tcb->stack_alloc_ptr, 0xaa, stack_size); + } +#endif + /* The SH family uses a push-down stack: the stack grows toward lower * addresses in memory. The stack pointer register, points to the * lowest, valid work address (the "top" of the stack). Items on the diff --git a/arch/renesas/src/m16c/chip.h b/arch/renesas/src/m16c/chip.h index 292e9565672..cc08d4cac76 100644 --- a/arch/renesas/src/m16c/chip.h +++ b/arch/renesas/src/m16c/chip.h @@ -266,7 +266,6 @@ extern uint32_t g_enronly; /* Start of relocated read-only data in FLASH * extern uint32_t g_efronly; /* Start of relocated read-only data in FLASH */ #endif extern uint32_t g_svarvect; /* Start of variable vectors */ -extern uint32_t g_idle_topstack; /* Start of the heap */ /* Address of the saved user stack pointer */ diff --git a/arch/renesas/src/m16c/m16c_dumpstate.c b/arch/renesas/src/m16c/m16c_dumpstate.c index f76e566fbbf..f5f6c11bf7d 100644 --- a/arch/renesas/src/m16c/m16c_dumpstate.c +++ b/arch/renesas/src/m16c/m16c_dumpstate.c @@ -151,16 +151,8 @@ void up_dumpstate(void) /* Get the limits on the user stack memory */ - if (rtcb->pid == 0) /* Check for CPU0 IDLE thread */ - { - ustackbase = g_idle_topstack - 1; - ustacksize = CONFIG_IDLETHREAD_STACKSIZE; - } - else - { - ustackbase = (uint16_t)rtcb->adj_stack_ptr; - ustacksize = (uint16_t)rtcb->adj_stack_size; - } + ustackbase = (uint16_t)rtcb->adj_stack_ptr; + ustacksize = (uint16_t)rtcb->adj_stack_size; /* Get the limits on the interrupt stack memory. * The near RAM memory map is as follows: diff --git a/arch/renesas/src/m16c/m16c_initialstate.c b/arch/renesas/src/m16c/m16c_initialstate.c index ac64f957f07..03953b092a1 100644 --- a/arch/renesas/src/m16c/m16c_initialstate.c +++ b/arch/renesas/src/m16c/m16c_initialstate.c @@ -70,6 +70,14 @@ void up_initial_state(FAR struct tcb_s *tcb) FAR struct xcptcontext *xcp = &tcb->xcp; FAR uint8_t *regs = xcp->regs; + /* Initialize the idle thread stack */ + + if (tcb->pid == 0) + { + up_use_stack(tcb, (FAR void *)(g_idle_topstack - + CONFIG_IDLETHREAD_STACKSIZE), CONFIG_IDLETHREAD_STACKSIZE); + } + /* Initialize the initial exception register context structure */ memset(xcp, 0, sizeof(struct xcptcontext)); diff --git a/arch/renesas/src/rx65n/rx65n_dumpstate.c b/arch/renesas/src/rx65n/rx65n_dumpstate.c index ed4d4a61a6c..a17896c229d 100644 --- a/arch/renesas/src/rx65n/rx65n_dumpstate.c +++ b/arch/renesas/src/rx65n/rx65n_dumpstate.c @@ -142,16 +142,8 @@ void up_dumpstate(void) /* Get the limits on the user stack memory */ - if (rtcb->pid == 0) /* Check for CPU0 IDLE thread */ - { - ustackbase = g_idle_topstack - 1; - ustacksize = CONFIG_IDLETHREAD_STACKSIZE; - } - else - { - ustackbase = (uint32_t)rtcb->adj_stack_ptr; - ustacksize = (uint16_t)rtcb->adj_stack_size; - } + ustackbase = (uint32_t)rtcb->adj_stack_ptr; + ustacksize = (uint16_t)rtcb->adj_stack_size; #if CONFIG_ARCH_INTERRUPTSTACK > 3 istackbase = ebss; /* check how to declare ebss, as of now declared in chip.h */ diff --git a/arch/renesas/src/rx65n/rx65n_initialstate.c b/arch/renesas/src/rx65n/rx65n_initialstate.c index 98d66ae5f86..6bb18cd2672 100644 --- a/arch/renesas/src/rx65n/rx65n_initialstate.c +++ b/arch/renesas/src/rx65n/rx65n_initialstate.c @@ -61,6 +61,14 @@ void up_initial_state(struct tcb_s *tcb) { struct xcptcontext *xcp = &tcb->xcp; + /* Initialize the idle thread stack */ + + if (tcb->pid == 0) + { + up_use_stack(tcb, (void *)(g_idle_topstack - + CONFIG_IDLETHREAD_STACKSIZE), CONFIG_IDLETHREAD_STACKSIZE); + } + /* Initialize the initial exception register context structure */ memset(xcp, 0, sizeof(struct xcptcontext)); diff --git a/arch/renesas/src/sh1/sh1_dumpstate.c b/arch/renesas/src/sh1/sh1_dumpstate.c index 10282029946..55b53ed6d79 100644 --- a/arch/renesas/src/sh1/sh1_dumpstate.c +++ b/arch/renesas/src/sh1/sh1_dumpstate.c @@ -138,16 +138,8 @@ void up_dumpstate(void) /* Get the limits on the user stack memory */ - if (rtcb->pid == 0) /* Check for CPU0 IDLE thread */ - { - ustackbase = g_idle_topstack - 4; - ustacksize = CONFIG_IDLETHREAD_STACKSIZE; - } - else - { - ustackbase = (uint32_t)rtcb->adj_stack_ptr; - ustacksize = (uint32_t)rtcb->adj_stack_size; - } + ustackbase = (uint32_t)rtcb->adj_stack_ptr; + ustacksize = (uint32_t)rtcb->adj_stack_size; /* Get the limits on the interrupt stack memory */ diff --git a/arch/renesas/src/sh1/sh1_initialstate.c b/arch/renesas/src/sh1/sh1_initialstate.c index 552db9f7215..045a9975c89 100644 --- a/arch/renesas/src/sh1/sh1_initialstate.c +++ b/arch/renesas/src/sh1/sh1_initialstate.c @@ -44,14 +44,6 @@ #include "up_internal.h" #include "up_arch.h" -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - -/**************************************************************************** - * Private Data - ****************************************************************************/ - /**************************************************************************** * Private Functions ****************************************************************************/ @@ -96,6 +88,14 @@ void up_initial_state(struct tcb_s *tcb) { struct xcptcontext *xcp = &tcb->xcp; + /* Initialize the idle thread stack */ + + if (tcb->pid == 0) + { + up_use_stack(tcb, (void *)(g_idle_topstack - + CONFIG_IDLETHREAD_STACKSIZE), CONFIG_IDLETHREAD_STACKSIZE); + } + /* Initialize the initial exception register context structure */ memset(xcp, 0, sizeof(struct xcptcontext)); diff --git a/arch/risc-v/src/common/riscv_initialize.c b/arch/risc-v/src/common/riscv_initialize.c index aefee0cf9a1..1fb5bc1c7d2 100644 --- a/arch/risc-v/src/common/riscv_initialize.c +++ b/arch/risc-v/src/common/riscv_initialize.c @@ -108,8 +108,6 @@ static inline void up_color_intstack(void) void up_initialize(void) { - FAR struct tcb_s *idle; - /* Colorize the interrupt stack */ up_color_intstack(); @@ -118,13 +116,6 @@ void up_initialize(void) up_addregion(); - /* Initialize the idle task stack info */ - - idle = this_task(); /* It should be idle task */ - idle->stack_alloc_ptr = _END_BSS; - idle->adj_stack_ptr = (FAR void *)g_idle_topstack; - idle->adj_stack_size = CONFIG_IDLETHREAD_STACKSIZE; - #ifdef CONFIG_PM /* Initialize the power management subsystem. This MCU-specific function * must be called *very* early in the initialization sequence *before* any diff --git a/arch/risc-v/src/common/riscv_usestack.c b/arch/risc-v/src/common/riscv_usestack.c index a0bc0d06d70..81dffd0f23a 100644 --- a/arch/risc-v/src/common/riscv_usestack.c +++ b/arch/risc-v/src/common/riscv_usestack.c @@ -70,14 +70,6 @@ #define STACK_ALIGN_DOWN(a) ((a) & ~STACK_ALIGN_MASK) #define STACK_ALIGN_UP(a) (((a) + STACK_ALIGN_MASK) & ~STACK_ALIGN_MASK) -/**************************************************************************** - * Private Types - ****************************************************************************/ - -/**************************************************************************** - * Private Function Prototypes - ****************************************************************************/ - /**************************************************************************** * Public Functions ****************************************************************************/ @@ -165,9 +157,12 @@ int up_use_stack(struct tcb_s *tcb, void *stack, size_t stack_size) * water marks. */ - up_stack_color((FAR void *)((uintptr_t)tcb->stack_alloc_ptr + - sizeof(struct tls_info_s)), - tcb->adj_stack_size - sizeof(struct tls_info_s)); + if (tcb->pid != 0) + { + up_stack_color((FAR void *)((uintptr_t)tcb->stack_alloc_ptr + + sizeof(struct tls_info_s)), + size_of_stack - sizeof(struct tls_info_s)); + } #endif return OK; diff --git a/arch/risc-v/src/rv32im/riscv_assert.c b/arch/risc-v/src/rv32im/riscv_assert.c index bcf85b3d58a..2dfe3c5f034 100644 --- a/arch/risc-v/src/rv32im/riscv_assert.c +++ b/arch/risc-v/src/rv32im/riscv_assert.c @@ -199,16 +199,8 @@ static void up_dumpstate(void) /* Get the limits on the user stack memory */ - if (rtcb->pid == 0) /* Check for CPU0 IDLE thread */ - { - ustackbase = g_idle_topstack - 4; - ustacksize = CONFIG_IDLETHREAD_STACKSIZE; - } - else - { - ustackbase = (uint32_t)rtcb->adj_stack_ptr; - ustacksize = (uint32_t)rtcb->adj_stack_size; - } + ustackbase = (uint32_t)rtcb->adj_stack_ptr; + ustacksize = (uint32_t)rtcb->adj_stack_size; /* Get the limits on the interrupt stack memory */ diff --git a/arch/risc-v/src/rv32im/riscv_initialstate.c b/arch/risc-v/src/rv32im/riscv_initialstate.c index 5f0ae555087..0aad94dafb4 100644 --- a/arch/risc-v/src/rv32im/riscv_initialstate.c +++ b/arch/risc-v/src/rv32im/riscv_initialstate.c @@ -72,6 +72,14 @@ void up_initial_state(struct tcb_s *tcb) struct xcptcontext *xcp = &tcb->xcp; uint32_t regval; + /* Initialize the idle thread stack */ + + if (tcb->pid == 0) + { + up_use_stack(tcb, (void *)(g_idle_topstack - + CONFIG_IDLETHREAD_STACKSIZE), CONFIG_IDLETHREAD_STACKSIZE); + } + /* Initialize the initial exception register context structure */ memset(xcp, 0, sizeof(struct xcptcontext)); diff --git a/arch/risc-v/src/rv64gc/riscv_assert.c b/arch/risc-v/src/rv64gc/riscv_assert.c index b23db6219f2..67071dae55d 100644 --- a/arch/risc-v/src/rv64gc/riscv_assert.c +++ b/arch/risc-v/src/rv64gc/riscv_assert.c @@ -210,16 +210,8 @@ static void up_dumpstate(void) /* Get the limits on the user stack memory */ - if (rtcb->pid == 0) /* Check for CPU0 IDLE thread */ - { - ustackbase = g_idle_topstack - 8; - ustacksize = CONFIG_IDLETHREAD_STACKSIZE; - } - else - { - ustackbase = (uintptr_t)rtcb->adj_stack_ptr; - ustacksize = (uintptr_t)rtcb->adj_stack_size; - } + ustackbase = (uintptr_t)rtcb->adj_stack_ptr; + ustacksize = (uintptr_t)rtcb->adj_stack_size; /* Get the limits on the interrupt stack memory */ diff --git a/arch/risc-v/src/rv64gc/riscv_initialstate.c b/arch/risc-v/src/rv64gc/riscv_initialstate.c index caa0c37e306..b0ebd1d7dbd 100644 --- a/arch/risc-v/src/rv64gc/riscv_initialstate.c +++ b/arch/risc-v/src/rv64gc/riscv_initialstate.c @@ -72,6 +72,14 @@ void up_initial_state(struct tcb_s *tcb) struct xcptcontext *xcp = &tcb->xcp; uint64_t regval; + /* Initialize the idle thread stack */ + + if (tcb->pid == 0) + { + up_use_stack(tcb, (void *)(g_idle_topstack - + CONFIG_IDLETHREAD_STACKSIZE), CONFIG_IDLETHREAD_STACKSIZE); + } + /* Initialize the initial exception register context structure */ memset(xcp, 0, sizeof(struct xcptcontext)); diff --git a/arch/sim/src/sim/up_initialstate.c b/arch/sim/src/sim/up_initialstate.c index 129d3be8ee4..03e5a35a036 100644 --- a/arch/sim/src/sim/up_initialstate.c +++ b/arch/sim/src/sim/up_initialstate.c @@ -66,6 +66,12 @@ void up_initial_state(struct tcb_s *tcb) { + if (tcb->pid == 0) + { + up_use_stack(tcb, (void *)(sim_getsp() - + CONFIG_IDLETHREAD_STACKSIZE), CONFIG_IDLETHREAD_STACKSIZE); + } + memset(&tcb->xcp, 0, sizeof(struct xcptcontext)); tcb->xcp.regs[JB_SP] = (xcpt_reg_t)tcb->adj_stack_ptr - sizeof(xcpt_reg_t); tcb->xcp.regs[JB_PC] = (xcpt_reg_t)tcb->start; diff --git a/arch/sim/src/sim/up_usestack.c b/arch/sim/src/sim/up_usestack.c index 1c21d81f7e3..b6e84802d6c 100644 --- a/arch/sim/src/sim/up_usestack.c +++ b/arch/sim/src/sim/up_usestack.c @@ -136,9 +136,12 @@ int up_use_stack(FAR struct tcb_s *tcb, FAR void *stack, size_t stack_size) * water marks. */ - up_stack_color((FAR void *)((uintptr_t)tcb->stack_alloc_ptr + - sizeof(struct tls_info_s)), - tcb->adj_stack_size - sizeof(struct tls_info_s)); + if (tcb->pid != 0) + { + up_stack_color((FAR void *)((uintptr_t)tcb->stack_alloc_ptr + + sizeof(struct tls_info_s)), + adj_stack_size - sizeof(struct tls_info_s)); + } #endif return OK; diff --git a/arch/x86/src/common/up_assert.c b/arch/x86/src/common/up_assert.c index 7dcb30ffc0d..620b55c8495 100644 --- a/arch/x86/src/common/up_assert.c +++ b/arch/x86/src/common/up_assert.c @@ -160,16 +160,8 @@ static void up_dumpstate(void) /* Get the limits on the user stack memory */ - if (rtcb->pid == 0) /* Check for CPU0 IDLE thread */ - { - ustackbase = g_idle_topstack - 4; - ustacksize = CONFIG_IDLETHREAD_STACKSIZE; - } - else - { - ustackbase = (uint32_t)rtcb->adj_stack_ptr; - ustacksize = (uint32_t)rtcb->adj_stack_size; - } + ustackbase = (uint32_t)rtcb->adj_stack_ptr; + ustacksize = (uint32_t)rtcb->adj_stack_size; /* Get the limits on the interrupt stack memory */ diff --git a/arch/x86/src/i486/up_initialstate.c b/arch/x86/src/i486/up_initialstate.c index d1c94b32d2b..2a788098d00 100644 --- a/arch/x86/src/i486/up_initialstate.c +++ b/arch/x86/src/i486/up_initialstate.c @@ -48,18 +48,6 @@ #include "up_internal.h" #include "up_arch.h" -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - -/**************************************************************************** - * Private Data - ****************************************************************************/ - -/**************************************************************************** - * Private Functions - ****************************************************************************/ - /**************************************************************************** * Public Functions ****************************************************************************/ @@ -81,6 +69,14 @@ void up_initial_state(struct tcb_s *tcb) { struct xcptcontext *xcp = &tcb->xcp; + /* Initialize the idle thread stack */ + + if (tcb->pid == 0) + { + up_use_stack(tcb, (void *)(g_idle_topstack - + CONFIG_IDLETHREAD_STACKSIZE), CONFIG_IDLETHREAD_STACKSIZE); + } + /* Initialize the initial exception register context structure */ memset(xcp, 0, sizeof(struct xcptcontext)); diff --git a/arch/x86/src/i486/up_usestack.c b/arch/x86/src/i486/up_usestack.c index 71f94cc3310..89760e8155a 100644 --- a/arch/x86/src/i486/up_usestack.c +++ b/arch/x86/src/i486/up_usestack.c @@ -50,14 +50,6 @@ #include "up_internal.h" -/**************************************************************************** - * Private Types - ****************************************************************************/ - -/**************************************************************************** - * Private Function Prototypes - ****************************************************************************/ - /**************************************************************************** * Public Functions ****************************************************************************/ @@ -114,6 +106,17 @@ int up_use_stack(struct tcb_s *tcb, void *stack, size_t stack_size) tcb->stack_alloc_ptr = stack; + /* If stack debug is enabled, then fill the stack with a recognizable value + * that we can use later to test for high water marks. + */ + +#ifdef CONFIG_STACK_COLORATION + if (tcb->pid != 0) + { + memset(tcb->stack_alloc_ptr, 0xaa, stack_size); + } +#endif + /* The i486 uses a push-down stack: the stack grows toward loweraddresses * in memory. The stack pointer register, points to the lowest, valid work * address (the "top" of the stack). Items on the stack are referenced as diff --git a/arch/x86_64/src/common/up_assert.c b/arch/x86_64/src/common/up_assert.c index b092a27e210..8e76edc63b6 100644 --- a/arch/x86_64/src/common/up_assert.c +++ b/arch/x86_64/src/common/up_assert.c @@ -123,16 +123,8 @@ static void up_dumpstate(void) /* Get the limits on the user stack memory */ - if (rtcb->pid == 0) - { - ustackbase = g_idle_topstack - 8; - ustacksize = CONFIG_IDLETHREAD_STACKSIZE; - } - else - { - ustackbase = (uint64_t)rtcb->adj_stack_ptr; - ustacksize = (uint64_t)rtcb->adj_stack_size; - } + ustackbase = (uint64_t)rtcb->adj_stack_ptr; + ustacksize = (uint64_t)rtcb->adj_stack_size; /* Get the limits on the interrupt stack memory */ @@ -216,7 +208,7 @@ static void _up_assert(void) { /* Are we in an interrupt handler or the idle task? */ - if (g_current_regs || (this_task())->pid == 0) + if (g_current_regs || (running_task())->flink == NULL) { (void)up_irq_save(); for (; ; ) diff --git a/arch/x86_64/src/common/up_initialize.c b/arch/x86_64/src/common/up_initialize.c index 6e0759cf172..8d29988ca6f 100644 --- a/arch/x86_64/src/common/up_initialize.c +++ b/arch/x86_64/src/common/up_initialize.c @@ -101,12 +101,6 @@ static void up_calibratedelay(void) void up_initialize(void) { - struct tcb_s *rtcb = this_task(); - - rtcb->adj_stack_size = CONFIG_IDLETHREAD_STACKSIZE; - rtcb->stack_alloc_ptr = - (void *)(g_idle_topstack - CONFIG_IDLETHREAD_STACKSIZE); - /* Initialize global variables */ g_current_regs = NULL; diff --git a/arch/x86_64/src/intel64/up_initialstate.c b/arch/x86_64/src/intel64/up_initialstate.c index a727b9b1ecb..caa7de3c964 100644 --- a/arch/x86_64/src/intel64/up_initialstate.c +++ b/arch/x86_64/src/intel64/up_initialstate.c @@ -34,18 +34,6 @@ #include "up_arch.h" #include "sched/sched.h" -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - -/**************************************************************************** - * Private Data - ****************************************************************************/ - -/**************************************************************************** - * Private Functions - ****************************************************************************/ - /**************************************************************************** * Public Functions ****************************************************************************/ @@ -70,6 +58,14 @@ void up_initial_state(struct tcb_s *tcb) struct xcptcontext *xcp = &tcb->xcp; struct tcb_s *rtcb; + /* Initialize the idle thread stack */ + + if (tcb->pid == 0) + { + up_use_stack(tcb, (void *)(g_idle_topstack - + CONFIG_IDLETHREAD_STACKSIZE), CONFIG_IDLETHREAD_STACKSIZE); + } + /* Initialize the initial exception register context structure */ memset(xcp, 0, sizeof(struct xcptcontext)); diff --git a/arch/x86_64/src/intel64/up_usestack.c b/arch/x86_64/src/intel64/up_usestack.c index bf3977f7be8..eb5d72771a7 100644 --- a/arch/x86_64/src/intel64/up_usestack.c +++ b/arch/x86_64/src/intel64/up_usestack.c @@ -35,14 +35,6 @@ #include "up_internal.h" -/**************************************************************************** - * Private Types - ****************************************************************************/ - -/**************************************************************************** - * Private Function Prototypes - ****************************************************************************/ - /**************************************************************************** * Public Functions ****************************************************************************/ @@ -99,6 +91,17 @@ int up_use_stack(struct tcb_s *tcb, void *stack, size_t stack_size) tcb->stack_alloc_ptr = stack; + /* If stack debug is enabled, then fill the stack with a recognizable value + * that we can use later to test for high water marks. + */ + +#ifdef CONFIG_STACK_COLORATION + if (tcb->pid != 0) + { + memset(tcb->stack_alloc_ptr, 0xaa, stack_size); + } +#endif + /* The intel64 uses a push-down stack: the stack grows toward lower * addresses in memory. The stack pointer register, points to the lowest, * valid work address (the "top" of the stack). Items on the stack are diff --git a/arch/xtensa/src/common/xtensa_dumpstate.c b/arch/xtensa/src/common/xtensa_dumpstate.c index cc213433cd3..04109a072e5 100644 --- a/arch/xtensa/src/common/xtensa_dumpstate.c +++ b/arch/xtensa/src/common/xtensa_dumpstate.c @@ -180,16 +180,8 @@ void xtensa_dumpstate(void) /* Get the limits on the user stack memory */ - if (rtcb->pid == 0) /* Check for CPU0 IDLE thread */ - { - ustackbase = (uint32_t)&g_idlestack[IDLETHREAD_STACKWORDS - 1]; - ustacksize = IDLETHREAD_STACKSIZE; - } - else - { - ustackbase = (uint32_t)rtcb->adj_stack_ptr; - ustacksize = (uint32_t)rtcb->adj_stack_size; - } + ustackbase = (uint32_t)rtcb->adj_stack_ptr; + ustacksize = (uint32_t)rtcb->adj_stack_size; /* Get the limits on the interrupt stack memory */ diff --git a/arch/xtensa/src/common/xtensa_initialstate.c b/arch/xtensa/src/common/xtensa_initialstate.c index be63bb90ec1..a6cc3c7720a 100644 --- a/arch/xtensa/src/common/xtensa_initialstate.c +++ b/arch/xtensa/src/common/xtensa_initialstate.c @@ -73,6 +73,13 @@ void up_initial_state(struct tcb_s *tcb) { struct xcptcontext *xcp = &tcb->xcp; + /* Initialize the idle thread stack */ + + if (tcb->pid == 0) + { + up_use_stack(tcb, g_idlestack, IDLETHREAD_STACKSIZE); + } + /* Initialize the initial exception register context structure */ memset(xcp, 0, sizeof(struct xcptcontext)); diff --git a/arch/xtensa/src/common/xtensa_usestack.c b/arch/xtensa/src/common/xtensa_usestack.c index f5990043748..c43d78b90f5 100644 --- a/arch/xtensa/src/common/xtensa_usestack.c +++ b/arch/xtensa/src/common/xtensa_usestack.c @@ -157,9 +157,12 @@ int up_use_stack(struct tcb_s *tcb, void *stack, size_t stack_size) * water marks. */ - up_stack_color((FAR void *)((uintptr_t)tcb->stack_alloc_ptr + - sizeof(struct tls_info_s)), - tcb->adj_stack_size - sizeof(struct tls_info_s)); + if (tcb->pid != 0) + { + up_stack_color((FAR void *)((uintptr_t)tcb->stack_alloc_ptr + + sizeof(struct tls_info_s)), + size_of_stack - sizeof(struct tls_info_s)); + } #endif return OK; diff --git a/arch/z16/src/common/z16_usestack.c b/arch/z16/src/common/z16_usestack.c index 7553e4383b4..3c5612537c7 100644 --- a/arch/z16/src/common/z16_usestack.c +++ b/arch/z16/src/common/z16_usestack.c @@ -35,14 +35,6 @@ #include "z16_internal.h" -/**************************************************************************** - * Private Types - ****************************************************************************/ - -/**************************************************************************** - * Private Function Prototypes - ****************************************************************************/ - /**************************************************************************** * Public Functions ****************************************************************************/ @@ -99,6 +91,17 @@ int up_use_stack(struct tcb_s *tcb, void *stack, size_t stack_size) tcb->stack_alloc_ptr = stack; + /* If stack debug is enabled, then fill the stack with a recognizable value + * that we can use later to test for high water marks. + */ + +#ifdef CONFIG_STACK_COLORATION + if (tcb->pid != 0) + { + memset(tcb->stack_alloc_ptr, 0xaa, stack_size); + } +#endif + /* The ZNEO uses a push-down stack: the stack grows toward lower * addresses in memory. The stack pointer register, points to the * lowest, valid work address (the "top" of the stack). Items on diff --git a/arch/z80/src/common/z80_stackframe.c b/arch/z80/src/common/z80_stackframe.c index d01d937034e..25d6ba4b7e1 100644 --- a/arch/z80/src/common/z80_stackframe.c +++ b/arch/z80/src/common/z80_stackframe.c @@ -103,9 +103,9 @@ FAR void *up_stack_frame(FAR struct tcb_s *tcb, size_t frame_size) tcb->adj_stack_ptr = (uint8_t *)tcb->adj_stack_ptr - frame_size; tcb->adj_stack_size -= frame_size; - /* Reset the initial state */ + /* Reset the initial stack pointer */ - up_initial_state(tcb); + tcb->xcp.regs[REG_RSP] = (chipreg_t)tcb->adj_stack_ptr; /* And return a pointer to the allocated memory */ diff --git a/arch/z80/src/common/z80_usestack.c b/arch/z80/src/common/z80_usestack.c index 2ce1829b1dc..a3fb4eba3de 100644 --- a/arch/z80/src/common/z80_usestack.c +++ b/arch/z80/src/common/z80_usestack.c @@ -34,14 +34,6 @@ #include "z80_internal.h" -/**************************************************************************** - * Private Types - ****************************************************************************/ - -/**************************************************************************** - * Private Function Prototypes - ****************************************************************************/ - /**************************************************************************** * Public Functions ****************************************************************************/ @@ -98,6 +90,17 @@ int up_use_stack(struct tcb_s *tcb, void *stack, size_t stack_size) tcb->stack_alloc_ptr = stack; + /* If stack debug is enabled, then fill the stack with a recognizable value + * that we can use later to test for high water marks. + */ + +#ifdef CONFIG_STACK_COLORATION + if (tcb->pid != 0) + { + memset(tcb->stack_alloc_ptr, 0xaa, stack_size); + } +#endif + /* The Z80 uses a push-down stack: the stack grows toward lower * addresses in memory. The stack pointer register, points to the * lowest, valid work address (the "top" of the stack). Items on diff --git a/arch/z80/src/z180/z180_initialstate.c b/arch/z80/src/z180/z180_initialstate.c index bafae8a54de..fb883fb3d73 100644 --- a/arch/z80/src/z180/z180_initialstate.c +++ b/arch/z80/src/z180/z180_initialstate.c @@ -31,18 +31,6 @@ #include "z80_internal.h" #include "z80_arch.h" -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - -/**************************************************************************** - * Private Data - ****************************************************************************/ - -/**************************************************************************** - * Private Functions - ****************************************************************************/ - /**************************************************************************** * Public Functions ****************************************************************************/ @@ -65,6 +53,14 @@ void up_initial_state(struct tcb_s *tcb) { struct xcptcontext *xcp = &tcb->xcp; + /* Initialize the idle thread stack */ + + if (tcb->pid == 0) + { + up_use_stack(tcb, + (void *)CONFIG_STACK_BASE, CONFIG_IDLETHREAD_STACKSIZE); + } + /* Initialize the initial exception register context structure */ memset(xcp, 0, sizeof(struct xcptcontext)); diff --git a/arch/z80/src/z80/z80_initialstate.c b/arch/z80/src/z80/z80_initialstate.c index 1507f6f996f..a068a3977ba 100644 --- a/arch/z80/src/z80/z80_initialstate.c +++ b/arch/z80/src/z80/z80_initialstate.c @@ -31,18 +31,6 @@ #include "z80_internal.h" #include "z80_arch.h" -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - -/**************************************************************************** - * Private Data - ****************************************************************************/ - -/**************************************************************************** - * Private Functions - ****************************************************************************/ - /**************************************************************************** * Public Functions ****************************************************************************/ @@ -65,6 +53,14 @@ void up_initial_state(struct tcb_s *tcb) { struct xcptcontext *xcp = &tcb->xcp; + /* Initialize the idle thread stack */ + + if (tcb->pid == 0) + { + up_use_stack(tcb, + (void *)CONFIG_STACK_BASE, CONFIG_IDLETHREAD_STACKSIZE); + } + /* Initialize the initial exception register context structure */ memset(xcp, 0, sizeof(struct xcptcontext)); diff --git a/boards/arm/cxd56xx/common/src/cxd56_crashdump.c b/boards/arm/cxd56xx/common/src/cxd56_crashdump.c index 3ff34e6310a..7139cc79da2 100644 --- a/boards/arm/cxd56xx/common/src/cxd56_crashdump.c +++ b/boards/arm/cxd56xx/common/src/cxd56_crashdump.c @@ -197,16 +197,8 @@ void board_crashdump(uintptr_t currentsp, FAR void *tcb, pdump->info.stacks.user.sp = currentsp; } - if (pdump->info.pid == 0) - { - pdump->info.stacks.user.top = g_idle_topstack - 4; - pdump->info.stacks.user.size = CONFIG_IDLETHREAD_STACKSIZE; - } - else - { - pdump->info.stacks.user.top = (uint32_t)rtcb->adj_stack_ptr; - pdump->info.stacks.user.size = (uint32_t)rtcb->adj_stack_size; - } + pdump->info.stacks.user.top = (uint32_t)rtcb->adj_stack_ptr; + pdump->info.stacks.user.size = (uint32_t)rtcb->adj_stack_size; #if CONFIG_ARCH_INTERRUPTSTACK > 3 /* Get the limits on the interrupt stack memory */ diff --git a/boards/arm/stm32/nucleo-f429zi/src/stm32_bbsram.c b/boards/arm/stm32/nucleo-f429zi/src/stm32_bbsram.c index 0b51b211afa..6c8c32442c7 100644 --- a/boards/arm/stm32/nucleo-f429zi/src/stm32_bbsram.c +++ b/boards/arm/stm32/nucleo-f429zi/src/stm32_bbsram.c @@ -449,16 +449,8 @@ void board_crashdump(uintptr_t currentsp, FAR void *tcb, pdump->info.stacks.user.sp = currentsp; } - if (pdump->info.pid == 0) - { - pdump->info.stacks.user.top = g_idle_topstack - 4; - pdump->info.stacks.user.size = CONFIG_IDLETHREAD_STACKSIZE; - } - else - { - pdump->info.stacks.user.top = (uint32_t) rtcb->adj_stack_ptr; - pdump->info.stacks.user.size = (uint32_t) rtcb->adj_stack_size; - } + pdump->info.stacks.user.top = (uint32_t) rtcb->adj_stack_ptr; + pdump->info.stacks.user.size = (uint32_t) rtcb->adj_stack_size; #if CONFIG_ARCH_INTERRUPTSTACK > 3 /* Get the limits on the interrupt stack memory */ diff --git a/boards/arm/stm32f7/nucleo-144/src/stm32_bbsram.c b/boards/arm/stm32f7/nucleo-144/src/stm32_bbsram.c index 2c8dd0e857a..51589adea06 100644 --- a/boards/arm/stm32f7/nucleo-144/src/stm32_bbsram.c +++ b/boards/arm/stm32f7/nucleo-144/src/stm32_bbsram.c @@ -464,16 +464,8 @@ void board_crashdump(uintptr_t currentsp, FAR void *tcb, pdump->info.stacks.user.sp = currentsp; } - if (pdump->info.pid == 0) - { - pdump->info.stacks.user.top = g_idle_topstack - 4; - pdump->info.stacks.user.size = CONFIG_IDLETHREAD_STACKSIZE; - } - else - { - pdump->info.stacks.user.top = (uint32_t) rtcb->adj_stack_ptr; - pdump->info.stacks.user.size = (uint32_t) rtcb->adj_stack_size; - } + pdump->info.stacks.user.top = (uint32_t) rtcb->adj_stack_ptr; + pdump->info.stacks.user.size = (uint32_t) rtcb->adj_stack_size; #if CONFIG_ARCH_INTERRUPTSTACK > 3 /* Get the limits on the interrupt stack memory */ diff --git a/boards/renesas/rx65n/rx65n-grrose/src/rx65n_sbram.c b/boards/renesas/rx65n/rx65n-grrose/src/rx65n_sbram.c index 90094c789e5..80d1d89ce83 100644 --- a/boards/renesas/rx65n/rx65n-grrose/src/rx65n_sbram.c +++ b/boards/renesas/rx65n/rx65n-grrose/src/rx65n_sbram.c @@ -403,16 +403,8 @@ void board_crashdump(uintptr_t currentsp, FAR void *tcb, pdump->info.stacks.user.sp = currentsp; } - if (pdump->info.pid == 0) - { - pdump->info.stacks.user.top = g_idle_topstack - 4; - pdump->info.stacks.user.size = CONFIG_IDLETHREAD_STACKSIZE; - } - else - { - pdump->info.stacks.user.top = (uint32_t) rtcb->adj_stack_ptr; - pdump->info.stacks.user.size = (uint32_t) rtcb->adj_stack_size; - } + pdump->info.stacks.user.top = (uint32_t) rtcb->adj_stack_ptr; + pdump->info.stacks.user.size = (uint32_t) rtcb->adj_stack_size; #if CONFIG_ARCH_INTERRUPTSTACK > 3 /* Get the limits on the interrupt stack memory */ diff --git a/boards/renesas/rx65n/rx65n-rsk2mb/src/rx65n_sbram.c b/boards/renesas/rx65n/rx65n-rsk2mb/src/rx65n_sbram.c index 10a69bd1dde..98f03d6eefe 100644 --- a/boards/renesas/rx65n/rx65n-rsk2mb/src/rx65n_sbram.c +++ b/boards/renesas/rx65n/rx65n-rsk2mb/src/rx65n_sbram.c @@ -401,16 +401,8 @@ void board_crashdump(uintptr_t currentsp, FAR void *tcb, pdump->info.stacks.user.sp = currentsp; } - if (pdump->info.pid == 0) - { - pdump->info.stacks.user.top = g_idle_topstack - 4; - pdump->info.stacks.user.size = CONFIG_IDLETHREAD_STACKSIZE; - } - else - { - pdump->info.stacks.user.top = (uint32_t) rtcb->adj_stack_ptr; - pdump->info.stacks.user.size = (uint32_t) rtcb->adj_stack_size; - } + pdump->info.stacks.user.top = (uint32_t) rtcb->adj_stack_ptr; + pdump->info.stacks.user.size = (uint32_t) rtcb->adj_stack_size; #if CONFIG_ARCH_INTERRUPTSTACK > 3 /* Get the limits on the interrupt stack memory */