From 0181436094935fc6fbb4fffe15873277c58dd0d7 Mon Sep 17 00:00:00 2001 From: jsg Date: Tue, 12 May 2015 04:31:10 +0000 Subject: [PATCH] Raise VM_PHYSSEG_MAX to two and load an additional physical memory segment if u-boot reports it. Needed for the utilite where u-boot reports two 1GB segments of physical memory. From Patrick Wildt in bitrig with some additional sanity checks added. --- sys/arch/armv7/armv7/armv7_machdep.c | 16 +++++++++++++--- sys/arch/armv7/include/vmparam.h | 4 ++-- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/sys/arch/armv7/armv7/armv7_machdep.c b/sys/arch/armv7/armv7/armv7_machdep.c index 5a85498b6a6..7857212b438 100644 --- a/sys/arch/armv7/armv7/armv7_machdep.c +++ b/sys/arch/armv7/armv7/armv7_machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: armv7_machdep.c,v 1.20 2015/05/10 15:56:28 jsg Exp $ */ +/* $OpenBSD: armv7_machdep.c,v 1.21 2015/05/12 04:31:10 jsg Exp $ */ /* $NetBSD: lubbock_machdep.c,v 1.2 2003/07/15 00:25:06 lukem Exp $ */ /* @@ -383,8 +383,7 @@ copy_io_area_map(pd_entry_t *new_pd) u_int initarm(void *arg0, void *arg1, void *arg2) { - int loop; - int loop1; + int loop, loop1, i, physsegs; u_int l1pagetable; pv_addr_t kernel_l1pt; paddr_t memstart; @@ -723,6 +722,17 @@ initarm(void *arg0, void *arg1, void *arg2) uvm_page_physload(atop(physical_freestart), atop(physical_freeend), atop(physical_freestart), atop(physical_freeend), 0); + physsegs = MIN(bootconfig.dramblocks, VM_PHYSSEG_MAX); + + for (i = 1; i < physsegs; i++) { + paddr_t dramstart = bootconfig.dram[i].address; + paddr_t dramend = MIN((uint64_t)dramstart + + bootconfig.dram[i].pages * PAGE_SIZE, (paddr_t)-PAGE_SIZE); + physmem += (dramend - dramstart) / PAGE_SIZE; + uvm_page_physload(atop(dramstart), atop(dramend), + atop(dramstart), atop(dramend), 0); + } + /* Boot strap pmap telling it where the kernel page table is */ #ifdef VERBOSE_INIT_ARM printf("pmap "); diff --git a/sys/arch/armv7/include/vmparam.h b/sys/arch/armv7/include/vmparam.h index a6fee2b8d4a..cc3f6e6c382 100644 --- a/sys/arch/armv7/include/vmparam.h +++ b/sys/arch/armv7/include/vmparam.h @@ -1,4 +1,4 @@ -/* $OpenBSD: vmparam.h,v 1.2 2015/05/10 15:56:28 jsg Exp $ */ +/* $OpenBSD: vmparam.h,v 1.3 2015/05/12 04:31:10 jsg Exp $ */ /* $NetBSD: vmparam.h,v 1.23 2003/05/22 05:47:07 thorpej Exp $ */ /* @@ -77,7 +77,7 @@ * max number of non-contig chunks of physical RAM you can have */ -#define VM_PHYSSEG_MAX 1 +#define VM_PHYSSEG_MAX 2 #define VM_PHYSSEG_STRAT VM_PSTRAT_RANDOM /* -- 2.20.1