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 6e866da7322bdfa35783b74d63fe87e48f5e7b14
Author: Yanfeng Liu <[email protected]>
AuthorDate: Fri Feb 28 13:41:14 2025 +0800

    arch/armv8-r: add SMP sources
    
    This adds SMP related sources to armv8-r mostly from armv7-r.
    The cpuhead.S is tweaked to support EL2 settings then switch
    to EL1.
    
    Signed-off-by: Yanfeng Liu <[email protected]>
---
 arch/arm/src/armv8-r/CMakeLists.txt     |   5 +
 arch/arm/src/armv8-r/Make.defs          |   8 +-
 arch/arm/src/armv8-r/arm_cpuhead.S      | 572 ++++++++++++++++++++++++++++++++
 arch/arm/src/armv8-r/arm_cpuidlestack.c | 132 ++++++++
 arch/arm/src/armv8-r/arm_cpustart.c     | 129 +++++++
 arch/arm/src/armv8-r/arm_scu.c          | 133 ++++++++
 arch/arm/src/armv8-r/arm_smpcall.c      | 120 +++++++
 arch/arm/src/armv8-r/scu.h              | 252 ++++++++++++++
 8 files changed, 1350 insertions(+), 1 deletion(-)

diff --git a/arch/arm/src/armv8-r/CMakeLists.txt 
b/arch/arm/src/armv8-r/CMakeLists.txt
index a414d5a8e0d..c05ca69be81 100644
--- a/arch/arm/src/armv8-r/CMakeLists.txt
+++ b/arch/arm/src/armv8-r/CMakeLists.txt
@@ -54,4 +54,9 @@ if(CONFIG_ARCH_HIPRI_INTERRUPT)
   list(APPEND SRCS arm_dofiq.c)
 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)
+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 7f740a53eba..d3f1b717d29 100644
--- a/arch/arm/src/armv8-r/Make.defs
+++ b/arch/arm/src/armv8-r/Make.defs
@@ -59,4 +59,10 @@ ifeq ($(CONFIG_ARCH_HIPRI_INTERRUPT),y)
   CMN_CSRCS += arm_dofiq.c
 endif
 
-VPATH += arm_a_r
\ No newline at end of file
+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
+endif
+
+VPATH += arm_a_r
diff --git a/arch/arm/src/armv8-r/arm_cpuhead.S 
b/arch/arm/src/armv8-r/arm_cpuhead.S
new file mode 100644
index 00000000000..b61418f68a6
--- /dev/null
+++ b/arch/arm/src/armv8-r/arm_cpuhead.S
@@ -0,0 +1,572 @@
+/****************************************************************************
+ * arch/arm/src/armv8-r/arm_cpuhead.S
+ *
+ * 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 <arch/irq.h>
+
+#include "arm.h"
+#include "cp15_cacheops.h"
+#include "sctlr.h"
+#include "smp.h"
+#include "chip.h"
+#include "arm_internal.h"
+
+#ifdef CONFIG_SMP
+
+  .file "arm_cpuhead.S"
+
+/****************************************************************************
+ * Configuration
+ ****************************************************************************/
+
+/* There are three operational memory configurations:
+ *
+ * 1. We execute in place in FLASH (CONFIG_BOOT_RUNFROMFLASH=y).  In this case
+ *    the boot logic must:
+ *
+ *    - Configure SDRAM (if present),
+ *    - Initialize the .data section in RAM, and
+ *    - Clear .bss section
+ *
+ * 2. We boot in FLASH but copy ourselves to SDRAM from better performance.
+ *    (CONFIG_BOOT_RUNFROMFLASH=n && CONFIG_BOOT_COPYTORAM=y).  In this case
+ *    the boot logic must:
+ *
+ *    - Configure SDRAM (if present),
+ *    - Copy ourself to DRAM, and
+ *    - Clear .bss section (data should be fully initialized)
+ *
+ *   In this case, we assume that the logic within this file executes from 
FLASH.
+ *
+ * 3. There is bootloader that copies us to SDRAM (but probably not to the 
beginning)
+ *    (CONFIG_BOOT_RUNFROMFLASH=n && CONFIG_BOOT_COPYTORAM=n). In this case 
SDRAM
+ *    was initialized by the boot loader, and this boot logic must:
+ *
+ *    - Clear .bss section (data should be fully initialized)
+ */
+
+/* Beginning (BOTTOM/BASE) and End+1 (TOP) of the IDLE stack.
+ *
+ * The IDLE stack is the stack that is used during initialization and,
+ * eventually, becomes the stack of the IDLE task when initialization
+ * is complete.
+ *
+ * REVISIT:  There are issues here in some configurations.  The stack
+ * pointer is initialized very early in the boot sequence.  But in some
+ * architectures the memory supporting the stack may not yet be
+ * initialized (SDRAM, for example, would not be ready yet).  In that
+ * case, ideally the IDLE stack should be in some other memory that does
+ * not require initialization (such as internal SRAM)
+ */
+
+/****************************************************************************
+ * .text
+ ****************************************************************************/
+
+  .text
+  .syntax unified
+  .arm
+
+  .extern __cpux_wfi
+  .extern __hyp_vector_start
+  .extern __sys_vector_start
+
+/****************************************************************************
+ * Name: __cpu[n]_start
+ * Desc: Setup stack and jump to __el2_boot
+ ****************************************************************************/
+
+#if CONFIG_SMP_NCPUS > 1
+  .global __cpu1_start
+  .type   __cpu1_start, #function
+__cpu1_start:
+  ldr   sp, .Lcpu1_stackpointer
+  b     __el2_boot
+#endif
+
+#if CONFIG_SMP_NCPUS > 2
+  .global __cpu2_start
+  .type   __cpu2_start, #function
+__cpu2_start:
+  ldr   sp, .Lcpu2_stackpointer
+  b     __el2_boot
+#endif
+
+#if CONFIG_SMP_NCPUS > 3
+  .global __cpu3_start
+  .type   __cpu3_start, #function
+__cpu3_start:
+  ldr   sp, .Lcpu3_stackpointer
+  b     __el2_boot
+#endif
+
+#if CONFIG_SMP_NCPUS > 4
+#  warn Need work for CONFIG_SMP_NCPUS > 4
+  b     _cpux_wfi
+#endif
+
+/****************************************************************************
+ * Name: __el2_boot
+ * Desc: Setup el2 and jump to __el1_boot
+ ****************************************************************************/
+
+__el2_boot:
+  ldr   r0, .Lhypvectorstart
+  mcr   CP15_HVBAR(r0)     /* Set Hyp/PL2 Vectortable base register */
+
+  bl    hsctlr_initialize  /* Init Hyp control register */
+
+  ldr   r0, =HACTLR_INIT
+  mcr   CP15_HACTLR(r0)    /* Enable EL1 access to IMP DEFINED regs */
+
+  bl    arm_el_init        /* Platform hook for highest EL */
+
+  /* Switch PL1 SYS with all exceptions masked */
+
+  mov   r0, #(PSR_MODE_SYS | PSR_I_BIT | PSR_F_BIT | PSR_A_BIT)
+  msr   spsr_hyp, r0
+
+  adr   r0, __el1_boot
+  msr   elr_hyp, r0
+  dsb
+  isb
+  eret
+
+/****************************************************************************
+ * Name: __el1_boot
+ * Desc: dispatch to __cpu[n]_boot per cpuid
+ ****************************************************************************/
+
+__el1_boot:
+  mrc   CP15_MPIDR(r0)      /* Get cpuindex */
+  and   r0, r0, #0x3
+  cmp   r0, #1
+  beq   __cpu1_boot
+
+#if CONFIG_SMP_NCPUS > 2
+  cmp   r0, #2
+  beq   __cpu2_boot
+#endif
+
+#if CONFIG_SMP_NCPUS > 3
+  cmp   r0, #3
+  beq   __cpu3_boot
+#endif
+
+/****************************************************************************
+ * Name: __cpu[n]_boot
+ *
+ * Description:
+ *   Boot functions for each CPU (other than CPU0).  These functions set up
+ *   the ARM operating mode, the initial stack, and configure co-processor
+ *   registers.  At the end of the boot, arm_cpu_boot() is called.
+ *
+ *   These functions are provided by the common ARMv8-R logic.
+ *
+ ****************************************************************************/
+
+#if CONFIG_SMP_NCPUS > 1
+
+__cpu1_boot:
+  /* Make sure that we are in SYS mode with IRQs and FIQs disabled */
+
+  cpsid   if, #PSR_MODE_SYS
+
+  /* Set up the stack pointer and the CPU index */
+
+  ldr   sp, .Lcpu1_stackpointer
+  sub   sp, sp, #XCPTCONTEXT_SIZE
+  mov   r5, #1
+
+  /* Then branch to the common startup logic (PC-relative) */
+
+  b   .Lcpu_start
+
+.Lcpu1_stackpointer:
+  .long .Lcpu1_stacktop
+  .size __cpu1_start, .-__cpu1_start
+
+#if CONFIG_SMP_NCPUS > 2
+
+__cpu2_boot:
+  /* Make sure that we are in SYS mode with IRQs and FIQs disabled */
+
+  cpsid   if, #PSR_MODE_SYS
+
+  /* Set up the stack pointer and the CPU index */
+
+  ldr   sp, .Lcpu2_stackpointer
+  sub   sp, sp, #XCPTCONTEXT_SIZE
+  mov   r5, #2
+
+  /* Then branch to the common startup logic (PC-relative) */
+
+  b   .Lcpu_start
+
+.Lcpu2_stackpointer:
+  .long .Lcpu2_stacktop
+  .size __cpu2_start, .-__cpu2_start
+
+#if CONFIG_SMP_NCPUS > 3
+
+__cpu3_boot:
+  /* Make sure that we are in SYS mode with IRQs and FIQs disabled */
+
+  cpsid   if, #PSR_MODE_SYS
+
+  /* Set up the stack pointer and the CPU index */
+
+  ldr   sp, .Lcpu3_stackpointer
+  sub   sp, sp, #XCPTCONTEXT_SIZE
+  mov   r5, #3
+
+  /* Then branch to the common startup logic (PC-relative) */
+
+  b   .Lcpu_start
+
+.Lcpu3_stackpointer:
+  .long .Lcpu3_stacktop
+  .size __cpu3_start, .-__cpu3_start
+
+#if CONFIG_SMP_NCPUS > 4
+#  error This logic needs to extended for CONFIG_SMP_NCPUS > 4
+
+#endif /* CONFIG_SMP_NCPUS > 4 */
+#endif /* CONFIG_SMP_NCPUS > 3 */
+#endif /* CONFIG_SMP_NCPUS > 2 */
+#endif /* CONFIG_SMP_NCPUS > 1 */
+
+/****************************************************************************
+ * Name: .Lcpu_start
+ *
+ * Description:
+ *   Common CPUn startup logic (n > 0)
+ *
+ * On input:
+ *   SP = Set to top of CPU IDLE stack
+ *   R5 = CPU number
+ *
+ ****************************************************************************/
+
+  .type .Lcpu_start, #function
+
+.Lcpu_start:
+  /* The MPU and caches should be disabled */
+
+  mrc   CP15_SCTLR(r0)
+  bic   r0, r0, #(SCTLR_M | SCTLR_C)
+  bic   r0, r0, #(SCTLR_I)
+  mcr   CP15_SCTLR(r0)
+
+  /* Invalidate caches and TLBs.
+   *
+   *   NOTE: "The ARMv7 Virtual Memory System Architecture (VMSA) does not
+   *   support a CP15 operation to invalidate the entire data cache. ...
+   *   In normal usage the only time the entire data cache has to be
+   *   invalidated is on reset."
+   *
+   * The instruction cache is virtually indexed and physically tagged but
+   * the data cache is physically indexed and physically tagged.  So it
+   * should not be an issue if the system comes up with a dirty Dcache;
+   * the ICache, however, must be invalidated.
+   */
+
+  mov   r0, #0
+  mcr   CP15_TPIDRPRW(r0) /* Initialize percpu reg TPIDRPRW */
+  mcr   CP15_BPIALL(r0)   /* Invalidate entire branch prediction array */
+  isb
+
+  /* Set lr = Resume at .Lcpu_vstart with the MMU enabled */
+
+  ldr   lr, .LCcpu_vstart   /* Abs. address */
+
+  /* Configure the system control register (see sctrl.h) */
+
+  mrc   CP15_SCTLR(r0)      /* Get control register */
+
+  /* Clear bits to reset values.  This is only necessary in situations like, 
for
+   * example, we get here via a bootloader and the control register is in some
+   * unknown state.
+   *
+   *   SCTLR_M        Bit 0:  MPU enable bit
+   *   SCTLR_A        Bit 1:  Strict alignment disabled
+   *   SCTLR_C        Bit 2:  DCache disabled
+   *   SCTLR_CCP15BEN Bit 5:  CP15 barrier enable
+   *   SCTLR_B        Bit 7:  Should be zero on ARMv7R
+   *
+   *   SCTLR_SW       Bit 10: SWP/SWPB not enabled
+   *   SCTLR_I        Bit 12: ICache disabled
+   *   SCTLR_V        Bit 13: Assume low vectors
+   *   SCTLR_RR       Bit 14: Round-robin replacement strategy.
+   *
+   *   SCTLR_BR       Bit 17: Background Region bit
+   *   SCTLR_DZ       Bit 19: Divide by Zero fault enable bit
+   *   SCTLR_FI       Bit 21: Fast interrupts configuration enable bit
+   *   SCTLR_U        Bit 22: Unaligned access model (always one)
+   *
+   *   SCTLR_VE       Bit 24: Interrupt Vectors Enable bit
+   *   SCTLR_EE       Bit 25: 0=Little endian.
+   *   SCTLR_NMFI     Bit 27: Non-maskable FIQ (NMFI) support
+   *   SCTLR_TE       Bit 30: All exceptions handled in ARM state.
+   */
+
+  bic   r0, r0, #(SCTLR_A  | SCTLR_C  | SCTLR_CCP15BEN | SCTLR_B)
+  bic   r0, r0, #(SCTLR_SW | SCTLR_I  | SCTLR_V        | SCTLR_RR)
+  bic   r0, r0, #(SCTLR_BR | SCTLR_DZ | SCTLR_FI)
+  bic   r0, r0, #(SCTLR_VE | SCTLR_EE | SCTLR_NMFI     | SCTLR_TE)
+
+  /* Set bits to enable the MPU
+   *
+   *   SCTLR_M     Bit 0:  Enable the MPU
+   */
+
+  orr   r0, r0, #(SCTLR_M)
+
+  /* Set configured bits */
+
+#ifdef CONFIG_ARMV8R_ALIGNMENT_TRAP
+  /* Alignment abort enable
+   *
+   *   SCTLR_A Bit 1:  Strict alignment enabled
+   */
+
+  orr   r0, r0, #(SCTLR_A)
+#endif
+
+#ifdef CONFIG_ARMV8R_SCTLR_CCP15BEN
+  /* Enable memory barriers
+   *
+   *  SCTLR_CCP15BEN Bit 5: CP15 barrier enable
+   */
+
+  orr   r0, r0, #(SCTLR_CCP15BEN)
+#endif
+
+#ifndef CONFIG_ARCH_LOWVECTORS
+  /* Position vectors to 0xffff0000 if so configured.
+   *
+   *   SCTLR_V    Bit 13: High vectors
+   */
+
+  orr   r0, r0, #(SCTLR_V)
+#endif
+
+#ifdef CONFIG_ARMV8R_CACHE_ROUND_ROBIN
+  /* Round Robin cache replacement
+   *
+   *   SCTLR_RR   Bit 14: Round-robin replacement strategy.
+   */
+
+  orr   r0, r0, #(SCTLR_RR)
+#endif
+
+#ifdef CONFIG_ARMV8R_BACKGROUND_REGION
+  /* Allow PL1 access to back region when MPU is enabled
+   *
+   *  SCTLR_BR Bit 17: Background Region bit
+   */
+
+  orr   r0, r0, #(SCTLR_BR)
+#endif
+
+#ifdef CONFIG_ARMV8R_DIV0_FAULT
+  /* Enable divide by zero faults
+   *
+   *   SCTLR_DZ Bit 19: Divide by Zero fault enable bit
+   */
+
+  orr   r0, r0, #(SCTLR_DZ)
+#endif
+
+#ifdef CONFIG_ARMV8R_FAST_INTERRUPT
+  /* Fast interrupts configuration enable bit
+   *
+   *   SCTLR_FI Bit 21: Fast interrupts configuration enable bit
+   */
+
+  orr   r0, r0, #(SCTLR_FI)
+#endif
+
+#ifdef CONFIG_ARMV8R_IMPL_VECTORS
+  /* Implementation defined interrupt vectors
+   *
+   *   SCTLR_VE Bit 24: Interrupt Vectors Enable bit
+   */
+
+  orr   r0, r0, #(SCTLR_VE)
+#endif
+
+#ifdef CONFIG_ENDIAN_BIG
+  /* Big endian mode
+   *
+   *   SCTLR_EE       Bit 25: 1=Big endian.
+   */
+
+  orr   r0, r0, #(SCTLR_EE)
+#endif
+
+#ifdef CONFIG_ARMV8R_NONMASKABLE_FIQ
+  /* Non-maskable FIQ support
+   *
+   *   SCTLR_NMFI Bit 27: Non-maskable FIQ (NMFI) support
+   */
+
+  orr   r0, r0, #(SCTLR_NMFI)
+#endif
+
+  /* Then write the configured control register */
+
+  mcr    CP15_SCTLR(r0)      /* Write control reg */
+  isb
+  .rept  12        /* Some CPUs want want lots of NOPs here */
+  nop
+  .endr
+
+  /* And "jump" to .Lcpu_vstart in the new virtual address space */
+
+  mov    pc, lr
+
+/****************************************************************************
+ * PC_Relative Data
+ ****************************************************************************/
+
+  /* The start address of the second phase boot logic */
+
+  .type .LCcpu_vstart, %object
+.LCcpu_vstart:
+  .long .Lcpu_vstart
+  .size .LCcpu_vstart, . -.LCcpu_vstart
+
+  .size .Lcpu_start, .-.Lcpu_start
+
+/****************************************************************************
+ * Name: .Lcpu_vstart
+ *
+ * Description:
+ *   Continue initialization after the MPU has been enabled.
+ *
+ *   The following is executed after the MPU has been enabled. This uses
+ *   absolute addresses; this is not position independent.
+ *
+ * On input:
+ *   SP = Set to top of CPU IDLE stack
+ *   R5 = CPU number
+ *
+ ****************************************************************************/
+
+  .align  8
+  .globl  arm_cpu_boot
+  .type .Lcpu_vstart, %function
+
+.Lcpu_vstart:
+
+#ifdef CONFIG_STACK_COLORATION
+  /* Write a known value to the IDLE thread stack to support stack
+   * monitoring logic
+   */
+
+  adr   r3, .Lstkinit
+  mov   r0, sp          /* R0 = end of IDLE stack */
+  ldmia r3, {r1, r2}    /* R1 = Size of stack; R2 = coloration */
+
+1:                      /* Top of the loop */
+  sub   r1, r1, #1      /* R1 = Number of words remaining */
+  cmp   r1, #0          /* Check (nwords == 0) */
+  str   r2, [r0, #-4]!  /* Save color word, increment stack address */
+  bne   1b              /* Bottom of the loop */
+#endif
+
+  /* Branch to continue C level CPU initialization */
+
+  mov   fp, #0        /* Clear framepointer */
+  mov   lr, #0        /* LR = return address (none) */
+  mov   r0, r5        /* Input parameter = CPU index */
+  b     arm_cpu_boot  /* Branch to C level CPU initialization */
+  .size .Lcpu_vstart, .-.Lcpu_vstart
+
+/***************************************************************************
+ * Text-section constants
+ ***************************************************************************/
+
+  /* Text-section constants: */
+
+#ifdef CONFIG_STACK_COLORATION
+  .type .Lstkinit, %object
+.Lstkinit:
+  .long SMP_STACK_WORDS - (XCPTCONTEXT_SIZE / 4)
+  .long STACK_COLOR       /* Stack coloration word */
+  .size .Lstkinit, . -.Lstkinit
+#endif
+
+.Lhypvectorstart:
+  .long _hyp_vector_start
+.Lsysvectorstart:
+  .long _sys_vector_start
+
+/***************************************************************************
+ * .noinit section data
+ ***************************************************************************/
+
+  .section  .noinit, "aw"
+
+#if CONFIG_SMP_NCPUS > 1
+  .align  8
+  .globl  g_cpu1_idlestack
+  .type g_cpu1_idlestack, object
+
+g_cpu1_idlestack:
+  .space  SMP_STACK_SIZE
+.Lcpu1_stacktop:
+  .size g_cpu1_idlestack, .Lcpu1_stacktop-g_cpu1_idlestack
+
+#if CONFIG_SMP_NCPUS > 2
+  .align  8
+  .globl  g_cpu2_idlestack
+  .type g_cpu2_idlestack, object
+
+g_cpu2_idlestack:
+  .space  SMP_STACK_SIZE
+.Lcpu2_stacktop:
+  .size g_cpu2_idlestack, .Lcpu2_stacktop-g_cpu2_idlestack
+
+#if CONFIG_SMP_NCPUS > 3
+  .align  8
+  .globl  g_cpu3_idlestack
+  .type g_cpu3_idlestack, object
+
+g_cpu3_idlestack:
+  .space  SMP_STACK_SIZE
+.Lcpu3_stacktop:
+  .size g_cpu3_idlestack, .Lcpu3_stacktop-g_cpu3_idlestack
+
+#if CONFIG_SMP_NCPUS > 4
+#  error This logic needs to extended for CONFIG_SMP_NCPUS > 4
+
+#endif /* CONFIG_SMP_NCPUS > 4 */
+#endif /* CONFIG_SMP_NCPUS > 3 */
+#endif /* CONFIG_SMP_NCPUS > 2 */
+#endif /* CONFIG_SMP_NCPUS > 1 */
+#endif /* CONFIG_SMP */
+  .end
diff --git a/arch/arm/src/armv8-r/arm_cpuidlestack.c 
b/arch/arm/src/armv8-r/arm_cpuidlestack.c
new file mode 100644
index 00000000000..5d7ee4190d7
--- /dev/null
+++ b/arch/arm/src/armv8-r/arm_cpuidlestack.c
@@ -0,0 +1,132 @@
+/****************************************************************************
+ * arch/arm/src/armv8-r/arm_cpuidlestack.c
+ *
+ * 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/arm_cpustart.c 
b/arch/arm/src/armv8-r/arm_cpustart.c
new file mode 100644
index 00000000000..74843199486
--- /dev/null
+++ b/arch/arm/src/armv8-r/arm_cpustart.c
@@ -0,0 +1,129 @@
+/****************************************************************************
+ * arch/arm/src/armv8-r/arm_cpustart.c
+ *
+ * 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 <stdint.h>
+#include <assert.h>
+#include <debug.h>
+
+#include <nuttx/arch.h>
+#include <nuttx/sched.h>
+#include <nuttx/sched_note.h>
+
+#include "arm_internal.h"
+#include "cp15_cacheops.h"
+#include "gic.h"
+#include "sched/sched.h"
+
+#ifdef CONFIG_SMP
+
+/****************************************************************************
+ * Private Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: arm_start_handler
+ *
+ * Description:
+ *   This is the handler for SGI1.  This handler simply returns from the
+ *   interrupt, restoring the state of the new task at the head of the ready
+ *   to run list.
+ *
+ * Input Parameters:
+ *   Standard interrupt handling
+ *
+ * Returned Value:
+ *   Zero on success; a negated errno value on failure.
+ *
+ ****************************************************************************/
+
+int arm_start_handler(int irq, void *context, void *arg)
+{
+  struct tcb_s *tcb = this_task();
+
+  sinfo("CPU%d Started\n", this_cpu());
+
+#ifdef CONFIG_SCHED_INSTRUMENTATION
+  /* Notify that this CPU has started */
+
+  sched_note_cpu_started(tcb);
+#endif
+
+  UNUSED(tcb);
+
+  return OK;
+}
+
+/****************************************************************************
+ * Name: up_cpu_start
+ *
+ * Description:
+ *   In an SMP configuration, only one CPU is initially active (CPU 0).
+ *   System initialization occurs on that single thread. At the completion of
+ *   the initialization of the OS, just before beginning normal multitasking,
+ *   the additional CPUs would be started by calling this function.
+ *
+ *   Each CPU is provided the entry point to its IDLE task when started.  A
+ *   TCB for each CPU's IDLE task has been initialized and placed in the
+ *   CPU's g_assignedtasks[cpu] list.  No stack has been allocated or
+ *   initialized.
+ *
+ *   The OS initialization logic calls this function repeatedly until each
+ *   CPU has been started, 1 through (CONFIG_SMP_NCPUS-1).
+ *
+ * Input Parameters:
+ *   cpu - The index of the CPU being started.  This will be a numeric
+ *         value in the range of one to (CONFIG_SMP_NCPUS-1).
+ *         (CPU 0 is already active)
+ *
+ * Returned Value:
+ *   Zero on success; a negated errno value on failure.
+ *
+ ****************************************************************************/
+
+int up_cpu_start(int cpu)
+{
+  sinfo("Starting CPU%d\n", cpu);
+
+  DEBUGASSERT(cpu >= 0 && cpu < CONFIG_SMP_NCPUS && cpu != this_cpu());
+
+#ifdef CONFIG_SCHED_INSTRUMENTATION
+  /* Notify of the start event */
+
+  sched_note_cpu_start(this_task(), cpu);
+#endif
+
+  /* Execute SGI1 */
+
+  arm_cpu_sgi(GIC_SMP_CPUSTART, (1 << cpu));
+
+  return OK;
+}
+
+#endif /* CONFIG_SMP */
diff --git a/arch/arm/src/armv8-r/arm_scu.c b/arch/arm/src/armv8-r/arm_scu.c
new file mode 100644
index 00000000000..7c8ee26e140
--- /dev/null
+++ b/arch/arm/src/armv8-r/arm_scu.c
@@ -0,0 +1,133 @@
+/****************************************************************************
+ * arch/arm/src/armv8-r/arm_scu.c
+ *
+ * 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 <stdint.h>
+
+#include <arch/barriers.h>
+#include <arch/irq.h>
+#include <sched/sched.h>
+
+#include "arm_internal.h"
+#include "cp15_cacheops.h"
+#include "sctlr.h"
+#include "scu.h"
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: arm_enable_smp
+ *
+ * Description:
+ *   Enable the SCU and make certain that current CPU is participating in
+ *   the SMP cache coherency.
+ *
+ * Assumption:
+ *   Called early in the CPU start-up.  No special critical sections are
+ *   needed if only CPU-private registers are modified.
+ *
+ ****************************************************************************/
+
+void arm_enable_smp(int cpu)
+{
+  uint32_t regval;
+
+  /* We need to confirm that current_task has been initialized. */
+
+  while (!current_task(this_cpu()));
+
+  /* Init idle task to percpu reg */
+
+  up_update_task(current_task(cpu));
+
+  /* Handle actions unique to CPU0 which comes up first */
+
+  if (cpu == 0)
+    {
+      /* Invalidate the SCU duplicate tags for all processors */
+
+      putreg32((SCU_INVALIDATE_ALL_WAYS << SCU_INVALIDATE_CPU0_SHIFT)
+               | (SCU_INVALIDATE_ALL_WAYS << SCU_INVALIDATE_CPU1_SHIFT)
+#if CONFIG_SMP_NCPUS > 2
+               | (SCU_INVALIDATE_ALL_WAYS << SCU_INVALIDATE_CPU2_SHIFT)
+               | (SCU_INVALIDATE_ALL_WAYS << SCU_INVALIDATE_CPU3_SHIFT)
+#endif
+               , SCU_INVALIDATE);
+
+      /* Invalidate CPUn L1 data cache so that is will we be reloaded from
+       * coherent L2.
+       */
+
+      cp15_invalidate_dcache_all();
+      UP_DSB();
+
+      /* Invalidate the L2C-310 -- Missing logic. */
+
+      /* Enable the SCU */
+
+      regval  = getreg32(SCU_CTRL);
+      regval |= SCU_CTRL_ENABLE;
+      putreg32(regval, SCU_CTRL);
+
+      /* Initialize done, kick other cpus which waiting on __start */
+
+      UP_SEV();
+    }
+
+  /* Actions for other CPUs */
+
+  else
+    {
+      /* Invalidate CPUn L1 data cache so that is will we be reloaded from
+       * coherent L2.
+       */
+
+      cp15_dcache_op_level(0, CP15_CACHE_INVALIDATE);
+      UP_DSB();
+
+      /* Wait for the SCU to be enabled by the primary processor -- should
+       * not be necessary.
+       */
+    }
+
+  /* Enable the data cache, set the SMP mode with ACTLR.SMP=1.
+   *
+   *   SMP - Sgnals if the processor is taking part in coherency
+   *         or not.
+   *
+   *   FW  - Cache and TLB maintenance broadcast.
+   */
+
+  regval  = CP15_GET(ACTLR);
+  regval |= ACTLR_SMP;
+  regval |= ACTLR_FW;
+  CP15_SET(ACTLR, regval);
+
+  regval  = CP15_GET(SCTLR);
+  regval |= SCTLR_C | SCTLR_I | SCTLR_M;
+  CP15_SET(SCTLR, regval);
+}
diff --git a/arch/arm/src/armv8-r/arm_smpcall.c 
b/arch/arm/src/armv8-r/arm_smpcall.c
new file mode 100644
index 00000000000..92afaca1ef5
--- /dev/null
+++ b/arch/arm/src/armv8-r/arm_smpcall.c
@@ -0,0 +1,120 @@
+/****************************************************************************
+ * arch/arm/src/armv8-r/arm_smpcall.c
+ *
+ * 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 <stdint.h>
+#include <assert.h>
+
+#include <nuttx/arch.h>
+#include <nuttx/sched.h>
+#include <nuttx/spinlock.h>
+#include <nuttx/sched_note.h>
+
+#include "arm_internal.h"
+#include "gic.h"
+#include "sched/sched.h"
+
+#ifdef CONFIG_SMP
+
+/****************************************************************************
+ * Private Data
+ ****************************************************************************/
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: arm_smp_sched_handler
+ *
+ * Description:
+ *   This is the handler for sched.
+ *
+ *   1. It saves the current task state at the head of the current assigned
+ *      task list.
+ *   2. It porcess g_delivertasks
+ *   3. Returns from interrupt, restoring the state of the new task at the
+ *      head of the ready to run list.
+ *
+ * Input Parameters:
+ *   Standard interrupt handling
+ *
+ * Returned Value:
+ *   Zero on success; a negated errno value on failure.
+ *
+ ****************************************************************************/
+
+int arm_smp_sched_handler(int irq, void *context, void *arg)
+{
+  nxsched_process_delivered(this_cpu());
+  return OK;
+}
+
+/****************************************************************************
+ * Name: up_send_smp_sched
+ *
+ * Description:
+ *   pause task execution on the CPU
+ *   check whether there are tasks delivered to specified cpu
+ *   and try to run them.
+ *
+ * Input Parameters:
+ *   cpu - The index of the CPU to be paused.
+ *
+ * Returned Value:
+ *   Zero on success; a negated errno value on failure.
+ *
+ * Assumptions:
+ *   Called from within a critical section;
+ *
+ ****************************************************************************/
+
+int up_send_smp_sched(int cpu)
+{
+  arm_cpu_sgi(GIC_SMP_SCHED, (1 << cpu));
+
+  return OK;
+}
+
+/****************************************************************************
+ * Name: up_send_smp_call
+ *
+ * Description:
+ *   Send smp call to target cpu.
+ *
+ * Input Parameters:
+ *   cpuset - The set of CPUs to receive the SGI.
+ *
+ * Returned Value:
+ *   None.
+ *
+ ****************************************************************************/
+
+void up_send_smp_call(cpu_set_t cpuset)
+{
+  up_trigger_irq(GIC_SMP_CALL, cpuset);
+}
+
+#endif /* CONFIG_SMP */
diff --git a/arch/arm/src/armv8-r/scu.h b/arch/arm/src/armv8-r/scu.h
new file mode 100644
index 00000000000..91fb679a514
--- /dev/null
+++ b/arch/arm/src/armv8-r/scu.h
@@ -0,0 +1,252 @@
+/****************************************************************************
+ * arch/arm/src/armv8-r/scu.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.
+ *
+ ****************************************************************************/
+
+/* Reference:
+ *   Cortex™-R8 MPCore, Revision: r0p3, Technical Reference Manual.
+ */
+
+#ifndef __ARCH_ARM_SRC_ARMV8_R_SCU_H
+#define __ARCH_ARM_SRC_ARMV8_R_SCU_H
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include "mpcore.h"                         /* For MPCORE_SCU_VBASE */
+
+/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+
+/* Register offsets *********************************************************/
+
+#define SCU_CTRL_OFFSET              0x0000           /* SCU Control Register 
(Implementation defined) */
+#define SCU_CONFIG_OFFSET            0x0004           /* SCU Configuration 
Register (Implementation defined) */
+#define SCU_PWRSTATUS_OFFSET         0x0008           /* SCU CPU Power Status 
Register */
+#define SCU_INVALIDATE_OFFSET        0x000c           /* SCU Invalidate All 
Registers in Secure State */
+#define SCU_FILTERSTART_OFFSET       0x0040           /* Filtering Start 
Address Register Defined by FILTERSTART input */
+#define SCU_FILTEREND_OFFSET         0x0044           /* Filtering End Address 
Register Defined by FILTEREND input */
+#define SCU_PFILTERSTART_OFFSET      0x0048           /* Peripherals Filtering 
Start Address Register */
+#define SCU_PFILTEREND_OFFSET        0x004c           /* Peripherals Filtering 
End Address Register */
+#define SCU_SAC_OFFSET               0x0050           /* SCU Access Control 
(SAC) Register */
+#define SCU_ERRBANKFST_OFFSET        0x0060           /* SCU Error Bank First 
Entry Register */
+#define SCU_ERRBANKSND_OFFSET        0x0064           /* SCU Error Bank Second 
Entry Register */
+#define SCU_DEBUGRAM_OFFSET          0x0070           /* SCU Debug Tag RAM 
Operation Register */
+#define SCU_DEBUGRAMDATA_OFFSET      0x0074           /* SCU Debug Tag RAM 
Data Value Register */
+#define SCU_DEBUGRAMECC_OFFSET       0x0078           /* SCU Debug Tag RAM ECC 
Chunk Register */
+#define SCU_ECCERR_OFFSET            0x007c           /* ECC Fatal Error 
Registe */
+#define SCU_FPPFILTERSTART_OFFSET(n) (0x0080 + (n)*8) /* FPP Filtering Start 
Address Register for core n */
+#define SCU_FPPFILTEREND_OFFSET(n)   (0x0084 + (n)*8) /* FPP Filtering End 
Address Register for core n */
+
+/* Register addresses *******************************************************/
+
+#define SCU_CTRL                     (MPCORE_SCU_VBASE+SCU_CTRL_OFFSET)
+#define SCU_CONFIG                   (MPCORE_SCU_VBASE+SCU_CONFIG_OFFSET)
+#define SCU_PWRSTATUS                (MPCORE_SCU_VBASE+SCU_PWRSTATUS_OFFSET)
+#define SCU_INVALIDATE               (MPCORE_SCU_VBASE+SCU_INVALIDATE_OFFSET)
+#define SCU_FILTERSTART              (MPCORE_SCU_VBASE+SCU_FILTERSTART_OFFSET)
+#define SCU_FILTEREND                (MPCORE_SCU_VBASE+SCU_FILTEREND_OFFSET)
+#define SCU_PFILTERSTART             (MPCORE_SCU_VBASE+SCU_PFILTERSTART_OFFSET)
+#define SCU_PFILTEREND               (MPCORE_SCU_VBASE+SCU_PFILTEREND_OFFSET)
+#define SCU_SAC                      (MPCORE_SCU_VBASE+SCU_SAC_OFFSET)
+#define SCU_ERRBANKFST               (MPCORE_SCU_VBASE+SCU_ERRBANKFST_OFFSET)
+#define SCU_ERRBANKSND               (MPCORE_SCU_VBASE+SCU_ERRBANKSND_OFFSET)
+#define SCU_DEBUGRAM                 (MPCORE_SCU_VBASE+SCU_DEBUGRAM_OFFSET)
+#define SCU_DEBUGRAMDATA             (MPCORE_SCU_VBASE+SCU_DEBUGRAMDATA_OFFSET)
+#define SCU_DEBUGRAMECC              (MPCORE_SCU_VBASE+SCU_DEBUGRAMECC_OFFSET)
+#define SCU_ECCERR                   (MPCORE_SCU_VBASE+SCU_ECCERR_OFFSET)
+#define SCU_FPPFILTERSTART(n)        
(MPCORE_SCU_VBASE+SCU_FPPFILTERSTART0_OFFSET(n))
+#define SCU_FPPFILTEREND(n)          
(MPCORE_SCU_VBASE+SCU_FPPFILTEREND0_OFFSET(n))
+
+/* Register bit-field definitions *******************************************/
+
+/* SCU Control Register (Implementation defined) */
+
+#define SCU_CTRL_ENABLE              (1 << 0)         /* SCU enable */
+#define SCU_CTRL_ADDRFILTER          (1 << 1)         /* Address filtering 
enable */
+#define SCU_CTRL_RAMPARITY           (1 << 2)         /* SCU RAMs ECC enable */
+#define SCU_CTRL_LINFILL             (1 << 3)         /* SCU speculative 
linefill enable */
+#define SCU_CTRL_STANDBY             (1 << 5)         /* SCU standby enable */
+#define SCU_CTRL_ICSTANDBY           (1 << 6)         /* IC standby enable */
+#define SCU_CTRL_ECCCHKEN_M0         (1 << 12)        /* ECC check enable on 
M0 */
+#define SCU_CTRL_ECCCHKEN_M1         (1 << 13)        /* ECC check enable on 
M1 */
+#define SCU_CTRL_ECCCHKEN_MP         (1 << 14)        /* ECC check enable on 
MP */
+#define SCU_CTRL_ECCCHKEN_ACP        (1 << 15)        /* ECC check enable on 
ACP */
+#define SCU_CTRL_ECCCHKEN_FPP(n)     (1 << ((n)+16))  /* ECC check enable on 
FPP for core n */
+#define SCU_CTRL_ECCCHKEN_TCM        (1 << 20)        /* ECC check enable on 
AXI TCM */
+
+/* SCU Configuration Register (Implementation defined) */
+
+#define SCU_CONFIG_NCPUS_SHIFT       0         /* CPU number Number of CPUs 
present */
+#define SCU_CONFIG_NCPUS_MASK        (3 << SCU_CONFIG_NCPUS_SHIFT)
+#  define SCU_CONFIG_NCPUS(r)        ((((uint32_t)(r) &  
SCU_CONFIG_NCPUS_MASK) >> SCU_CONFIG_NCPUS_SHIFT) + 1)
+#define SCU_CONFIG_SMPCPUS_SHIFT     4         /* Processors that are in SMP 
or AMP mode */
+#define SCU_CONFIG_SMPCPUS_MASK      (15 << SCU_CONFIG_SMPCPUS_SHIFT)
+#  define SCU_CONFIG_CPU_SMP(n)      (1 << ((n)+4))
+#  define SCU_CONFIG_CPU0_SMP        (1 << 4)
+#  define SCU_CONFIG_CPU1_SMP        (1 << 5)
+#  define SCU_CONFIG_CPU2_SMP        (1 << 6)
+#  define SCU_CONFIG_CPU3_SMP        (1 << 7)
+
+#define SCU_CONFIG_CACHE_0KB         0
+#define SCU_CONFIG_CACHE_4KB         1
+#define SCU_CONFIG_CACHE_8KB         2
+#define SCU_CONFIG_CACHE_16KB        3
+#define SCU_CONFIG_CACHE_32KB        4
+#define SCU_CONFIG_CACHE_64KB        5
+
+#define SCU_CONFIG_CPU0_CACHE_SHIFT  8         /* CPU 0 cache size */
+#define SCU_CONFIG_CPU0_CACHE_MASK   (4 << SCU_CONFIG_CPU0_CACHE_SHIFT)
+#define SCU_CONFIG_CPU1_CACHE_SHIFT  12        /* CPU 1 cache size */
+#define SCU_CONFIG_CPU1_CACHE_MASK   (4 << SCU_CONFIG_CPU1_CACHE_SHIFT)
+#define SCU_CONFIG_CPU2_CACHE_SHIFT  16        /* CPU 2 cache size */
+#define SCU_CONFIG_CPU2_CACHE_MASK   (4 << SCU_CONFIG_CPU2_CACHE_SHIFT)
+#define SCU_CONFIG_CPU3_CACHE_SHIFT  20        /* CPU 3 cache size */
+#define SCU_CONFIG_CPU3_CACHE_MASK   (4 << SCU_CONFIG_CPU3_CACHE_SHIFT)
+
+#define SCU_CONFIG_AXI_PORT1_SHIFT   31
+
+/* SCU CPU Power Status Register */
+
+#define SCU_PWRSTATUS_NORMAL         0
+#define SCU_PWRSTATUS_DORMANT        2
+#define SCU_PWRSTATUS_PWROFF         3
+
+#define SCU_PWRSTATUS_CPU0_SHIFT     0         /* CPU0 status Power status */
+#define SCU_PWRSTATUS_CPU0_MASK      (3 << SCU_PWRSTATUS_CPU0_SHIFT)
+#define SCU_PWRSTATUS_CPU1_SHIFT     8         /* CPU1 status Power status */
+#define SCU_PWRSTATUS_CPU1_MASK      (3 << SCU_PWRSTATUS_CPU1_SHIFT)
+#define SCU_PWRSTATUS_CPU2_SHIFT     16        /* CPU2 status Power status */
+#define SCU_PWRSTATUS_CPU2_MASK      (3 << SCU_PWRSTATUS_CPU2_SHIFT)
+#define SCU_PWRSTATUS_CPU3_SHIFT     24        /* CPU3 status Power status */
+#define SCU_PWRSTATUS_CPU3_MASK      (3 << SCU_PWRSTATUS_CPU3_SHIFT)
+
+/* SCU Invalidate All Registers in Secure State */
+
+#define SCU_INVALIDATE_ALL_WAYS      15
+#define SCU_INVALIDATE_CPU0_SHIFT    0         /* Ways that must be 
invalidated for CPU0 */
+#define SCU_INVALIDATE_CPU0_MASK     (15 << SCU_INVALIDATE_CPU0_SHIFT)
+#define SCU_INVALIDATE_CPU1_SHIFT    4         /* Ways that must be 
invalidated for CPU1 */
+#define SCU_INVALIDATE_CPU1_MASK     (15 << SCU_INVALIDATE_CPU1_SHIFT)
+#define SCU_INVALIDATE_CPU2_SHIFT    8         /* Ways that must be 
invalidated for CPU2 */
+#define SCU_INVALIDATE_CPU2_MASK     (15 << SCU_INVALIDATE_CPU2_SHIFT)
+#define SCU_INVALIDATE_CPU3_SHIFT    12        /* Ways that must be 
invalidated for CPU3 */
+#define SCU_INVALIDATE_CPU3_MASK     (15 << SCU_INVALIDATE_CPU3_SHIFT)
+
+/* Filtering Start Address Register Defined by FILTERSTART input */
+
+#define SCU_FILTERSTART_SHIFT        20        /* Filtering start address */
+#define SCU_FILTERSTART_MASK         (0xfff << SCU_FILTERSTART_SHIFT)
+
+/* Filtering End Address Register Defined by FILTEREND input */
+
+#define SCU_FILTEREND_SHIFT          20        /* Filtering start address */
+#define SCU_FILTEREND_MASK           (0xfff << SCU_FILTEREND_SHIFT)
+
+/* LLP Filtering Start Address Register */
+
+#define SCU_LLPFILTERSTART_SHIFT     20
+#define SCU_LLPFILTERSTART_MASK      (0xfff << SCU_LLPFILTERSTART_SHIFT)
+
+/* LLP Filtering End Address Register */
+
+#define SCU_LLPFILTEREND_SHIFT       20
+#define SCU_LLPFILTEREND_MASK        (0xfff << SCU_LLPFILTEREND_SHIFT)
+
+/* SCU Access Control (SAC) Register */
+
+#define SCU_SAC_CPU(n)               (1 << (n)) /* CPUn may access components 
*/
+
+/* SCU Error Bank First Entry Register */
+
+#define SCU_ERRBANKFST_STATUS_SHIFT  0
+#define SCU_ERRBANKFST_STATUS_MASK   (3 << SCU_ERRBANKFST_STATUS_SHIFT)
+
+#define SCU_ERRBANKFST_WAYS_SHIFT(n) (16 + (n)*4)
+#define SCU_ERRBANKFST_WAYS_MASK(n)  (0xf << SCU_ERRBANKFST_WAYS_SHIFT(n))
+
+/* SCU Error Bank Second Entry Register */
+
+#define SCU_ERRBANKSND_STATUS_SHIFT  0
+#define SCU_ERRBANKSND_STATUS_MASK   (3 << SCU_ERRBANKSND_STATUS_SHIFT)
+
+#define SCU_ERRBANKSND_INDEX_SHIFT   5
+#define SCU_ERRBANKSND_INDEX_MASK    (0x1ff << SCU_ERRBANKSND_INDEX_SHIFT)
+
+#define SCU_ERRBANKSND_WAYS_SHIFT    16
+#define SCU_ERRBANKSND_WAYS_MASK     (0xffff << SCU_ERRBANKSND_WAYS_SHIFT)
+
+/* SCU Debug Tag RAM Operation Register */
+
+#define SCU_DEBUGRAM_READ            0
+#define SCU_DEBUGRAM_WRITE           1
+
+#define SCU_DEBUGRAM_INDEX_SHIFT     5
+#define SCU_DEBUGRAM_INDEX_MASK      (0x1ff << SCU_DEBUGRAM_INDEX_SHIFT)
+
+#define SCU_DEBUGRAM_CORE_SHIFT      24
+#define SCU_DEBUGRAM_CORE_MASK       (3 << SCU_DEBUGRAM_CORE_SHIFT)
+
+#define SCU_DEBUGRAM_WAY_SHIFT       30
+#define SCU_DEBUGRAM_WAY_MASK        (3 << SCU_DEBUGRAM_WAY_SHIFT)
+
+/* SCU Debug Tag RAM Data Value Register */
+
+#define SCU_DEBUGRAMDATA_VALUE_SHIFT 17
+#define SCU_DEBUGRAMDATA_VALUE_MASK  (0x1f << SCU_DEBUGRAMDATA_VALUE_SHIFT)
+
+#define SCU_DEBUGRAMDATA_VALID       (1 << 22)
+
+/* SCU Debug Tag RAM ECC Chunk Register */
+
+#define SCU_DEBUGRAMECC_CHUNK_SHIFT  0
+#define SCU_DEBUGRAMECC_CHUNK_MASK   (0x3f << SCU_DEBUGRAMECC_CHUNK_SHIFT)
+
+/* ECC Fatal Error Register */
+
+#define SCU_ECCERR_CORE_DETECTED(n)  (n)
+#define SCU_ECCERR_DETECTED          (1 << 8)
+
+/* FPP Filtering Start Address Registers 0-3 */
+
+#define SCU_FPPFILTERSTART_SHIFT     20
+#define SCU_FPPFILTERSTART_MASK      (0xfff << SCU_FPPFILTERSTART_SHIFT)
+
+/* FPP Filtering End Address Registers 0-3 */
+
+#define SCU_FPPFILTEREND_SHIFT       20
+#define SCU_FPPFILTEREND_MASK        (0xfff << SCU_FPPFILTEREND_SHIFT)
+
+/****************************************************************************
+ * Public Functions Prototypes
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: arm_enable_smp
+ *
+ * Description:
+ *   Enable the SCU and make certain that current CPU is participating in
+ *   the SMP cache coherency.
+ *
+ ****************************************************************************/
+
+void arm_enable_smp(int cpu);
+
+#endif /* __ARCH_ARM_SRC_ARMV8_R_SCU_H */

Reply via email to