fdt_parser/
chosen.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
use crate::node::Node;

pub struct Chosen<'a> {
    node: Node<'a>,
}

impl<'a> Chosen<'a> {
    pub fn new(node: Node<'a>) -> Self {
        Chosen { node }
    }

    /// Contains the bootargs, if they exist
    pub fn bootargs(&self) -> Option<&'a str> {
        self.node.find_property("bootargs").map(|p| p.str())
    }

    /// Searches for the node representing `stdout`, if the property exists,
    /// attempting to resolve aliases if the node name doesn't exist as-is
    pub fn stdout(&self) -> Option<Stdout<'a>> {
        let path = self.node.find_property("stdout-path")?.str();
        let mut sp = path.split(':');
        let name = sp.next()?;
        let params = sp.next();
        let node = self.node.fdt.find_nodes(name).next()?;
        Some(Stdout { params, node })
    }
}

pub struct Stdout<'a> {
    pub params: Option<&'a str>,
    pub node: Node<'a>,
}