pub struct Fdt {
pub boot_cpuid_phys: u32,
pub memory_reservations: Vec<MemoryReservation>,
/* private fields */
}Expand description
An editable Flattened Device Tree (FDT).
All nodes are stored in a flat BTreeMap<NodeId, Node>. The tree structure
is maintained through Vec<NodeId> children lists in each Node and an
optional parent: Option<NodeId> back-pointer.
Fields§
§boot_cpuid_phys: u32Boot CPU ID
memory_reservations: Vec<MemoryReservation>Memory reservation block entries
Implementations§
Source§impl Fdt
impl Fdt
Sourcepub fn parent_of(&self, id: NodeId) -> Option<NodeId>
pub fn parent_of(&self, id: NodeId) -> Option<NodeId>
Returns the parent node ID for the given node, if any.
Sourcepub fn node(&self, id: NodeId) -> Option<&Node>
pub fn node(&self, id: NodeId) -> Option<&Node>
Returns a reference to the node with the given ID.
Sourcepub fn node_mut(&mut self, id: NodeId) -> Option<&mut Node>
pub fn node_mut(&mut self, id: NodeId) -> Option<&mut Node>
Returns a mutable reference to the node with the given ID.
Sourcepub fn node_count(&self) -> usize
pub fn node_count(&self) -> usize
Returns the total number of nodes in the tree.
Sourcepub fn add_node(&mut self, parent: NodeId, node: Node) -> NodeId
pub fn add_node(&mut self, parent: NodeId, node: Node) -> NodeId
Adds a new node as a child of parent, returning the new node’s ID.
Sets the new node’s parent field and updates the parent’s children list
and name cache.
Sourcepub fn remove_node(&mut self, parent: NodeId, name: &str) -> Option<NodeId>
pub fn remove_node(&mut self, parent: NodeId, name: &str) -> Option<NodeId>
Removes a child node (by name) from the given parent, and recursively removes the entire subtree from the arena.
Returns the removed node’s ID if found.
pub fn resolve_alias(&self, alias: &str) -> Option<&str>
Sourcepub fn get_by_path_id(&self, path: &str) -> Option<NodeId>
pub fn get_by_path_id(&self, path: &str) -> Option<NodeId>
Looks up a node by its full path (e.g. “/soc/uart@10000”),
returning its NodeId.
The root node is matched by “/” or “”.
Sourcepub fn get_by_phandle_id(&self, phandle: Phandle) -> Option<NodeId>
pub fn get_by_phandle_id(&self, phandle: Phandle) -> Option<NodeId>
Looks up a node by its phandle value, returning its NodeId.
Sourcepub fn path_of(&self, id: NodeId) -> String
pub fn path_of(&self, id: NodeId) -> String
Computes the full path string for a node by walking up parent links.
Sourcepub fn remove_by_path(&mut self, path: &str) -> Option<NodeId>
pub fn remove_by_path(&mut self, path: &str) -> Option<NodeId>
Removes a node and its subtree by path.
Returns the removed node’s ID if found.
Sourcepub fn iter_node_ids(&self) -> NodeDfsIter<'_> ⓘ
pub fn iter_node_ids(&self) -> NodeDfsIter<'_> ⓘ
Returns a depth-first iterator over all node IDs in the tree.
Sourcepub fn from_bytes(data: &[u8]) -> Result<Self, FdtError>
pub fn from_bytes(data: &[u8]) -> Result<Self, FdtError>
Parses an FDT from raw byte data.
Sourcepub unsafe fn from_ptr(ptr: *mut u8) -> Result<Self, FdtError>
pub unsafe fn from_ptr(ptr: *mut u8) -> Result<Self, FdtError>
Parses an FDT from a raw pointer.
§Safety
The caller must ensure that the pointer is valid and points to a valid FDT data structure.
Sourcepub fn get_by_path(&self, path: &str) -> Option<NodeType<'_>>
pub fn get_by_path(&self, path: &str) -> Option<NodeType<'_>>
Looks up a node by path and returns an immutable classified view.
Sourcepub fn get_by_path_mut(&mut self, path: &str) -> Option<NodeTypeMut<'_>>
pub fn get_by_path_mut(&mut self, path: &str) -> Option<NodeTypeMut<'_>>
Looks up a node by path and returns a mutable classified view.
Sourcepub fn get_by_phandle(&self, phandle: Phandle) -> Option<NodeType<'_>>
pub fn get_by_phandle(&self, phandle: Phandle) -> Option<NodeType<'_>>
Looks up a node by phandle and returns an immutable classified view.
Sourcepub fn get_by_phandle_mut(
&mut self,
phandle: Phandle,
) -> Option<NodeTypeMut<'_>>
pub fn get_by_phandle_mut( &mut self, phandle: Phandle, ) -> Option<NodeTypeMut<'_>>
Looks up a node by phandle and returns a mutable classified view.
Sourcepub fn all_nodes(&self) -> impl Iterator<Item = NodeType<'_>>
pub fn all_nodes(&self) -> impl Iterator<Item = NodeType<'_>>
Returns a depth-first iterator over classified NodeTypes.
pub fn root_mut(&mut self) -> NodeTypeMut<'_>
Sourcepub fn find_compatible(&self, compatible: &[&str]) -> Vec<NodeType<'_>>
pub fn find_compatible(&self, compatible: &[&str]) -> Vec<NodeType<'_>>
Finds nodes with matching compatible strings.
Source§impl Fdt
impl Fdt
Sourcepub fn view_typed(&self, id: NodeId) -> Option<NodeType<'_>>
pub fn view_typed(&self, id: NodeId) -> Option<NodeType<'_>>
Returns a classified NodeType for the given node ID.
Sourcepub fn view_typed_mut(&mut self, id: NodeId) -> Option<NodeTypeMut<'_>>
pub fn view_typed_mut(&mut self, id: NodeId) -> Option<NodeTypeMut<'_>>
Returns a classified NodeTypeMut for the given node ID.