BarfRod is a modern x86_64 kernel written in Zig, featuring multiboot compliance, memory management, task scheduling, and an interactive command-line interface. Originally designed to use both Limine and GRUB bootloaders, it has been streamlined to use GRUB exclusively for maximum compatibility and reliability. Please Note...
- This Kernel/OS is just a hobby project DO NOT EXPECT STABILITY
- Multiboot-compliant: Boots reliably with GRUB using proper multiboot headers
- Memory Management: Physical memory manager and kernel heap allocator
- Task Scheduling: Preemptive multitasking with context switching
Interactive CLI: Built-in command-line interface for kernel interaction(In Progress)- VGA Text Mode: Basic text output for debugging and user interface
- Serial Output: Comprehensive serial logging for development and debugging
- IDT Support: Interrupt descriptor table setup and management
- Paging: Virtual memory management with page tables
Before building BarfRod, ensure you have the following tools installed:
- Zig 0.14.0 (included in
toolchain/
directory) - GRUB utilities:
grub-mkrescue
,grub-pc-bin
,grub-efi-amd64-bin
- ISO creation tools:
xorriso
,mtools
,dosfstools
- QEMU:
qemu-system-x86_64
(for testing)
sudo apt-get update
sudo apt-get install mtools dosfstools grub-pc-bin grub-efi-amd64-bin xorriso qemu-system-x86
# Build kernel only
zig build
# Build kernel and create bootable ISO
zig build iso
# Build and run in QEMU
zig build run
# Clean previous builds
./scripts/clean.sh
# Build kernel ELF
zig build
# Create bootable ISO with GRUB
./scripts/make_iso.sh
# Run in QEMU
./scripts/run_qemu.sh
-
In QEMU (Recommended for development):
zig build run
-
On Real Hardware:
- Burn the generated
barfrod.iso
to a USB drive or CD - Boot from the USB/CD on x86_64 hardware
- Burn the generated
- GRUB loads and displays boot menu
- Kernel initializes serial communication
- VGA text mode displays "BARF" banner
- IDT (Interrupt Descriptor Table) initialization
- Memory management and paging setup
- 6-second delay for system stabilization
- Interactive CLI becomes available
Once booted, the kernel provides an interactive command-line interface with various debugging and system commands.
BarfRod/
├── src/kernel/ # Kernel source code
│ ├── main.zig # Entry point and boot logic
│ ├── vga.zig # VGA text mode driver
│ ├── serial.zig # Serial communication
│ ├── idt.zig # Interrupt handling
│ ├── paging.zig # Virtual memory management
│ ├── pmm.zig # Physical memory manager
│ ├── kheap.zig # Kernel heap allocator
│ ├── scheduler.zig # Task scheduler
│ ├── context.zig # Context switching
│ ├── task.zig # Task management
│ └── cli.zig # Command-line interface
├── scripts/ # Build and utility scripts
├── toolchain/ # Zig compiler toolchain
├── grub.cfg # GRUB configuration
├── linker.ld # Custom linker script
└── build.zig # Zig build configuration
- Multiboot Header: Properly aligned 4-byte multiboot header in
.multiboot
section - Memory Management: Physical and virtual memory managers with heap allocation
- Task System: Preemptive multitasking with round-robin scheduling
- I/O Systems: VGA text output and serial communication for debugging
- Boot Protocol: GRUB-compatible multiboot implementation
-
"No multiboot header found" error:
- This was a known issue with Zig release mode optimization
- Fixed: Proper multiboot header alignment and linker script ordering
- The kernel now boots reliably in both debug and release modes
-
ISO creation fails:
- Ensure all GRUB tools are installed:
grub-mkrescue
,xorriso
- Check that you have write permissions in the project directory
- Ensure all GRUB tools are installed:
-
QEMU doesn't start:
- Verify
qemu-system-x86_64
is installed and in PATH - Check that the ISO file exists:
ls -la barfrod.iso
- Verify
The kernel provides extensive serial logging. To capture debug output:
- Serial output is available on
stdio
when running in QEMU - Physical hardware: Connect to COM1 (115200 baud, 8N1)
- Debug log file:
debug.log
(when using QEMU debugcon)
- Adding new features: Create new
.zig
files insrc/kernel/
- Updating build: Modify
build.zig
for new dependencies - Testing changes: Use
zig build run
for quick testing - Memory debugging: Check serial output for allocation/deallocation info
Latest Version: GRUB-Only Release
- ✅ Removed Limine bootloader dependency
- ✅ Fixed multiboot header alignment issues
- ✅ Streamlined build process for GRUB-only usage
- ✅ Improved boot reliability across different systems
- ✅ Enhanced serial debugging output
- Fork the repository
- Create a feature branch:
git checkout -b feature-name
- Make your changes and test thoroughly
- Ensure the kernel builds and boots:
zig build run
- Submit a pull request with a clear description
- Follow Zig naming conventions
- Use meaningful variable names
- Include comments for complex algorithms
- Test changes in both debug and release modes
Haven't decided which license to put... Will add one soon.
- Zig Language Team: For creating an excellent systems programming language
- GRUB Project: For the reliable multiboot bootloader implementation
- OSDev Community: For extensive documentation and support
- QEMU Project: For providing excellent emulation for kernel development
Happy kernel hacking! 🚀
For questions, issues, or contributions, please open an issue on the project repository.