|
|
||
|---|---|---|
| .. | ||
| .cargo | ||
| docs | ||
| examples | ||
| linker | ||
| src | ||
| tests | ||
| Cargo.toml | ||
| README.md | ||
| build.rs | ||
README.md
NOS UEFI Bootloader Implementation
This directory contains the UEFI bootloader implementation for the NOS operating system.
Phase 2: UEFI Implementation (Weeks 5-8)
Completed Features
✅ UEFI 2.10 Core Protocol Support
- System Table and Boot Services interfaces
- Runtime Services support
- Protocol abstraction layer
- UEFI application entry point
- Memory management integration
✅ UEFI Graphics Output Protocol (GOP)
- Framebuffer detection and initialization
- Pixel format conversion
- Basic drawing primitives
- Font rendering system
- Boot splash screen support
✅ UEFI Memory Management
- UEFI pool and page allocation
- Memory map parsing and conversion
- Dynamic memory allocation strategies
- Memory type conversion
- Memory statistics reporting
✅ UEFI Secure Boot Foundation
- Platform Key (PK) support
- Key Exchange Key (KEK) support
- Signature Database (db/dbx) management
- Kernel signature verification
- Secure Boot status reporting
- Setup Mode detection
✅ UEFI File System Support
- Simple File System Protocol implementation
- Kernel loading from EFI partition
- EFI variable access
- LoadOptions parsing
- Multi-path kernel search
Architecture Support
The bootloader supports all three target architectures:
- x86_64: Complete UEFI 2.10 support
- AArch64: UEFI application with PE/COFF format
- RISC-V 64: UEFI application support
Key Components
Core Modules
src/uefi/main.rs- UEFI application entry pointsrc/uefi/protocol.rs- UEFI protocol implementationsrc/uefi/memory.rs- UEFI memory managementsrc/uefi/secure_boot.rs- Secure boot implementation
Supporting Modules
src/graphics/mod.rs- Graphics and framebuffer supportsrc/arch/x86_64.rs- x86_64-specific UEFI supportsrc/arch/aarch64.rs- AArch64-specific UEFI supportsrc/arch/riscv64.rs- RISC-V 64-specific UEFI support
Features
UEFI 2.10 Compliance
- Full UEFI specification compliance
- Modern boot protocol support
- Cross-platform compatibility
- Industry-standard interface
Security Features
- UEFI Secure Boot implementation
- Digital signature verification
- Platform key management
- Secure boot chain validation
Graphics Support
- UEFI Graphics Output Protocol (GOP)
- Multi-resolution framebuffer support
- Custom boot screens and menus
- Font rendering system
File System Support
- EFI file system partition access
- Kernel loading from multiple paths
- Configuration file support
- Command line parsing
Build Configuration
Features
uefi_support- Enable UEFI bootloadergraphics_support- Enable graphics outputsecure_boot_support- Enable secure bootnetwork_support- Enable network booting
Build Targets
x86_64-unknown-uefi- x86_64 UEFI targetaarch64-unknown-uefi- AArch64 UEFI targetriscv64-unknown-uefi- RISC-V 64 UEFI target
Usage
Building for UEFI
# Build for x86_64 UEFI
cargo build --release --target x86_64-unknown-uefi
# Build for AArch64 UEFI
cargo build --release --target aarch64-unknown-uefi
# Build for RISC-V UEFI
cargo build --release --target riscv64-unknown-uefi
Running in QEMU
# UEFI firmware required
qemu-system-x86_64 \
-bios OVMF.fd \
-drive if=pflash,format=raw,readonly,file=bootloader.efi \
-serial mon:stdio \
-nographic
qemu-system-aarch64 \
-bios QEMU_EFI.fd \
-drive if=pflash,format=raw,readonly=file=bootloader.efi \
-serial mon:stdio
Testing
UEFI Compatibility Testing
- Test with different UEFI firmware versions
- Validate UEFI specification compliance
- Test secure boot functionality
- Verify graphics output support
Integration Testing
- Test kernel loading from EFI partitions
- Verify memory map handling
- Test boot parameter passing
- Validate graphics initialization
Dependencies
Core Dependencies
uefi- UEFI 2.10 specification implementationuefi-services- High-level UEFI servicesuefi-macros- UEFI utility macros
Optional Dependencies
embedded-graphics- Graphics renderingtinybmp- BMP image supportsmoltcp- Network stack support
Architecture Details
Boot Flow
- UEFI firmware loads bootloader as EFI application
- Bootloader initializes UEFI services
- Bootloader detects system capabilities
- Optional: Display boot menu or splash screen
- Bootloader loads kernel from EFI partition
- Bootloader verifies kernel signature (if secure boot)
- Bootloader exits UEFI boot services
- Bootloader transfers control to kernel
Memory Layout
- UEFI memory pool allocation for bootloader data
- Page allocation for kernel image
- Dynamic memory map handling
- Runtime services preservation
Protocol Integration
- System table access for UEFI services
- Boot services for early boot operations
- Runtime services for persistent operations
- Protocol abstraction for cross-platform support
Next Steps
Phase 3: BIOS/Multiboot2 Implementation
- Traditional BIOS interrupt services
- Multiboot2 specification support
- Legacy VGA graphics support
- BIOS bootloader implementation
Phase 4: Advanced Features
- Interactive boot menu system
- Network boot (PXE/iPXE) support
- Recovery mode implementation
- Configuration management
Phase 5: Integration and Testing
- Complete system integration
- Comprehensive testing suite
- Performance optimization
- Production deployment
Standards Compliance
UEFI 2.10 Specification
- Full compliance with UEFI 2.10
- Industry-standard boot protocol support
- Cross-vendor compatibility
Security Standards
- UEFI Secure Boot 2.4 compliance
- Digital signature verification
- Certificate chain validation
Contributing
Development Guidelines
- Follow UEFI specification guidelines
- Maintain cross-platform compatibility
- Implement comprehensive error handling
- Add thorough documentation
Code Style
- Use Rust
#![no_std]environment - Implement proper error handling
- Follow memory safety guidelines
- Add comprehensive comments
This implementation represents a significant milestone in making NOS a modern, production-ready operating system with full UEFI support.