somehal-0.4.8 has been yanked.
SomeHAL
SomeHAL is a hardware abstraction layer library designed specifically for AArch64 chips with MMU functionality. It provides bootloader capabilities to complete MMU initialization and run code at specified virtual addresses.
Features
- 🚀 Dynamic MMU Initialization: Automatically configures page tables, enables MMU, and redirects to virtual addresses
- 📱 Multi-Privilege Level Support: Supports both EL1 and EL2 (hypervisor) privilege levels
- 🔧 Position Independent Boot: Uses PIE (Position Independent Executable) bootloader
- 💾 Memory Management: Automatically parses device tree and manages memory regions
- 🐛 Early Debug Support: Provides early debug output functionality
- ⚡ Multi-Core Support: Supports multi-core CPU boot
Architecture Support
- AArch64: ✅ Full support
- EL1 (Exception Level 1)
- EL2 (Exception Level 2, Hypervisor)
Getting Started
Adding Dependencies
Add to your Cargo.toml:
[]
= "0.3"
Basic Usage
use ;
!
Multi-Core Support
use ;
!
!
Core Concepts
Boot Process
- Kernel Entry (
_start) - Save boot parameters - PIE Bootloader - Position-independent bootloader responsible for:
- Parsing device tree (FDT)
- Configuring page table mappings
- Enabling MMU
- Redirecting to virtual addresses
- Virtual Entry - Call user's main function
Memory Layout
Virtual Address Space:
0xffff_0000_0000_0000 +----------------+
| Kernel Space |
| |
0xffff_8000_0000_0000 +----------------+
| Linear Mapping|
| (Physical Mem) |
0xffff_0000_0000_0000 +----------------+
BootInfo Structure
BootInfo provides important boot-time information:
Feature Flags
hv: Enable hypervisor mode (EL2) support
Hypervisor Mode Example
[]
= { = "0.3", = ["hv"] }
Memory Management
Getting Memory Region Information
use ;
!
I/O Memory Mapping
use iomap;
// Map I/O device memory
let device_base = 0x1000_0000;
let device_size = 0x1000;
match iomap
Debug Features
Early Debug Output
use *;
println!;
Build Configuration
Linker Script
SomeHAL requires specific linker script configuration. Create link.ld in your project:
STACK_SIZE = 0x40000;
INCLUDE "somehal.x"
SECTIONS
{
# other sections...
}
Build Script
In build.rs:
Platform Testing
The project provides test configurations for multiple platforms:
# Test runtime
# Test configuration with VM functionality
Example Projects
Check the tests/test-some-rt directory for complete usage examples.
Important Notes
- Target Architecture: Currently only supports
aarch64-unknown-none-softfloattarget - no_std: This is a no_std library for bare-metal environments
- MMU Requirement: Requires hardware MMU support
- Device Tree: Requires a valid device tree (FDT) to obtain hardware information
License
This project is licensed under the MIT License. See the LICENSE file for details.
Contributing
Issues and pull requests are welcome!