diff options
| author | salmonik <salmonik@tuta.io> | 2026-07-31 15:51:28 +0200 |
|---|---|---|
| committer | salmonik <salmonik@tuta.io> | 2026-07-31 15:51:28 +0200 |
| commit | 5e03409586efc37931f07b40ee0c71a9a9e109f7 (patch) | |
| tree | a1e6e014b94fb410ffce49a7611bf94295165729 /rsnix/src/uefi.rs | |
| parent | rsboot: loader file buffers use LoaderData (2) instead of RuntimeData (6) (diff) | |
| download | rs-dos-5e03409586efc37931f07b40ee0c71a9a9e109f7.tar.gz rs-dos-5e03409586efc37931f07b40ee0c71a9a9e109f7.zip | |
rsnix: memory management — free-list heap, bitmap pages, paging adoption
- uefi.rs: full EfiMemoryType constants (0-14) + memory_type_name(); fix
MEMORY_TYPE_LOADER_DATA from 6 to 2 per the UEFI spec
- memory.rs: replace the bump allocator with a first-fit free-list heap
(splitting, coalescing, 8-byte back-pointer for alignment-safe free);
add a bitmap physical page allocator (heap region reserved, page-0
guard, aligned runs); grow the heap from the page allocator on demand
- paging.rs: identity page-table helpers — adopt_tables() rebuilds the
firmware map into our own tables (OVMF maps its tables read-only, so
the firmware tree can't be modified in place) and switches CR3;
map_page/unmap_page/is_mapped with 2 MB/1 GB large-page splitting
- main.rs: boot self-tests for heap, pages, and paging
Diffstat (limited to '')
| -rw-r--r-- | rsnix/src/uefi.rs | 40 |
1 files changed, 35 insertions, 5 deletions
diff --git a/rsnix/src/uefi.rs b/rsnix/src/uefi.rs index 2e3ed6b..619739e 100644 --- a/rsnix/src/uefi.rs +++ b/rsnix/src/uefi.rs | |||
| @@ -116,13 +116,43 @@ pub struct MemoryDescriptor { | |||
| 116 | pub attribute: u64, | 116 | pub attribute: u64, |
| 117 | } | 117 | } |
| 118 | 118 | ||
| 119 | pub const MEMORY_TYPE_CONVENTIONAL: u32 = 7; | 119 | pub const MEMORY_TYPE_RESERVED: u32 = 0; |
| 120 | #[allow(dead_code)] | 120 | pub const MEMORY_TYPE_LOADER_CODE: u32 = 1; |
| 121 | pub const MEMORY_TYPE_LOADER_DATA: u32 = 6; | 121 | pub const MEMORY_TYPE_LOADER_DATA: u32 = 2; |
| 122 | #[allow(dead_code)] | ||
| 123 | pub const MEMORY_TYPE_BOOT_SERVICES_CODE: u32 = 3; | 122 | pub const MEMORY_TYPE_BOOT_SERVICES_CODE: u32 = 3; |
| 124 | #[allow(dead_code)] | ||
| 125 | pub const MEMORY_TYPE_BOOT_SERVICES_DATA: u32 = 4; | 123 | pub const MEMORY_TYPE_BOOT_SERVICES_DATA: u32 = 4; |
| 124 | pub const MEMORY_TYPE_RUNTIME_CODE: u32 = 5; | ||
| 125 | pub const MEMORY_TYPE_RUNTIME_DATA: u32 = 6; | ||
| 126 | pub const MEMORY_TYPE_CONVENTIONAL: u32 = 7; | ||
| 127 | pub const MEMORY_TYPE_UNUSABLE: u32 = 8; | ||
| 128 | pub const MEMORY_TYPE_ACPI_RECLAIM: u32 = 9; | ||
| 129 | pub const MEMORY_TYPE_ACPI_NVS: u32 = 10; | ||
| 130 | pub const MEMORY_TYPE_MMIO: u32 = 11; | ||
| 131 | pub const MEMORY_TYPE_MMIO_PORT: u32 = 12; | ||
| 132 | pub const MEMORY_TYPE_PAL_CODE: u32 = 13; | ||
| 133 | pub const MEMORY_TYPE_PERSISTENT: u32 = 14; | ||
| 134 | |||
| 135 | /// Human-readable name for a UEFI memory type. | ||
| 136 | pub fn memory_type_name(kind: u32) -> &'static str { | ||
| 137 | match kind { | ||
| 138 | 0 => "Reserved", | ||
| 139 | 1 => "LoaderCode", | ||
| 140 | 2 => "LoaderData", | ||
| 141 | 3 => "BootServicesCode", | ||
| 142 | 4 => "BootServicesData", | ||
| 143 | 5 => "RuntimeCode", | ||
| 144 | 6 => "RuntimeData", | ||
| 145 | 7 => "Conventional", | ||
| 146 | 8 => "Unusable", | ||
| 147 | 9 => "ACPIReclaim", | ||
| 148 | 10 => "ACPINVS", | ||
| 149 | 11 => "MMIO", | ||
| 150 | 12 => "MMIOPort", | ||
| 151 | 13 => "PalCode", | ||
| 152 | 14 => "Persistent", | ||
| 153 | _ => "Unknown", | ||
| 154 | } | ||
| 155 | } | ||
| 126 | 156 | ||
| 127 | // --------------------------------------------------------------------------- | 157 | // --------------------------------------------------------------------------- |
| 128 | // Boot services table | 158 | // Boot services table |
