Skip to content

Commit

Permalink
fdt: enumerate all memory nodes present
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
Thomas Barrett committed Aug 19, 2024
1 parent 4c33124 commit 83531ed
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/fdt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 83531ed

Please sign in to comment.