Subject: Pmap tweaks (was Re: pmap tweaking)
To: Chris Gilbert <chris@paradox.demon.co.uk>
From: John Fremlin <vii@users.sourceforge.net>
List: port-arm32
Date: 06/02/2001 17:36:04
--=-=-=

Hi Chris,

I had a look at pmap a day or so ago while I was trying to figure out
why my port was dying in pmap_bootstrap, and changed a few things

        (1) When I ripped out my added printfs I also changed all the
        MYCROFT_HACK stuff into PDEBUG(10,...)
        
        (2) msgbufpte is not used anywhere, and can be removed.
        
        (3) Cleaned up lots of panic strings with \n at the end.

Here is the patch


--=-=-=
Content-Type: text/x-patch
Content-Disposition: attachment;
  filename=netbsd-20010601-pmap-cleanup.patch

Index: pmap.c
===================================================================
RCS file: /pub/NetBSD-CVS/syssrc/sys/arch/arm/arm32/pmap.c,v
retrieving revision 1.9
diff -u -r1.9 pmap.c
--- pmap.c	2001/05/26 21:27:04	1.9
+++ pmap.c	2001/06/02 16:30:20
@@ -128,7 +128,6 @@
 pagehook_t page_hook0;
 pagehook_t page_hook1;
 char *memhook;
-pt_entry_t msgbufpte;
 extern caddr_t msgbufaddr;
 
 #ifdef DIAGNOSTIC
@@ -188,10 +187,6 @@
 static __inline void pmap_map_in_l1 __P((pmap_t pmap, vaddr_t va,
      vaddr_t l2pa));
 
-#ifdef MYCROFT_HACK
-int mycroft_hack = 0;
-#endif
-
 /* Function to set the debug level of the pmap code */
 
 #ifdef PMAP_DEBUG
@@ -705,6 +700,7 @@
 	while (loop < bootconfig.dramblocks) {
 		start = (paddr_t)bootconfig.dram[loop].address;
 		end = start + (bootconfig.dram[loop].pages * NBPG);
+
 		if (start < physical_freestart)
 			start = physical_freestart;
 		if (end > physical_freeend)
@@ -772,9 +768,7 @@
 		++loop;
 	}
 
-#ifdef MYCROFT_HACK
-	printf("npages = %ld\n", npages);
-#endif
+	PDEBUG(10, printf("npages = %ld\n", npages));
 
 	virtual_start = KERNEL_VM_BASE;
 	virtual_end = virtual_start + KERNEL_VM_SIZE - 1;
@@ -790,11 +784,11 @@
 	virtual_start += NBPG;
 
 	msgbufaddr = (caddr_t)virtual_start;
-	msgbufpte = (pt_entry_t)pmap_pte(kernel_pmap, virtual_start);
 	virtual_start += round_page(MSGBUFSIZE);
 
 	size = npages * sizeof(struct pv_entry);
 	boot_pvent = (struct pv_entry *)uvm_pageboot_alloc(size);
+
 	bzero(boot_pvent, size);
 	size = npages * sizeof(char);
 	boot_attrs = (char *)uvm_pageboot_alloc(size);
@@ -817,11 +811,9 @@
 pmap_init()
 {
 	int lcv;
-    
-#ifdef MYCROFT_HACK
-	printf("physmem = %d\n", physmem);
-#endif
 
+	PDEBUG(10, printf("physmem = %d\n", physmem));
+
 	/*
 	 * Set the available memory vars - These do not map to real memory
 	 * addresses and cannot as the physical memory is fragmented.
@@ -886,7 +878,7 @@
 		/* Allocate a L1 page table */
 		pt = pmap_alloc_l1pt();
 		if (!pt)
-			panic("Cannot allocate static L1 page tables\n");
+			panic("Cannot allocate static L1 page tables");
 
 		/* Clean it */
 		bzero((void *)pt->pt_va, PD_SIZE);
@@ -948,7 +940,7 @@
 	va = uvm_km_valloc(kernel_map, PD_SIZE);
 	if (va == 0) {
 #ifdef DIAGNOSTIC
-		printf("pmap: Cannot allocate pageable memory for L1\n");
+		printf("pmap: Cannot allocate pageable memory for L1");
 #endif	/* DIAGNOSTIC */
 		return(NULL);
 	}
@@ -994,7 +986,7 @@
 
 #ifdef DIAGNOSTIC
 	if (m)
-		panic("pmap_alloc_l1pt: pglist not empty\n");
+		panic("pmap_alloc_l1pt: pglist not empty");
 #endif	/* DIAGNOSTIC */
 
 	pt->pt_flags = 0;
@@ -1084,7 +1076,7 @@
 #ifdef DIAGNOSTIC
 	if (pmap->pm_vptpt) {
 		/* XXX What if we have one already ? */
-		panic("pmap_allocpagedir: have pt already\n");
+		panic("pmap_allocpagedir: have pt already");
 	}
 #endif	/* DIAGNOSTIC */
 	pmap->pm_vptpt = uvm_km_zalloc(kernel_map, NBPG);
@@ -1401,7 +1393,7 @@
 #endif
 
 	if ((bank = vm_physseg_find(atop(phys), &off)) == -1)
-		panic("pmap_find_pv: not a real page, phys=%lx\n", phys);
+		panic("pmap_find_pv: not a real page, phys=%lx", phys);
 	pv = &vm_physmem[bank].pmseg.pvent[off];
 	return (pv);
 }
@@ -2073,6 +2065,7 @@
 
 	/* Is the pte valid ? If so then this page is already mapped */
 	if (pmap_pte_v(pte)) {
+
 		/* Get the physical address of the current page mapped */
 		opa = pmap_pte_pa(pte);
 
@@ -2094,11 +2087,12 @@
  			}
 		} else {
 			/* We are replacing the page with a new one. */
-			cpu_cache_purgeID_rng(va, NBPG);
-
 			PDEBUG(0, printf("Case 03 in pmap_enter (V%08lx P%08lx P%08lx)\n",
 			    va, pa, opa));
 
+			cpu_cache_purgeID_rng(va, NBPG);
+
+
 			/*
 			 * If it is part of our managed memory then we
 			 * must remove it from the PV list
@@ -2118,20 +2112,20 @@
 		++pmap->pm_stats.resident_count;
 
 	enter:
-		/*
+
+                /*
 		 * Enter on the PV list if part of our managed memory
 		 */
 		if ((bank = vm_physseg_find(atop(pa), &off)) != -1) {
 			pv = &vm_physmem[bank].pmseg.pvent[off];
+
 			pmap_enter_pv(pmap, va, pv, nflags);
 		}
 	}
 
-#ifdef MYCROFT_HACK
-	if (mycroft_hack)
-		printf("pmap_enter: pmap=%p va=%lx pa=%lx opa=%lx bank=%d off=%d pv=%p\n", pmap, va, pa, opa, bank, off, pv);
-#endif
 
+	PDEBUG(10, printf("pmap_enter: pmap=%p va=%lx pa=%lx opa=%lx bank=%d off=%d pv=%p\n", pmap, va, pa, opa, bank, off, pv));
+
 	/* Construct the pte, giving the correct access. */
 	npte = (pa & PG_FRAME);
 
@@ -2162,10 +2156,7 @@
 			npte |= L2_INVAL;
 	}
 
-#ifdef MYCROFT_HACK
-	if (mycroft_hack)
-		printf("pmap_enter: pmap=%p va=%lx pa=%lx prot=%x wired=%d access_type=%x npte=%08x\n", pmap, va, pa, prot, wired, flags & VM_PROT_ALL, npte);
-#endif
+	PDEBUG(10, printf("pmap_enter: pmap=%p va=%lx pa=%lx prot=%x wired=%d access_type=%x npte=%08x\n", pmap, va, pa, prot, wired, flags & VM_PROT_ALL, npte));
 
 	*pte = npte;
 
@@ -2354,7 +2345,7 @@
 			    (PROCESS_PAGE_TBLS_BASE >> PDSHIFT))) &
 			    PG_FRAME));
 			printf("pptpt=%lx\n", p->p_vmspace->vm_map.pmap->pm_pptpt);
-			panic("pmap_pte: current and pmap mismatch\n");
+			panic("pmap_pte: current and pmap mismatch");
 		}
 #endif
 

--=-=-=


-- 

	http://ape.n3.net

--=-=-=--