1extern crate flat_device_tree as fdt;
2
3static MY_FDT: &[u8] = include_bytes!("../dtb/test.dtb");
4
5fn main() {
6 let fdt = fdt::Fdt::new(MY_FDT).unwrap();
7
8 println!("This is a devicetree representation of a {}", fdt.root().unwrap().model());
9 println!(
10 "...which is compatible with at least: {}",
11 fdt.root().unwrap().compatible().first().unwrap()
12 );
13 println!("...and has {} CPU(s)", fdt.cpus().count());
14 println!(
15 "...and has at least one memory location at: {:#X}\n",
16 fdt.memory().unwrap().regions().next().unwrap().starting_address as usize
17 );
18
19 let chosen = fdt.chosen().unwrap();
20 if let Some(bootargs) = chosen.bootargs() {
21 println!("The bootargs are: {:?}", bootargs);
22 }
23
24 if let Some(stdout) = chosen.stdout() {
25 println!(
26 "It would write stdout to: {} with params: {:?}",
27 stdout.node().name,
28 stdout.params()
29 );
30 }
31
32 let soc = fdt.find_node("/soc");
33 println!("Does it have a `/soc` node? {}", if soc.is_some() { "yes" } else { "no" });
34 if let Some(soc) = soc {
35 println!("...and it has the following children:");
36 for child in soc.children() {
37 println!(" {}", child.name);
38 }
39 }
40}