How 0bvdnt/obv-os works
Project type and purpose
• obv-OS is a minimal, educational, monolithic RISC-V operating system.
• Each folder under learning-basics/ is a self-contained module demonstrating one OS concept (kernel entry, console output, memory management, exception handling, context switching, scheduler).
File structure
• Top level:
• .gitignore, README.md
• learning-basics/: contains one directory per learning module
• Module directory (e.g. memory-allocation/):
• kernel.c, common.c, common.h, kernel.h – C source and headers
• kernel.ld – linker script
• opensbi-riscv32-generic-fw_dynamic.bin – OpenSBI firmware
• run.sh – build & QEMU launch script
• README.md – module description
• No separate “frontend/backend” – it's a bare-metal, single-executable kernel.
README for additional insights
• The root README enumerates modules and prerequisites (RISC-V toolchain, QEMU, OpenSBI).
• Emphasis on incremental layering: simple kernel → I/O → memory → exceptions → multitasking.
• A tree with 3 levels:
− Root
└ learning-basics
├ implementing-simple-kernel
├ output-from-the-kernel
├ memory-allocation
├ exception-handling
├ process-control-and-context-switching
└ process-scheduler-and-exception-handler
• Within each module, list key files (.c/.h, .ld, firmware, run script).
1. Host Machine (build environment)
– RISC-V Toolchain
– llvm-nm / objdump
2. Emulator Layer
– QEMU virt
– OpenSBI firmware
3. Kernel Image
– Entry & startup (implemented in kernel.c & kernel.ld)
• Console I/O (functions: putchar(), printf(), SBI calls)
• Memory Manager (bump allocator: alloc_pages(), free_pages())
• Exception Handler (trap vector setup, trap_frame struct, panic())
• Process Control (PCB struct, context (registers) struct)
• Scheduler (switch_context(), round-robin logic)
4. Data flows
– Build scripts → compilers → link via kernel.ld → QEMU loads OpenSBI + kernel
– Kernel ↔ SBI → Console
– Kernel ↔ physical memory (via page allocator)
– Kernel ↔ CPU (traps & context switches)
• PCB
– Fields: register array, stack pointer, state
• trap_frame
– Fields: saved registers
• Allocator
– Functions: alloc_pages(), init_allocator()
• Context Switch
– Functions: switch_context(old_pcb, new_pcb)
• Console
– Functions: sbi_call(), putchar(), printf()
• Relationships
– Scheduler “owns” a list of PCB instances
– Exception Handler uses trap_frame to save/restore registers
– Allocator is called by kernel startup and by processes
Don’t overthink – break the kernel into as many logical pieces as possible
• Each learning-basics module becomes a layer in your monolithic design view.
• How code is organized on disk
• How the build & runtime environments interact
• How the kernel’s internal modules and data structures collaborate at runtime
• Which source files implement each subsystem