]> Projects (at) Tadryanom (dot) Me - AdrOS.git/commit
feat: multi-arch ARM64/RISC-V bring-up with QEMU virt boot
authorTulio A M Mendes <[email protected]>
Sun, 15 Feb 2026 03:50:50 +0000 (00:50 -0300)
committerTulio A M Mendes <[email protected]>
Sun, 15 Feb 2026 03:50:50 +0000 (00:50 -0300)
commitcce0d2f5918806f9f6cb23a203280e1d047a9765
tree58a728357c0b261e322d6cfce33ebb88aff3dd07
parent517e5dca7b246886d1421baf5c70983879a4a494
feat: multi-arch ARM64/RISC-V bring-up with QEMU virt boot

ARM64 (AArch64):
- boot.S: EL2->EL1 transition, FP/SIMD enable (CPACR_EL1.FPEN),
  BSS zeroing, 16KB stack
- PL011 UART at 0x09000000 for serial console
- Linker script at 0x40000000 with proper section alignment
- Stubs for kernel subsystems not yet ported (PMM, VMM, scheduler,
  filesystem, syscalls, etc.)

RISC-V 64:
- boot.S: M-mode CSR init, BSS zeroing, 16KB stack
- NS16550 UART at 0x10000000 for serial console
- Linker script at 0x80000000 with proper section alignment
- Stubs matching ARM64 coverage

Build system:
- Makefile restructured: x86 gets full kernel/drivers/mm wildcards,
  ARM/RISC-V get minimal KERNEL_COMMON set (main, console, utils,
  cmdline, driver, cpu_features) + HAL + arch sources
- BOOT_OBJ now arch-specific (build/ARCH/arch/ARCH/boot.o)
- Added QEMU run targets: make run-arm, make run-riscv
- ARM64: -mno-outline-atomics to avoid libgcc atomic calls

Spinlock portability:
- Added AArch64 irq_save/irq_restore using DAIF register
- Simple volatile-flag spinlock for AArch64/RISC-V single-core
  bring-up (exclusive monitors need cacheable memory / MMU)

Key bug fix:
- AArch64 variadic functions (kprintf etc.) trap without FP/SIMD
  enabled — GCC saves q0-q7 in va_list register save area

Both architectures boot on QEMU virt and reach idle loop:
  make ARCH=arm && make run-arm
  make ARCH=riscv && make run-riscv

x86 unaffected: 35/35 smoke, 16/16 battery, cppcheck clean.
12 files changed:
Makefile
include/spinlock.h
src/arch/arm/arch_early_setup.c
src/arch/arm/boot.S
src/arch/arm/linker.ld
src/arch/arm/stubs.c [new file with mode: 0644]
src/arch/riscv/arch_early_setup.c
src/arch/riscv/boot.S
src/arch/riscv/linker.ld
src/arch/riscv/stubs.c [new file with mode: 0644]
src/hal/arm/usermode.c
src/hal/riscv/usermode.c