-/* $OpenBSD: pmap.c,v 1.2 1996/12/28 06:22:14 rahnds Exp $ */
+/* $OpenBSD: pmap.c,v 1.3 1997/01/09 03:07:16 rahnds Exp $ */
/* $NetBSD: pmap.c,v 1.1 1996/09/30 16:34:52 ws Exp $ */
/*
}
static void
-pmap_remove_pv(pteidx, va, pind, pte)
+pmap_remove_pv(pm, pteidx, va, pind, pte)
+ struct pmap *pm;
int pteidx;
vm_offset_t va;
int pind;
if (npv) {
*pv = *npv;
pmap_free_pv(npv);
- } else
+ } else {
pv->pv_idx = -1;
+ }
+ if (pm != NULL) {
+ /* if called from pmap_page_protect,
+ * we don't know what pmap it was removed from.
+ * BAD DESIGN.
+ */
+ pm->pm_stats.resident_count--;
+ }
} else {
for (; npv = pv->pv_next; pv = npv)
if (pteidx == npv->pv_idx && va == npv->pv_va)
if (npv) {
pv->pv_next = npv->pv_next;
pmap_free_pv(npv);
+ if (pm != NULL) {
+ pm->pm_stats.resident_count--;
+ }
}
#ifdef DIAGNOSTIC
else
* Have to remove any existing mapping first.
*/
pmap_remove(pm, va, va + NBPG - 1);
+
+ pm->pm_stats.resident_count++;
/*
* Compute the HTAB index.
idx = pteidx(sr = ptesr(pm->pm_sr, va), va);
for (ptp = ptable + idx * 8, i = 8; --i >= 0; ptp++)
if (ptematch(ptp, sr, va, PTE_VALID)) {
- pmap_remove_pv(idx, va, pmap_page_index(ptp->pte_lo), ptp);
+ pmap_remove_pv(pm, idx, va,
+ pmap_page_index(ptp->pte_lo), ptp);
ptp->pte_hi &= ~PTE_VALID;
asm volatile ("sync");
tlbie(va);
}
for (ptp = ptable + (idx ^ ptab_mask) * 8, i = 8; --i >= 0; ptp++)
if (ptematch(ptp, sr, va, PTE_VALID | PTE_HID)) {
- pmap_remove_pv(idx, va, pmap_page_index(ptp->pte_lo), ptp);
+ pmap_remove_pv(pm, idx, va,
+ pmap_page_index(ptp->pte_lo), ptp);
ptp->pte_hi &= ~PTE_VALID;
asm volatile ("sync");
tlbie(va);
for (po = potable[idx].lh_first; po; po = npo) {
npo = po->po_list.le_next;
if (ptematch(&po->po_pte, sr, va, 0)) {
- pmap_remove_pv(idx, va, pmap_page_index(po->po_pte.pte_lo),
+ pmap_remove_pv(pm, idx, va,
+ pmap_page_index(po->po_pte.pte_lo),
&po->po_pte);
LIST_REMOVE(po, po_list);
pofree(po, 1);
for (ptp = ptable + idx * 8, i = 8; --i >= 0; ptp++)
if ((ptp->pte_hi & PTE_VALID)
&& (ptp->pte_lo & PTE_RPGN) == pa) {
- pmap_remove_pv(idx, va, pind, ptp);
+ pmap_remove_pv(NULL, idx, va, pind, ptp);
ptp->pte_hi &= ~PTE_VALID;
asm volatile ("sync");
tlbie(va);
for (ptp = ptable + (idx ^ ptab_mask) * 8, i = 8; --i >= 0; ptp++)
if ((ptp->pte_hi & PTE_VALID)
&& (ptp->pte_lo & PTE_RPGN) == pa) {
- pmap_remove_pv(idx, va, pind, ptp);
+ pmap_remove_pv(NULL, idx, va, pind, ptp);
ptp->pte_hi &= ~PTE_VALID;
asm volatile ("sync");
tlbie(va);
for (po = potable[idx].lh_first; po; po = npo) {
npo = po->po_list.le_next;
if ((po->po_pte.pte_lo & PTE_RPGN) == pa) {
- pmap_remove_pv(idx, va, pind, &po->po_pte);
+ pmap_remove_pv(NULL,idx, va, pind, &po->po_pte);
LIST_REMOVE(po, po_list);
pofree(po, 1);
}