Expand description
Post-EBS Global Allocator
Uses linked_list_allocator for a battle-tested, no_std heap. Initialized from a static buffer after ExitBootServices.
§Architecture
┌─────────────────────────────────────────────────────────────┐
│ Static Heap Buffer │
│ (1MB default) │
│ │
│ ┌─────────────────────────────────────────────────────┐ │
│ │ linked_list_allocator::Heap │ │
│ │ │ │
│ │ Free List: [block] -> [block] -> [block] -> ... │ │
│ │ │ │
│ └─────────────────────────────────────────────────────┘ │
└─────────────────────────────────────────────────────────────┘§Usage
ⓘ
// In bare_metal_main, before any allocations:
unsafe { crate::alloc::init_heap(); }
// Now Vec, Box, String all work:
let v = vec![1, 2, 3];
let s = String::from("hello");§Feature Flags
post_ebs_allocator: Enable#[global_allocator]attribute. Only enable this when running standalone post-EBS, not when used as a library by the bootloader (which has its own UEFI allocator).
§Safety
init_heap()must be called exactly ONCE before any allocations- Must be called after ExitBootServices (UEFI allocator is gone)
- Thread-safety: Uses spin lock internally (safe for single-core post-EBS)
Structs§
- Page-aligned heap buffer wrapper
- Heap statistics
- Locked heap wrapper implementing GlobalAlloc
Constants§
- Heap size: 1MB - sufficient for FAT32 ops, manifest handling, etc. Can be increased if needed.
Statics§
- GLOBAL 🔒
- Static heap buffer - lives in .bss, zero-initialized
- Track if heap is already initialized
Functions§
- Get heap statistics for debugging
- Initialize the heap allocator
- Check if heap is initialized