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

GUIDINGLI pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git

commit b2f9466462cfca8d56d74d4bbe29707eee8ecd7d
Author: hujun5 <[email protected]>
AuthorDate: Mon Dec 29 11:19:35 2025 +0800

    arm_a_r: merge arm_cpuidlestack.c
    
    merge arm_cpuidlestack.c
    
    Signed-off-by: hujun5 <[email protected]>
---
 arch/arm/src/arm_a_r/CMakeLists.txt                |   1 +
 arch/arm/src/arm_a_r/Make.defs                     |   2 +-
 .../src/{armv7-a => arm_a_r}/arm_cpuidlestack.c    |   2 +-
 arch/arm/src/armv7-a/CMakeLists.txt                |   2 +-
 arch/arm/src/armv7-a/Make.defs                     |   2 +-
 arch/arm/src/armv7-r/CMakeLists.txt                |   9 +-
 arch/arm/src/armv7-r/Make.defs                     |   2 +-
 arch/arm/src/armv7-r/arm_cpuidlestack.c            | 134 ---------------------
 arch/arm/src/armv8-r/CMakeLists.txt                |   2 +-
 arch/arm/src/armv8-r/Make.defs                     |   2 +-
 arch/arm/src/armv8-r/arm_cpuidlestack.c            | 134 ---------------------
 11 files changed, 9 insertions(+), 283 deletions(-)

diff --git a/arch/arm/src/arm_a_r/CMakeLists.txt 
b/arch/arm/src/arm_a_r/CMakeLists.txt
index e8918919822..3d2b3763bc1 100644
--- a/arch/arm/src/arm_a_r/CMakeLists.txt
+++ b/arch/arm/src/arm_a_r/CMakeLists.txt
@@ -40,6 +40,7 @@ list(
   arm_dataabort.c
   arm_syscall.c
   arm_prefetchabort.c
+  arm_cpuidlestack.c
   arm_userfault.c)
 
 target_sources(arch PRIVATE ${CSRCS})
diff --git a/arch/arm/src/arm_a_r/Make.defs b/arch/arm/src/arm_a_r/Make.defs
index 4c4addd97cc..c112b6dc6fd 100644
--- a/arch/arm/src/arm_a_r/Make.defs
+++ b/arch/arm/src/arm_a_r/Make.defs
@@ -23,7 +23,7 @@
 # Common ARM_A_R files
 
 CMN_CSRCS += arm_tcbinfo.c arm_doirq.c arm_dataabort.c arm_syscall.c
-CMN_CSRCS += arm_prefetchabort.c arm_userfault.c
+CMN_CSRCS += arm_prefetchabort.c arm_userfault.c arm_cpuidlestack.c
 
 ifeq ($(CONFIG_ENABLE_ALL_SIGNALS),y)
   CMN_CSRCS += arm_schedulesigaction.c arm_sigdeliver.c
diff --git a/arch/arm/src/armv7-a/arm_cpuidlestack.c 
b/arch/arm/src/arm_a_r/arm_cpuidlestack.c
similarity index 99%
rename from arch/arm/src/armv7-a/arm_cpuidlestack.c
rename to arch/arm/src/arm_a_r/arm_cpuidlestack.c
index 58f1b58c5e8..eb4aa942bf8 100644
--- a/arch/arm/src/armv7-a/arm_cpuidlestack.c
+++ b/arch/arm/src/arm_a_r/arm_cpuidlestack.c
@@ -1,5 +1,5 @@
 /****************************************************************************
- * arch/arm/src/armv7-a/arm_cpuidlestack.c
+ * arch/arm/src/arm_a_r/arm_cpuidlestack.c
  *
  * SPDX-License-Identifier: Apache-2.0
  *
diff --git a/arch/arm/src/armv7-a/CMakeLists.txt 
b/arch/arm/src/armv7-a/CMakeLists.txt
index c1262cc244b..fbdda9e76f2 100644
--- a/arch/arm/src/armv7-a/CMakeLists.txt
+++ b/arch/arm/src/armv7-a/CMakeLists.txt
@@ -105,7 +105,7 @@ if(CONFIG_ARCH_FPU)
 endif()
 
 if(CONFIG_SMP)
-  list(APPEND SRCS arm_cpustart.c arm_smpcall.c arm_cpuidlestack.c arm_scu.c)
+  list(APPEND SRCS arm_cpustart.c arm_smpcall.c arm_scu.c)
 endif()
 
 if(CONFIG_ARM_PSCI)
diff --git a/arch/arm/src/armv7-a/Make.defs b/arch/arm/src/armv7-a/Make.defs
index 8112bd50801..09d3b26bf2e 100644
--- a/arch/arm/src/armv7-a/Make.defs
+++ b/arch/arm/src/armv7-a/Make.defs
@@ -94,7 +94,7 @@ ifeq ($(CONFIG_ARCH_FPU),y)
 endif
 
 ifeq ($(CONFIG_SMP),y)
-  CMN_CSRCS += arm_cpustart.c arm_smpcall.c arm_cpuidlestack.c
+  CMN_CSRCS += arm_cpustart.c arm_smpcall.c
   CMN_CSRCS += arm_scu.c
 endif
 
diff --git a/arch/arm/src/armv7-r/CMakeLists.txt 
b/arch/arm/src/armv7-r/CMakeLists.txt
index acf419401e9..b75b4a4833f 100644
--- a/arch/arm/src/armv7-r/CMakeLists.txt
+++ b/arch/arm/src/armv7-r/CMakeLists.txt
@@ -61,14 +61,7 @@ if(CONFIG_ARCH_FPU)
 endif()
 
 if(CONFIG_SMP)
-  list(
-    APPEND
-    SRCS
-    arm_cpuhead.S
-    arm_cpustart.c
-    arm_smpcall.c
-    arm_cpuidlestack.c
-    arm_scu.c)
+  list(APPEND SRCS arm_cpuhead.S arm_cpustart.c arm_smpcall.c arm_scu.c)
 endif()
 
 target_sources(arch PRIVATE ${SRCS})
diff --git a/arch/arm/src/armv7-r/Make.defs b/arch/arm/src/armv7-r/Make.defs
index 5237ce35a4c..6ef399b388a 100644
--- a/arch/arm/src/armv7-r/Make.defs
+++ b/arch/arm/src/armv7-r/Make.defs
@@ -62,7 +62,7 @@ endif
 ifeq ($(CONFIG_SMP),y)
   CMN_ASRCS += arm_cpuhead.S
   CMN_CSRCS += arm_cpustart.c arm_smpcall.c
-  CMN_CSRCS += arm_cpuidlestack.c arm_scu.c
+  CMN_CSRCS += arm_scu.c
 endif
 
 ifeq ($(CONFIG_ARCH_HAVE_PERF_EVENTS_USER_ACCESS),y)
diff --git a/arch/arm/src/armv7-r/arm_cpuidlestack.c 
b/arch/arm/src/armv7-r/arm_cpuidlestack.c
deleted file mode 100644
index 059e19a552d..00000000000
--- a/arch/arm/src/armv7-r/arm_cpuidlestack.c
+++ /dev/null
@@ -1,134 +0,0 @@
-/****************************************************************************
- * arch/arm/src/armv7-r/arm_cpuidlestack.c
- *
- * SPDX-License-Identifier: Apache-2.0
- *
- * 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 <assert.h>
-
-#include <nuttx/arch.h>
-#include <nuttx/sched.h>
-
-#include "smp.h"
-#include "arm_internal.h"
-
-#ifdef CONFIG_SMP
-
-/****************************************************************************
- * Pre-processor Definitions
- ****************************************************************************/
-
-/* Stack alignment macros */
-
-#define STACK_ISALIGNED(a) ((uintptr_t)(a) & ~SMP_STACK_MASK)
-
-/****************************************************************************
- * Private Data
- ****************************************************************************/
-
-#if CONFIG_SMP_NCPUS > 1
-static const uint32_t *g_cpu_stackalloc[CONFIG_SMP_NCPUS] =
-{
-    0
-  , g_cpu1_idlestack
-#if CONFIG_SMP_NCPUS > 2
-  , g_cpu2_idlestack
-#if CONFIG_SMP_NCPUS > 3
-  , g_cpu3_idlestack
-#endif /* CONFIG_SMP_NCPUS > 3 */
-#endif /* CONFIG_SMP_NCPUS > 2 */
-};
-#endif
-
-/****************************************************************************
- * Public Functions
- ****************************************************************************/
-
-/****************************************************************************
- * Name: up_cpu_idlestack
- *
- * Description:
- *   Allocate a stack for the CPU[n] IDLE task (n > 0) if appropriate and
- *   setup up stack-related information in the IDLE task's TCB.  This
- *   function is always called before up_cpu_start().  This function is
- *   only called for the CPU's initial IDLE task; up_create_task is used for
- *   all normal tasks, pthreads, and kernel threads for all CPUs.
- *
- *   The initial IDLE task is a special case because the CPUs can be started
- *   in different wans in different environments:
- *
- *   1. The CPU may already have been started and waiting in a low power
- *      state for up_cpu_start().  In this case, the IDLE thread's stack
- *      has already been allocated and is already in use.  Here
- *      up_cpu_idlestack() only has to provide information about the
- *      already allocated stack.
- *
- *   2. The CPU may be disabled but started when up_cpu_start() is called.
- *      In this case, a new stack will need to be created for the IDLE
- *      thread and this function is then equivalent to:
- *
- *      return up_create_stack(tcb, stack_size, TCB_FLAG_TTYPE_KERNEL);
- *
- *   The following TCB fields must be initialized by this function:
- *
- *   - 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
- *   - stack_base_ptr: Adjusted stack base pointer after the TLS Data and
- *     Arguments has been removed from the stack allocation.
- *
- * Input Parameters:
- *   - cpu:         CPU index that indicates which CPU the IDLE task is
- *                  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_SMP_STACK_SIZE.
- *
- ****************************************************************************/
-
-int up_cpu_idlestack(int cpu, struct tcb_s *tcb, size_t stack_size)
-{
-#if CONFIG_SMP_NCPUS > 1
-  uintptr_t stack_alloc;
-
-  DEBUGASSERT(cpu > 0 && cpu < CONFIG_SMP_NCPUS && tcb != NULL &&
-              stack_size <= SMP_STACK_SIZE);
-
-  /* Get the top of the stack */
-
-  stack_alloc          = (uintptr_t)g_cpu_stackalloc[cpu];
-  DEBUGASSERT(stack_alloc != 0 && STACK_ISALIGNED(stack_alloc));
-
-  tcb->adj_stack_size  = SMP_STACK_SIZE;
-  tcb->stack_alloc_ptr = (void *)stack_alloc;
-  tcb->stack_base_ptr  = tcb->stack_alloc_ptr;
-#endif
-
-  return OK;
-}
-
-#endif /* CONFIG_SMP */
diff --git a/arch/arm/src/armv8-r/CMakeLists.txt 
b/arch/arm/src/armv8-r/CMakeLists.txt
index a5258f2f728..723666a05cb 100644
--- a/arch/arm/src/armv8-r/CMakeLists.txt
+++ b/arch/arm/src/armv8-r/CMakeLists.txt
@@ -52,7 +52,7 @@ endif()
 
 if(CONFIG_SMP)
   list(APPEND SRCS arm_cpuhead.S arm_cpustart.c)
-  list(APPEND SRCS arm_smpcall.c arm_cpuidlestack.c arm_scu.c)
+  list(APPEND SRCS arm_smpcall.c arm_scu.c)
 endif()
 
 target_sources(arch PRIVATE ${SRCS})
diff --git a/arch/arm/src/armv8-r/Make.defs b/arch/arm/src/armv8-r/Make.defs
index de2b995d698..0f11b069940 100644
--- a/arch/arm/src/armv8-r/Make.defs
+++ b/arch/arm/src/armv8-r/Make.defs
@@ -62,7 +62,7 @@ endif
 ifeq ($(CONFIG_SMP),y)
   CMN_ASRCS += arm_cpuhead.S
   CMN_CSRCS += arm_cpustart.c arm_smpcall.c
-  CMN_CSRCS += arm_cpuidlestack.c arm_scu.c
+  CMN_CSRCS += arm_scu.c
 endif
 
 VPATH += arm_a_r
diff --git a/arch/arm/src/armv8-r/arm_cpuidlestack.c 
b/arch/arm/src/armv8-r/arm_cpuidlestack.c
deleted file mode 100644
index acef88e867d..00000000000
--- a/arch/arm/src/armv8-r/arm_cpuidlestack.c
+++ /dev/null
@@ -1,134 +0,0 @@
-/****************************************************************************
- * arch/arm/src/armv8-r/arm_cpuidlestack.c
- *
- * SPDX-License-Identifier: Apache-2.0
- *
- * 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 <assert.h>
-
-#include <nuttx/arch.h>
-#include <nuttx/sched.h>
-
-#include "smp.h"
-#include "arm_internal.h"
-
-#ifdef CONFIG_SMP
-
-/****************************************************************************
- * Pre-processor Definitions
- ****************************************************************************/
-
-/* Stack alignment macros */
-
-#define STACK_ISALIGNED(a) ((uintptr_t)(a) & ~SMP_STACK_MASK)
-
-/****************************************************************************
- * Private Data
- ****************************************************************************/
-
-#if CONFIG_SMP_NCPUS > 1
-static const uint32_t *g_cpu_stackalloc[CONFIG_SMP_NCPUS] =
-{
-    0
-  , g_cpu1_idlestack
-#if CONFIG_SMP_NCPUS > 2
-  , g_cpu2_idlestack
-#if CONFIG_SMP_NCPUS > 3
-  , g_cpu3_idlestack
-#endif /* CONFIG_SMP_NCPUS > 3 */
-#endif /* CONFIG_SMP_NCPUS > 2 */
-};
-#endif
-
-/****************************************************************************
- * Public Functions
- ****************************************************************************/
-
-/****************************************************************************
- * Name: up_cpu_idlestack
- *
- * Description:
- *   Allocate a stack for the CPU[n] IDLE task (n > 0) if appropriate and
- *   setup up stack-related information in the IDLE task's TCB.  This
- *   function is always called before up_cpu_start().  This function is
- *   only called for the CPU's initial IDLE task; up_create_task is used for
- *   all normal tasks, pthreads, and kernel threads for all CPUs.
- *
- *   The initial IDLE task is a special case because the CPUs can be started
- *   in different wans in different environments:
- *
- *   1. The CPU may already have been started and waiting in a low power
- *      state for up_cpu_start().  In this case, the IDLE thread's stack
- *      has already been allocated and is already in use.  Here
- *      up_cpu_idlestack() only has to provide information about the
- *      already allocated stack.
- *
- *   2. The CPU may be disabled but started when up_cpu_start() is called.
- *      In this case, a new stack will need to be created for the IDLE
- *      thread and this function is then equivalent to:
- *
- *      return up_create_stack(tcb, stack_size, TCB_FLAG_TTYPE_KERNEL);
- *
- *   The following TCB fields must be initialized by this function:
- *
- *   - 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
- *   - stack_base_ptr: Adjusted stack base pointer after the TLS Data and
- *     Arguments has been removed from the stack allocation.
- *
- * Input Parameters:
- *   - cpu:         CPU index that indicates which CPU the IDLE task is
- *                  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_SMP_STACK_SIZE.
- *
- ****************************************************************************/
-
-int up_cpu_idlestack(int cpu, struct tcb_s *tcb, size_t stack_size)
-{
-#if CONFIG_SMP_NCPUS > 1
-  uintptr_t stack_alloc;
-
-  DEBUGASSERT(cpu > 0 && cpu < CONFIG_SMP_NCPUS && tcb != NULL &&
-              stack_size <= SMP_STACK_SIZE);
-
-  /* Get the top of the stack */
-
-  stack_alloc          = (uintptr_t)g_cpu_stackalloc[cpu];
-  DEBUGASSERT(stack_alloc != 0 && STACK_ISALIGNED(stack_alloc));
-
-  tcb->adj_stack_size  = SMP_STACK_SIZE;
-  tcb->stack_alloc_ptr = (void *)stack_alloc;
-  tcb->stack_base_ptr  = tcb->stack_alloc_ptr;
-#endif
-
-  return OK;
-}
-
-#endif /* CONFIG_SMP */

Reply via email to