You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by xi...@apache.org on 2022/04/25 17:37:00 UTC

[incubator-nuttx] branch master updated: arch/xtensa: Simply use xtensa_createstack for CPU1 idle task.

This is an automated email from the ASF dual-hosted git repository.

xiaoxiang 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 aaa5316235 arch/xtensa: Simply use xtensa_createstack for CPU1 idle task.
aaa5316235 is described below

commit aaa53162357923837071499a3edfbaa86141a6f2
Author: Abdelatif Guettouche <ab...@espressif.com>
AuthorDate: Mon Apr 25 14:54:18 2022 +0200

    arch/xtensa: Simply use xtensa_createstack for CPU1 idle task.
    
    Signed-off-by: Abdelatif Guettouche <ab...@espressif.com>
---
 arch/xtensa/src/esp32/esp32_cpuidlestack.c     | 38 ++------------------------
 arch/xtensa/src/esp32/esp32_smp.h              | 15 ----------
 arch/xtensa/src/esp32s3/esp32s3_cpuidlestack.c | 38 ++------------------------
 arch/xtensa/src/esp32s3/esp32s3_smp.h          | 15 ----------
 4 files changed, 6 insertions(+), 100 deletions(-)

diff --git a/arch/xtensa/src/esp32/esp32_cpuidlestack.c b/arch/xtensa/src/esp32/esp32_cpuidlestack.c
index dae3d4122a..164f0a0204 100644
--- a/arch/xtensa/src/esp32/esp32_cpuidlestack.c
+++ b/arch/xtensa/src/esp32/esp32_cpuidlestack.c
@@ -34,11 +34,6 @@
  * Public Data
  ****************************************************************************/
 
-/* Address of the CPU0 IDLE thread */
-
-uint32_t g_cpu1_idlestack[CPU1_IDLETHREAD_STACKWORDS]
-  aligned_data(16) locate_data(".noinit");
-
 /****************************************************************************
  * Public Functions
  ****************************************************************************/
@@ -81,41 +76,14 @@ uint32_t g_cpu1_idlestack[CPU1_IDLETHREAD_STACKWORDS]
  *                  being created for.
  *   - tcb:         The TCB of new CPU IDLE task
  *   - stack_size:  The requested stack size for the IDLE task.  At least
- *                  this much must be allocated.  This should be
- *                  CONFIG_IDLETHREAD_STACKSIZE.
+ *                  this much must be allocated.
  *
  ****************************************************************************/
 
 int up_cpu_idlestack(int cpu, struct tcb_s *tcb, size_t stack_size)
 {
-  /* XTENSA uses a push-down stack:  the stack grows toward lower* addresses
-   * in memory.  The stack pointer register points to the lowest, valid
-   * working address (the "top" of the stack).  Items on the stack are
-   * referenced as positive word offsets from sp.
-   */
-
-  /* Save information about pre-allocated IDLE thread stack */
-
-  tcb->stack_alloc_ptr = g_cpu1_idlestack;
-  tcb->adj_stack_size  = CPU1_IDLETHREAD_STACKSIZE;
-  tcb->stack_base_ptr  = tcb->stack_alloc_ptr;
-
-#ifdef CONFIG_STACK_COLORATION
-    {
-      register uint32_t *ptr;
-      register int i;
-
-      /* If stack debug is enabled, then fill the stack with a recognizable
-       * value that we can use later to test for high water marks.
-       */
-
-      for (i = 0, ptr = (uint32_t *)tcb->stack_alloc_ptr;
-           i < tcb->adj_stack_size;
-           i += sizeof(uint32_t))
-        {
-          *ptr++ = STACK_COLOR;
-        }
-    }
+#if CONFIG_SMP_NCPUS > 1
+  up_create_stack(tcb, stack_size, TCB_FLAG_TTYPE_KERNEL);
 #endif
 
 #if XCHAL_CP_NUM > 0
diff --git a/arch/xtensa/src/esp32/esp32_smp.h b/arch/xtensa/src/esp32/esp32_smp.h
index 3b1d142e22..b8d560be14 100644
--- a/arch/xtensa/src/esp32/esp32_smp.h
+++ b/arch/xtensa/src/esp32/esp32_smp.h
@@ -33,25 +33,10 @@
  * Pre-procesor Definitions
  ****************************************************************************/
 
-/* An IDLE thread stack size for CPU0 must be defined */
-
-#if !defined(CONFIG_IDLETHREAD_STACKSIZE)
-#  error CONFIG_IDLETHREAD_STACKSIZE is not defined
-#elif CONFIG_IDLETHREAD_STACKSIZE < 16
-#  error CONFIG_IDLETHREAD_STACKSIZE is to small
-#endif
-
-#define CPU1_IDLETHREAD_STACKSIZE ((CONFIG_IDLETHREAD_STACKSIZE + 15) & ~15)
-#define CPU1_IDLETHREAD_STACKWORDS (CPU1_IDLETHREAD_STACKSIZE >> 2)
-
 /****************************************************************************
  * Public Data
  ****************************************************************************/
 
-/* This is the CPU1 IDLE stack */
-
-extern uint32_t g_cpu1_idlestack[CPU1_IDLETHREAD_STACKWORDS];
-
 /****************************************************************************
  * Public Function Prototypes
  ****************************************************************************/
diff --git a/arch/xtensa/src/esp32s3/esp32s3_cpuidlestack.c b/arch/xtensa/src/esp32s3/esp32s3_cpuidlestack.c
index b028abee4d..9af708ef78 100644
--- a/arch/xtensa/src/esp32s3/esp32s3_cpuidlestack.c
+++ b/arch/xtensa/src/esp32s3/esp32s3_cpuidlestack.c
@@ -34,11 +34,6 @@
  * Public Data
  ****************************************************************************/
 
-/* Address of the CPU1 IDLE thread */
-
-uint32_t g_cpu1_idlestack[CPU1_IDLETHREAD_STACKWORDS]
-  aligned_data(16) locate_data(".noinit");
-
 /****************************************************************************
  * Public Functions
  ****************************************************************************/
@@ -81,41 +76,14 @@ uint32_t g_cpu1_idlestack[CPU1_IDLETHREAD_STACKWORDS]
  *                  being created for.
  *   - tcb:         The TCB of new CPU IDLE task
  *   - stack_size:  The requested stack size for the IDLE task.  At least
- *                  this much must be allocated.  This should be
- *                  CONFIG_IDLETHREAD_STACKSIZE.
+ *                  this much must be allocated.
  *
  ****************************************************************************/
 
 int up_cpu_idlestack(int cpu, struct tcb_s *tcb, size_t stack_size)
 {
-  /* XTENSA uses a push-down stack:  the stack grows toward lower* addresses
-   * in memory.  The stack pointer register points to the lowest, valid
-   * working address (the "top" of the stack).  Items on the stack are
-   * referenced as positive word offsets from sp.
-   */
-
-  /* Save information about pre-allocated IDLE thread stack */
-
-  tcb->stack_alloc_ptr = g_cpu1_idlestack;
-  tcb->adj_stack_size  = CPU1_IDLETHREAD_STACKSIZE;
-  tcb->stack_base_ptr  = tcb->stack_alloc_ptr;
-
-#ifdef CONFIG_STACK_COLORATION
-    {
-      register uint32_t *ptr;
-      register int i;
-
-      /* If stack debug is enabled, then fill the stack with a recognizable
-       * value that we can use later to test for high water marks.
-       */
-
-      for (i = 0, ptr = (uint32_t *)tcb->stack_alloc_ptr;
-           i < tcb->adj_stack_size;
-           i += sizeof(uint32_t))
-        {
-          *ptr++ = STACK_COLOR;
-        }
-    }
+#if CONFIG_SMP_NCPUS > 1
+  up_create_stack(tcb, stack_size, TCB_FLAG_TTYPE_KERNEL);
 #endif
 
   return OK;
diff --git a/arch/xtensa/src/esp32s3/esp32s3_smp.h b/arch/xtensa/src/esp32s3/esp32s3_smp.h
index 80a1cef55b..eb9aef2070 100644
--- a/arch/xtensa/src/esp32s3/esp32s3_smp.h
+++ b/arch/xtensa/src/esp32s3/esp32s3_smp.h
@@ -33,25 +33,10 @@
  * Pre-procesor Definitions
  ****************************************************************************/
 
-/* An IDLE thread stack size for CPU0 must be defined */
-
-#if !defined(CONFIG_IDLETHREAD_STACKSIZE)
-#  error CONFIG_IDLETHREAD_STACKSIZE is not defined
-#elif CONFIG_IDLETHREAD_STACKSIZE < 16
-#  error CONFIG_IDLETHREAD_STACKSIZE is to small
-#endif
-
-#define CPU1_IDLETHREAD_STACKSIZE ((CONFIG_IDLETHREAD_STACKSIZE + 15) & ~15)
-#define CPU1_IDLETHREAD_STACKWORDS (CPU1_IDLETHREAD_STACKSIZE >> 2)
-
 /****************************************************************************
  * Public Data
  ****************************************************************************/
 
-/* This is the CPU1 IDLE stack */
-
-extern uint32_t g_cpu1_idlestack[CPU1_IDLETHREAD_STACKWORDS];
-
 /****************************************************************************
  * Public Function Prototypes
  ****************************************************************************/