Context

Struct Context 

Source
pub struct Context<'a> {
    pub parents: Vec<&'a Node>,
    pub phandle_map: BTreeMap<Phandle, &'a Node>,
}
Expand description

遍历上下文,存储从根到当前节点的父节点引用栈

Fields§

§parents: Vec<&'a Node>

父节点引用栈(从根节点到当前节点的父节点) 栈底是根节点,栈顶是当前节点的直接父节点

§phandle_map: BTreeMap<Phandle, &'a Node>

phandle 到节点引用的映射 用于通过 phandle 快速查找节点(如中断父节点)

Implementations§

Source§

impl<'a> Context<'a>

Source

pub fn new() -> Self

创建新的上下文

Source

pub fn current_path(&self) -> String

Source

pub fn for_root() -> Self

创建用于根节点的上下文

Source

pub fn depth(&self) -> usize

获取当前深度(父节点数量 + 1)

Source

pub fn parent(&self) -> Option<&'a Node>

获取直接父节点

Source

pub fn parent_address_cells(&self) -> u32

获取父节点的 #address-cells 优先从直接父节点获取,否则返回默认值 2

Source

pub fn parent_size_cells(&self) -> u32

获取父节点的 #size-cells 优先从直接父节点获取,否则返回默认值 1

Source

pub fn interrupt_parent(&self) -> Option<Phandle>

查找中断父节点 phandle 从当前父节点向上查找,返回最近的 interrupt-parent

Source

pub fn is_disabled(&self) -> bool

检查节点是否被禁用 检查父节点栈中是否有任何节点被禁用

Source

pub fn collect_ranges(&self) -> Vec<Vec<RangesEntry>>

解析当前路径上所有父节点的 ranges,用于地址转换 返回从根到父节点的 ranges 栈

Source

pub fn current_ranges(&self) -> Option<Vec<RangesEntry>>

获取最近一层的 ranges(用于当前节点的地址转换)

Source

pub fn push(&mut self, node: &'a Node)

Source

pub fn find_by_phandle(&self, phandle: Phandle) -> Option<&'a Node>

通过 phandle 查找节点

Source

pub fn build_phandle_map_from_node( node: &'a Node, map: &mut BTreeMap<Phandle, &'a Node>, )

从 Fdt 构建 phandle 映射

Trait Implementations§

Source§

impl<'a> Clone for Context<'a>

Source§

fn clone(&self) -> Context<'a>

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<'a> Default for Context<'a>

Source§

fn default() -> Context<'a>

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl<'a> Freeze for Context<'a>

§

impl<'a> RefUnwindSafe for Context<'a>

§

impl<'a> Send for Context<'a>

§

impl<'a> Sync for Context<'a>

§

impl<'a> Unpin for Context<'a>

§

impl<'a> UnwindSafe for Context<'a>

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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

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

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.