Struct Devicetree

Source
pub struct Devicetree { /* private fields */ }
Expand description

Devicetree blob.

Alignment: Same as u64.

Implementations§

Source§

impl Devicetree

Source

pub fn root_node(&self) -> Result<Node<'_>, BlobError>

The devicetree’s root node.

Source

pub fn next_token( &self, cursor: &mut Cursor, ) -> Result<Option<Token<'_>>, BlobError>

Returns the token pointed to by the cursor and advance the cursor.

Source§

impl Devicetree

Source

pub unsafe fn from_ptr(ptr: NonNull<u64>) -> Result<&'static Self, BlobError>

Constructs a devicetree from a raw byte pointer. Mutable access is not required.

§Safety

Only use this if necessary. This function doesn’t work with pointer provenance and doesn’t pass Stacked Borrows rules.

The pointer has to point to a valid DTB. Some safety checks are done nonetheless. Alignment is not checked.

Source

pub fn from_slice(blob: &[u64]) -> Result<&Self, BlobError>

Constructs a devicetree from a slice containing a DTB.

If you only have a &[u8] value, consider using zerocopy::Ref or bytemuck::try_cast_slice.

Source

pub fn from_vec(blob: Vec<u64>) -> Result<Box<Self>, BlobError>

Constructs a devicetree from a vec containing a DTB.

If you only have a vector of u8s, you are out of luck. Either use Devicetree::from_unaligned, which will copy your vector, or Devicetree::from_slice, which will return a reference.

Source

pub fn from_unaligned(blob: &[u8]) -> Result<Box<Self>, BlobError>

Constructs a devicetree from an unaligned slice containing a DTB.

Source

pub fn exact_size(&self) -> u32

The exact byte size of the devicetree. This might be a bit smaller than size_of_val(dt) (or dt.blob_u8().len()) because Rust’s memory model requires 8-byte-aligned types (such as u64 on most platforms) to also have a size that’s a multiple of 8, whereas the devicetree spec doesn’t.

Source

pub fn version(&self) -> u32

The devicetree blob specification version.

It has been at 0x11 ever since version 0.1 of the spec.

Source

pub fn last_comp_version(&self) -> u32

The last version compatible with this devicetree blob’s version.

Currently required to be 16.

Source

pub fn boot_core_id(&self) -> u32

The ID of the system’s physical boot CPU.

Source

pub fn blob_u8(&self) -> &[u8]

The blob data as a u8 slice.

Source

pub fn blob_u32(&self) -> &[u32]

The blob data as a u32 slice.

Source

pub fn blob(&self) -> &[u64]

The blob data as a u64 slice.

Source

pub fn struct_blob(&self) -> &[u32]

The blob data of the struct block.

Source

pub fn strings_blob(&self) -> &[u8]

The blob data of the strings block.

Source

pub fn get_node<P: Path + ?Sized>(&self, path: &P) -> Result<Option<Node<'_>>>

Gets a node from the struct block by (loosely-matching) path. Try using Self::get_node_strict instead.

Doesn’t respect aliases. The components need not match the node names exactly; the unit address (the part starting with an @) can be left out. If it is, the node name has to be unambiguous.

Source

pub fn get_node_strict<P: Path + ?Sized>( &self, path: &P, ) -> Result<Option<Node<'_>>>

Gets a node from the struct block by path.

The components have to match the node names exactly; the unit address (the part starting with an @) cannot be left out.

Source

pub fn parse_root<'dtb, T: DeserializeNode<'dtb>>(&'dtb self) -> Result<T>

Source

pub fn mem_reserve_entries(&self) -> Result<MemReserveEntries<'_>, BlobError>

Iterates over the memory reservation block.

Trait Implementations§

Source§

impl Debug for Devicetree

Source§

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

Formats the value using the given formatter. Read more
Source§

impl<'a> From<&'a Devicetree> for &'a [u64]

Source§

fn from(dt: &'a Devicetree) -> Self

Converts to this type from the input type.
Source§

impl<'a> From<&'a Devicetree> for Box<Devicetree>

Source§

fn from(this: &'a Devicetree) -> Self

Converts to this type from the input type.
Source§

impl ToOwned for Devicetree

Source§

type Owned = Box<Devicetree>

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> Self::Owned

Creates owned data from borrowed data, usually by cloning. Read more
1.63.0 · Source§

fn clone_into(&self, target: &mut Self::Owned)

Uses borrowed data to replace owned data, usually by cloning. Read more

Auto Trait Implementations§

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