Skip to main content

Header

Struct Header 

Source
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: u32

FDT header magic number (must be 0xd00dfeed)

§totalsize: u32

Total size in bytes of the FDT structure

§off_dt_struct: u32

Offset in bytes from the start of the header to the structure block

§off_dt_strings: u32

Offset in bytes from the start of the header to the strings block

§off_mem_rsvmap: u32

Offset in bytes from the start of the header to the memory reservation block

§version: u32

FDT version number

§last_comp_version: u32

Last compatible FDT version

§boot_cpuid_phys: u32

Physical ID of the boot CPU

§size_dt_strings: u32

Length in bytes of the strings block

§size_dt_struct: u32

Length in bytes of the structure block

Implementations§

Source§

impl Header

Source

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.

Source

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.

Source

pub const fn alignment() -> usize

Returns the required alignment for FDT structures.

Trait Implementations§

Source§

impl Clone for Header

Source§

fn clone(&self) -> Header

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Header

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Freeze for Header

§

impl RefUnwindSafe for Header

§

impl Send for Header

§

impl Sync for Header

§

impl Unpin for Header

§

impl UnwindSafe for Header

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.