linguini1 commented on code in PR #18861:
URL: https://github.com/apache/nuttx/pull/18861#discussion_r3214683800
##########
arch/arm64/src/bcm2711/bcm2711_boot.c:
##########
@@ -124,7 +132,44 @@ int arm64_get_cpuid(uint64_t mpid)
void arm64_el_init(void)
{
- /* TODO: what goes here? */
+ /* According to the bcm2711.dtsi file in the Linux source tree [1], the
+ * CPUs on the BCM2711 use a spin-table enable method and poll the
+ * following addresses:
+ *
+ * CPU0: 0x000000d8 (BCM_MBOX_CLR06)
+ * CPU1: 0x000000e0 (BCM_MBOX_CLR08)
+ * CPU2: 0x000000e8 (BCM_MBOX_CLR10)
+ * CPU3: 0x000000f0 (BCM_MBOX_CLR12)
+ *
+ * Some kernel docs about booting [2] have a handy explanation of how this
+ * works:
+ *
+ * "polling their cpu-release-addr location, which must be contained in the
+ * reserved region ... when a read of the location pointed to by the
+ * cpu-release-addr returns a non-zero value, the CPU must jump to this
+ * value" [2]
+ *
+ * In our case, we want these CPUs to load the NuttX kernel defined by
+ * `_start`. We don't need to worry about CPU0, that one always starts.
+ * These are 64-bit words (hence skipping every second register).
+ *
+ * [1] https://github.com/raspberrypi/linux/blob/rpi-6.12.y/
+ * arch/arm/boot/dts/broadcom/bcm2711.dtsi
+ *
+ * [2] https://www.kernel.org/doc/Documentation/arm64/booting.txt
+ */
+
+#ifdef CONFIG_SMP
+
+ for (uint8_t cpu = 0; cpu < CONFIG_SMP_NCPUS; cpu++)
+ {
+ putreg64((uint64_t)_start, BCM_SPINTBL_CPU(cpu));
Review Comment:
@xiaoxiang781216 has Xiaomi ever used a device with spin tables for SMP?
Could you inform me if this is a good approach, or if there is a better
starting location to jump to after CPU0 has initialized memory and subsystems?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]