<meta http-equiv="Content-Type" content="text/html; charset=utf-8"><div dir="ltr"><div>A couple of comments inline below.</div><div><br></div><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, Apr 12, 2024 at 9:33 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 change dynamically e.g. if the system goes into reduced power or in low power mode. Thus the clock speed adapts to the overall system performance 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 Timer.<br>
---<br>
bsps/aarch64/raspberrypi/include/bsp/irq.h | 15 ++++++---<br>
.../raspberrypi/include/bsp/raspberrypi.h | 28 +++++++++--------<br>
spec/build/bsps/aarch64/grp.yml | 3 --<br>
.../aarch64/raspberrypi/bspraspberrypi4.yml | 7 +++--<br>
.../bsps/aarch64/raspberrypi/objclock.yml | 31 +++++++++++++++++++<br>
.../aarch64/raspberrypi/objsystemtimer.yml | 23 ++++++++++++++<br>
.../aarch64/raspberrypi/optsystemtimer.yml | 24 ++++++++++++++<br>
7 files changed, 107 insertions(+), 24 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 b/bsps/aarch64/raspberrypi/include/bsp/irq.h<br>
index 1ff6ae80de..f2dd2f6c14 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>
@@ -24,6 +25,7 @@<br>
<br>
#include <rtems.h><br>
#include <dev/irq/arm-gic-irq.h><br>
+#include <rtems/irq.h><br>
<br>
/**<br>
* @defgroup raspberrypi_interrupt Interrrupt Support<br>
@@ -33,15 +35,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 b/bsps/aarch64/raspberrypi/include/bsp/raspberrypi.h<br>
index 55dd9ed1e9..3d6a03c715 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>
@@ -184,19 +186,19 @@<br>
* it's own RTOS. 1 and 3 are available for use in<br>
* RTEMS.<br>
*/<br>
-#define BCM2711_GPU_TIMER_BASE (RPI_PERIPHERAL_BASE + 0x3000)<br>
-<br>
-#define BCM2711_GPU_TIMER_CS (BCM2711_GPU_TIMER_BASE + 0x00)<br>
-#define BCM2711_GPU_TIMER_CS_M0 0x00000001<br>
-#define BCM2711_GPU_TIMER_CS_M1 0x00000002<br>
-#define BCM2711_GPU_TIMER_CS_M2 0x00000004<br>
-#define BCM2711_GPU_TIMER_CS_M3 0x00000008<br>
-#define BCM2711_GPU_TIMER_CLO (BCM2711_GPU_TIMER_BASE + 0x04)<br>
-#define BCM2711_GPU_TIMER_CHI (BCM2711_GPU_TIMER_BASE + 0x08)<br>
-#define BCM2711_GPU_TIMER_C0 (BCM2711_GPU_TIMER_BASE + 0x0C)<br>
-#define BCM2711_GPU_TIMER_C1 (BCM2711_GPU_TIMER_BASE + 0x10)<br>
-#define BCM2711_GPU_TIMER_C2 (BCM2711_GPU_TIMER_BASE + 0x14)<br>
-#define BCM2711_GPU_TIMER_C3 (BCM2711_GPU_TIMER_BASE + 0x18)<br>
+#define BCM2835_GPU_TIMER_BASE (RPI_PERIPHERAL_BASE + 0x3000)<br>
+<br>
+#define BCM2835_GPU_TIMER_CS (BCM2835_GPU_TIMER_BASE + 0x00)<br>
+#define BCM2835_GPU_TIMER_CS_M0 0x00000001<br>
+#define BCM2835_GPU_TIMER_CS_M1 0x00000002<br>
+#define BCM2835_GPU_TIMER_CS_M2 0x00000004<br>
+#define BCM2835_GPU_TIMER_CS_M3 0x00000008<br>
+#define BCM2835_GPU_TIMER_CLO (BCM2835_GPU_TIMER_BASE + 0x04)<br>
+#define BCM2835_GPU_TIMER_CHI (BCM2835_GPU_TIMER_BASE + 0x08)<br>
+#define BCM2835_GPU_TIMER_C0 (BCM2835_GPU_TIMER_BASE + 0x0C)<br>
+#define BCM2835_GPU_TIMER_C1 (BCM2835_GPU_TIMER_BASE + 0x10)<br>
+#define BCM2835_GPU_TIMER_C2 (BCM2835_GPU_TIMER_BASE + 0x14)<br>
+#define BCM2835_GPU_TIMER_C3 (BCM2835_GPU_TIMER_BASE + 0x18)<br></blockquote><div><br></div><div>Instead of renaming these to the old chip identifier, it would be better to redefine the ones you need as an alias to the BCM2711 defines with an explicit note that it's for compatibility with the system timer driver. Specifically, it looks like you need BCM2835_GPU_TIMER_CS_M3, BCM2835_GPU_TIMER_C3, BCM2835_GPU_TIMER_CLO, and BCM2835_GPU_TIMER_CS.</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<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 b/spec/build/bsps/aarch64/raspberrypi/bspraspberrypi4.yml<br>
index a579c094ba..53677c85d5 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,16 +54,13 @@ 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>
- bsps/shared/dev/serial/console-termios.c<br>
- bsps/shared/dev/serial/arm-pl011.c<br>
-- bsps/shared/dev/getentropy/getentropy-cpucounter.c<br></blockquote><div><br></div><div><div>The removal of
bsps/shared/dev/getentropy/getentropy-cpucounter.c from the build causes
a build failure for getentropy01 when using either timer. <span class="gmail-im">Make sure you are building with tests enabled.</span></div></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
- bsps/shared/dev/btimer/btimer-cpucounter.c<br>
- bsps/shared/irq/irq-default-handler.c<br>
- bsps/shared/start/bspfatal-default.c<br>
diff --git a/spec/build/bsps/aarch64/raspberrypi/objclock.yml 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 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 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 can change dynamically e.g. if the system<br>
+ goes into reduced power or in low power 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>
+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>
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></div>