Um kernel didático completo em Rust, com componentes em x86_64 Assembly e C. Projeto educacional para aprender arquitetura de kernels modernos.
Arquitetura: x86_64 64-bit Linguagem Principal: Rust Bootloader: Multiboot2 compliant Gerenciamento: Memória, Processos, Interrupts Drivers: Timer (PIT), Interrupt Controller (PIC) Sistema de Arquivos: RAMDisk simples Syscalls: Interface base
labubuntu/
├── src/
│ ├── main.rs # Entry point do kernel
│ ├── lib.rs # Lib do kernel
│ ├── serial.rs # Driver UART serial
│ ├── panic.rs # Panic handler
│ ├── arch/ # Arquitetura x86_64
│ │ ├── gdt.rs # Global Descriptor Table
│ │ ├── interrupts.rs # Interrupt handlers
│ │ └── x86_64/
│ ├── mm/ # Memory Management
│ │ ├── allocator.rs # Memory allocator
│ │ ├── paging.rs # Virtual memory
│ │ └── heap.rs # Kernel heap
│ ├── process/ # Process management
│ │ ├── process.rs # Process structure
│ │ ├── scheduler.rs # Process scheduler
│ │ └── task.rs # Task/thread manager
│ ├── drivers/ # Hardware drivers
│ │ ├── pit.rs # Programmable Interval Timer
│ │ └── pic.rs # Programmable Interrupt Controller
│ ├── fs/ # File system
│ │ ├── ramdisk.rs # RAM-based filesystem
│ │ └── inode.rs # Inode structure
│ └── syscall/ # System calls
│ ├── mod.rs # Syscall infrastructure
│ ├── call_numbers.rs # x86_64 syscall numbers
│ └── dispatch.rs # Syscall dispatcher
├── bootloader/
│ ├── boot.asm # X86_64 bootloader
│ └── kernel.ld # Linker script
├── userland/ # User-mode programs
├── Cargo.toml # Cargo dependencies
├── Makefile # Build system
└── README.md # This file
- Rust 1.70+ (nightly)
- QEMU (para emular)
- GCC/Clang (para compilar C/Assembly)
- GNU Make
x86_64 = "0.15"
uart_16550 = "0.3"
volatile = "0.5"
spin = "0.9"
xmas-elf = "0.9"# Compilar kernel
make build
# Ou com cargo direto
cargo build --release --target x86_64-unknown-none# Rodar em QEMU
make run
# Debug com GDB
make debug
# Em outro terminal:
gdb -ex 'target remote :1234' target/x86_64-unknown-none/release/kernelmake iso
# Resultado: labubuntu.iso- Multiboot2 bootloader
- Long mode (64-bit) setup
- GDT (Global Descriptor Table)
- IDT (Interrupt Descriptor Table)
- Basic exception handlers
- Kernel heap (256KB)
- Virtual memory paging (basic)
- Bump allocator
- Page frame allocator
- Process table (256 processes max)
- Process states (Ready, Running, Blocked, Terminated)
- Process context switching
- Round-Robin scheduler (basic)
- Exception handlers (Breakpoint, GPF, Page Fault)
- Interrupt controller setup
- Timer interrupt (PIT)
- Keyboard interrupt (basic)
- Serial UART (16550 compatible)
- Programmable Interval Timer (PIT 8254)
- Programmable Interrupt Controller (PIC 8259)
- Syscall dispatcher
- Basic syscalls: write, exit, getpid
- x86_64 AMD64 ABI compliant
- Simple RAM disk filesystem
- Inode structures
- Basic file operations (create, read, write)
#include <syscall.h>
void main() {
syscall_write(1, "Hello from LABUBUNTU!\n", 23);
syscall_exit(0);
}# User program (from userland/)
gcc -nostdlib -o hello hello.c
# Vai rodar no kernel- Rust style via
cargo fmt - Linting with
cargo clippy
make fmt # Format code
make clippy # Lint code
make check # Type check
make docs # Generate docs- Basic bootloader
- GDT/IDT setup
- Memory management basics
- serial console
- Simple process manager
- Full paging implementation
- User mode execution
- More syscalls
- Keyboard driver
- Shell (basic command interpreter)
- File system (ext2-like)
- Network stack (basic)
- Multi-core support
- Shared memory
# Start with monitor
qemu-system-x86_64 -kernel kernel -monitor stdio
# Useful QEMU monitor commands:
# info registers
# info mem
# xp /10i $rip (examine 10 instructions at RIP)gdb target/x86_64-unknown-none/release/kernel
# GDB commands:
# b main - Break at main
# c - Continue
# si - Step instruction
# p $rax - Print register
# x/10i $rip - Examine 10 instructions
# bt - BacktraceIdeias para contribuição:
- Implementar mais drivers (e.g., AHCI, XHCI)
- Expandir filesystem (journaling, ext2)
- Adicionar networking básico
- Implementar mutex/semaphores robustos
- Criar shell de usuário
- Portar programas userland
MIT License - Veja LICENSE para detalhes
LABUBUNTU Kernel Team
- Educacional
- Open Source
- Learning Resource
**Building the future of open-source kernels! **