diff options
Diffstat (limited to 'sys/riscv')
-rw-r--r-- | sys/riscv/riscv/machdep.c | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/sys/riscv/riscv/machdep.c b/sys/riscv/riscv/machdep.c index 399be20..6fcf4a0 100644 --- a/sys/riscv/riscv/machdep.c +++ b/sys/riscv/riscv/machdep.c @@ -729,9 +729,13 @@ fake_preload_metadata(struct riscv_bootparams *rvbp __unused) void initriscv(struct riscv_bootparams *rvbp) { + struct mem_region mem_regions[FDT_MEM_REGIONS]; vm_offset_t lastaddr; + int mem_regions_sz; vm_size_t kernlen; + uint32_t memsize; caddr_t kmdp; + int i; /* Set the module data location */ lastaddr = fake_preload_metadata(rvbp); @@ -752,11 +756,12 @@ initriscv(struct riscv_bootparams *rvbp) /* Load the physical memory ranges */ physmap_idx = 0; - /* - * RISCVTODO: figure out whether platform provides ranges, - * or grab from FDT. - */ - add_physmap_entry(0, 0x8000000, physmap, &physmap_idx); + /* Grab physical memory regions information from device tree. */ + if (fdt_get_mem_regions(mem_regions, &mem_regions_sz, &memsize) != 0) + panic("Cannot get physical memory regions"); + for (i = 0; i < mem_regions_sz; i++) + add_physmap_entry(mem_regions[i].mr_start, + mem_regions[i].mr_size, physmap, &physmap_idx); /* Set the pcpu data, this is needed by pmap_bootstrap */ pcpup = &__pcpu[0]; |