lowczarc/arm-kernel
💾 An ARM kernel in Zig.
The goal is to write a simple ARM kernel for Raspberry (only Pi 2 for now but it won't be too hard to port) in Zig. I want to understand how my computer work and I like learning by doing. This is not and will never be intended for any kind of production environment.
[x] Boot [x] UART Read/Write [x] Kernel/Userspace memory separation [x] "device file" model [x] open, read, write, close syscalls (on char devices only) [x] brk syscall, malloc/free in userspace [x] Framebuffer Read/Write [x] Virtual TTY with a home-made font :) [ ] Keyboard [ ] File system [x] Multiple processes running at the same time, context switching [ ] Non system-blocking syscalls [ ] Pipe [ ] Userspace shell ... Maybe more, don't know yet
You need to have the bare-metal ARM cross-assembly/link tools install On Archlinux it's extra/arm-none-eabi-binutils
As well as the zig compiler and qemu if you want to test it on your machine.
You can build the kernel with: make
This will build the kernel to an ./init.bin file
To launch it in qemu: make qemu-screen
This project is licensed under the "THE GAME LICENSE"
https://developer.arm.com/documentation/ddi0595/2021-12/AArch32-Registers
@AsahiLina's explanation of CVE-2022-32947 is a very entertaining way to understand page tables https://www.youtube.com/watch?v=hDek2cp0dmI
BROADCOM BCM2837 ARM Peripherals datasheet
https://linux-kernel-labs.github.io/refs/heads/master/index.html