Skip to content

Commit 83531ed

Browse files
author
Thomas Barrett
committed
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 <tbarrett@crusoe.ai>
1 parent 4c33124 commit 83531ed

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/fdt.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,11 +78,15 @@ impl Info for StartInfo<'_> {
7878
}
7979

8080
fn num_entries(&self) -> usize {
81-
self.fdt.memory().regions().count()
81+
let nodes = self.fdt.find_all_nodes("/memory");
82+
let regions = nodes.flat_map(|n| n.reg().unwrap());
83+
regions.count()
8284
}
8385

8486
fn entry(&self, idx: usize) -> MemoryEntry {
85-
for (i, region) in self.fdt.memory().regions().enumerate() {
87+
let nodes = self.fdt.find_all_nodes("/memory");
88+
let regions = nodes.flat_map(|n| n.reg().unwrap());
89+
for (i, region) in regions.enumerate() {
8690
if i == idx {
8791
return MemoryEntry {
8892
addr: region.starting_address as u64,

0 commit comments

Comments
 (0)