Skip to content

Hoteira/swiftboot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation


Swiftboot Logo

Swiftboot

Three-stage x86 bootloader written in Rust

Rust License no_std

🚀 Three-Stage Boot • 🦀 Pure Rust • 💻 Real Mode → Protected Mode


Quick Start

# Clone and build
git clone https://github.com/Hoteira/swiftboot.git
cd swiftboot

# Install nightly and components
rustup toolchain install nightly
rustup component add rust-src llvm-tools-preview
cargo install cargo-binutils

# Build bootloader
cargo compile

# Attach your kernel (replace with your kernel path)
dd if=path/to/your/kernel.bin of=build/disk.img bs=512 seek=5120 conv=notrunc

# Run
qemu-system-x86_64 -drive file=build/disk.img,format=raw -m 1G -serial stdio

Features

  • 🚀 Three-Stage Boot — Modular 512B → 16KB → 16KB → Kernel progression
  • 🔧 Hardware Setup — Configures GDT, TSS, memory map (E820), RSDP, and VBE graphics
  • 💾 Disk I/O — BIOS interrupts (16-bit) and ATA PIO (32-bit)
  • 🦀 Pure Rust — Minimal assembly, custom target specs for 16/32-bit

Architecture

Stage 1 (0x7c00)  →  Stage 2 (0x7e00)  →  Stage 3 (0xfe00)  →  Kernel (0x10_0000)
  512 bytes            16KB real mode       16KB protected       Your kernel here
  BIOS loads           Sets up hardware     Loads kernel         Receives boot info

Disk Layout:

  • LBA 0: Stage 1 (MBR)
  • LBA 2048: Stage 2
  • LBA 3072: Stage 3
  • LBA 5120: Kernel (1MB reserved)

Boot Info Passed to Kernel:

struct BootInfo {
    mmap: MemoryMap,        // E820 memory map
    rsdp: Rsdp,             // ACPI table
    tss: u16,               // TSS selector
    vbe: VbeInfoBlock,      // VBE info
    mode: VbeModeInfoBlock, // Graphics mode
}

#[unsafe(no_mangle)]
extern "C" fn _start(bootinfo_ptr: *const BootInfo) { ... }

Custom Build System

The cargo-compile tool orchestrates the build:

cargo compile  # Builds all stages, converts to raw binaries, assembles disk.img

Uses custom target specs:

  • bits16.json — 16-bit real mode (Stage 1, 2)
  • bits32.json — 32-bit protected mode (Stage 3)

All stages have constants pointing to the next stage (both in the disk and in the RAM) Stage 2 also defines the parameters for the display mode that will be chosen (feel free to customize them to your liking):

MAX_BPP: u8 = 32;
MIN_BPP: u8 = 24;

MAX_WIDTH: u16 = 1024;
MIN_WIDTH: u16 = 0;
MAX_HEIGHT: u16 = 800;
MIN_HEIGHT: u16 = 0;

MODE: u16 = 0x1; // 0 => VGA, 1 => VBE

Future Features

  • 64-bit mode
  • Multiboot2 compliant

License

Licensed under the MIT License.


Boots fast 🚀 or breaks trying 😰

About

x86 bootloader written in Rust

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published