From 83531ed09ee3d14363ee7d404fff059279e0473a Mon Sep 17 00:00:00 2001 From: Thomas Barrett Date: Mon, 19 Aug 2024 22:56:44 +0000 Subject: [PATCH] fdt: enumerate all memory nodes present It is possible for the device tree to have multiple memory nodes. Iterate through all regions defined by all memory nodes. Signed-off-by: Thomas Barrett --- src/fdt.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/fdt.rs b/src/fdt.rs index b823c555..00d485d0 100644 --- a/src/fdt.rs +++ b/src/fdt.rs @@ -78,11 +78,15 @@ impl Info for StartInfo<'_> { } fn num_entries(&self) -> usize { - self.fdt.memory().regions().count() + let nodes = self.fdt.find_all_nodes("/memory"); + let regions = nodes.flat_map(|n| n.reg().unwrap()); + regions.count() } fn entry(&self, idx: usize) -> MemoryEntry { - for (i, region) in self.fdt.memory().regions().enumerate() { + let nodes = self.fdt.find_all_nodes("/memory"); + let regions = nodes.flat_map(|n| n.reg().unwrap()); + for (i, region) in regions.enumerate() { if i == idx { return MemoryEntry { addr: region.starting_address as u64,