pub struct Header {
pub magic: u32,
pub totalsize: u32,
pub off_dt_struct: u32,
pub off_dt_strings: u32,
pub off_mem_rsvmap: u32,
pub version: u32,
pub last_comp_version: u32,
pub boot_cpuid_phys: u32,
pub size_dt_strings: u32,
pub size_dt_struct: u32,
}Expand description
The FDT header structure.
Every device tree blob begins with this header, which contains metadata about the layout and version of the FDT. All fields are stored in big-endian byte order on-disk and are converted to host byte order when parsed.
Fields§
§magic: u32FDT header magic number (must be 0xd00dfeed)
totalsize: u32Total size in bytes of the FDT structure
off_dt_struct: u32Offset in bytes from the start of the header to the structure block
off_dt_strings: u32Offset in bytes from the start of the header to the strings block
off_mem_rsvmap: u32Offset in bytes from the start of the header to the memory reservation block
version: u32FDT version number
last_comp_version: u32Last compatible FDT version
boot_cpuid_phys: u32Physical ID of the boot CPU
size_dt_strings: u32Length in bytes of the strings block
size_dt_struct: u32Length in bytes of the structure block
Implementations§
Source§impl Header
impl Header
Sourcepub fn from_bytes(data: &[u8]) -> Result<Self, FdtError>
pub fn from_bytes(data: &[u8]) -> Result<Self, FdtError>
Read a header from a byte slice.
Parses an FDT header from the beginning of a byte slice, validating the magic number and converting all fields from big-endian to host order.
§Errors
Returns FdtError::BufferTooSmall if the slice is too small to contain
a complete header, or FdtError::InvalidMagic if the magic number doesn’t
match the expected value.
Sourcepub unsafe fn from_ptr(ptr: *mut u8) -> Result<Self, FdtError>
pub unsafe fn from_ptr(ptr: *mut u8) -> Result<Self, FdtError>
Read a header from a raw pointer.
Parses an FDT header from the memory location pointed to by ptr,
validating the magic number and converting all fields from big-endian
to host order. Handles unaligned pointers by copying to an aligned buffer.
§Safety
The caller must ensure that the pointer is valid and points to a
memory region of at least size_of::<Header>() bytes that contains a
valid device tree blob header.
§Errors
Returns FdtError::InvalidPtr if the pointer is null, or
FdtError::InvalidMagic if the magic number doesn’t match.