pub struct Devicetree { /* private fields */ }Expand description
Devicetree blob.
Alignment: Same as u64.
Implementations§
Source§impl Devicetree
impl Devicetree
Source§impl Devicetree
impl Devicetree
Sourcepub unsafe fn from_ptr(ptr: NonNull<u64>) -> Result<&'static Self, BlobError>
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.
Sourcepub fn from_slice(blob: &[u64]) -> Result<&Self, BlobError>
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.
Sourcepub fn from_vec(blob: Vec<u64>) -> Result<Box<Self>, BlobError>
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.
Sourcepub fn from_unaligned(blob: &[u8]) -> Result<Box<Self>, BlobError>
pub fn from_unaligned(blob: &[u8]) -> Result<Box<Self>, BlobError>
Constructs a devicetree from an unaligned slice containing a DTB.
Sourcepub fn exact_size(&self) -> u32
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.
Sourcepub fn version(&self) -> u32
pub fn version(&self) -> u32
The devicetree blob specification version.
It has been at 0x11 ever since version 0.1 of the spec.
Sourcepub fn last_comp_version(&self) -> u32
pub fn last_comp_version(&self) -> u32
The last version compatible with this devicetree blob’s version.
Currently required to be 16.
Sourcepub fn boot_core_id(&self) -> u32
pub fn boot_core_id(&self) -> u32
The ID of the system’s physical boot CPU.
Sourcepub fn struct_blob(&self) -> &[u32]
pub fn struct_blob(&self) -> &[u32]
The blob data of the struct block.
Sourcepub fn strings_blob(&self) -> &[u8] ⓘ
pub fn strings_blob(&self) -> &[u8] ⓘ
The blob data of the strings block.
Sourcepub fn get_node<P: Path + ?Sized>(&self, path: &P) -> Result<Option<Node<'_>>>
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.
Sourcepub fn get_node_strict<P: Path + ?Sized>(
&self,
path: &P,
) -> Result<Option<Node<'_>>>
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.
pub fn parse_root<'dtb, T: DeserializeNode<'dtb>>(&'dtb self) -> Result<T>
Sourcepub fn mem_reserve_entries(&self) -> Result<MemReserveEntries<'_>, BlobError>
pub fn mem_reserve_entries(&self) -> Result<MemReserveEntries<'_>, BlobError>
Iterates over the memory reservation block.