Module Name:    src
Committed By:   matt
Date:           Wed Oct 17 18:53:45 UTC 2012

Modified Files:
        src/sys/arch/arm/arm32: arm32_boot.c

Log Message:
Change the semantics of the boot_physmem array to select a freelist to use
with uvm_page_physload.  Reduces duplication of work.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/arm/arm32/arm32_boot.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/arm/arm32/arm32_boot.c
diff -u src/sys/arch/arm/arm32/arm32_boot.c:1.1 src/sys/arch/arm/arm32/arm32_boot.c:1.2
--- src/sys/arch/arm/arm32/arm32_boot.c:1.1	Fri Aug 31 23:59:51 2012
+++ src/sys/arch/arm/arm32/arm32_boot.c	Wed Oct 17 18:53:45 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: arm32_boot.c,v 1.1 2012/08/31 23:59:51 matt Exp $	*/
+/*	$NetBSD: arm32_boot.c,v 1.2 2012/10/17 18:53:45 matt Exp $	*/
 
 /*
  * Copyright (c) 2002, 2003, 2005  Genetec Corporation.  All rights reserved.
@@ -123,7 +123,7 @@
 
 #include <sys/cdefs.h>
 
-__KERNEL_RCSID(1, "$NetBSD: arm32_boot.c,v 1.1 2012/08/31 23:59:51 matt Exp $");
+__KERNEL_RCSID(1, "$NetBSD: arm32_boot.c,v 1.2 2012/10/17 18:53:45 matt Exp $");
 
 #include <sys/param.h>
 #include <sys/reboot.h>
@@ -215,27 +215,42 @@ initarm_common(vaddr_t kvm_base, vsize_t
 #ifdef VERBOSE_INIT_ARM
 	printf("pmap_physload ");
 #endif
+	KASSERT(bp != NULL || nbp == 0);
+	KASSERT(bp == NULL || nbp != 0);
 
-	if (bp == NULL) {
-		KASSERT(nbp == 0);
-		for (size_t i = 0; i < bmi->bmi_nfreeblocks; i++) {
-			pv_addr_t * const pv = &bmi->bmi_freeblocks[i];
-			const paddr_t start = atop(pv->pv_pa);
-			const paddr_t end = start + atop(pv->pv_size);
-
-			uvm_page_physload(start, end, start, end,
-			    VM_FREELIST_DEFAULT);
-		}
-	}
-
-	for (; nbp-- > 0; bp++) {
-		const paddr_t start = bp->bp_start;
-		const paddr_t end = start + bp->bp_pages;
-
-		if (start < end) {
-			KASSERT(bp->bp_freelist < VM_NFREELIST);
-			uvm_page_physload(start, end, start, end,
-			    bp->bp_freelist);
+	for (size_t i = 0; i < bmi->bmi_nfreeblocks; i++) {
+		pv_addr_t * const pv = &bmi->bmi_freeblocks[i];
+		paddr_t start = atop(pv->pv_pa);
+		const paddr_t end = start + atop(pv->pv_size);
+
+		while (start < end) {
+			int vm_freelist = VM_FREELIST_DEFAULT;
+			paddr_t segend = end;
+			/*
+			 * This assumes the bp list is sorted in ascending
+			 * order.
+			 */
+			for (size_t j = 0; j < nbp; j++) {
+				paddr_t bp_start = bp[j].bp_start;
+				paddr_t bp_end = bp_start + bp[j].bp_pages;
+				if (start < bp_start) {
+					if (segend > bp_start) {
+						segend = bp_start;
+					}
+					break;
+				}
+				if (start < bp_end) {
+					if (segend > bp_end) {
+						segend = bp_end;
+					}
+					vm_freelist = bp[j].bp_freelist;
+					break;
+				}
+			}
+	
+			uvm_page_physload(start, segend, start, segend,
+			    vm_freelist);
+			start = segend;
 		}
 	}
 

Reply via email to