Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch/powerpc implement pmap_wired_count(). fix some pla...
details: https://anonhg.NetBSD.org/src/rev/8919f7c7ffbd
branches: trunk
changeset: 572993:8919f7c7ffbd
user: chs <chs%NetBSD.org@localhost>
date: Sun Jan 16 21:35:58 2005 +0000
description:
implement pmap_wired_count(). fix some places we would forget to splx().
move the parts of pte.h that were used into pmap.c (since they were really
pmap-internal details) and delete ibm4xx/pte.h. other misc cleanup.
diffstat:
sys/arch/powerpc/ibm4xx/pmap.c | 148 ++++++++++++++------------------
sys/arch/powerpc/include/ibm4xx/pmap.h | 21 ++--
sys/arch/powerpc/include/ibm4xx/pte.h | 54 ------------
sys/arch/powerpc/include/pte.h | 4 +-
4 files changed, 76 insertions(+), 151 deletions(-)
diffs (truncated from 496 to 300 lines):
diff -r a8575d9359c6 -r 8919f7c7ffbd sys/arch/powerpc/ibm4xx/pmap.c
--- a/sys/arch/powerpc/ibm4xx/pmap.c Sun Jan 16 20:17:37 2005 +0000
+++ b/sys/arch/powerpc/ibm4xx/pmap.c Sun Jan 16 21:35:58 2005 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: pmap.c,v 1.29 2004/07/31 13:28:53 simonb Exp $ */
+/* $NetBSD: pmap.c,v 1.30 2005/01/16 21:35:58 chs Exp $ */
/*
* Copyright 2001 Wasabi Systems, Inc.
@@ -67,7 +67,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.29 2004/07/31 13:28:53 simonb Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.30 2005/01/16 21:35:58 chs Exp $");
#include <sys/param.h>
#include <sys/malloc.h>
@@ -146,7 +146,9 @@
#define PV_WIRED 0x1
#define PV_WIRE(pv) ((pv)->pv_va |= PV_WIRED)
-#define PV_CMPVA(va,pv) (!(((pv)->pv_va^(va))&(~PV_WIRED)))
+#define PV_UNWIRE(pv) ((pv)->pv_va &= ~PV_WIRED)
+#define PV_ISWIRED(pv) ((pv)->pv_va & PV_WIRED)
+#define PV_CMPVA(va,pv) (!(((pv)->pv_va ^ (va)) & (~PV_WIRED)))
struct pv_entry {
struct pv_entry *pv_next; /* Linked list of mappings */
@@ -167,9 +169,7 @@
static inline volatile u_int *pte_find(struct pmap *, vaddr_t);
static inline int pte_enter(struct pmap *, vaddr_t, u_int);
-static void pmap_pinit(pmap_t);
-static void pmap_release(pmap_t);
-static inline int pmap_enter_pv(struct pmap *, vaddr_t, paddr_t);
+static inline int pmap_enter_pv(struct pmap *, vaddr_t, paddr_t, boolean_t);
static void pmap_remove_pv(struct pmap *, vaddr_t, paddr_t);
@@ -207,7 +207,8 @@
if (!pm->pm_ptbl[seg]) {
/* Don't allocate a page to clear a non-existent mapping. */
- if (!pte) return (0);
+ if (!pte)
+ return (0);
/* Allocate a page XXXX this will sleep! */
pm->pm_ptbl[seg] =
(uint *)uvm_km_zalloc(kernel_map, PAGE_SIZE);
@@ -503,8 +504,7 @@
vaddr_t kbreak = VM_MIN_KERNEL_ADDRESS;
vaddr_t
-pmap_growkernel(maxkvaddr)
- vaddr_t maxkvaddr;
+pmap_growkernel(vaddr_t maxkvaddr)
{
int s;
int seg;
@@ -518,7 +518,8 @@
kbreak += PTMAP) {
seg = STIDX(kbreak);
- if (pte_find(pm, kbreak)) continue;
+ if (pte_find(pm, kbreak))
+ continue;
if (uvm.page_init_done) {
pg = (paddr_t)VM_PAGE_TO_PHYS(vm_page_alloc1());
@@ -542,9 +543,11 @@
* Allocate and return a memory cell with no associated object.
*/
struct vm_page *
-vm_page_alloc1()
+vm_page_alloc1(void)
{
- struct vm_page *pg = uvm_pagealloc(NULL, 0, NULL, UVM_PGA_USERESERVE);
+ struct vm_page *pg;
+
+ pg = uvm_pagealloc(NULL, 0, NULL, UVM_PGA_USERESERVE);
if (pg) {
pg->wire_count = 1; /* no mappings yet */
pg->flags &= ~PG_BUSY; /* never busy */
@@ -561,8 +564,7 @@
* Object and page must be locked prior to entry.
*/
void
-vm_page_free1(mem)
- struct vm_page *mem;
+vm_page_free1(struct vm_page *mem)
{
#ifdef DIAGNOSTIC
if (mem->flags != (PG_CLEAN|PG_FAKE)) {
@@ -588,29 +590,13 @@
{
struct pmap *pm;
- pm = (struct pmap *)malloc(sizeof *pm, M_VMPMAP, M_WAITOK);
- memset((caddr_t)pm, 0, sizeof *pm);
- pmap_pinit(pm);
+ pm = malloc(sizeof *pm, M_VMPMAP, M_WAITOK);
+ memset(pm, 0, sizeof *pm);
+ pm->pm_refs = 1;
return pm;
}
/*
- * Initialize a preallocated and zeroed pmap structure.
- */
-void
-pmap_pinit(struct pmap *pm)
-{
- int i;
-
- /*
- * Allocate some segment registers for this pmap.
- */
- pm->pm_refs = 1;
- for (i = 0; i < STSZ; i++)
- pm->pm_ptbl[i] = NULL;
-}
-
-/*
* Add a reference to the given pmap.
*/
void
@@ -627,29 +613,22 @@
void
pmap_destroy(struct pmap *pm)
{
-
- if (--pm->pm_refs == 0) {
- pmap_release(pm);
- free((caddr_t)pm, M_VMPMAP);
- }
-}
-
-/*
- * Release any resources held by the given physical map.
- * Called when a pmap initialized by pmap_pinit is being released.
- */
-static void
-pmap_release(struct pmap *pm)
-{
int i;
+ if (--pm->pm_refs > 0) {
+ return;
+ }
+ KASSERT(pm->pm_stats.resident_count == 0);
+ KASSERT(pm->pm_stats.wired_count == 0);
for (i = 0; i < STSZ; i++)
if (pm->pm_ptbl[i]) {
uvm_km_free(kernel_map, (vaddr_t)pm->pm_ptbl[i],
PAGE_SIZE);
pm->pm_ptbl[i] = NULL;
}
- if (pm->pm_ctx) ctx_free(pm);
+ if (pm->pm_ctx)
+ ctx_free(pm);
+ free(pm, M_VMPMAP);
}
/*
@@ -721,7 +700,7 @@
* This returns whether this is the first mapping of a page.
*/
static inline int
-pmap_enter_pv(struct pmap *pm, vaddr_t va, paddr_t pa)
+pmap_enter_pv(struct pmap *pm, vaddr_t va, paddr_t pa, boolean_t wired)
{
struct pv_entry *pv, *npv = NULL;
int s;
@@ -730,17 +709,7 @@
return 0;
s = splvm();
-
pv = pa_to_pv(pa);
-for (npv = pv; npv; npv = npv->pv_next)
-if (npv->pv_va == va && npv->pv_pm == pm) {
-printf("Duplicate pv: va %lx pm %p\n", va, pm);
-#ifdef DDB
-Debugger();
-#endif
-return (1);
-}
-
if (!pv->pv_pm) {
/*
* No entries yet, use header as the first entry.
@@ -754,12 +723,14 @@
* Place this entry after the header.
*/
npv = pool_get(&pv_pool, PR_WAITOK);
- if (!npv) return (0);
npv->pv_va = va;
npv->pv_pm = pm;
npv->pv_next = pv->pv_next;
pv->pv_next = npv;
}
+ if (wired) {
+ PV_WIRE(pv);
+ }
splx(s);
return (1);
}
@@ -773,7 +744,8 @@
* Remove from the PV table.
*/
pv = pa_to_pv(pa);
- if (!pv) return;
+ if (!pv)
+ return;
/*
* If it is the first entry on the list, it is actually
@@ -782,6 +754,9 @@
* the entry. In either case we free the now unused entry.
*/
if (pm == pv->pv_pm && PV_CMPVA(va, pv)) {
+ if (PV_ISWIRED(pv)) {
+ pm->pm_stats.wired_count--;
+ }
if ((npv = pv->pv_next)) {
*pv = *npv;
pool_put(&pv_pool, npv);
@@ -793,6 +768,9 @@
break;
if (npv) {
pv->pv_next = npv->pv_next;
+ if (PV_ISWIRED(npv)) {
+ pm->pm_stats.wired_count--;
+ }
pool_put(&pv_pool, npv);
}
}
@@ -813,11 +791,8 @@
*/
pmap_remove(pm, va, va + PAGE_SIZE);
- if (flags & PMAP_WIRED) flags |= prot;
-
- /* If it has no protections don't bother w/the rest */
- if (!(flags & VM_PROT_ALL))
- return (0);
+ if (flags & PMAP_WIRED)
+ flags |= prot;
managed = 0;
if (vm_physseg_find(atop(pa), NULL) != -1)
@@ -861,7 +836,7 @@
if (pmap_initialized && managed) {
char *attr;
- if (!pmap_enter_pv(pm, va, pa)) {
+ if (!pmap_enter_pv(pm, va, pa, flags & PMAP_WIRED)) {
/* Could not enter pv on a managed page */
return 1;
}
@@ -873,9 +848,9 @@
panic("managed but no attr");
#endif
if (flags & VM_PROT_ALL)
- *attr |= PTE_HI_REF;
+ *attr |= PMAP_ATTR_REF;
if (flags & VM_PROT_WRITE)
- *attr |= PTE_HI_CHG;
+ *attr |= PMAP_ATTR_CHG;
}
s = splvm();
@@ -893,6 +868,9 @@
if ((prot & VM_PROT_EXECUTE) && (tte & TTE_I) == 0)
__syncicache((void *)pa, PAGE_SIZE);
+ if (flags & PMAP_WIRED)
+ pm->pm_stats.wired_count++;
+
return 0;
}
@@ -901,20 +879,15 @@
{
struct pv_entry *pv, *npv;
paddr_t pa;
- int s = splvm();
-
- if (pm == NULL) {
- return;
- }
+ int s;
if (!pmap_extract(pm, va, &pa)) {
return;
}
- va |= PV_WIRED;
-
Home |
Main Index |
Thread Index |
Old Index