arch: Initialize idle thread stack information

and remove the special handling in the stack dump

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Change-Id: Ia1ef9a427bd4c7f6cee9838d0445f29cfaca3998
This commit is contained in:
Xiang Xiao
2020-07-05 13:37:48 +08:00
committed by David Sidrane
parent 5fec6191c3
commit bf7399a982
91 changed files with 747 additions and 828 deletions
+8 -47
View File
@@ -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 This file summarizes known NuttX bugs, limitations, inconsistencies with
@@ -295,49 +295,10 @@ o Task/Scheduler (sched/)
Task: IDLE THREAD TCB SETUP Task: IDLE THREAD TCB SETUP
Description: There are issues with setting IDLE thread stacks: Description: There are issues with setting IDLE thread stacks:
1. One problem is stack-related data in the IDLE threads TCB. The problem is colorizing that stack to use with stack usage
A solution might be to standardize the use of g_idle_topstack. monitoring logic. There is logic in some start functions to
That you could add initialization like this in nx_start: do this in a function called go_nx_start.
It is available in these architectures:
@@ -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:
./arm/src/efm32/efm32_start.c:static void go_nx_start(void *pv, unsigned int nbytes) ./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) ./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/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) ./arm/src/xmc4/xmc4_start.c:static void go_nx_start(void *pv, unsigned int nbytes)
But no others. But no others.
Status: Open Status: Open
Priority: Low, only needed for more complete debug. Priority: Low, only needed for more complete debug.
Title: PRIORITY INHERITANCE WITH SPORADIC SCHEDULER Title: PRIORITY INHERITANCE WITH SPORADIC SCHEDULER
Description: The sporadic scheduler manages CPU utilization by a task by Description: The sporadic scheduler manages CPU utilization by a task by
+2 -10
View File
@@ -187,16 +187,8 @@ static void up_dumpstate(void)
/* Get the limits on the user stack memory */ /* Get the limits on the user stack memory */
if (rtcb->pid == 0) /* Check for CPU0 IDLE thread */ ustackbase = (uint32_t)rtcb->adj_stack_ptr;
{ ustacksize = (uint32_t)rtcb->adj_stack_size;
ustackbase = g_idle_topstack - 4;
ustacksize = CONFIG_IDLETHREAD_STACKSIZE;
}
else
{
ustackbase = (uint32_t)rtcb->adj_stack_ptr;
ustacksize = (uint32_t)rtcb->adj_stack_size;
}
/* Get the limits on the interrupt stack memory */ /* Get the limits on the interrupt stack memory */
+8 -12
View File
@@ -48,18 +48,6 @@
#include "arm_internal.h" #include "arm_internal.h"
#include "arm_arch.h" #include "arm_arch.h"
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/****************************************************************************
* Private Data
****************************************************************************/
/****************************************************************************
* Private Functions
****************************************************************************/
/**************************************************************************** /****************************************************************************
* Public Functions * Public Functions
****************************************************************************/ ****************************************************************************/
@@ -83,6 +71,14 @@ void up_initial_state(struct tcb_s *tcb)
struct xcptcontext *xcp = &tcb->xcp; struct xcptcontext *xcp = &tcb->xcp;
uint32_t cpsr; 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 */ /* Initialize the initial exception register context structure */
memset(xcp, 0, sizeof(struct xcptcontext)); memset(xcp, 0, sizeof(struct xcptcontext));
+2 -10
View File
@@ -224,16 +224,8 @@ static void up_dumpstate(void)
/* Get the limits on the user stack memory */ /* Get the limits on the user stack memory */
if (rtcb->pid == 0) /* Check for CPU0 IDLE thread */ ustackbase = (uint32_t)rtcb->adj_stack_ptr;
{ ustacksize = (uint32_t)rtcb->adj_stack_size;
ustackbase = g_idle_topstack - 4;
ustacksize = CONFIG_IDLETHREAD_STACKSIZE;
}
else
{
ustackbase = (uint32_t)rtcb->adj_stack_ptr;
ustacksize = (uint32_t)rtcb->adj_stack_size;
}
/* Get the limits on the interrupt stack memory */ /* Get the limits on the interrupt stack memory */
+8 -12
View File
@@ -51,18 +51,6 @@
#include "psr.h" #include "psr.h"
#include "exc_return.h" #include "exc_return.h"
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/****************************************************************************
* Private Data
****************************************************************************/
/****************************************************************************
* Private Functions
****************************************************************************/
/**************************************************************************** /****************************************************************************
* Public Functions * Public Functions
****************************************************************************/ ****************************************************************************/
@@ -85,6 +73,14 @@ void up_initial_state(struct tcb_s *tcb)
{ {
struct xcptcontext *xcp = &tcb->xcp; 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 */ /* Initialize the initial exception register context structure */
memset(xcp, 0, sizeof(struct xcptcontext)); memset(xcp, 0, sizeof(struct xcptcontext));
+2 -10
View File
@@ -212,16 +212,8 @@ static void up_dumpstate(void)
/* Get the limits on the user stack memory */ /* Get the limits on the user stack memory */
if (rtcb->pid == 0) /* Check for CPU0 IDLE thread */ ustackbase = (uint32_t)rtcb->adj_stack_ptr;
{ ustacksize = (uint32_t)rtcb->adj_stack_size;
ustackbase = g_idle_topstack - 4;
ustacksize = CONFIG_IDLETHREAD_STACKSIZE;
}
else
{
ustackbase = (uint32_t)rtcb->adj_stack_ptr;
ustacksize = (uint32_t)rtcb->adj_stack_size;
}
_alert("Current sp: %08x\n", sp); _alert("Current sp: %08x\n", sp);
+8
View File
@@ -71,6 +71,14 @@ void up_initial_state(struct tcb_s *tcb)
struct xcptcontext *xcp = &tcb->xcp; struct xcptcontext *xcp = &tcb->xcp;
uint32_t cpsr; 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 */ /* Initialize the initial exception register context structure */
memset(xcp, 0, sizeof(struct xcptcontext)); memset(xcp, 0, sizeof(struct xcptcontext));
+2 -10
View File
@@ -217,16 +217,8 @@ static void up_dumpstate(void)
/* Get the limits on the user stack memory */ /* Get the limits on the user stack memory */
if (rtcb->pid == 0) /* Check for CPU0 IDLE thread */ ustackbase = (uint32_t)rtcb->adj_stack_ptr;
{ ustacksize = (uint32_t)rtcb->adj_stack_size;
ustackbase = g_idle_topstack - 4;
ustacksize = CONFIG_IDLETHREAD_STACKSIZE;
}
else
{
ustackbase = (uint32_t)rtcb->adj_stack_ptr;
ustacksize = (uint32_t)rtcb->adj_stack_size;
}
#if CONFIG_ARCH_INTERRUPTSTACK > 7 #if CONFIG_ARCH_INTERRUPTSTACK > 7
/* Get the limits on the interrupt stack memory */ /* Get the limits on the interrupt stack memory */
+8
View File
@@ -59,6 +59,14 @@ void up_initial_state(struct tcb_s *tcb)
{ {
struct xcptcontext *xcp = &tcb->xcp; 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 */ /* Initialize the initial exception register context structure */
memset(xcp, 0, sizeof(struct xcptcontext)); memset(xcp, 0, sizeof(struct xcptcontext));
+2 -10
View File
@@ -209,16 +209,8 @@ static void up_dumpstate(void)
/* Get the limits on the user stack memory */ /* Get the limits on the user stack memory */
if (rtcb->pid == 0) /* Check for CPU0 IDLE thread */ ustackbase = (uint32_t)rtcb->adj_stack_ptr;
{ ustacksize = (uint32_t)rtcb->adj_stack_size;
ustackbase = g_idle_topstack - 4;
ustacksize = CONFIG_IDLETHREAD_STACKSIZE;
}
else
{
ustackbase = (uint32_t)rtcb->adj_stack_ptr;
ustacksize = (uint32_t)rtcb->adj_stack_size;
}
_alert("Current sp: %08x\n", sp); _alert("Current sp: %08x\n", sp);
+8 -12
View File
@@ -48,18 +48,6 @@
#include "arm_internal.h" #include "arm_internal.h"
#include "arm_arch.h" #include "arm_arch.h"
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/****************************************************************************
* Private Data
****************************************************************************/
/****************************************************************************
* Private Functions
****************************************************************************/
/**************************************************************************** /****************************************************************************
* Public Functions * Public Functions
****************************************************************************/ ****************************************************************************/
@@ -83,6 +71,14 @@ void up_initial_state(struct tcb_s *tcb)
struct xcptcontext *xcp = &tcb->xcp; struct xcptcontext *xcp = &tcb->xcp;
uint32_t cpsr; 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 */ /* Initialize the initial exception register context structure */
memset(xcp, 0, sizeof(struct xcptcontext)); memset(xcp, 0, sizeof(struct xcptcontext));
+2 -10
View File
@@ -217,16 +217,8 @@ static void up_dumpstate(void)
/* Get the limits on the user stack memory */ /* Get the limits on the user stack memory */
if (rtcb->pid == 0) /* Check for CPU0 IDLE thread */ ustackbase = (uint32_t)rtcb->adj_stack_ptr;
{ ustacksize = (uint32_t)rtcb->adj_stack_size;
ustackbase = g_idle_topstack - 4;
ustacksize = CONFIG_IDLETHREAD_STACKSIZE;
}
else
{
ustackbase = (uint32_t)rtcb->adj_stack_ptr;
ustacksize = (uint32_t)rtcb->adj_stack_size;
}
#if CONFIG_ARCH_INTERRUPTSTACK > 7 #if CONFIG_ARCH_INTERRUPTSTACK > 7
/* Get the limits on the interrupt stack memory */ /* Get the limits on the interrupt stack memory */
+8
View File
@@ -59,6 +59,14 @@ void up_initial_state(struct tcb_s *tcb)
{ {
struct xcptcontext *xcp = &tcb->xcp; 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 */ /* Initialize the initial exception register context structure */
memset(xcp, 0, sizeof(struct xcptcontext)); memset(xcp, 0, sizeof(struct xcptcontext));
+5 -2
View File
@@ -146,8 +146,11 @@ int up_use_stack(struct tcb_s *tcb, void *stack, size_t stack_size)
* water marks. * water marks.
*/ */
arm_stack_color((FAR void *)((uintptr_t)tcb->adj_stack_ptr - if (tcb->pid != 0)
tcb->adj_stack_size), tcb->adj_stack_size); {
arm_stack_color((FAR void *)((uintptr_t)tcb->adj_stack_ptr -
tcb->adj_stack_size), tcb->adj_stack_size);
}
#endif /* CONFIG_STACK_COLORATION */ #endif /* CONFIG_STACK_COLORATION */
return OK; return OK;
-16
View File
@@ -42,22 +42,6 @@
#include <nuttx/config.h> #include <nuttx/config.h>
/****************************************************************************
* 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 * Public Functions
****************************************************************************/ ****************************************************************************/
-11
View File
@@ -77,17 +77,6 @@ extern "C"
#define EXTERN extern #define EXTERN extern
#endif #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 * Public Function Prototypes
************************************************************************************/ ************************************************************************************/
-16
View File
@@ -42,22 +42,6 @@
#include <nuttx/config.h> #include <nuttx/config.h>
/************************************************************************************
* 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 * Public Function Prototypes
************************************************************************************/ ************************************************************************************/
-16
View File
@@ -42,22 +42,6 @@
#include <nuttx/config.h> #include <nuttx/config.h>
/************************************************************************************
* 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 * Public Function Prototypes
************************************************************************************/ ************************************************************************************/
@@ -42,22 +42,6 @@
#include <nuttx/config.h> #include <nuttx/config.h>
/************************************************************************************
* 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 * Public Function Prototypes
************************************************************************************/ ************************************************************************************/
-15
View File
@@ -50,23 +50,8 @@
#include "arm_internal.h" #include "arm_internal.h"
#include "chip.h" #include "chip.h"
/************************************************************************************
* Public Data
************************************************************************************/
#ifndef __ASSEMBLY__ #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 * Public Function Prototypes
************************************************************************************/ ************************************************************************************/
-15
View File
@@ -50,23 +50,8 @@
#include "arm_internal.h" #include "arm_internal.h"
#include "chip.h" #include "chip.h"
/************************************************************************************
* Public Data
************************************************************************************/
#ifndef __ASSEMBLY__ #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 * Public Function Prototypes
************************************************************************************/ ************************************************************************************/
-15
View File
@@ -50,23 +50,8 @@
#include "arm_internal.h" #include "arm_internal.h"
#include "chip.h" #include "chip.h"
/************************************************************************************
* Public Data
************************************************************************************/
#ifndef __ASSEMBLY__ #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 * Public Function Prototypes
************************************************************************************/ ************************************************************************************/
-11
View File
@@ -56,17 +56,6 @@
#ifndef __ASSEMBLY__ #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 /* Each S32K1xx board must provide the following initialized structure. This is
* needed to establish the initial board clocking. * needed to establish the initial board clocking.
*/ */
-16
View File
@@ -42,22 +42,6 @@
#include <nuttx/config.h> #include <nuttx/config.h>
/************************************************************************************
* 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 * Public Function Prototypes
************************************************************************************/ ************************************************************************************/
-16
View File
@@ -42,22 +42,6 @@
#include <nuttx/config.h> #include <nuttx/config.h>
/************************************************************************************
* 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 * Public Function Prototypes
************************************************************************************/ ************************************************************************************/
-27
View File
@@ -50,24 +50,8 @@
#include "arm_internal.h" #include "arm_internal.h"
#include "chip.h" #include "chip.h"
/************************************************************************************
* Pre-processor Definitions
************************************************************************************/
/************************************************************************************
* Public Types
************************************************************************************/
/************************************************************************************
* Inline Functions
************************************************************************************/
#ifndef __ASSEMBLY__ #ifndef __ASSEMBLY__
/************************************************************************************
* Public Data
************************************************************************************/
#undef EXTERN #undef EXTERN
#if defined(__cplusplus) #if defined(__cplusplus)
#define EXTERN extern "C" #define EXTERN extern "C"
@@ -77,17 +61,6 @@ extern "C"
#define EXTERN extern #define EXTERN extern
#endif #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 * Public Function Prototypes
************************************************************************************/ ************************************************************************************/
-16
View File
@@ -42,22 +42,6 @@
#include <nuttx/config.h> #include <nuttx/config.h>
/************************************************************************************
* 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 * Public Function Prototypes
************************************************************************************/ ************************************************************************************/
-15
View File
@@ -50,10 +50,6 @@
#include "arm_internal.h" #include "arm_internal.h"
#include "chip.h" #include "chip.h"
/************************************************************************************
* Public Data
************************************************************************************/
#ifndef __ASSEMBLY__ #ifndef __ASSEMBLY__
#undef EXTERN #undef EXTERN
@@ -65,17 +61,6 @@ extern "C"
#define EXTERN extern #define EXTERN extern
#endif #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 * Public Function Prototypes
************************************************************************************/ ************************************************************************************/
-15
View File
@@ -50,10 +50,6 @@
#include "arm_internal.h" #include "arm_internal.h"
#include "chip.h" #include "chip.h"
/************************************************************************************
* Public Data
************************************************************************************/
#ifndef __ASSEMBLY__ #ifndef __ASSEMBLY__
#undef EXTERN #undef EXTERN
@@ -65,17 +61,6 @@ extern "C"
#define EXTERN extern #define EXTERN extern
#endif #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 * Public Function Prototypes
************************************************************************************/ ************************************************************************************/
-16
View File
@@ -42,22 +42,6 @@
#include <nuttx/config.h> #include <nuttx/config.h>
/****************************************************************************
* 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 * Public Functions
****************************************************************************/ ****************************************************************************/
-27
View File
@@ -50,24 +50,8 @@
#include "arm_internal.h" #include "arm_internal.h"
#include "chip.h" #include "chip.h"
/************************************************************************************
* Pre-processor Definitions
************************************************************************************/
/************************************************************************************
* Public Types
************************************************************************************/
/************************************************************************************
* Inline Functions
************************************************************************************/
#ifndef __ASSEMBLY__ #ifndef __ASSEMBLY__
/************************************************************************************
* Public Data
************************************************************************************/
#undef EXTERN #undef EXTERN
#if defined(__cplusplus) #if defined(__cplusplus)
#define EXTERN extern "C" #define EXTERN extern "C"
@@ -77,17 +61,6 @@ extern "C"
#define EXTERN extern #define EXTERN extern
#endif #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 * Public Function Prototypes
************************************************************************************/ ************************************************************************************/
+2 -10
View File
@@ -154,16 +154,8 @@ void up_dumpstate(void)
/* Get the limits on the user stack memory */ /* Get the limits on the user stack memory */
if (rtcb->pid == 0) /* Check for CPU0 IDLE thread */ ustackbase = (uint16_t)rtcb->adj_stack_ptr;
{ ustacksize = (uint16_t)rtcb->adj_stack_size;
ustackbase = g_idle_topstack - 1;
ustacksize = CONFIG_IDLETHREAD_STACKSIZE;
}
else
{
ustackbase = (uint16_t)rtcb->adj_stack_ptr;
ustacksize = (uint16_t)rtcb->adj_stack_size;
}
/* Get the limits on the interrupt stack memory */ /* Get the limits on the interrupt stack memory */
+8
View File
@@ -71,6 +71,14 @@ void up_initial_state(struct tcb_s *tcb)
{ {
struct xcptcontext *xcp = &tcb->xcp; 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 /* Initialize the initial exception register context structure. Zeroing
* all registers is a good debug helper, but should not be necessary. * all registers is a good debug helper, but should not be necessary.
*/ */
+4 -9
View File
@@ -51,14 +51,6 @@
#include "up_internal.h" #include "up_internal.h"
/****************************************************************************
* Private Types
****************************************************************************/
/****************************************************************************
* Private Function Prototypes
****************************************************************************/
/**************************************************************************** /****************************************************************************
* Public Functions * Public Functions
****************************************************************************/ ****************************************************************************/
@@ -119,7 +111,10 @@ int up_use_stack(struct tcb_s *tcb, void *stack, size_t stack_size)
*/ */
#ifdef CONFIG_STACK_COLORATION #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 #endif
/* The AVR uses a push-down stack: the stack grows toward loweraddresses /* The AVR uses a push-down stack: the stack grows toward loweraddresses
+2 -10
View File
@@ -124,16 +124,8 @@ void up_dumpstate(void)
/* Get the limits on the user stack memory */ /* Get the limits on the user stack memory */
if (rtcb->pid == 0) /* Check for CPU0 IDLE thread */ ustackbase = (uint32_t)rtcb->adj_stack_ptr;
{ ustacksize = (uint32_t)rtcb->adj_stack_size;
ustackbase = g_idle_topstack - 4;
ustacksize = CONFIG_IDLETHREAD_STACKSIZE;
}
else
{
ustackbase = (uint32_t)rtcb->adj_stack_ptr;
ustacksize = (uint32_t)rtcb->adj_stack_size;
}
/* Get the limits on the interrupt stack memory */ /* Get the limits on the interrupt stack memory */
+8 -12
View File
@@ -48,18 +48,6 @@
#include "up_internal.h" #include "up_internal.h"
#include "up_arch.h" #include "up_arch.h"
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/****************************************************************************
* Private Data
****************************************************************************/
/****************************************************************************
* Private Functions
****************************************************************************/
/**************************************************************************** /****************************************************************************
* Public Functions * Public Functions
****************************************************************************/ ****************************************************************************/
@@ -81,6 +69,14 @@ void up_initial_state(struct tcb_s *tcb)
{ {
struct xcptcontext *xcp = &tcb->xcp; 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 /* Initialize the initial exception register context structure. Zeroing
* all registers is a good debug helper, but should not be necessary. * all registers is a good debug helper, but should not be necessary.
*/ */
+4 -9
View File
@@ -50,14 +50,6 @@
#include "up_internal.h" #include "up_internal.h"
/****************************************************************************
* Private Types
****************************************************************************/
/****************************************************************************
* Private Function Prototypes
****************************************************************************/
/**************************************************************************** /****************************************************************************
* Public Functions * Public Functions
****************************************************************************/ ****************************************************************************/
@@ -119,7 +111,10 @@ int up_use_stack(struct tcb_s *tcb, void *stack, size_t stack_size)
*/ */
#ifdef CONFIG_STACK_COLORATION #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 #endif
/* The AVR32 uses a push-down stack: the stack grows /* The AVR32 uses a push-down stack: the stack grows
+11 -8
View File
@@ -49,14 +49,6 @@
#include "up_internal.h" #include "up_internal.h"
/****************************************************************************
* Private Types
****************************************************************************/
/****************************************************************************
* Private Function Prototypes
****************************************************************************/
/**************************************************************************** /****************************************************************************
* Public Functions * 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; 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 /* The CPU12 uses a push-down stack: the stack grows
* toward lower addresses in memory. Because the CPU12 stack * toward lower addresses in memory. Because the CPU12 stack
* operates as a decrement then store stack, the value assigned * operates as a decrement then store stack, the value assigned
+2 -10
View File
@@ -199,16 +199,8 @@ static void up_dumpstate(void)
/* Get the limits on the user stack memory */ /* Get the limits on the user stack memory */
if (rtcb->pid == 0) /* Check for CPU0 IDLE thread */ ustackbase = (uint16_t)rtcb->adj_stack_ptr;
{ ustacksize = (uint16_t)rtcb->adj_stack_size;
ustackbase = g_idle_topstack - 4;
ustacksize = CONFIG_IDLETHREAD_STACKSIZE;
}
else
{
ustackbase = (uint16_t)rtcb->adj_stack_ptr;
ustacksize = (uint16_t)rtcb->adj_stack_size;
}
/* Get the limits on the interrupt stack memory */ /* Get the limits on the interrupt stack memory */
+8 -12
View File
@@ -46,18 +46,6 @@
#include "up_internal.h" #include "up_internal.h"
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/****************************************************************************
* Private Data
****************************************************************************/
/****************************************************************************
* Private Functions
****************************************************************************/
/**************************************************************************** /****************************************************************************
* Public Functions * Public Functions
****************************************************************************/ ****************************************************************************/
@@ -80,6 +68,14 @@ void up_initial_state(struct tcb_s *tcb)
{ {
struct xcptcontext *xcp = &tcb->xcp; 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 */ /* Initialize the initial exception register context structure */
memset(xcp, 0, sizeof(struct xcptcontext)); memset(xcp, 0, sizeof(struct xcptcontext));
+11 -8
View File
@@ -70,14 +70,6 @@
#define STACK_ALIGN_DOWN(a) ((a) & ~STACK_ALIGN_MASK) #define STACK_ALIGN_DOWN(a) ((a) & ~STACK_ALIGN_MASK)
#define STACK_ALIGN_UP(a) (((a) + STACK_ALIGN_MASK) & ~STACK_ALIGN_MASK) #define STACK_ALIGN_UP(a) (((a) + STACK_ALIGN_MASK) & ~STACK_ALIGN_MASK)
/****************************************************************************
* Private Types
****************************************************************************/
/****************************************************************************
* Private Function Prototypes
****************************************************************************/
/**************************************************************************** /****************************************************************************
* Public Functions * 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; 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 /* MIPS uses a push-down stack: the stack grows toward loweraddresses in
* memory. The stack pointer register, points to the lowest, valid work * memory. The stack pointer register, points to the lowest, valid work
* address (the "top" of the stack). Items on the stack are referenced * address (the "top" of the stack). Items on the stack are referenced
+2 -10
View File
@@ -144,16 +144,8 @@ void up_dumpstate(void)
/* Get the limits on the user stack memory */ /* Get the limits on the user stack memory */
if (rtcb->pid == 0) /* Check for CPU0 IDLE thread */ ustackbase = (uint32_t)rtcb->adj_stack_ptr;
{ ustacksize = (uint32_t)rtcb->adj_stack_size;
ustackbase = g_idle_topstack - 4;
ustacksize = CONFIG_IDLETHREAD_STACKSIZE;
}
else
{
ustackbase = (uint32_t)rtcb->adj_stack_ptr;
ustacksize = (uint32_t)rtcb->adj_stack_size;
}
/* Get the limits on the interrupt stack memory */ /* Get the limits on the interrupt stack memory */
+8
View File
@@ -73,6 +73,14 @@ void up_initial_state(struct tcb_s *tcb)
struct xcptcontext *xcp = &tcb->xcp; struct xcptcontext *xcp = &tcb->xcp;
uint32_t regval; 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 */ /* Initialize the initial exception register context structure */
memset(xcp, 0, sizeof(struct xcptcontext)); memset(xcp, 0, sizeof(struct xcptcontext));
+1 -1
View File
@@ -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_irq.c lm32_releasepending.c lm32_releasestack.c
CHIP_CSRCS += lm32_stackframe.c lm32_swint.c lm32_unblocktask.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_reprioritizertr.c lm32_schedulesigaction.c lm32_sigdeliver.c
CHIP_CSRCS += lm32_flushcache.c CHIP_CSRCS += lm32_flushcache.c lm32_usetack.c
+2 -10
View File
@@ -141,16 +141,8 @@ void lm32_dumpstate(void)
/* Get the limits on the user stack memory */ /* Get the limits on the user stack memory */
if (rtcb->pid == 0) /* Check for CPU0 IDLE thread */ ustackbase = (uint32_t)rtcb->adj_stack_ptr;
{ ustacksize = (uint32_t)rtcb->adj_stack_size;
ustackbase = g_idle_topstack - 4;
ustacksize = CONFIG_IDLETHREAD_STACKSIZE;
}
else
{
ustackbase = (uint32_t)rtcb->adj_stack_ptr;
ustacksize = (uint32_t)rtcb->adj_stack_size;
}
/* Get the limits on the interrupt stack memory */ /* Get the limits on the interrupt stack memory */
+8 -12
View File
@@ -49,18 +49,6 @@
#include "lm32.h" #include "lm32.h"
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/****************************************************************************
* Private Data
****************************************************************************/
/****************************************************************************
* Private Functions
****************************************************************************/
/**************************************************************************** /****************************************************************************
* Public Functions * Public Functions
****************************************************************************/ ****************************************************************************/
@@ -83,6 +71,14 @@ void up_initial_state(struct tcb_s *tcb)
{ {
struct xcptcontext *xcp = &tcb->xcp; 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 */ /* Initialize the initial exception register context structure */
memset(xcp, 0, sizeof(struct xcptcontext)); memset(xcp, 0, sizeof(struct xcptcontext));
+128
View File
@@ -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 <nuttx/config.h>
#include <sys/types.h>
#include <stdint.h>
#include <sched.h>
#include <debug.h>
#include <nuttx/kmalloc.h>
#include <nuttx/arch.h>
#include <nuttx/tls.h>
/****************************************************************************
* 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;
}
+1 -1
View File
@@ -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_irq.c minerva_releasepending.c minerva_releasestack.c
CHIP_CSRCS += minerva_stackframe.c minerva_swint.c minerva_unblocktask.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_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
+2 -10
View File
@@ -148,16 +148,8 @@ void minerva_dumpstate(void)
* == NULL) * == NULL)
*/ */
if (rtcb->flink == NULL) ustackbase = (uint32_t) rtcb->adj_stack_ptr;
{ ustacksize = (uint32_t) rtcb->adj_stack_size;
ustackbase = g_idle_topstack - 4;
ustacksize = CONFIG_IDLETHREAD_STACKSIZE;
}
else
{
ustackbase = (uint32_t) rtcb->adj_stack_ptr;
ustacksize = (uint32_t) rtcb->adj_stack_size;
}
/* Get the limits on the interrupt stack memory */ /* Get the limits on the interrupt stack memory */
@@ -75,6 +75,14 @@ void up_initial_state(struct tcb_s *tcb)
uint32_t regval; uint32_t regval;
struct xcptcontext *xcp = &tcb->xcp; 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 */ /* Initialize the initial exception register context structure */
memset(xcp, 0, sizeof(struct xcptcontext)); memset(xcp, 0, sizeof(struct xcptcontext));

Some files were not shown because too many files have changed in this diff Show More