<meta http-equiv="Content-Type" content="text/html; charset=utf-8"><div dir="ltr"><div>Looks good, thanks!</div><div><br></div><div>Kinsey<br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Apr 16, 2024 at 5:20 AM Ning Yang <<a href="mailto:yangn0@qq.com">yangn0@qq.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">The clock from the ARM timer is derived from the system clock. This clock can <br>
change dynamically e.g. if the system goes into reduced power or in low power <br>
mode. Thus the clock speed adapts to the overall system performance <br>
capabilities. For accurate timing it is recommended to use the system timers.<br>
<br>
if BSP_CLOCK_USE_SYSTEMTIMER = 1, use the System Timer, otherwise use the ARM <br>
Timer.<br>
---<br>
 bsps/aarch64/raspberrypi/include/bsp/irq.h    | 14 ++++++---<br>
 .../raspberrypi/include/bsp/raspberrypi.h     |  9 ++++++<br>
 spec/build/bsps/aarch64/grp.yml               |  3 --<br>
 .../aarch64/raspberrypi/bspraspberrypi4.yml   |  6 ++--<br>
 .../bsps/aarch64/raspberrypi/objclock.yml     | 31 +++++++++++++++++++<br>
 .../aarch64/raspberrypi/objsystemtimer.yml    | 23 ++++++++++++++<br>
 .../aarch64/raspberrypi/optsystemtimer.yml    | 24 ++++++++++++++<br>
 7 files changed, 100 insertions(+), 10 deletions(-)<br>
 create mode 100644 spec/build/bsps/aarch64/raspberrypi/objclock.yml<br>
 create mode 100644 spec/build/bsps/aarch64/raspberrypi/objsystemtimer.yml<br>
 create mode 100644 spec/build/bsps/aarch64/raspberrypi/optsystemtimer.yml<br>
<br>
diff --git a/bsps/aarch64/raspberrypi/include/bsp/irq.h <br>
b/bsps/aarch64/raspberrypi/include/bsp/irq.h<br>
index 1ff6ae80de..d493e83707 100644<br>
--- a/bsps/aarch64/raspberrypi/include/bsp/irq.h<br>
+++ b/bsps/aarch64/raspberrypi/include/bsp/irq.h<br>
@@ -9,6 +9,7 @@<br>
 /**<br>
  * Copyright (c) 2013 Alan Cudmore<br>
  * Copyright (c) 2022 Mohd Noor Aman<br>
+ * Copyright (c) 2024 Ning Yang<br>
  *<br>
  *  The license and distribution terms for this file may be<br>
  *  found in the file LICENSE in this distribution or at<br>
@@ -33,15 +34,18 @@<br>
  * @brief Interrupt support.<br>
  */<br>
<br>
-#define BCM2835_INTC_TOTAL_IRQ       (64 + 8)<br>
+#define BCM2835_INTC_TOTAL_IRQ       216<br>
<br>
 #define BCM2835_IRQ_SET1_MIN         0<br>
 #define BCM2835_IRQ_SET2_MIN         32<br>
<br>
-#define BCM2835_IRQ_ID_GPU_TIMER_M0  0<br>
-#define BCM2835_IRQ_ID_GPU_TIMER_M1  1<br>
-#define BCM2835_IRQ_ID_GPU_TIMER_M2  2<br>
-#define BCM2835_IRQ_ID_GPU_TIMER_M3  3<br>
+#define BCM2711_IRQ_VC_PERIPHERAL_BASE 96<br>
+<br>
+/* Interrupt Vectors: System Timer */<br>
+#define BCM2835_IRQ_ID_GPU_TIMER_M0    (BCM2711_IRQ_VC_PERIPHERAL_BASE + 0)<br>
+#define BCM2835_IRQ_ID_GPU_TIMER_M1    (BCM2711_IRQ_VC_PERIPHERAL_BASE + 1)<br>
+#define BCM2835_IRQ_ID_GPU_TIMER_M2    (BCM2711_IRQ_VC_PERIPHERAL_BASE + 2)<br>
+#define BCM2835_IRQ_ID_GPU_TIMER_M3    (BCM2711_IRQ_VC_PERIPHERAL_BASE + 3)<br>
<br>
 #define BCM2835_IRQ_ID_USB           9<br>
 #define BCM2835_IRQ_ID_AUX           29<br>
diff --git a/bsps/aarch64/raspberrypi/include/bsp/raspberrypi.h <br>
b/bsps/aarch64/raspberrypi/include/bsp/raspberrypi.h<br>
index 55dd9ed1e9..f185d1df57 100644<br>
--- a/bsps/aarch64/raspberrypi/include/bsp/raspberrypi.h<br>
+++ b/bsps/aarch64/raspberrypi/include/bsp/raspberrypi.h<br>
@@ -8,6 +8,7 @@<br>
<br>
 /*<br>
  *  Copyright (c) 2022 Mohd Noor Aman<br>
+ *  Copyright (c) 2024 Ning Yang<br>
  *<br>
  *  The license and distribution terms for this file may be<br>
  *  found in the file LICENSE in this distribution or at<br>
@@ -44,6 +45,7 @@<br>
<br>
 #define BCM2711_REG(x)           (*(volatile uint64_t *)(x))<br>
 #define BCM2711_BIT(n)           (1 << (n))<br>
+#define BCM2835_REG(addr)        (*(volatile uint32_t*)(addr))<br>
<br>
 /** @} */<br>
<br>
@@ -198,6 +200,13 @@<br>
 #define BCM2711_GPU_TIMER_C2         (BCM2711_GPU_TIMER_BASE + 0x14)<br>
 #define BCM2711_GPU_TIMER_C3         (BCM2711_GPU_TIMER_BASE + 0x18)<br>
<br>
+/**<br>
+ * NOTE: compatible with the BCM2835 system timer<br>
+ */<br>
+#define BCM2835_GPU_TIMER_CS_M3      BCM2711_GPU_TIMER_CS_M3<br>
+#define BCM2835_GPU_TIMER_C3         BCM2711_GPU_TIMER_C3<br>
+#define BCM2835_GPU_TIMER_CLO        BCM2711_GPU_TIMER_CLO<br>
+#define BCM2835_GPU_TIMER_CS         BCM2711_GPU_TIMER_CS<br>
 /** @} */<br>
<br>
 /**<br>
diff --git a/spec/build/bsps/aarch64/grp.yml b/spec/build/bsps/aarch64/grp.yml<br>
index 9428fb9435..8f40a9952e 100644<br>
--- a/spec/build/bsps/aarch64/grp.yml<br>
+++ b/spec/build/bsps/aarch64/grp.yml<br>
@@ -12,9 +12,6 @@ install:<br>
   source:<br>
   - bsps/aarch64/include/bsp/linker-symbols.h<br>
   - bsps/aarch64/include/bsp/start.h<br>
-- destination: ${BSP_INCLUDEDIR}/dev/clock<br>
-  source:<br>
-  - bsps/include/dev/clock/arm-generic-timer.h<br>
 - destination: ${BSP_INCLUDEDIR}/dev/irq<br>
   source:<br>
   - bsps/aarch64/include/dev/irq/arm-gic-arch.h<br>
diff --git a/spec/build/bsps/aarch64/raspberrypi/bspraspberrypi4.yml <br>
b/spec/build/bsps/aarch64/raspberrypi/bspraspberrypi4.yml<br>
index a579c094ba..7b6511a8cc 100644<br>
--- a/spec/build/bsps/aarch64/raspberrypi/bspraspberrypi4.yml<br>
+++ b/spec/build/bsps/aarch64/raspberrypi/bspraspberrypi4.yml<br>
@@ -19,6 +19,10 @@ install:<br>
   - bsps/aarch64/raspberrypi/include/bsp/irq.h<br>
   - bsps/aarch64/raspberrypi/include/bsp/raspberrypi.h<br>
 links:<br>
+- role: build-dependency<br>
+  uid: objclock<br>
+- role: build-dependency<br>
+  uid: objsystemtimer<br>
 - role: build-dependency<br>
   uid: ../grp<br>
 - role: build-dependency<br>
@@ -50,10 +54,8 @@ source:<br>
 - bsps/aarch64/raspberrypi/start/bspstart.c<br>
 - bsps/aarch64/raspberrypi/start/bspstarthooks.c<br>
 - bsps/aarch64/raspberrypi/start/bspstartmmu.c<br>
-- bsps/aarch64/shared/clock/arm-generic-timer-aarch64.c<br>
 - bsps/aarch64/shared/cache/cache.c<br>
 - bsps/aarch64/shared/mmu/vmsav8-64.c<br>
-- bsps/shared/dev/clock/arm-generic-timer.c<br>
 - bsps/shared/dev/irq/arm-gicv2.c<br>
 - bsps/shared/dev/irq/arm-gicv2-get-attributes.c<br>
 - bsps/shared/dev/serial/console-termios-init.c<br>
diff --git a/spec/build/bsps/aarch64/raspberrypi/objclock.yml <br>
b/spec/build/bsps/aarch64/raspberrypi/objclock.yml<br>
new file mode 100644<br>
index 0000000000..c4a8227bc9<br>
--- /dev/null<br>
+++ b/spec/build/bsps/aarch64/raspberrypi/objclock.yml<br>
@@ -0,0 +1,31 @@<br>
+SPDX-License-Identifier: CC-BY-SA-4.0 OR BSD-2-Clause<br>
+copyrights:<br>
+  - Copyright (C) 2022 Mohd Noor Aman<br>
+  - Copyright (C) 2023 Utkarsh Verma<br>
+  - Copyright (C) 2024 Ning Yang<br>
+<br>
+type: build<br>
+enabled-by:<br>
+  not: BSP_CLOCK_USE_SYSTEMTIMER<br>
+<br>
+build-type: objects<br>
+cflags: []<br>
+cppflags: []<br>
+cxxflags: []<br>
+includes: []<br>
+install:<br>
+- destination: ${BSP_INCLUDEDIR}/dev/clock<br>
+  source:<br>
+  - bsps/include/dev/clock/arm-generic-timer.h<br>
+<br>
+source:<br>
+  - bsps/aarch64/shared/clock/arm-generic-timer-aarch64.c<br>
+  - bsps/shared/dev/clock/arm-generic-timer.c<br>
+<br>
+links:<br>
+  - role: build-dependency<br>
+    uid: ../optgtusevirt<br>
+  - role: build-dependency<br>
+    uid: ../optgtuseps<br>
+  - role: build-dependency<br>
+    uid: optsystemtimer<br>
\ No newline at end of file<br>
diff --git a/spec/build/bsps/aarch64/raspberrypi/objsystemtimer.yml <br>
b/spec/build/bsps/aarch64/raspberrypi/objsystemtimer.yml<br>
new file mode 100644<br>
index 0000000000..8a91a0555a<br>
--- /dev/null<br>
+++ b/spec/build/bsps/aarch64/raspberrypi/objsystemtimer.yml<br>
@@ -0,0 +1,23 @@<br>
+SPDX-License-Identifier: CC-BY-SA-4.0 OR BSD-2-Clause<br>
+copyrights:<br>
+  - Copyright (C) 2024 Ning Yang<br>
+<br>
+type: build<br>
+enabled-by:<br>
+- BSP_CLOCK_USE_SYSTEMTIMER<br>
+<br>
+build-type: objects<br>
+cflags: []<br>
+cppflags: []<br>
+cxxflags: []<br>
+includes: []<br>
+install: []<br>
+<br>
+source:<br>
+  - bsps/shared/dev/clock/bcm2835-system-timer.c<br>
+  - bsps/shared/dev/cpucounter/cpucounterfrequency.c<br>
+  - bsps/shared/dev/cpucounter/cpucounterread.c<br>
+<br>
+links:<br>
+  - role: build-dependency<br>
+    uid: optsystemtimer<br>
\ No newline at end of file<br>
diff --git a/spec/build/bsps/aarch64/raspberrypi/optsystemtimer.yml <br>
b/spec/build/bsps/aarch64/raspberrypi/optsystemtimer.yml<br>
new file mode 100644<br>
index 0000000000..1cceebf22b<br>
--- /dev/null<br>
+++ b/spec/build/bsps/aarch64/raspberrypi/optsystemtimer.yml<br>
@@ -0,0 +1,24 @@<br>
+SPDX-License-Identifier: CC-BY-SA-4.0 OR BSD-2-Clause<br>
+copyrights:<br>
+  - Copyright (C) 2024 Ning Yang<br>
+<br>
+type: build<br>
+build-type: option<br>
+<br>
+enabled-by: true<br>
+name: BSP_CLOCK_USE_SYSTEMTIMER<br>
+description: |<br>
+  The clock from the ARM timer is derived from the system clock. This clock <br>
can change dynamically e.g. if the system<br>
+  goes into reduced power or in low power mode. Thus the clock speed adapts <br>
to the overall system performance<br>
+  capabilities. For accurate timing it is recommended to use the system <br>
timers.<br>
+<br>
+actions:<br>
+  - get-boolean: null<br>
+  - define-condition: null<br>
+  - env-enable: null<br>
+default:<br>
+  - enabled-by:<br>
+    - aarch64/raspberrypi4b<br>
+    value: false<br>
+<br>
+links: []<br>
\ No newline at end of file<br>
-- <br>
2.34.1<br>
<br>
<br>
<br>
_______________________________________________<br>
devel mailing list<br>
<a href="mailto:devel@rtems.org" target="_blank">devel@rtems.org</a><br>
<a href="http://lists.rtems.org/mailman/listinfo/devel" rel="noreferrer" target="_blank">http://lists.rtems.org/mailman/listinfo/devel</a><br>
</blockquote></div>