From: Ard Biesheuvel <ardb@xxxxxxxxxx> Add handling of the QEMU provided DTB, which we will need to consult to find the DRAM layout and the fwcfg device. Initially, just dump the /chosen/bootargs only, if one is provided. --- Cargo.lock | 7 +++++++ Cargo.toml | 1 + src/main.rs | 10 ++++++++++ 3 files changed, 18 insertions(+) diff --git a/Cargo.lock b/Cargo.lock index 617acc9c6086..2750d4a3937c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -12,12 +12,19 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" name = "efilite" version = "0.1.0" dependencies = [ + "fdt", "linked_list_allocator", "log", "mmio", "rlibc", ] +[[package]] +name = "fdt" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b643857cf70949306b81d7e92cb9d47add673868edac9863c4a49c42feaf3f1e" + [[package]] name = "linked_list_allocator" version = "0.9.1" diff --git a/Cargo.toml b/Cargo.toml index 9bc2b39f6e9b..b073376d9e16 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,6 +10,7 @@ rlibc = "1.0.0" linked_list_allocator = "0.9.1" log = "0.4.14" mmio = "2.1.0" +fdt = "0.1.3" [profile.dev] panic = "abort" diff --git a/src/main.rs b/src/main.rs index 698e9c5724bf..6d880732b469 100644 --- a/src/main.rs +++ b/src/main.rs @@ -13,6 +13,10 @@ use log::{error, info}; #[global_allocator] pub static ALLOCATOR: LockedHeap = LockedHeap::empty(); +extern "C" { + static _dtb: u8; +} + #[no_mangle] extern "C" fn efilite_main(base: usize, mapped: usize, used: usize) { #[cfg(debug_assertions)] @@ -28,6 +32,12 @@ extern "C" fn efilite_main(base: usize, mapped: usize, used: usize) { unsafe { ALLOCATOR.lock().init(base + used, mapped - used); } + + let fdt = unsafe { fdt::Fdt::from_ptr(&_dtb).expect("Failed to parse device tree") }; + + fdt.chosen() + .bootargs() + .map(|args| info!("/chosen/bootargs: {:?}\n", args)); } #[no_mangle] -- 2.30.2