Developer Guide
Prerequisites
- Rust nightly (recommended:
nightly-2024-10-01or later) cargo install bootimage- QEMU (
qemu-system-x86_64)
Building and Running
- Clone the repository:
git clone https://github.com/daxo-developer/daxo_os cd daxo_os - Build the bootable image:
cargo bootimage - Run in QEMU:
(Usescargo run.cargo/config.tomlto pass QEMU arguments.) - To test:
(This runs the integration tests incargo testtests/.)
Repository Structure
src/– kernel sourcesrc/allocator/– heap allocatorssrc/task/– async executor and keyboard handlingtests/– integration tests (boot, heap, panic, stack overflow)verification/– Lean 4 formal proofsuser/– example user‑space programs (future)disk.bin– test disk image for ATA driverx86_64-daxo_os.json– target specification
Adding a New Driver
Create a new module in src/ (e.g., my_driver.rs). Implement a struct with methods for port I/O or MMIO. Register it in lib.rs.
Example: follow the ATA driver structure – use Port from x86_64::instructions::port, implement a polling loop, and use a Mutex for global access.
Adding a System Call
- Define a new syscall number in
src/syscall.rs. - Write the handler function (e.g.,
fn handle_syscall(rax: u64, ...)). - In the
syscallinterrupt handler, match onraxand call the corresponding function. - Update the user‑space code to invoke
syscallwith the new number.
Debugging
- Use
serial_println!to output to the host terminal (QEMU shows serial output). - Run QEMU with
-s -Sand attach GDB:gdb target/x86_64-daxo_os/debug/daxo_os (gdb) target remote :1234 - Enable QEMU’s internal logging with
-d cpu_reset,page,mmu.
Running Tests
Use cargo test. The test framework uses QemuExitCode to signal success/failure via the isa‑debug‑exit device.
To run a specific test: cargo test --test basic_boot.