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 96d134636079ca2d116a63449191e5ce50186985
Author: hujun5 <[email protected]>
AuthorDate: Mon Nov 24 02:08:54 2025 +0800

    arch/arm: move up_cpu_index from irq.h to arch.h
    
    move up_cpu_index from irq.h to arch.h
    
    Signed-off-by: buxiasen <[email protected]>
    Signed-off-by: hujun5 <[email protected]>
---
 arch/arm/include/arch.h         |  6 ++++
 arch/arm/include/arm_a_r/arch.h | 67 +++++++++++++++++++++++++++++++++++++++++
 arch/arm/include/arm_a_r/cp15.h | 18 +++++++++++
 arch/arm/include/armv7-a/irq.h  | 40 +-----------------------
 arch/arm/include/armv7-r/irq.h  | 40 +-----------------------
 arch/arm/include/armv8-r/irq.h  | 38 -----------------------
 arch/arm/include/irq.h          |  1 +
 7 files changed, 94 insertions(+), 116 deletions(-)

diff --git a/arch/arm/include/arch.h b/arch/arm/include/arch.h
index c81a81ee3c8..55be62554bc 100644
--- a/arch/arm/include/arch.h
+++ b/arch/arm/include/arch.h
@@ -38,6 +38,10 @@
 #endif
 
 #include <arch/barriers.h>
+#if defined(CONFIG_ARCH_ARMV7A) || defined(CONFIG_ARCH_ARMV7R) || \
+    defined(CONFIG_ARCH_ARMV8R)
+#  include <arch/arm_a_r/arch.h>
+#endif
 
 #if defined(CONFIG_ARCH_ARM_A_R)
 #  include <arch/arm_a_r/arch.h>
@@ -187,6 +191,7 @@ static inline void up_fdpic_invoke(uintptr_t arg, uintptr_t 
entry,
  * Public Types
  ****************************************************************************/
 
+#ifndef __ASSEMBLY__
 #ifdef CONFIG_ARCH_ADDRENV
 /* The task group resources are retained in a single structure, task_group_s
  * that is defined in the header file nuttx/include/nuttx/sched.h. The type
@@ -225,6 +230,7 @@ struct arch_addrenv_s
 
 typedef struct arch_addrenv_s arch_addrenv_t;
 #endif
+#endif /* __ASSEMBLY__ */
 
 /****************************************************************************
  * Public Data
diff --git a/arch/arm/include/arm_a_r/arch.h b/arch/arm/include/arm_a_r/arch.h
new file mode 100644
index 00000000000..663793240fd
--- /dev/null
+++ b/arch/arm/include/arm_a_r/arch.h
@@ -0,0 +1,67 @@
+/****************************************************************************
+ * arch/arm/include/arm_a_r/arch.h
+ *
+ * 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.
+ *
+ ****************************************************************************/
+
+#ifndef __ARCH_ARM_INCLUDE_ARMV_A_R_ARCH_H
+#define __ARCH_ARM_INCLUDE_ARMV_A_R_ARCH_H
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+#include <nuttx/compiler.h>
+
+#include <stdint.h>
+
+#include <arch/arm_a_r/cp15.h>
+
+/****************************************************************************
+ * Pre-processor Prototypes
+ ****************************************************************************/
+
+#ifndef __ASSEMBLY__
+
+/****************************************************************************
+ * Name: up_cpu_index
+ *
+ * Description:
+ *   Return the real core number regardless CONFIG_SMP setting
+ *
+ ****************************************************************************/
+
+#ifdef CONFIG_ARCH_HAVE_MULTICPU
+noinstrument_function
+static inline_function int up_cpu_index(void)
+{
+  uint32_t mpidr;
+
+  /* Read the Multiprocessor Affinity Register (MPIDR) */
+
+  mpidr = CP15_GET(MPIDR);
+
+  /* And return the CPU ID field */
+
+  return (mpidr & MPIDR_CPUID_MASK) >> MPIDR_CPUID_SHIFT;
+}
+#endif /* CONFIG_ARCH_HAVE_MULTICPU */
+
+#endif /* __ASSEMBLY__ */
+
+#endif /* __ARCH_ARM_INCLUDE_ARMV_A_R_ARCH_H */
diff --git a/arch/arm/include/arm_a_r/cp15.h b/arch/arm/include/arm_a_r/cp15.h
index 135d305af32..77b765a0568 100644
--- a/arch/arm/include/arm_a_r/cp15.h
+++ b/arch/arm/include/arm_a_r/cp15.h
@@ -317,6 +317,24 @@
 #define MPIDR_AFF1_SHIFT    (8)
 #define MPIDR_AFF2_SHIFT    (16)
 
+/* Multiprocessor Affinity Register (MPIDR): CRn=c0, opc1=0, CRm=c0, opc2=5 */
+
+#define MPIDR_CPUID_SHIFT   (0)       /* Bits 0-2: CPU ID */
+#define MPIDR_CPUID_MASK    (7 << MPIDR_CPUID_SHIFT)
+#  define MPIDR_CPUID_CPU0  (0 << MPIDR_CPUID_SHIFT)
+#  define MPIDR_CPUID_CPU1  (1 << MPIDR_CPUID_SHIFT)
+#  define MPIDR_CPUID_CPU2  (2 << MPIDR_CPUID_SHIFT)
+#  define MPIDR_CPUID_CPU3  (3 << MPIDR_CPUID_SHIFT)
+#  define MPIDR_CPUID_CPU4  (4 << MPIDR_CPUID_SHIFT)
+#  define MPIDR_CPUID_CPU5  (5 << MPIDR_CPUID_SHIFT)
+#  define MPIDR_CPUID_CPU6  (6 << MPIDR_CPUID_SHIFT)
+#  define MPIDR_CPUID_CPU7  (7 << MPIDR_CPUID_SHIFT)
+                                      /* Bits 3-7: Reserved */
+#define MPIDR_CLUSTID_SHIFT (8)       /* Bits 8-11: Cluster ID value */
+#define MPIDR_CLUSTID_MASK  (15 << MPIDR_CLUSTID_SHIFT)
+                                      /* Bits 12-29: Reserved */
+#define MPIDR_U             (1 << 30) /* Bit 30: Multiprocessing Extensions. */
+
 /* mpidr register, the register is define:
  *   - bit 0~7:   Aff0
  *   - bit 8~15:  Aff1
diff --git a/arch/arm/include/armv7-a/irq.h b/arch/arm/include/armv7-a/irq.h
index ab4cb3d2b9f..f8a8985353f 100644
--- a/arch/arm/include/armv7-a/irq.h
+++ b/arch/arm/include/armv7-a/irq.h
@@ -38,7 +38,7 @@
 #  include <stdint.h>
 #endif
 
-#include <arch/arm_a_r/cp15.h>
+#include <arch/arch.h>
 
 /****************************************************************************
  * Pre-processor Prototypes
@@ -206,20 +206,6 @@
 
 #define REG_PIC             REG_R9
 
-/* Multiprocessor Affinity Register (MPIDR): CRn=c0, opc1=0, CRm=c0, opc2=5 */
-
-#define MPIDR_CPUID_SHIFT   (0)       /* Bits 0-1: CPU ID */
-#define MPIDR_CPUID_MASK    (3 << MPIDR_CPUID_SHIFT)
-#  define MPIDR_CPUID_CPU0  (0 << MPIDR_CPUID_SHIFT)
-#  define MPIDR_CPUID_CPU1  (1 << MPIDR_CPUID_SHIFT)
-#  define MPIDR_CPUID_CPU2  (2 << MPIDR_CPUID_SHIFT)
-#  define MPIDR_CPUID_CPU3  (3 << MPIDR_CPUID_SHIFT)
-                                      /* Bits 2-7: Reserved */
-#define MPIDR_CLUSTID_SHIFT (8)       /* Bits 8-11: Cluster ID value */
-#define MPIDR_CLUSTID_MASK  (15 << MPIDR_CLUSTID_SHIFT)
-                                      /* Bits 12-29: Reserved */
-#define MPIDR_U             (1 << 30) /* Bit 30: Multiprocessing Extensions. */
-
 /****************************************************************************
  * Public Types
  ****************************************************************************/
@@ -456,30 +442,6 @@ void up_irq_restore(irqstate_t flags)
     );
 }
 
-/****************************************************************************
- * Name: up_cpu_index
- *
- * Description:
- *   Return the real core number regardless CONFIG_SMP setting
- *
- ****************************************************************************/
-
-#ifdef CONFIG_ARCH_HAVE_MULTICPU
-noinstrument_function
-static inline_function int up_cpu_index(void)
-{
-  unsigned int mpidr;
-
-  /* Read the Multiprocessor Affinity Register (MPIDR) */
-
-  mpidr = CP15_GET(MPIDR);
-
-  /* And return the CPU ID field */
-
-  return (mpidr & MPIDR_CPUID_MASK) >> MPIDR_CPUID_SHIFT;
-}
-#endif /* CONFIG_ARCH_HAVE_MULTICPU */
-
 /* Return program counter */
 
 static inline_function uint32_t up_getpc(void)
diff --git a/arch/arm/include/armv7-r/irq.h b/arch/arm/include/armv7-r/irq.h
index bed74bb445a..8e65fc21243 100644
--- a/arch/arm/include/armv7-r/irq.h
+++ b/arch/arm/include/armv7-r/irq.h
@@ -38,7 +38,7 @@
 #  include <stdint.h>
 #endif
 
-#include <arch/arm_a_r/cp15.h>
+#include <arch/arch.h>
 
 /****************************************************************************
  * Pre-processor Prototypes
@@ -206,20 +206,6 @@
 
 #define REG_PIC             REG_R9
 
-/* Multiprocessor Affinity Register (MPIDR): CRn=c0, opc1=0, CRm=c0, opc2=5 */
-
-#define MPIDR_CPUID_SHIFT   (0)       /* Bits 0-1: CPU ID */
-#define MPIDR_CPUID_MASK    (3 << MPIDR_CPUID_SHIFT)
-#  define MPIDR_CPUID_CPU0  (0 << MPIDR_CPUID_SHIFT)
-#  define MPIDR_CPUID_CPU1  (1 << MPIDR_CPUID_SHIFT)
-#  define MPIDR_CPUID_CPU2  (2 << MPIDR_CPUID_SHIFT)
-#  define MPIDR_CPUID_CPU3  (3 << MPIDR_CPUID_SHIFT)
-                                      /* Bits 2-7: Reserved */
-#define MPIDR_CLUSTID_SHIFT (8)       /* Bits 8-11: Cluster ID value */
-#define MPIDR_CLUSTID_MASK  (15 << MPIDR_CLUSTID_SHIFT)
-                                      /* Bits 12-29: Reserved */
-#define MPIDR_U             (1 << 30) /* Bit 30: Multiprocessing Extensions. */
-
 /****************************************************************************
  * Public Types
  ****************************************************************************/
@@ -437,30 +423,6 @@ void up_irq_restore(irqstate_t flags)
     );
 }
 
-/****************************************************************************
- * Name: up_cpu_index
- *
- * Description:
- *   Return the real core number regardless CONFIG_SMP setting
- *
- ****************************************************************************/
-
-#ifdef CONFIG_ARCH_HAVE_MULTICPU
-noinstrument_function
-static inline_function int up_cpu_index(void)
-{
-  uint32_t mpidr;
-
-  /* Read the Multiprocessor Affinity Register (MPIDR) */
-
-  mpidr = CP15_GET(MPIDR);
-
-  /* And return the CPU ID field */
-
-  return (mpidr & MPIDR_CPUID_MASK) >> MPIDR_CPUID_SHIFT;
-}
-#endif /* CONFIG_ARCH_HAVE_MULTICPU */
-
 /* Return program counter */
 
 static inline_function uint32_t up_getpc(void)
diff --git a/arch/arm/include/armv8-r/irq.h b/arch/arm/include/armv8-r/irq.h
index bb8b09af64a..97cf88cbc1d 100644
--- a/arch/arm/include/armv8-r/irq.h
+++ b/arch/arm/include/armv8-r/irq.h
@@ -206,20 +206,6 @@
 
 #define REG_PIC             REG_R9
 
-/* Multiprocessor Affinity Register (MPIDR): CRn=c0, opc1=0, CRm=c0, opc2=5 */
-
-#define MPIDR_CPUID_SHIFT   (0)       /* Bits 0-1: CPU ID */
-#define MPIDR_CPUID_MASK    (3 << MPIDR_CPUID_SHIFT)
-#  define MPIDR_CPUID_CPU0  (0 << MPIDR_CPUID_SHIFT)
-#  define MPIDR_CPUID_CPU1  (1 << MPIDR_CPUID_SHIFT)
-#  define MPIDR_CPUID_CPU2  (2 << MPIDR_CPUID_SHIFT)
-#  define MPIDR_CPUID_CPU3  (3 << MPIDR_CPUID_SHIFT)
-                                      /* Bits 2-7: Reserved */
-#define MPIDR_CLUSTID_SHIFT (8)       /* Bits 8-11: Cluster ID value */
-#define MPIDR_CLUSTID_MASK  (15 << MPIDR_CLUSTID_SHIFT)
-                                      /* Bits 12-29: Reserved */
-#define MPIDR_U             (1 << 30) /* Bit 30: Multiprocessing Extensions. */
-
 /****************************************************************************
  * Public Types
  ****************************************************************************/
@@ -437,30 +423,6 @@ void up_irq_restore(irqstate_t flags)
     );
 }
 
-/****************************************************************************
- * Name: up_cpu_index
- *
- * Description:
- *   Return the real core number regardless CONFIG_SMP setting
- *
- ****************************************************************************/
-
-#ifdef CONFIG_ARCH_HAVE_MULTICPU
-noinstrument_function
-static inline_function int up_cpu_index(void)
-{
-  uint32_t mpidr;
-
-  /* Read the Multiprocessor Affinity Register (MPIDR) */
-
-  mpidr = CP15_GET(MPIDR);
-
-  /* And return the CPU ID field */
-
-  return (mpidr & MPIDR_CPUID_MASK) >> MPIDR_CPUID_SHIFT;
-}
-#endif /* CONFIG_ARCH_HAVE_MULTICPU */
-
 /* Return program counter */
 
 static inline_function uint32_t up_getpc(void)
diff --git a/arch/arm/include/irq.h b/arch/arm/include/irq.h
index d1accdbee62..58de3789a70 100644
--- a/arch/arm/include/irq.h
+++ b/arch/arm/include/irq.h
@@ -36,6 +36,7 @@
 #  include <stdbool.h>
 #  include <arch/syscall.h>
 #endif
+#include <arch/arch.h>
 
 /****************************************************************************
  * Public Function Prototypes

Reply via email to