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 7fede9c5fc5211fd3063b3a15568520235069428
Author: Yanfeng Liu <[email protected]>
AuthorDate: Sat Feb 15 09:38:42 2025 +0800

    chip/qemu: fix CORTEXR52 build issue
    
    This adds GICD_BASE, GICR_BASE etc to fix QEMU CORTEXR52 build issues.
    It also adds arm_el_init() for ARMV8R to fix link issue.
    It also tweaks Make.defs to add dependency on armv8-r if required.
    
    Signed-off-by: Yanfeng Liu <[email protected]>
---
 arch/arm/include/qemu/chip.h     | 19 +++++++++++++++++++
 arch/arm/src/qemu/CMakeLists.txt |  4 ++++
 arch/arm/src/qemu/Make.defs      |  4 ++++
 arch/arm/src/qemu/qemu_boot.c    | 26 ++++++++++++++++++++++++++
 arch/arm/src/qemu/qemu_timer.c   |  7 ++++++-
 5 files changed, 59 insertions(+), 1 deletion(-)

diff --git a/arch/arm/include/qemu/chip.h b/arch/arm/include/qemu/chip.h
index 73e7e4e66d3..800afa641a4 100644
--- a/arch/arm/include/qemu/chip.h
+++ b/arch/arm/include/qemu/chip.h
@@ -33,6 +33,25 @@
  * Pre-processor Prototypes
  ****************************************************************************/
 
+#if CONFIG_ARM_GIC_VERSION == 2
+
+#define CONFIG_GICD_BASE           0x8000000
+#define CONFIG_GICR_BASE           0x8010000
+#define CONFIG_GICM_BASE           0x8020000
+
+#elif CONFIG_ARM_GIC_VERSION == 3 || CONFIG_ARM_GIC_VERSION == 4
+
+#define CONFIG_GICD_BASE           0x8000000
+#define CONFIG_GICR_BASE           0x80a0000
+#define CONFIG_GICR_OFFSET         0x20000
+#else
+
+#error CONFIG_ARM64_GIC_VERSION should be 2, 3 or 4
+
+#endif /* CONFIG_ARM_GIC_VERSION */
+
+#define MPID_TO_CLUSTER_ID(mpid)  ((mpid) & ~0xff)
+
 /****************************************************************************
  * Public Types
  ****************************************************************************/
diff --git a/arch/arm/src/qemu/CMakeLists.txt b/arch/arm/src/qemu/CMakeLists.txt
index 03585b259d5..92dbd5ae0c0 100644
--- a/arch/arm/src/qemu/CMakeLists.txt
+++ b/arch/arm/src/qemu/CMakeLists.txt
@@ -22,6 +22,10 @@
 
 set(SRCS qemu_boot.c qemu_serial.c qemu_irq.c qemu_timer.c)
 
+if(CONFIG_ARCH_ARMV7R OR CONFIG_ARCH_ARMV8R)
+  nuttx_add_subdirectory()
+endif()
+
 if(CONFIG_ARCH_ARMV7A)
   list(APPEND SRCS qemu_pgalloc.c qemu_memorymap.c)
 endif()
diff --git a/arch/arm/src/qemu/Make.defs b/arch/arm/src/qemu/Make.defs
index c9c70790a5c..b24ca109b7c 100644
--- a/arch/arm/src/qemu/Make.defs
+++ b/arch/arm/src/qemu/Make.defs
@@ -28,6 +28,10 @@ ifeq ($(CONFIG_ARCH_ARMV7R),y)
 include armv7-r/Make.defs
 endif
 
+ifeq ($(CONFIG_ARCH_ARMV8R),y)
+include armv8-r/Make.defs
+endif
+
 # qemu-specific C source files
 CHIP_CSRCS  = qemu_boot.c qemu_serial.c qemu_irq.c qemu_timer.c
 
diff --git a/arch/arm/src/qemu/qemu_boot.c b/arch/arm/src/qemu/qemu_boot.c
index 9c2b70ff112..d96df0735d5 100644
--- a/arch/arm/src/qemu/qemu_boot.c
+++ b/arch/arm/src/qemu/qemu_boot.c
@@ -52,6 +52,10 @@
 #  include <nuttx/init.h>
 #endif
 
+#ifdef CONFIG_ARCH_ARMV8R
+#  include "sctlr.h"
+#endif
+
 /****************************************************************************
  * Pre-processor Definitions
  ****************************************************************************/
@@ -141,3 +145,25 @@ int up_cpu_start(int cpu)
   return psci_cpu_on(cpu, (uintptr_t)__start);
 }
 #endif
+
+#ifdef CONFIG_ARCH_ARMV8R
+/****************************************************************************
+ * Name: arm_el_init
+ *
+ * Description:
+ *   The function called from arm_head.S at very early stage to:
+ *   - Handling special hardware initialize routine which is need to
+ *     run at high ELs
+ *   - Initialize system software such as hypervisor or security firmware
+ *     which is need to run at high ELs
+ *
+ ****************************************************************************/
+
+void arm_el_init(void)
+{
+  CP15_SET(ICC_HSRE, ICC_SRE_ELX_SRE_BIT | ICC_SRE_ELX_DFB_BIT |
+                     ICC_SRE_ELX_DIB_BIT | ICC_SRE_EL3_EN_BIT);
+
+  UP_ISB();
+}
+#endif
diff --git a/arch/arm/src/qemu/qemu_timer.c b/arch/arm/src/qemu/qemu_timer.c
index 0f66fc0e719..9014bfaac54 100644
--- a/arch/arm/src/qemu/qemu_timer.c
+++ b/arch/arm/src/qemu/qemu_timer.c
@@ -24,8 +24,11 @@
  * Included Files
  ****************************************************************************/
 
-#include <nuttx/timers/arch_alarm.h>
+#include <nuttx/config.h>
+
+#ifndef CONFIG_ARCH_ARMV8R
 
+#include <nuttx/timers/arch_alarm.h>
 #include "arm_timer.h"
 
 /****************************************************************************
@@ -36,3 +39,5 @@ void up_timer_initialize(void)
 {
   up_alarm_set_lowerhalf(arm_timer_initialize(0));
 }
+
+#endif /* CONFIG_ARCH_ARMV8R */
\ No newline at end of file

Reply via email to