Expand description
Device Tree (FDT) parsing Device Tree (FDT) parsing for the custom boot protocol.
Parses the Flattened Device Tree to extract boot information:
- Memory map
- Framebuffer
- ACPI RSDP (via EFI System Table)
- Boot command line
- HHDM offset (derived from memory map)
Β§FDT format
The DTB is a binary blob with big-endian fields. Structure tokens:
- 0x1 = FDT_BEGIN_NODE
- 0x2 = FDT_END_NODE
- 0x3 = FDT_PROP
- 0x4 = FDT_NOP
- 0x9 = FDT_END
Β§Cell sizes
The root node defines #address-cells and #size-cells which determine
how many 32-bit cells are used for addresses and sizes in reg properties.
Default on most platforms: #address-cells=2, #size-cells=2 (8 bytes each).
StructsΒ§
- FdtHeader π
ConstantsΒ§
- DEFAULT_
HHDM_ πOFFSET - Default HHDM offset for x86_64 (4 GiB). Used when DTB doesnβt specify one.
- MAX_
CSTRING_ πLEN - Maximum string length for FDT strings
- MAX_
DTB_ πMEMORY_ REGIONS - Maximum number of memory regions supported from DTB
StaticsΒ§
- DTB_
MEMORY_ πMAP - Static storage for memory map parsed from DTB.
FunctionsΒ§
- build_
kernel_ βargs_ from_ dtb - Parse the Flattened Device Tree and build a KernelArgs structure.
- derive_
hhdm_ πoffset - Derive HHDM offset from the memory map.
- find_
rsdp_ π βfrom_ efi_ systab - Find RSDP from EFI System Table.
- parse_
chosen_ π βnode - Parse /chosen node for bootargs, initrd, stdout-path, uefi-systab.
- parse_
fdt_ π βheader - parse_
framebuffer π β - Parse framebuffer information from DTB.
- parse_
memory_ π βnodes - Parse /memory nodes to build the memory map.
- parse_
root_ π βproperties - Parse root node properties to extract #address-cells and #size-cells.
- read_
be32 π β - Read a big-endian 32-bit value.
- read_
be64 π β - Read a big-endian 64-bit value.
- read_
be_ π βint - Read a big-endian integer of
num_bytesbytes (1β8). - read_
cstring π β - Read a null-terminated string from memory.
- read_
prop_ π βu64 - Read a property value as u64 (32 or 64 bit depending on prop_len).
- read_
reg_ π βproperty - Read a
regproperty value using the correct cell sizes.