Booting Raspberry Pi 3: Difference between revisions

m
[unchecked revision][unchecked revision]
(switched pre to source)
Line 100:
 
_start:
mrs x0x4, mpidr_el1
and x0x4, x0x4, #3
cbz x0x4, _init
0: wfe
b 0b
</source>
 
The mrs instruction loads data from specialty registers into a standard register. This special register in question is called the MPIDR or the Multiprocessor Affinity Register. Caring only about the first two bits only we use a bitwise and to weed out any core ID's that aren't zero. Then we apply the cbz instruction, which is a shorthand instruction for comparing the x0x4 register with 0 and branching if they are equal, i.e. core 0.
 
If the core ID is 0, we branch to another section that will initialize the environment and will hand control over to the kernel. For now, the C function for our kernel will simply by kern_main.
 
<source lang="asm">
_init: ldr x4, =_start
mov sp, x4
b kern_main
</source>
 
Note that with the latest firmware, this is not necessary, as only the primary core runs. It is enough to set up stack and branch to kern_main.
 
<source lang="asm">
// for latest firmware, after 2020-01-01
.section .boot
 
.global _start
 
_start: ldr x4, =_start
mov sp, x4
b kern_main
</source>
Anonymous user