From ed522fedd4944ad56dd38ceac0d926c1c92b970f Mon Sep 17 00:00:00 2001 From: br Date: Wed, 17 Dec 2014 09:34:54 +0000 Subject: [PATCH] Use memory regions information provided in FDT. Reviewed by: brooks Sponsored by: DARPA, AFRL --- sys/mips/beri/beri_machdep.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/sys/mips/beri/beri_machdep.c b/sys/mips/beri/beri_machdep.c index deda11968f72..714ee3d583e4 100644 --- a/sys/mips/beri/beri_machdep.c +++ b/sys/mips/beri/beri_machdep.c @@ -88,6 +88,11 @@ static void mips_init(void) { int i; +#ifdef FDT + struct mem_region mr[FDT_MEM_REGIONS]; + int mr_cnt, val; + int j; +#endif for (i = 0; i < 10; i++) { phys_avail[i] = 0; @@ -102,6 +107,29 @@ mips_init(void) physmem = realmem; +#ifdef FDT + if (fdt_get_mem_regions(mr, &mr_cnt, &val) == 0) { + + physmem = btoc(val); + + KASSERT((phys_avail[0] >= mr[0].mr_start) && \ + (phys_avail[0] < (mr[0].mr_start + mr[0].mr_size)), + ("First region is not within FDT memory range")); + + /* Limit size of the first region */ + phys_avail[1] = MIN(mr[0].mr_size, ctob(realmem)); + dump_avail[1] = phys_avail[1]; + + /* Add the rest of regions */ + for (i = 1, j = 2; i < mr_cnt; i++, j+=2) { + phys_avail[j] = mr[i].mr_start; + phys_avail[j+1] = mr[i].mr_size; + dump_avail[j] = phys_avail[j]; + dump_avail[j+1] = phys_avail[j+1]; + } + } +#endif + init_param1(); init_param2(physmem); mips_cpu_init();