ARM64 Target (Raspberry Pi 3 / QEMU)
The arm64 target compiles Yog programs to AArch64 machine code for Raspberry Pi 3 and QEMU.
Entry Point
ARM64 programs define a single main() function. The bootstrap sets up the stack pointer and calls it. If main() returns, the CPU halts.
function main(): void {
uart_init();
uart_print("Hello, World!\n");
}Compile
yogc examples/arm64-hello/main.yog kernel8.img
# or explicitly:
yogc --target arm64 examples/arm64-hello/main.yog kernel8.imgarm64 is the default target, so --target is optional.
Run in QEMU
Install QEMU:
brew install qemu # macOS
sudo apt install qemu-system-aarch64 # Ubuntu/DebianBoot:
qemu-system-aarch64 -M raspi3b -kernel kernel8.img -serial stdio -display noneExpected output:
Hello, World!Press Ctrl-A X to quit QEMU.
Run on Real Hardware (Raspberry Pi 3)
Format an SD card as FAT32.
Download the Raspberry Pi firmware:
bootcode.bin,start.elf,fixup.dat.Copy those files plus your
kernel8.imgto the SD card root.Create
config.txtwith:inienable_uart=1 arm_64bit=1Insert the SD card, connect a USB-serial adapter to GPIO pins 14/15, and power on.
Open a terminal at 115200 baud to see output.
Hardware Details
| Property | Value |
|---|---|
| CPU | ARM Cortex-A53 (AArch64) |
| Load address | 0x80000 |
| UART | PL011 at 0x3F201000 |
| Baud rate | 115200 (48 MHz ref clock) |
Boot Sequence
The VideoCore GPU reads kernel8.img from the SD card and loads it at 0x80000. Execution starts at the very first instruction (the bootstrap stub). The stub:
- Reads
MPIDR_EL1to get the core ID. - Parks cores 1–3 in a
WFEloop. - Sets
SP = 0x80000(stack grows down from the load address). - Calls
main(). - Hangs if
main()returns.
Intrinsics Available
| Call | Description |
|---|---|
uart_init() | Initialise PL011 UART at 115200 baud |
uart_print("...") | Write a string literal to UART |
Memory.read32(addr) | Load a 32-bit MMIO register |
Memory.write32(addr, val) | Store a 32-bit MMIO register |