@@ -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"
@@ -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"
@@ -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]
From: Ard Biesheuvel <ardb@google.com> 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(+)