[PATCH v2] irq/arm-gicv3.h: Customize ICC_IGRPEN0/1 init

Sebastian Huber sebastian.huber at embedded-brains.de
Fri Jul 1 13:21:47 UTC 2022


Use the existing WRITE_SR() abstraction to access the interrupt group 0 and 1
enable registers.  This fixes the build for the AArch32 target.
---
 bsps/include/dev/irq/arm-gicv3.h              | 30 ++++++++-----------
 spec/build/bsps/aarch64/a53/grp.yml           |  2 ++
 spec/build/bsps/aarch64/a53/obj.yml           |  1 -
 spec/build/bsps/aarch64/a72/grp.yml           |  2 ++
 spec/build/bsps/aarch64/a72/obj.yml           |  1 -
 spec/build/bsps/aarch64/grp.yml               |  1 -
 spec/build/bsps/aarch64/xilinx-versal/grp.yml |  2 ++
 spec/build/bsps/aarch64/xilinx-versal/obj.yml |  1 -
 spec/build/bsps/arm/fvp/grp.yml               |  2 ++
 spec/build/bsps/arm/fvp/obj.yml               |  1 -
 spec/build/bsps/arm/grp.yml                   |  1 -
 spec/build/bsps/objarmgic.yml                 | 21 +++++++++++++
 spec/build/bsps/optarmgic-icc-igrpen0.yml     | 20 +++++++++++++
 spec/build/bsps/optarmgic-icc-igrpen1.yml     | 17 +++++++++++
 14 files changed, 78 insertions(+), 24 deletions(-)
 create mode 100644 spec/build/bsps/objarmgic.yml
 create mode 100644 spec/build/bsps/optarmgic-icc-igrpen0.yml
 create mode 100644 spec/build/bsps/optarmgic-icc-igrpen1.yml

diff --git a/bsps/include/dev/irq/arm-gicv3.h b/bsps/include/dev/irq/arm-gicv3.h
index a79368ebdf..4cd8cfaaed 100644
--- a/bsps/include/dev/irq/arm-gicv3.h
+++ b/bsps/include/dev/irq/arm-gicv3.h
@@ -116,9 +116,11 @@ extern "C" {
 #else /* ARM_MULTILIB_ARCH_V4 */
 
 /* AArch64 GICv3 registers are not named in GCC */
-#define ICC_IGRPEN0 "S3_0_C12_C12_6, %0"
-#define ICC_IGRPEN1 "S3_0_C12_C12_7, %0"
+#define ICC_IGRPEN0_EL1 "S3_0_C12_C12_6, %0"
+#define ICC_IGRPEN1_EL1 "S3_0_C12_C12_7, %0"
 #define ICC_IGRPEN1_EL3 "S3_6_C12_C12_7, %0"
+#define ICC_IGRPEN0 ICC_IGRPEN0_EL1
+#define ICC_IGRPEN1 ICC_IGRPEN1_EL1
 #define ICC_PMR     "S3_0_C4_C6_0, %0"
 #define ICC_EOIR1   "S3_0_C12_C12_1, %0"
 #define ICC_SRE     "S3_0_C12_C12_5, %0"
@@ -300,20 +302,6 @@ static void gicv3_init_dist(volatile gic_dist *dist)
   }
 }
 
-/*
- * A better way to access these registers than special opcodes
- */
-#define isb() __asm __volatile("isb" : : : "memory")
-
-#define  WRITE_SPECIALREG(reg, _val)                                    \
-  __asm __volatile("msr  " __STRING(reg) ", %0" : : "r"((uint64_t)_val))
-
-#define  gic_icc_write(reg, val)            \
-do {                                        \
-  WRITE_SPECIALREG(icc_ ##reg ##_el1, val); \
-  isb();                                    \
-} while (0)
-
 static void gicv3_init_cpu_interface(uint32_t cpu_index)
 {
   uint32_t sre_value = 0x7;
@@ -334,8 +322,14 @@ static void gicv3_init_cpu_interface(uint32_t cpu_index)
     sgi_ppi->icspiprior[id] = PRIORITY_DEFAULT;
   }
 
-  /* Enable interrupt groups 0 and 1 */
-  gic_icc_write(IGRPEN1, 1);
+  /* Initialize the group 0 and 1 interrupt enable */
+#ifdef BSP_ARM_GIC_ICC_IGRPEN0
+  WRITE_SR(ICC_IGRPEN0, BSP_ARM_GIC_ICC_IGRPEN0);
+#endif
+#ifdef BSP_ARM_GIC_ICC_IGRPEN1
+  WRITE_SR(ICC_IGRPEN1, BSP_ARM_GIC_ICC_IGRPEN1);
+#endif
+
   WRITE_SR(ICC_CTLR, 0x0);
 }
 
diff --git a/spec/build/bsps/aarch64/a53/grp.yml b/spec/build/bsps/aarch64/a53/grp.yml
index 091f18d6f5..2f23915a81 100644
--- a/spec/build/bsps/aarch64/a53/grp.yml
+++ b/spec/build/bsps/aarch64/a53/grp.yml
@@ -32,6 +32,8 @@ links:
   uid: ../../obj
 - role: build-dependency
   uid: ../../objirq
+- role: build-dependency
+  uid: ../../objarmgic
 - role: build-dependency
   uid: ../../objmem
 - role: build-dependency
diff --git a/spec/build/bsps/aarch64/a53/obj.yml b/spec/build/bsps/aarch64/a53/obj.yml
index 242631fba2..33c0884b85 100644
--- a/spec/build/bsps/aarch64/a53/obj.yml
+++ b/spec/build/bsps/aarch64/a53/obj.yml
@@ -26,7 +26,6 @@ source:
 - bsps/shared/dev/btimer/btimer-cpucounter.c
 - bsps/shared/dev/clock/arm-generic-timer.c
 - bsps/shared/dev/getentropy/getentropy-cpucounter.c
-- bsps/shared/dev/irq/arm-gicv3.c
 - bsps/shared/dev/serial/console-termios-init.c
 - bsps/shared/dev/serial/console-termios.c
 - bsps/shared/irq/irq-default-handler.c
diff --git a/spec/build/bsps/aarch64/a72/grp.yml b/spec/build/bsps/aarch64/a72/grp.yml
index 341f832a61..4cd4719a62 100644
--- a/spec/build/bsps/aarch64/a72/grp.yml
+++ b/spec/build/bsps/aarch64/a72/grp.yml
@@ -32,6 +32,8 @@ links:
   uid: ../../obj
 - role: build-dependency
   uid: ../../objirq
+- role: build-dependency
+  uid: ../../objarmgic
 - role: build-dependency
   uid: ../../objmem
 - role: build-dependency
diff --git a/spec/build/bsps/aarch64/a72/obj.yml b/spec/build/bsps/aarch64/a72/obj.yml
index f797762b41..4fb5e59ba3 100644
--- a/spec/build/bsps/aarch64/a72/obj.yml
+++ b/spec/build/bsps/aarch64/a72/obj.yml
@@ -26,7 +26,6 @@ source:
 - bsps/shared/dev/btimer/btimer-cpucounter.c
 - bsps/shared/dev/clock/arm-generic-timer.c
 - bsps/shared/dev/getentropy/getentropy-cpucounter.c
-- bsps/shared/dev/irq/arm-gicv3.c
 - bsps/shared/dev/serial/console-termios-init.c
 - bsps/shared/dev/serial/console-termios.c
 - bsps/shared/irq/irq-default-handler.c
diff --git a/spec/build/bsps/aarch64/grp.yml b/spec/build/bsps/aarch64/grp.yml
index ba4ec6c6cf..9428fb9435 100644
--- a/spec/build/bsps/aarch64/grp.yml
+++ b/spec/build/bsps/aarch64/grp.yml
@@ -22,7 +22,6 @@ install:
   - bsps/include/dev/irq/arm-gic-regs.h
   - bsps/include/dev/irq/arm-gic-tm27.h
   - bsps/include/dev/irq/arm-gic.h
-  - bsps/include/dev/irq/arm-gicv3.h
 - destination: ${BSP_LIBDIR}
   source:
   - bsps/aarch64/shared/start/linkcmds.base
diff --git a/spec/build/bsps/aarch64/xilinx-versal/grp.yml b/spec/build/bsps/aarch64/xilinx-versal/grp.yml
index 0f23e20950..1d1d303001 100644
--- a/spec/build/bsps/aarch64/xilinx-versal/grp.yml
+++ b/spec/build/bsps/aarch64/xilinx-versal/grp.yml
@@ -40,6 +40,8 @@ links:
   uid: ../../obj
 - role: build-dependency
   uid: ../../objirq
+- role: build-dependency
+  uid: ../../objarmgic
 - role: build-dependency
   uid: ../../objdevspizynq
 - role: build-dependency
diff --git a/spec/build/bsps/aarch64/xilinx-versal/obj.yml b/spec/build/bsps/aarch64/xilinx-versal/obj.yml
index d5748aca9a..04ac3761f9 100644
--- a/spec/build/bsps/aarch64/xilinx-versal/obj.yml
+++ b/spec/build/bsps/aarch64/xilinx-versal/obj.yml
@@ -33,7 +33,6 @@ source:
 - bsps/shared/dev/btimer/btimer-cpucounter.c
 - bsps/shared/dev/clock/arm-generic-timer.c
 - bsps/shared/dev/getentropy/getentropy-cpucounter.c
-- bsps/shared/dev/irq/arm-gicv3.c
 - bsps/shared/dev/serial/console-termios-init.c
 - bsps/shared/dev/serial/console-termios.c
 - bsps/shared/irq/irq-default-handler.c
diff --git a/spec/build/bsps/arm/fvp/grp.yml b/spec/build/bsps/arm/fvp/grp.yml
index 8de7d10917..dc74fba60c 100644
--- a/spec/build/bsps/arm/fvp/grp.yml
+++ b/spec/build/bsps/arm/fvp/grp.yml
@@ -24,6 +24,8 @@ links:
   uid: ../../obj
 - role: build-dependency
   uid: ../../objirq
+- role: build-dependency
+  uid: ../../objarmgic
 - role: build-dependency
   uid: ../../objmem
 - role: build-dependency
diff --git a/spec/build/bsps/arm/fvp/obj.yml b/spec/build/bsps/arm/fvp/obj.yml
index 3db46c6ccc..05fa6dc368 100644
--- a/spec/build/bsps/arm/fvp/obj.yml
+++ b/spec/build/bsps/arm/fvp/obj.yml
@@ -34,7 +34,6 @@ source:
 - bsps/shared/dev/btimer/btimer-cpucounter.c
 - bsps/shared/dev/clock/arm-generic-timer.c
 - bsps/shared/dev/getentropy/getentropy-cpucounter.c
-- bsps/shared/dev/irq/arm-gicv3.c
 - bsps/shared/dev/serial/console-termios.c
 - bsps/shared/irq/irq-default-handler.c
 - bsps/shared/start/bspfatal-default.c
diff --git a/spec/build/bsps/arm/grp.yml b/spec/build/bsps/arm/grp.yml
index bb51734b3c..37229fddc2 100644
--- a/spec/build/bsps/arm/grp.yml
+++ b/spec/build/bsps/arm/grp.yml
@@ -46,7 +46,6 @@ install:
   - bsps/include/dev/irq/arm-gic-regs.h
   - bsps/include/dev/irq/arm-gic-tm27.h
   - bsps/include/dev/irq/arm-gic.h
-  - bsps/include/dev/irq/arm-gicv3.h
 - destination: ${BSP_INCLUDEDIR}/libcpu
   source:
   - bsps/arm/include/libcpu/am335x.h
diff --git a/spec/build/bsps/objarmgic.yml b/spec/build/bsps/objarmgic.yml
new file mode 100644
index 0000000000..30c46f2317
--- /dev/null
+++ b/spec/build/bsps/objarmgic.yml
@@ -0,0 +1,21 @@
+SPDX-License-Identifier: CC-BY-SA-4.0 OR BSD-2-Clause
+build-type: objects
+cflags: []
+copyrights:
+- Copyright (C) 2022 embedded brains GmbH (http://www.embedded-brains.de)
+cppflags: []
+cxxflags: []
+enabled-by: true
+includes: []
+install:
+- destination: ${BSP_INCLUDEDIR}/dev/irq
+  source:
+  - bsps/include/dev/irq/arm-gicv3.h
+links:
+- role: build-dependency
+  uid: optarmgic-icc-igrpen0
+- role: build-dependency
+  uid: optarmgic-icc-igrpen1
+source:
+- bsps/shared/dev/irq/arm-gicv3.c
+type: build
diff --git a/spec/build/bsps/optarmgic-icc-igrpen0.yml b/spec/build/bsps/optarmgic-icc-igrpen0.yml
new file mode 100644
index 0000000000..5acd37617d
--- /dev/null
+++ b/spec/build/bsps/optarmgic-icc-igrpen0.yml
@@ -0,0 +1,20 @@
+SPDX-License-Identifier: CC-BY-SA-4.0 OR BSD-2-Clause
+actions:
+- get-integer: null
+- define: null
+build-type: option
+copyrights:
+- Copyright (C) 2022 embedded brains GmbH (http://www.embedded-brains.de)
+default: 1
+default-by-variant:
+- value: null
+  variants:
+  - aarch64
+description: |
+  Optionally, defines the initial value of the ICC_IGRPEN0 register of the ARM
+  GIC CPU Interface.
+enabled-by: true
+format: '{:#010x}'
+links: []
+name: BSP_ARM_GIC_ICC_IGRPEN0
+type: build
diff --git a/spec/build/bsps/optarmgic-icc-igrpen1.yml b/spec/build/bsps/optarmgic-icc-igrpen1.yml
new file mode 100644
index 0000000000..a3910bfc16
--- /dev/null
+++ b/spec/build/bsps/optarmgic-icc-igrpen1.yml
@@ -0,0 +1,17 @@
+SPDX-License-Identifier: CC-BY-SA-4.0 OR BSD-2-Clause
+actions:
+- get-integer: null
+- define: null
+build-type: option
+copyrights:
+- Copyright (C) 2022 embedded brains GmbH (http://www.embedded-brains.de)
+default: 1
+default-by-variant: []
+description: |
+  Optionally, defines the initial value of the ICC_IGRPEN1 register of the ARM
+  GIC CPU Interface.
+enabled-by: true
+format: '{:#010x}'
+links: []
+name: BSP_ARM_GIC_ICC_IGRPEN1
+type: build
-- 
2.35.3



More information about the devel mailing list