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

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

commit c662615997dea94b473f59a289eea4ef1f0fae2b
Author: hujun5 <[email protected]>
AuthorDate: Sun Oct 26 13:24:42 2025 +0800

    arm64: fvp add support for BMP
    
    fvp add support for BMP
    
    Signed-off-by: hujun5 <[email protected]>
---
 arch/arm64/src/common/CMakeLists.txt               |  7 +-
 arch/arm64/src/common/Make.defs                    |  7 +-
 arch/arm64/src/common/arm64_allocateheap.c         | 10 ++-
 arch/arm64/src/common/arm64_cpuidlestack.c         | 18 ++---
 arch/arm64/src/common/arm64_cpustart.c             | 63 +++++++++---------
 arch/arm64/src/common/arm64_doirq.c                | 27 --------
 arch/arm64/src/common/arm64_getintstack.c          |  4 +-
 arch/arm64/src/common/arm64_gicv3.c                |  7 +-
 arch/arm64/src/common/arm64_head.S                 | 16 ++---
 arch/arm64/src/common/arm64_initialize.c           | 39 ++---------
 arch/arm64/src/common/arm64_initialstate.c         | 10 +--
 arch/arm64/src/common/arm64_internal.h             | 52 ++++++++-------
 arch/arm64/src/common/arm64_vectors.S              |  4 +-
 .../fvp-v8r/fvp-armv8r/configs/nsh_bmp/defconfig   | 77 ++++++++++++++++++++++
 14 files changed, 181 insertions(+), 160 deletions(-)

diff --git a/arch/arm64/src/common/CMakeLists.txt 
b/arch/arm64/src/common/CMakeLists.txt
index 9cfb36f032d..e2068ca5c79 100644
--- a/arch/arm64/src/common/CMakeLists.txt
+++ b/arch/arm64/src/common/CMakeLists.txt
@@ -31,7 +31,7 @@ list(APPEND SRCS arm64_nputs.c arm64_createstack.c)
 list(APPEND SRCS arm64_releasestack.c arm64_stackframe.c arm64_usestack.c)
 list(APPEND SRCS arm64_exit.c arm64_fork.c)
 list(APPEND SRCS arm64_getintstack.c arm64_registerdump.c)
-list(APPEND SRCS arm64_perf.c arm64_tcbinfo.c)
+list(APPEND SRCS arm64_perf.c arm64_tcbinfo.c arm64_cpuidlestack.c)
 
 # Common C source files ( hardware BSP )
 list(APPEND SRCS arm64_arch_timer.c arm64_cache.c)
@@ -100,8 +100,11 @@ if(CONFIG_ARM64_PSCI)
   list(APPEND SRCS arm64_cpu_psci.c)
 endif()
 
+if(NOT CONFIG_UP)
+  list(APPEND SRCS arm64_cpustart.c)
+endif()
+
 if(CONFIG_SMP)
-  list(APPEND SRCS arm64_cpuidlestack.c arm64_cpustart.c)
   list(APPEND SRCS arm64_smpcall.c)
 endif()
 
diff --git a/arch/arm64/src/common/Make.defs b/arch/arm64/src/common/Make.defs
index 1d4053d7812..1b605338e40 100644
--- a/arch/arm64/src/common/Make.defs
+++ b/arch/arm64/src/common/Make.defs
@@ -40,7 +40,7 @@ CMN_CSRCS += arm64_nputs.c arm64_createstack.c
 CMN_CSRCS += arm64_releasestack.c arm64_stackframe.c arm64_usestack.c
 CMN_CSRCS += arm64_exit.c arm64_fork.c
 CMN_CSRCS += arm64_getintstack.c arm64_registerdump.c
-CMN_CSRCS += arm64_perf.c arm64_tcbinfo.c
+CMN_CSRCS += arm64_perf.c arm64_tcbinfo.c arm64_cpuidlestack.c
 
 # Common C source files ( hardware BSP )
 CMN_CSRCS += arm64_arch_timer.c arm64_cache.c
@@ -114,8 +114,11 @@ ifeq ($(CONFIG_ARM64_PSCI),y)
 CMN_CSRCS += arm64_cpu_psci.c
 endif
 
+ifneq ($(CONFIG_UP),y)
+CMN_CSRCS += arm64_cpustart.c
+endif
+
 ifeq ($(CONFIG_SMP),y)
-CMN_CSRCS += arm64_cpuidlestack.c arm64_cpustart.c
 CMN_CSRCS += arm64_smpcall.c
 endif
 
diff --git a/arch/arm64/src/common/arm64_allocateheap.c 
b/arch/arm64/src/common/arm64_allocateheap.c
index a15214ad3ef..a1ecff329cd 100644
--- a/arch/arm64/src/common/arm64_allocateheap.c
+++ b/arch/arm64/src/common/arm64_allocateheap.c
@@ -128,8 +128,16 @@ void up_allocate_heap(void **heap_start, size_t *heap_size)
 
   /* Return the heap settings */
 
-  *heap_start = g_idle_topstack;
   *heap_size  = CONFIG_RAM_END - (size_t)g_idle_topstack;
+
+#ifdef CONFIG_BMP
+  *heap_size = *heap_size / CONFIG_NCPUS;
+  *heap_start = (void *)((uintptr_t)g_idle_topstack +
+                         *heap_size * up_cpu_index());
+#else
+  *heap_start = g_idle_topstack;
+#endif
+
   sinfo("heap_start=0x%p, heap_size=0x%"PRIx64"\n", *heap_start, *heap_size);
 #endif
 }
diff --git a/arch/arm64/src/common/arm64_cpuidlestack.c 
b/arch/arm64/src/common/arm64_cpuidlestack.c
index 7453543031b..e1a1665a37d 100644
--- a/arch/arm64/src/common/arm64_cpuidlestack.c
+++ b/arch/arm64/src/common/arm64_cpuidlestack.c
@@ -84,27 +84,17 @@
  *   - 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.
+ *                  CONFIG_IDLETHREAD_STACKSIZE.
  *
  ****************************************************************************/
 
 int up_cpu_idlestack(int cpu, struct tcb_s *tcb, size_t stack_size)
 {
-#ifndef CONFIG_UP
-  uintptr_t stack_alloc;
+  DEBUGASSERT(cpu >= 0 && cpu < CONFIG_NCPUS && tcb != NULL);
 
-  DEBUGASSERT(cpu < CONFIG_NCPUS && tcb != NULL &&
-              stack_size <= SMP_STACK_SIZE);
-
-  /* Get the top of the stack */
-
-  stack_alloc          = (uintptr_t)g_cpu_idlestackalloc[cpu];
-  DEBUGASSERT(stack_alloc != 0 && STACKFRAME_IS_ALIGNED(stack_alloc));
-
-  tcb->adj_stack_size  = SMP_STACK_SIZE;
-  tcb->stack_alloc_ptr = (void *)stack_alloc;
+  tcb->adj_stack_size  = stack_size;
+  tcb->stack_alloc_ptr = (void *)g_cpu_idlestackalloc[cpu];
   tcb->stack_base_ptr  = tcb->stack_alloc_ptr;
-#endif
 
   return OK;
 }
diff --git a/arch/arm64/src/common/arm64_cpustart.c 
b/arch/arm64/src/common/arm64_cpustart.c
index 5ba175c9478..fb60c987252 100644
--- a/arch/arm64/src/common/arm64_cpustart.c
+++ b/arch/arm64/src/common/arm64_cpustart.c
@@ -58,21 +58,21 @@
 
 uint64_t *const g_cpu_int_stacktop[CONFIG_NCPUS] =
 {
-  (uint64_t *)(g_interrupt_stacks[0] + INTSTACK_SIZE),
+  (uint64_t *)(g_interrupt_stack[0] + INTSTACK_SIZE),
 #if CONFIG_NCPUS > 1
-  (uint64_t *)(g_interrupt_stacks[1] + INTSTACK_SIZE),
+  (uint64_t *)(g_interrupt_stack[1] + INTSTACK_SIZE),
 #if CONFIG_NCPUS > 2
-  (uint64_t *)(g_interrupt_stacks[2] + INTSTACK_SIZE),
+  (uint64_t *)(g_interrupt_stack[2] + INTSTACK_SIZE),
 #if CONFIG_NCPUS > 3
-  (uint64_t *)(g_interrupt_stacks[3] + INTSTACK_SIZE),
+  (uint64_t *)(g_interrupt_stack[3] + INTSTACK_SIZE),
 #if CONFIG_NCPUS > 4
-  (uint64_t *)(g_interrupt_stacks[4] + INTSTACK_SIZE),
+  (uint64_t *)(g_interrupt_stack[4] + INTSTACK_SIZE),
 #if CONFIG_NCPUS > 5
-  (uint64_t *)(g_interrupt_stacks[5] + INTSTACK_SIZE),
+  (uint64_t *)(g_interrupt_stack[5] + INTSTACK_SIZE),
 #if CONFIG_NCPUS > 6
-  (uint64_t *)(g_interrupt_stacks[6] + INTSTACK_SIZE),
+  (uint64_t *)(g_interrupt_stack[6] + INTSTACK_SIZE),
 #if CONFIG_NCPUS > 7
-  (uint64_t *)(g_interrupt_stacks[7] + INTSTACK_SIZE),
+  (uint64_t *)(g_interrupt_stack[7] + INTSTACK_SIZE),
 #if CONFIG_NCPUS > 8
 #  error This logic needs to extended for CONFIG_NCPUS > 8
 #endif /* CONFIG_NCPUS > 8 */
@@ -85,26 +85,24 @@ uint64_t *const g_cpu_int_stacktop[CONFIG_NCPUS] =
 #endif /* CONFIG_NCPUS > 1 */
 };
 
-uint32_t g_smp_busy_wait_flag;
-
 #ifdef CONFIG_ARCH_HIPRI_INTERRUPT
 uint64_t *const g_cpu_int_fiq_stacktop[CONFIG_NCPUS] =
 {
-  (uint64_t *)(g_interrupt_fiq_stacks[0] + INTSTACK_SIZE),
+  (uint64_t *)(g_interrupt_fiq_stack[0] + INTSTACK_SIZE),
 #if CONFIG_NCPUS > 1
-  (uint64_t *)(g_interrupt_fiq_stacks[1] + INTSTACK_SIZE),
+  (uint64_t *)(g_interrupt_fiq_stack[1] + INTSTACK_SIZE),
 #if CONFIG_NCPUS > 2
-  (uint64_t *)(g_interrupt_fiq_stacks[2] + INTSTACK_SIZE),
+  (uint64_t *)(g_interrupt_fiq_stack[2] + INTSTACK_SIZE),
 #if CONFIG_NCPUS > 3
-  (uint64_t *)(g_interrupt_fiq_stacks[3] + INTSTACK_SIZE),
+  (uint64_t *)(g_interrupt_fiq_stack[3] + INTSTACK_SIZE),
 #if CONFIG_NCPUS > 4
-  (uint64_t *)(g_interrupt_fiq_stacks[4] + INTSTACK_SIZE),
+  (uint64_t *)(g_interrupt_fiq_stack[4] + INTSTACK_SIZE),
 #if CONFIG_NCPUS > 5
-  (uint64_t *)(g_interrupt_fiq_stacks[5] + INTSTACK_SIZE),
+  (uint64_t *)(g_interrupt_fiq_stack[5] + INTSTACK_SIZE),
 #if CONFIG_NCPUS > 6
-  (uint64_t *)(g_interrupt_fiq_stacks[6] + INTSTACK_SIZE),
+  (uint64_t *)(g_interrupt_fiq_stack[6] + INTSTACK_SIZE),
 #if CONFIG_NCPUS > 7
-  (uint64_t *)(g_interrupt_fiq_stacks[7] + INTSTACK_SIZE),
+  (uint64_t *)(g_interrupt_fiq_stack[7] + INTSTACK_SIZE),
 #if CONFIG_NCPUS > 8
 #  error This logic needs to extended for CONFIG_NCPUS > 8
 #endif /* CONFIG_NCPUS > 8 */
@@ -126,6 +124,7 @@ uint64_t *const g_cpu_int_fiq_stacktop[CONFIG_NCPUS] =
  * Private Functions
  ****************************************************************************/
 
+#ifdef CONFIG_SMP
 static void arm64_smp_init_top(void)
 {
   struct tcb_s *tcb = current_task(this_cpu());
@@ -141,11 +140,16 @@ static void arm64_smp_init_top(void)
 #endif /* CONFIG_STACK_COLORATION */
 
 #ifndef CONFIG_SUPPRESS_INTERRUPTS
+  arm64_gic_secondary_init();
+  arm64_color_intstack();
+
   /* And finally, enable interrupts */
 
   up_irq_enable();
 #endif
 
+  arm64_timer_secondary_init();
+
 #ifdef CONFIG_SCHED_INSTRUMENTATION
 
   /* Notify that this CPU has started */
@@ -157,6 +161,7 @@ static void arm64_smp_init_top(void)
 
   nx_idle_trampoline();
 }
+#endif
 
 static void arm64_start_cpu(int cpu_num)
 {
@@ -225,13 +230,6 @@ int up_cpu_start(int cpu)
   sched_note_cpu_start(this_task(), cpu);
 #endif
 
-#ifdef CONFIG_SMP
-  uint32_t *address = &g_smp_busy_wait_flag;
-
-  *address = 1;
-  up_flush_dcache((uintptr_t)address, (uintptr_t)address + sizeof(address));
-#endif
-
   arm64_start_cpu(cpu);
 
   return 0;
@@ -254,16 +252,21 @@ void arm64_boot_secondary_c_routine(void)
 #endif
 
   /* We need to confirm that current_task has been initialized. */
+#undef g_nx_initstate
+  while (OSINIT_OS_INITIALIZING());
 
-  while (!current_task(this_cpu()));
+#ifdef CONFIG_ARCH_PERF_EVENTS
+  up_perf_init((void *)up_perf_getfreq());
+#endif
+
+#if defined(CONFIG_BMP)
+  nx_start();
+#elif defined(CONFIG_SMP)
 
   /* Init idle task to percpu reg */
 
   up_update_task(current_task(this_cpu()));
 
-  arm64_gic_secondary_init();
-
-  arm64_timer_secondary_init();
-
   arm64_smp_init_top();
+#endif
 }
diff --git a/arch/arm64/src/common/arm64_doirq.c 
b/arch/arm64/src/common/arm64_doirq.c
index c1fe07d1f04..e03c8de02a6 100644
--- a/arch/arm64/src/common/arm64_doirq.c
+++ b/arch/arm64/src/common/arm64_doirq.c
@@ -48,33 +48,6 @@
  * Private Functions
  ****************************************************************************/
 
-/****************************************************************************
- * Name: arm64_color_intstack
- *
- * Description:
- *   Set the interrupt stack to a value so that later we can determine how
- *   much stack space was used by interrupt handling logic
- *
- ****************************************************************************/
-
-#if defined(CONFIG_STACK_COLORATION) && CONFIG_ARCH_INTERRUPTSTACK > 3
-static inline void arm64_color_intstack(void)
-{
-#ifdef CONFIG_SMP
-  int cpu;
-
-  for (cpu = 0; cpu < CONFIG_SMP_NCPUS; cpu++)
-    {
-      arm64_stack_color((void *)up_get_intstackbase(cpu), INTSTACK_SIZE);
-    }
-#else
-  arm64_stack_color((void *)g_interrupt_stack, INTSTACK_SIZE);
-#endif
-}
-#else
-#  define arm64_color_intstack()
-#endif
-
 /****************************************************************************
  * Public Functions
  ****************************************************************************/
diff --git a/arch/arm64/src/common/arm64_getintstack.c 
b/arch/arm64/src/common/arm64_getintstack.c
index 5c412b1383b..26191957e65 100644
--- a/arch/arm64/src/common/arm64_getintstack.c
+++ b/arch/arm64/src/common/arm64_getintstack.c
@@ -38,9 +38,9 @@
  * Name: up_get_intstackbase
  ****************************************************************************/
 
-#if !defined(CONFIG_SMP) && CONFIG_ARCH_INTERRUPTSTACK > 7
+#if CONFIG_ARCH_INTERRUPTSTACK > 7
 uintptr_t up_get_intstackbase(int cpu)
 {
-  return (uintptr_t)g_interrupt_stack;
+  return (uintptr_t)g_interrupt_stack[cpu];
 }
 #endif
diff --git a/arch/arm64/src/common/arm64_gicv3.c 
b/arch/arm64/src/common/arm64_gicv3.c
index c27aa3b1d01..f6a2279034c 100644
--- a/arch/arm64/src/common/arm64_gicv3.c
+++ b/arch/arm64/src/common/arm64_gicv3.c
@@ -1078,14 +1078,17 @@ int arm64_gic_initialize(void)
       return err;
     }
 
-  gicv3_dist_init();
+  if (this_cpu() == 0)
+    {
+      gicv3_dist_init();
+    }
 
   arm64_gic_init();
 
   return 0;
 }
 
-#ifdef CONFIG_SMP
+#ifndef CONFIG_UP
 void arm64_gic_secondary_init(void)
 {
   arm64_gic_init();
diff --git a/arch/arm64/src/common/arm64_head.S 
b/arch/arm64/src/common/arm64_head.S
index a02ed9125f5..e491146b613 100644
--- a/arch/arm64/src/common/arm64_head.S
+++ b/arch/arm64/src/common/arm64_head.S
@@ -118,7 +118,7 @@ real_start:
     /* Disable all exceptions and interrupts */
 
     msr    DAIFSet, 0xf
-#ifdef CONFIG_SMP
+#ifndef CONFIG_UP
     get_cpu_id x1
 
     /* The global variable cpu_boot_params is not safety to
@@ -141,14 +141,6 @@ real_start:
     cmp    x1, #0
     beq    primary_core
 
-    /* Wait until cpu0 notify */
-
-    ldr    x2, =g_smp_busy_wait_flag
-1:
-    ldr    w3, [x2, #0]
-    cmp    w3, #0
-    beq    1b
-
     /* we can now load our stack pointer value and move on */
 
     ldr    x24, =g_cpu_idlestackalloc
@@ -160,7 +152,7 @@ real_start:
      */
 1:
     sub    x1, x1, #1
-    add    x24, x24, #(SMP_STACK_SIZE)
+    add    x24, x24, #(CONFIG_IDLETHREAD_STACKSIZE)
     cmp    x1, #0
     bne    1b
 
@@ -170,7 +162,7 @@ real_start:
      * x24 to the stack top.
      */
 
-    add    x24, x24, #(SMP_STACK_SIZE)
+    add    x24, x24, #(CONFIG_IDLETHREAD_STACKSIZE)
 
     /* Initialize percpu reg tpidr_el1 */
 
@@ -197,7 +189,7 @@ primary_core:
 
     /* load stack and entry point */
 
-    ldr    x24, =(g_idle_stack + CONFIG_IDLETHREAD_STACKSIZE)
+    ldr    x24, =(g_cpu_idlestackalloc + CONFIG_IDLETHREAD_STACKSIZE)
 #endif /* CONFIG_SMP */
 
     /* Initialize percpu reg tpidr_el1 */
diff --git a/arch/arm64/src/common/arm64_initialize.c 
b/arch/arm64/src/common/arm64_initialize.c
index ac6bf3187ce..73440227f03 100644
--- a/arch/arm64/src/common/arm64_initialize.c
+++ b/arch/arm64/src/common/arm64_initialize.c
@@ -56,49 +56,20 @@
 static struct notifier_block g_fpu_panic_block;
 #endif
 
-#if CONFIG_NCPUS > 1
 INIT_STACK_ARRAY_DEFINE(g_cpu_idlestackalloc, CONFIG_NCPUS,
-                          SMP_STACK_SIZE);
-INIT_STACK_ARRAY_DEFINE(g_interrupt_stacks, CONFIG_NCPUS,
-                          INTSTACK_SIZE);
+                        CONFIG_IDLETHREAD_STACKSIZE);
 
-#ifdef CONFIG_ARCH_HIPRI_INTERRUPT
-INIT_STACK_ARRAY_DEFINE(g_interrupt_fiq_stacks, CONFIG_NCPUS,
-                          INTSTACK_SIZE);
-#endif
-
-#else
-/* idle thread stack for primary core */
-
-INIT_STACK_DEFINE(g_idle_stack, CONFIG_IDLETHREAD_STACKSIZE);
-INIT_STACK_DEFINE(g_interrupt_stack, INTSTACK_SIZE);
+INIT_STACK_ARRAY_DEFINE(g_interrupt_stack, CONFIG_NCPUS,
+                        INTSTACK_SIZE);
 
 #ifdef CONFIG_ARCH_HIPRI_INTERRUPT
-INIT_STACK_DEFINE(g_interrupt_fiq_stack, INTSTACK_SIZE);
+INIT_STACK_ARRAY_DEFINE(g_interrupt_fiq_stack, CONFIG_NCPUS,
+                        INTSTACK_SIZE);
 #endif
-
-#endif
-
 /****************************************************************************
  * Public Functions
  ****************************************************************************/
 
-/****************************************************************************
- * Name: up_get_intstackbase
- *
- * Description:
- *   Return a pointer to the "alloc" the correct interrupt stack allocation
- *   for the current CPU.
- *
- ****************************************************************************/
-
-#ifdef CONFIG_SMP
-uintptr_t up_get_intstackbase(int cpu)
-{
-  return (uintptr_t)(g_interrupt_stacks[cpu]);
-}
-#endif
-
 /****************************************************************************
  * Name: arm64_panic_disable_fpu
  *
diff --git a/arch/arm64/src/common/arm64_initialstate.c 
b/arch/arm64/src/common/arm64_initialstate.c
index 756acf108e3..752f4b5ddb7 100644
--- a/arch/arm64/src/common/arm64_initialstate.c
+++ b/arch/arm64/src/common/arm64_initialstate.c
@@ -144,13 +144,9 @@ void up_initial_state(struct tcb_s *tcb)
   if (tcb->pid == IDLE_PROCESS_ID)
     {
       /* Initialize the idle thread stack */
-#ifdef CONFIG_SMP
-      tcb->stack_alloc_ptr = (void *)(g_cpu_idlestackalloc[0]);
-#else
-      tcb->stack_alloc_ptr = (void *)(g_idle_stack);
-#endif
-      tcb->stack_base_ptr  = tcb->stack_alloc_ptr;
-      tcb->adj_stack_size  = CONFIG_IDLETHREAD_STACKSIZE;
+
+      up_cpu_idlestack(this_cpu(), tcb,
+                       CONFIG_IDLETHREAD_STACKSIZE);
 
       /* set initialize idle thread tcb core 0, idle0 */
 
diff --git a/arch/arm64/src/common/arm64_internal.h 
b/arch/arm64/src/common/arm64_internal.h
index 1cd038b7625..9221dba97c3 100644
--- a/arch/arm64/src/common/arm64_internal.h
+++ b/arch/arm64/src/common/arm64_internal.h
@@ -96,13 +96,8 @@
 #define STACK_COLOR    0xdeaddead
 #define HEAP_COLOR     'h'
 
-#ifdef CONFIG_SMP
-/* The size of interrupt and idle stack.  This is the configured
- * value aligned the 8-bytes as required by the ARM EABI.
- */
-
-#  define SMP_STACK_SIZE    STACKFRAME_ALIGN_UP(CONFIG_IDLETHREAD_STACKSIZE)
-#  define SMP_STACK_WORDS   (SMP_STACK_SIZE >> 2)
+#ifndef CONFIG_UP
+#  define STACK_WORDS   (CONFIG_IDLETHREAD_STACKSIZE >> 2)
 #endif
 
 /* Context switching */
@@ -151,28 +146,16 @@ extern "C"
 
 #define INTSTACK_SIZE        STACKFRAME_ALIGN_DOWN(CONFIG_ARCH_INTERRUPTSTACK)
 
-#ifndef CONFIG_UP
-
-INIT_STACK_ARRAY_DEFINE_EXTERN(g_cpu_idlestackalloc, CONFIG_NCPUS,
-                          SMP_STACK_SIZE);
-INIT_STACK_ARRAY_DEFINE_EXTERN(g_interrupt_stacks, CONFIG_NCPUS,
-                          INTSTACK_SIZE);
-
 #ifdef CONFIG_ARCH_HIPRI_INTERRUPT
-INIT_STACK_ARRAY_DEFINE_EXTERN(g_interrupt_fiq_stacks, CONFIG_NCPUS,
-                          INTSTACK_SIZE);
+INIT_STACK_ARRAY_DEFINE_EXTERN(g_interrupt_fiq_stack, CONFIG_NCPUS,
+                               INTSTACK_SIZE);
 #endif
-#else
-/* idle thread stack for primary core */
-
-INIT_STACK_DEFINE_EXTERN(g_idle_stack, CONFIG_IDLETHREAD_STACKSIZE);
-INIT_STACK_DEFINE_EXTERN(g_interrupt_stack, INTSTACK_SIZE);
 
-#ifdef CONFIG_ARCH_HIPRI_INTERRUPT
-INIT_STACK_DEFINE_EXTERN(g_interrupt_fiq_stack, INTSTACK_SIZE);
-#endif
+INIT_STACK_ARRAY_DEFINE_EXTERN(g_cpu_idlestackalloc, CONFIG_NCPUS,
+                               CONFIG_IDLETHREAD_STACKSIZE);
 
-#endif
+INIT_STACK_ARRAY_DEFINE_EXTERN(g_interrupt_stack, CONFIG_NCPUS,
+                               INTSTACK_SIZE);
 
 /* This is the beginning of heap as provided from arm64_head.S.
  * This is the first address in DRAM after the loaded
@@ -398,6 +381,25 @@ void arm64_stack_color(void *stackbase, size_t nbytes);
 void arm64_enable_dbgmonitor(void);
 #endif
 
+/****************************************************************************
+ * Name: arm64_color_intstack
+ *
+ * Description:
+ *   Set the interrupt stack to a value so that later we can determine how
+ *   much stack space was used by interrupt handling logic
+ *
+ ****************************************************************************/
+
+#if defined(CONFIG_STACK_COLORATION) && CONFIG_ARCH_INTERRUPTSTACK > 3
+static inline_function void arm64_color_intstack(void)
+{
+  arm64_stack_color((void *)up_get_intstackbase(this_cpu()),
+                    INTSTACK_SIZE);
+}
+#else
+#  define arm64_color_intstack()
+#endif
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/arch/arm64/src/common/arm64_vectors.S 
b/arch/arm64/src/common/arm64_vectors.S
index ddfab27c23b..56c95069ce2 100644
--- a/arch/arm64/src/common/arm64_vectors.S
+++ b/arch/arm64/src/common/arm64_vectors.S
@@ -257,7 +257,7 @@ reserved_syscall:
 #endif
 
     /* Switch to IRQ stack and save current sp on it. */
-#ifdef CONFIG_SMP
+#ifndef CONFIG_UP
     get_cpu_id x0
     ldr    x1, =(g_cpu_int_stacktop)
     lsl    x0, x0, #3
@@ -341,7 +341,7 @@ SECTION_FUNC(text, arm64_irq_handler)
     str    x9,  [sp, #8 * REG_TPIDR_EL0]
 
     /* Switch to IRQ stack and save current sp on it. */
-#ifdef CONFIG_SMP
+#ifndef CONFIG_UP
     get_cpu_id x0
     ldr    x1, =(g_cpu_int_stacktop)
     lsl    x0, x0, #3
diff --git a/boards/arm64/fvp-v8r/fvp-armv8r/configs/nsh_bmp/defconfig 
b/boards/arm64/fvp-v8r/fvp-armv8r/configs/nsh_bmp/defconfig
new file mode 100644
index 00000000000..d70ecf60490
--- /dev/null
+++ b/boards/arm64/fvp-v8r/fvp-armv8r/configs/nsh_bmp/defconfig
@@ -0,0 +1,77 @@
+#
+# This file is autogenerated: PLEASE DO NOT EDIT IT.
+#
+# You can use "make menuconfig" to make any modifications to the installed 
.config file.
+# You can then do "make savedefconfig" to generate a new defconfig file that 
includes your
+# modifications.
+#
+CONFIG_ARCH="arm64"
+CONFIG_ARCH_ARM64=y
+CONFIG_ARCH_BOARD="fvp-armv8r"
+CONFIG_ARCH_BOARD_FVP_ARMV8R=y
+CONFIG_ARCH_CHIP="fvp-v8r"
+CONFIG_ARCH_CHIP_FVP_ARMV8R=y
+CONFIG_ARCH_CHIP_FVP_R82=y
+CONFIG_ARCH_EARLY_PRINT=y
+CONFIG_ARCH_INTERRUPTSTACK=4096
+CONFIG_ARM64_STRING_FUNCTION=y
+CONFIG_BMP=y
+CONFIG_BOARDCTL_IRQ_AFFINITY=y
+CONFIG_BUILTIN=y
+CONFIG_DEBUG_ASSERTIONS=y
+CONFIG_DEBUG_FEATURES=y
+CONFIG_DEBUG_FULLOPT=y
+CONFIG_DEBUG_SCHED=y
+CONFIG_DEBUG_SCHED_ERROR=y
+CONFIG_DEBUG_SCHED_WARN=y
+CONFIG_DEBUG_SYMBOLS=y
+CONFIG_DEFAULT_TASK_STACKSIZE=8192
+CONFIG_EXAMPLES_HELLO=y
+CONFIG_EXPERIMENTAL=y
+CONFIG_FS_PROCFS=y
+CONFIG_FS_ROMFS=y
+CONFIG_IDLETHREAD_STACKSIZE=8192
+CONFIG_INIT_ENTRYPOINT="nsh_main"
+CONFIG_INTELHEX_BINARY=y
+CONFIG_NCPUS=4
+CONFIG_NSH_ARCHINIT=y
+CONFIG_NSH_BUILTIN_APPS=y
+CONFIG_NSH_FILEIOSIZE=512
+CONFIG_NSH_READLINE=y
+CONFIG_PREALLOC_TIMERS=4
+CONFIG_PTHREAD_STACK_MIN=8192
+CONFIG_RAMLOG=y
+CONFIG_RAM_SIZE=134217728
+CONFIG_RAM_START=0x0000000
+CONFIG_RAW_BINARY=y
+CONFIG_READLINE_CMD_HISTORY=y
+CONFIG_RR_INTERVAL=200
+CONFIG_SCHED_HPWORK=y
+CONFIG_SCHED_HPWORKPRIORITY=192
+CONFIG_STACK_COLORATION=y
+CONFIG_START_MONTH=3
+CONFIG_START_YEAR=2022
+CONFIG_SYMTAB_ORDEREDBYNAME=y
+CONFIG_SYSLOG_BUFFER=y
+CONFIG_SYSLOG_PROCESSID=y
+CONFIG_SYSLOG_PROCESS_NAME=y
+CONFIG_SYSTEM_NSH=y
+CONFIG_SYSTEM_SYSTEM=y
+CONFIG_SYSTEM_TIME64=y
+CONFIG_TESTING_GETPRIME=y
+CONFIG_TESTING_OSTEST=y
+CONFIG_UART0_BASE=0x9c090000
+CONFIG_UART0_IRQ=37
+CONFIG_UART0_PL011=y
+CONFIG_UART1_BASE=0x9c0a0000
+CONFIG_UART1_IRQ=38
+CONFIG_UART1_PL011=y
+CONFIG_UART1_SERIAL_CONSOLE=y
+CONFIG_UART2_BASE=0x9c0b0000
+CONFIG_UART2_IRQ=39
+CONFIG_UART2_PL011=y
+CONFIG_UART3_BASE=0x9c0c0000
+CONFIG_UART3_IRQ=40
+CONFIG_UART3_PL011=y
+CONFIG_UART_PL011=y
+CONFIG_USEC_PER_TICK=1000

Reply via email to