From https://github.com/s-matyukevich/raspberry-pi-os/blob/master/docs/lesson01/rpi-os.md I found such a statement:
The Raspberry Pi 3 has four core processors, and after the device is powered on, each core begins to
execute the same code.
This means that once control is taken over the kernel, all 4 cores starts executing it as they all would be primary CPUs, is this correct?
I fuond Booting ARM Cortex-A secondary cores with Linux, but I have no idea what kind of boot_reg
they're talking about
Do you know any documentation which documents booting procedure for primary/secondary CPUs for ARMv8 (aarch64) overall and especially for RPi4 (BCM2711)? Thank you in advance!
How to boot secondary CPUs in Cortex-A72 processor?
P.S.: Those how wants to close the question, don't you want to specify the reason in comments, so I will be able to modify the question and add more details if you need?
That's correct, all cores start executing the same code. Since normally you want them to do different things eventually, you're expected to write that common code such that it causes the core to fetch its own ID number (from the mpidr_el1
system register) and do whatever is appropriate for that core.
The code you've linked is a simple toy example, in which only core #0 goes on to do anything interesting (print the hello message). The others branch to proc_hang
which is an infinite loop, so they never do anything except waste electricity. We can just ignore them from there on, as if they didn't even exist.
For a real multiprocessor operating system, you'd want the other cores to eventually do something useful. Typically you have core #0 do some necessary initialization, and send the others into a loop where they wait (preferably in a lower-power state) to be notified to wake up by core #0. The inter-processor communication mechanisms for doing this exist outside of the CPU cores themselves, as part of the peripheral hardware of the SoC or board platform, so you won't find them discussed in the Cortex A-72 documentation.
The boot_reg
discussed at Booting ARM Cortex-A secondary cores with Linux is specific to a platform called Versatile Express. It doesn't exist on the Broadcom chips used by Raspberry Pi (e.g. BCM2711 for the Pi 4) but they have a similar feature called "mailboxes" that allows one core to cause an interrupt on another core. See Chapter 13 of the BCM2711 datasheet for more.