basic_info.rs 1.1 KB

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