Move to multi arch support and added memory map

This commit is contained in:
2026-07-03 11:11:19 +01:00
parent c2435760c4
commit 628c4f6d57
11 changed files with 423 additions and 41 deletions
+41
View File
@@ -32,8 +32,49 @@ pub const Framebuffer = extern struct {
format: PixelFormat,
};
/// Page size the memory map is measured in. 4 KiB on every architecture danos
/// targets so far.
pub const page_size = 4096;
/// danos's own classification of a span of physical memory — deliberately not
/// UEFI's vocabulary. Each boot path (UEFI now, device tree later) translates its
/// native memory description into these kinds, so the kernel never learns what
/// booted it. [[arch]] keeps the same discipline for CPU code.
pub const MemoryKind = enum(u32) {
/// Free RAM the kernel may allocate.
usable,
/// Firmware, MMIO, the kernel image, our own boot buffers — never hand out.
reserved,
/// Usable once the kernel is done with boot-time structures (e.g. UEFI boot
/// services memory, which is free after ExitBootServices).
reclaimable,
/// ACPI tables: parse, then reclaim.
acpi_tables,
/// ACPI non-volatile storage: preserve across sleep, do not allocate.
acpi_nvs,
};
/// One contiguous span of physical memory. Because danos defines this layout
/// itself (unlike the UEFI descriptor it's built from), `@sizeOf` is
/// authoritative — the kernel walks a plain `[]MemoryRegion`, with none of the
/// firmware's variable descriptor-stride to worry about.
pub const MemoryRegion = extern struct {
base: u64, // physical start address
pages: u64, // length in `page_size` units
kind: MemoryKind,
_pad: u32 = 0,
};
/// The physical memory layout handed to the kernel: a pointer to an array of
/// `len` `MemoryRegion`s, in a buffer that outlives the loader.
pub const MemoryMap = extern struct {
regions: usize, // address of a `[len]MemoryRegion`
len: usize,
};
/// Handoff structure the bootloader fills in and passes to the kernel's
/// `_start` in RDI (the first argument under the SysV AMD64 C ABI).
pub const BootInfo = extern struct {
framebuffer: Framebuffer,
memory_map: MemoryMap,
};