You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by pk...@apache.org on 2022/03/12 22:28:19 UTC
[incubator-nuttx] branch master updated: arch/ceva: Move the idle stack initialization to up_initial_state
This is an automated email from the ASF dual-hosted git repository.
pkarashchenko pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git
The following commit(s) were added to refs/heads/master by this push:
new f94093b arch/ceva: Move the idle stack initialization to up_initial_state
f94093b is described below
commit f94093bc2eb95c1f737dde4501aa8487dbac3942
Author: Xiang Xiao <xi...@xiaomi.com>
AuthorDate: Sat Mar 12 23:46:52 2022 +0800
arch/ceva: Move the idle stack initialization to up_initial_state
to follow other arch's implementation
Signed-off-by: Xiang Xiao <xi...@xiaomi.com>
---
arch/ceva/include/arch.h | 2 ++
arch/ceva/src/common/up_createstack.c | 8 ++++++--
arch/ceva/src/common/up_initialize.c | 11 -----------
arch/ceva/src/common/up_start.c | 4 ----
arch/ceva/src/xc5/up_initialstate.c | 19 +++++++++++++++++++
arch/ceva/src/xm6/up_initialstate.c | 19 +++++++++++++++++++
6 files changed, 46 insertions(+), 17 deletions(-)
diff --git a/arch/ceva/include/arch.h b/arch/ceva/include/arch.h
index 4dfdd2d..ecb877d 100644
--- a/arch/ceva/include/arch.h
+++ b/arch/ceva/include/arch.h
@@ -30,6 +30,8 @@
****************************************************************************/
#include <nuttx/config.h>
+
+#include <arch/irq.h>
#include <arch/chip/chip.h>
/****************************************************************************
diff --git a/arch/ceva/src/common/up_createstack.c b/arch/ceva/src/common/up_createstack.c
index 0868af0..1eab7ad 100644
--- a/arch/ceva/src/common/up_createstack.c
+++ b/arch/ceva/src/common/up_createstack.c
@@ -230,8 +230,12 @@ int up_create_stack(FAR struct tcb_s *tcb, size_t stack_size, uint8_t ttype)
#ifdef CONFIG_STACK_COLORATION
void up_stack_color(FAR void *stackbase, size_t nbytes)
{
- uint32_t *stkptr = stackbase;
- size_t nwords = nbytes / sizeof(uint32_t);
+ /* Take extra care that we do not write outsize the stack boundaries */
+
+ uint32_t *stkptr = (uint32_t *)(((uintptr_t)stackbase + 3) & ~3);
+ uintptr_t stkend = nbytes ? (((uintptr_t)stackbase + nbytes) & ~3) :
+ up_getsp(); /* 0: colorize the running stack */
+ size_t nwords = (stkend - (uintptr_t)stackbase) >> 2;
/* Set the entire stack to the coloration value */
diff --git a/arch/ceva/src/common/up_initialize.c b/arch/ceva/src/common/up_initialize.c
index 8a82cf8..c2476b0 100644
--- a/arch/ceva/src/common/up_initialize.c
+++ b/arch/ceva/src/common/up_initialize.c
@@ -47,8 +47,6 @@
#include "up_internal.h"
#include "chip.h"
-#include "sched/sched.h"
-
/****************************************************************************
* Private Functions
****************************************************************************/
@@ -98,19 +96,10 @@ static inline void up_color_intstack(void)
void up_initialize(void)
{
- struct tcb_s *idle;
-
/* Initialize global variables */
CURRENT_REGS = NULL;
- /* Initialize the idle task stack info */
-
- idle = this_task(); /* It should be idle task */
- idle->stack_alloc_ptr = g_idle_basestack;
- idle->stack_base_ptr = g_idle_topstack;
- idle->adj_stack_size = g_idle_topstack - g_idle_basestack;
-
/* Colorize the interrupt stack */
up_color_intstack();
diff --git a/arch/ceva/src/common/up_start.c b/arch/ceva/src/common/up_start.c
index 754f36c..94e91e4 100644
--- a/arch/ceva/src/common/up_start.c
+++ b/arch/ceva/src/common/up_start.c
@@ -243,10 +243,6 @@ static void init_kernelspace(void)
mpu_priv_data(g_idle_basestack,
g_idle_topstack - g_idle_basestack);
-#ifdef CONFIG_STACK_COLORATION
- up_stack_color(g_idle_basestack,
- g_idle_topstack - g_idle_basestack - 256);
-#endif
}
#ifdef CONFIG_BUILD_PROTECTED
diff --git a/arch/ceva/src/xc5/up_initialstate.c b/arch/ceva/src/xc5/up_initialstate.c
index 6c94a2d..bdd62bd 100644
--- a/arch/ceva/src/xc5/up_initialstate.c
+++ b/arch/ceva/src/xc5/up_initialstate.c
@@ -29,6 +29,8 @@
#include <nuttx/arch.h>
#include <nuttx/irq.h>
+#include "up_internal.h"
+
/****************************************************************************
* Public Functions
****************************************************************************/
@@ -51,6 +53,23 @@ void up_initial_state(struct tcb_s *tcb)
{
struct xcptcontext *xcp = &tcb->xcp;
+ /* Initialize the idle thread stack */
+
+ if (tcb->pid == 0)
+ {
+ tcb->stack_alloc_ptr = g_idle_basestack;
+ tcb->stack_base_ptr = tcb->stack_alloc_ptr;
+ tcb->adj_stack_size = g_idle_topstack - g_idle_basestack;
+#ifdef CONFIG_STACK_COLORATION
+ /* If stack debug is enabled, then fill the stack with a
+ * recognizable value that we can use later to test for high
+ * water marks.
+ */
+
+ up_stack_color(tcb->stack_alloc_ptr, 0);
+#endif /* CONFIG_STACK_COLORATION */
+ }
+
/* Initialize the initial exception register context structure */
memset(xcp, 0, sizeof(struct xcptcontext));
diff --git a/arch/ceva/src/xm6/up_initialstate.c b/arch/ceva/src/xm6/up_initialstate.c
index d9f7025..d7207cb 100644
--- a/arch/ceva/src/xm6/up_initialstate.c
+++ b/arch/ceva/src/xm6/up_initialstate.c
@@ -29,6 +29,8 @@
#include <nuttx/arch.h>
#include <nuttx/irq.h>
+#include "up_internal.h"
+
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
@@ -57,6 +59,23 @@ void up_initial_state(struct tcb_s *tcb)
{
struct xcptcontext *xcp = &tcb->xcp;
+ /* Initialize the idle thread stack */
+
+ if (tcb->pid == 0)
+ {
+ tcb->stack_alloc_ptr = g_idle_basestack;
+ tcb->stack_base_ptr = tcb->stack_alloc_ptr;
+ tcb->adj_stack_size = g_idle_topstack - g_idle_basestack;
+#ifdef CONFIG_STACK_COLORATION
+ /* If stack debug is enabled, then fill the stack with a
+ * recognizable value that we can use later to test for high
+ * water marks.
+ */
+
+ up_stack_color(tcb->stack_alloc_ptr, 0);
+#endif /* CONFIG_STACK_COLORATION */
+ }
+
/* Initialize the initial exception register context structure */
memset(xcp, 0, sizeof(struct xcptcontext));