Simple OS project for Dlang community and Kaktus Media! (Муну жаңылыктарга кошуп коюңуздарчы)
BelowOS is a minimalist 32-bit x86 operating system built from scratch using the D programming language in -betterC mode. This project demonstrates system-level programming without a standard library or runtime, focusing on direct hardware interaction and manual resource management.
The kernel is compiled using the -betterC subset of the D language. This ensures:
- Zero Runtime Overhead: No Garbage Collector (GC), TypeInfo, or ModuleInfo.
- Static Linking: The resulting binary is a freestanding ELF file capable of running directly on x86 hardware.
- Manual Memory Control: All memory operations are explicit, preventing hidden allocations.
Storage is handled by a custom Integrated Drive Electronics (IDE) driver operating in Programmed I/O (PIO) mode.
- Direct Port I/O: Communication occurs via I/O ports
0x1F0through0x1F7. - Sector Synchronization: The system implements a
sync_to_disk()function that flushes the in-memory filesystem table directly to the disk sectors, ensuring persistence.
The filesystem uses a flat-indexed structure to represent hierarchical data:
- Parent Indexing: Every file entry stores a
parentIdx, allowing for directory navigation without complex pointer trees. - Slot-Based Management: The filesystem is an array of fixed-size structures.
- The Nuke Mechanism: To ensure RAM efficiency, a dedicated "Nuke" routine performs a byte-level zeroing of memory slots, physically clearing data from the system's address space.
Output is managed via the VGA text buffer at memory address 0xB8000.
- 16-Color Palette: Uses a standard VGA attribute byte (4 bits for background, 4 bits for foreground).
- Type Safety: Core variables use
size_tandptrdiff_tto maintain architectural alignment and prevent overflow during memory addressing.
| Command | Operation | Priority |
|---|---|---|
ls |
Scans the fs array for entries matching the currentDir index. |
Standard |
cd |
Updates the currentDir pointer to the index of the target directory. |
Standard |
nuke |
Mandatory Erasure. Zeroes out the name and content buffers in RAM and Disk. | Critical |
cls |
Fills the 0xB8000 buffer with empty characters and resets the cursor. |
Utility |
BSOD |
Triggers a manual write of all cached filesystem entries to the HDD image. | System |
| and more) |
- LDC2: LLVM-based D Compiler.
- NASM: For the 16-bit real-mode bootloader.
- GNU Make: Project automation.
- QEMU: Hardware emulation (i386).
- Compile the bootloader and kernel using the provided Linker Script.
- Generate a raw
hdd.imgfile for storage emulation. - Launch via QEMU:
qemu-system-i386 -drive file=hdd.img,format=raw
or just type:
make run
- Freestanding Environment: No dependency on
libcorlibphobos. - Memory Mapping: Uses custom aliases for system-specific types to ensure portability across different x86 compilers.
- Hardware Reset: Implements a soft-reboot via the PS/2 controller (Port
0x64).