Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch/mvme68k/mvme68k Apply pmap_k{enter_pa, remove} patch...
details: https://anonhg.NetBSD.org/src/rev/9daacf74d876
branches: trunk
changeset: 513093:9daacf74d876
user: scw <scw%NetBSD.org@localhost>
date: Mon Jul 23 20:34:00 2001 +0000
description:
Apply pmap_k{enter_pa,remove} patches provided by Chuck Silvers.
diffstat:
sys/arch/mvme68k/mvme68k/pmap.c | 102 +++++++++++++++------------------------
1 files changed, 40 insertions(+), 62 deletions(-)
diffs (276 lines):
diff -r ce4b83b1fb88 -r 9daacf74d876 sys/arch/mvme68k/mvme68k/pmap.c
--- a/sys/arch/mvme68k/mvme68k/pmap.c Mon Jul 23 20:14:36 2001 +0000
+++ b/sys/arch/mvme68k/mvme68k/pmap.c Mon Jul 23 20:34:00 2001 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: pmap.c,v 1.64 2001/07/18 17:18:53 scw Exp $ */
+/* $NetBSD: pmap.c,v 1.65 2001/07/23 20:34:00 scw Exp $ */
/*-
* Copyright (c) 1999 The NetBSD Foundation, Inc.
@@ -485,7 +485,7 @@
s = ptoa(npages);
addr2 = addr + s;
kpt_pages = &((struct kpt_page *)addr2)[npages];
- kpt_free_list = (struct kpt_page *) 0;
+ kpt_free_list = NULL;
do {
addr2 -= NBPG;
(--kpt_pages)->kpt_next = kpt_free_list;
@@ -797,9 +797,6 @@
{
int count;
- if (pmap == NULL)
- return;
-
PMAP_DPRINTF(PDB_FOLLOW, ("pmap_destroy(%p)\n", pmap));
simple_lock(&pmap->pm_lock);
@@ -849,10 +846,6 @@
pmap_reference(pmap)
pmap_t pmap;
{
-
- if (pmap == NULL)
- return;
-
PMAP_DPRINTF(PDB_FOLLOW, ("pmap_reference(%p)\n", pmap));
simple_lock(&pmap->pm_lock);
@@ -929,9 +922,6 @@
PMAP_DPRINTF(PDB_FOLLOW|PDB_REMOVE|PDB_PROTECT,
("pmap_remove(%p, %lx, %lx)\n", pmap, sva, eva));
- if (pmap == NULL)
- return;
-
flags = active_pmap(pmap) ? PRM_TFLUSH : 0;
while (sva < eva) {
nssva = m68k_trunc_seg(sva) + NBSEG;
@@ -1044,9 +1034,6 @@
("pmap_protect(%p, %lx, %lx, %x)\n",
pmap, sva, eva, prot));
- if (pmap == NULL)
- return;
-
#ifdef PMAPSTATS
protect_stats.calls++;
#endif
@@ -1054,9 +1041,6 @@
pmap_remove(pmap, sva, eva);
return;
}
- if (prot & VM_PROT_WRITE)
- return;
-
isro = pte_prot(pmap, prot);
needtflush = active_pmap(pmap);
firstpage = TRUE;
@@ -1356,30 +1340,39 @@
{
pmap_t pmap = pmap_kernel();
pt_entry_t *pte;
- int npte;
+ int s, npte;
PMAP_DPRINTF(PDB_FOLLOW|PDB_ENTER,
("pmap_kenter_pa(%lx, %lx, %x)\n", va, pa, prot));
-#ifdef DIAGNOSTIC
- /*
- * pmap_kenter() should never be used for CADDR1 and CADDR2.
- */
- if (va == (vaddr_t)CADDR1 || va == (vaddr_t)CADDR2)
- panic("pmap_kenter_pa: used for CADDR1 or CADDR2");
-#endif
-
/*
* Segment table entry not valid, we need a new PT page
*/
- if (!pmap_ste_v(pmap, va))
+
+ if (!pmap_ste_v(pmap, va)) {
+ s = splvm();
pmap_enter_ptpage(pmap, va);
+ splx(s);
+ }
+
+ pa = m68k_trunc_page(pa);
+ pte = pmap_pte(pmap, va);
+
+ PMAP_DPRINTF(PDB_ENTER, ("enter: pte %p, *pte %x\n", pte, *pte));
+ KASSERT(!pmap_pte_v(pte));
+
+ /*
+ * Increment counters
+ */
+
+ pmap->pm_stats.resident_count++;
+ pmap->pm_stats.wired_count++;
/*
* Build the new PTE.
*/
- pte = pmap_pte(pmap, va);
- npte = pa | pte_prot(pmap, prot) | PG_V;
+
+ npte = pa | pte_prot(pmap, prot) | PG_V | PG_W;
#if defined(M68040) || defined(M68060)
#if defined(M68020) || defined(M68030)
if (mmutype == MMU_68040 && (npte & PG_PROT) == PG_RW)
@@ -1393,8 +1386,6 @@
#endif
*pte = npte;
- TBIS (va);
- pmap->pm_stats.resident_count++;
}
void
@@ -1418,18 +1409,15 @@
/*
* Invalidate every valid mapping within this segment.
*/
+
pte = pmap_pte(pmap, sva);
while (sva < nssva) {
if (!pmap_pte_v(pte)) {
- printf ("pmap_kremove: attempt to remove invalid mapping.\n");
pte++;
sva += NBPG;
continue;
}
- if (pmap_pte_w(pte)) {
- printf ("pmap_kremove: attempt to remove wired mapping.\n");
- pmap->pm_stats.wired_count--;
- }
+ pmap->pm_stats.wired_count--;
pmap->pm_stats.resident_count--;
*pte = PG_NV;
TBIS(sva);
@@ -1456,9 +1444,6 @@
PMAP_DPRINTF(PDB_FOLLOW,
("pmap_unwire(%p, %lx)\n", pmap, va));
- if (pmap == NULL)
- return;
-
pte = pmap_pte(pmap, va);
#ifdef DEBUG
/*
@@ -1516,7 +1501,7 @@
PMAP_DPRINTF(PDB_FOLLOW,
("pmap_extract(%p, %lx) -> ", pmap, va));
- if (pmap && pmap_ste_v(pmap, va)) {
+ if (pmap_ste_v(pmap, va)) {
pte = *(u_int *)pmap_pte(pmap, va);
if (pte) {
pa = (pte & PG_FRAME) | (va & ~PG_FRAME);
@@ -1685,12 +1670,12 @@
* that page back on the free list.
*/
for (pkpt = &kpt_used_list, kpt = *pkpt;
- kpt != (struct kpt_page *)0;
+ kpt != NULL;
pkpt = &kpt->kpt_next, kpt = *pkpt)
if (kpt->kpt_pa == kpa)
break;
#ifdef DEBUG
- if (kpt == (struct kpt_page *)0)
+ if (kpt == NULL)
panic("pmap_collect: lost a KPT page");
if (pmapdebug & (PDB_PTPAGE|PDB_COLLECT))
printf("collect: %lx (%lx) to free list\n",
@@ -2200,6 +2185,11 @@
PMAP_DPRINTF(PDB_REMOVE|PDB_SEGTAB,
("remove: free stab %p\n",
ptpmap->pm_stab));
+ pmap_remove(pmap_kernel(),
+ (vaddr_t)ptpmap->pm_stab,
+ (vaddr_t)ptpmap->pm_stab + HP_STSIZE);
+ uvm_pagefree(PHYS_TO_VM_PAGE((paddr_t)
+ ptpmap->pm_stpa));
uvm_km_free_wakeup(st_map,
(vaddr_t)ptpmap->pm_stab,
HP_STSIZE);
@@ -2259,14 +2249,13 @@
pt_entry_t *pte;
int s;
- if (PAGE_IS_MANAGED(pa) == 0)
- return(FALSE);
-
pv = pa_to_pvh(pa);
s = splvm();
+
/*
* Check saved info first
*/
+
if (*pa_to_attribute(pa) & bit) {
splx(s);
return(TRUE);
@@ -2314,15 +2303,13 @@
PMAP_DPRINTF(PDB_BITS,
("pmap_changebit(%lx, %x, %x)\n", pa, set, mask));
- if (PAGE_IS_MANAGED(pa) == 0)
- return(r);
-
pv = pa_to_pvh(pa);
s = splvm();
/*
* Clear saved attributes (modify, reference)
*/
+
*pa_to_attribute(pa) &= mask;
/*
@@ -2338,15 +2325,6 @@
toflush |= (pv->pv_pmap == pmap_kernel()) ? 2 : 1;
#endif
va = pv->pv_va;
-
- /*
- * XXX don't write protect pager mappings
- */
- if (set == PG_RO) {
- if (va >= uvm.pager_sva && va < uvm.pager_eva)
- continue;
- }
-
pte = pmap_pte(pv->pv_pmap, va);
npte = (*pte | set) & mask;
if (*pte != npte) {
@@ -2489,7 +2467,7 @@
struct kpt_page *kpt;
s = splvm();
- if ((kpt = kpt_free_list) == (struct kpt_page *)0) {
+ if ((kpt = kpt_free_list) == NULL) {
/*
* No PT pages available.
* Try once to free up unused ones.
@@ -2497,7 +2475,7 @@
PMAP_DPRINTF(PDB_COLLECT,
("enter: no KPT pages, collecting...\n"));
pmap_collect(pmap_kernel());
- if ((kpt = kpt_free_list) == (struct kpt_page *)0)
+ if ((kpt = kpt_free_list) == NULL)
panic("pmap_enter_ptpage: can't get KPT page");
}
kpt_free_list = kpt->kpt_next;
@@ -2505,8 +2483,8 @@
kpt_used_list = kpt;
ptpa = kpt->kpt_pa;
memset((caddr_t)kpt->kpt_va, 0, NBPG);
- pmap_enter(pmap, va, ptpa, VM_PROT_DEFAULT,
- VM_PROT_DEFAULT|PMAP_WIRED);
+ pmap_enter(pmap, va, ptpa, VM_PROT_READ | VM_PROT_WRITE,
+ VM_PROT_READ | VM_PROT_WRITE | PMAP_WIRED);
pmap_update();
#ifdef DEBUG
if (pmapdebug & (PDB_ENTER|PDB_PTPAGE)) {
Home |
Main Index |
Thread Index |
Old Index