A single-header C library that exposes QEMU's virtual hardware, SiFive machine layout, UART, and other emulated peripherals, to bare-metal bootloader and kernel code.
Before real silicon (or even an FPGA bitstream) is in the loop, QEMU stands in as the target platform. qemu_dev.h is the thin, dependency-free layer that lets a bootloader or kernel talk to QEMU's emulated devices without hand-rolling register offsets and memory maps every time. It's meant to be dropped straight into a freestanding bootloader/kernel build with #include "qemu_dev.h" - no build system, no linking, just one header.
- Memory-mapped register definitions and addresses for QEMU's SiFive-based RISC-V machine
- UART access (init, putchar/getchar-style primitives) for early boot console output
- Header-only, freestanding-friendly - no libc dependency, suitable for bootloader/early-kernel contexts
(More devices will be added as the bootloader and kernel grow - CLINT/PLIC, timers, virtio, etc. Contributions welcome.)
#include "qemu_dev.h"
void _start(void) {
uart_init();
uart_puts("hello from the bootloader\n");
// ...
}Build/run against QEMU's virt machine (RISC-V SiFive-based), e.g.:
qemu-system-riscv64 -machine virt -nographic -bios none -kernel your_bootloader.elfEarly stage and actively evolving alongside the bootloader/kernel it supports. Expect the API to shift as more of QEMU's virtual devices get wired in. Not much active development right now, but the project is very much alive - issues and PRs are welcome, and slow-but-steady progress continues.
Issues, PRs, and ideas are all welcome, especially around additional QEMU device support (CLINT/PLIC, virtio, timers).