summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sys/amd64/amd64/pmap.c151
-rw-r--r--sys/i386/i386/pmap.c151
2 files changed, 124 insertions, 178 deletions
diff --git a/sys/amd64/amd64/pmap.c b/sys/amd64/amd64/pmap.c
index 498f653..92d56ef 100644
--- a/sys/amd64/amd64/pmap.c
+++ b/sys/amd64/amd64/pmap.c
@@ -39,7 +39,7 @@
* SUCH DAMAGE.
*
* from: @(#)pmap.c 7.7 (Berkeley) 5/12/91
- * $Id: pmap.c,v 1.223 1999/02/19 14:25:33 luoqi Exp $
+ * $Id: pmap.c,v 1.224 1999/03/05 08:05:44 alc Exp $
*/
/*
@@ -851,6 +851,41 @@ pmap_is_managed(pa)
***************************************************/
/*
+ * add a wired page to the kva
+ * note that in order for the mapping to take effect -- you
+ * should do a invltlb after doing the pmap_kenter...
+ */
+PMAP_INLINE void
+pmap_kenter(va, pa)
+ vm_offset_t va;
+ register vm_offset_t pa;
+{
+ register unsigned *pte;
+ unsigned npte, opte;
+
+ npte = pa | PG_RW | PG_V | pgeflag;
+ pte = (unsigned *)vtopte(va);
+ opte = *pte;
+ *pte = npte;
+ if (opte)
+ invltlb_1pg(va);
+}
+
+/*
+ * remove a page from the kernel pagetables
+ */
+PMAP_INLINE void
+pmap_kremove(va)
+ vm_offset_t va;
+{
+ register unsigned *pte;
+
+ pte = (unsigned *)vtopte(va);
+ *pte = 0;
+ invltlb_1pg(va);
+}
+
+/*
* Add a list of wired pages to the kva
* this routine is only used for temporary
* kernel mappings that do not need to have
@@ -865,17 +900,10 @@ pmap_qenter(va, m, count)
int count;
{
int i;
- register unsigned *pte;
for (i = 0; i < count; i++) {
vm_offset_t tva = va + i * PAGE_SIZE;
- unsigned npte = VM_PAGE_TO_PHYS(m[i]) | PG_RW | PG_V | pgeflag;
- unsigned opte;
- pte = (unsigned *)vtopte(tva);
- opte = *pte;
- *pte = npte;
- if (opte)
- invltlb_1pg(tva);
+ pmap_kenter(tva, VM_PAGE_TO_PHYS(m[i]));
}
}
@@ -889,51 +917,13 @@ pmap_qremove(va, count)
int count;
{
int i;
- register unsigned *pte;
for (i = 0; i < count; i++) {
- pte = (unsigned *)vtopte(va);
- *pte = 0;
- invltlb_1pg(va);
+ pmap_kremove(va);
va += PAGE_SIZE;
}
}
-/*
- * add a wired page to the kva
- * note that in order for the mapping to take effect -- you
- * should do a invltlb after doing the pmap_kenter...
- */
-PMAP_INLINE void
-pmap_kenter(va, pa)
- vm_offset_t va;
- register vm_offset_t pa;
-{
- register unsigned *pte;
- unsigned npte, opte;
-
- npte = pa | PG_RW | PG_V | pgeflag;
- pte = (unsigned *)vtopte(va);
- opte = *pte;
- *pte = npte;
- if (opte)
- invltlb_1pg(va);
-}
-
-/*
- * remove a page from the kernel pagetables
- */
-PMAP_INLINE void
-pmap_kremove(va)
- vm_offset_t va;
-{
- register unsigned *pte;
-
- pte = (unsigned *)vtopte(va);
- *pte = 0;
- invltlb_1pg(va);
-}
-
static vm_page_t
pmap_page_lookup(object, pindex)
vm_object_t object;
@@ -1946,11 +1936,9 @@ pmap_remove_all(pa)
register pv_entry_t pv;
pv_table_t *ppv;
register unsigned *pte, tpte;
- int nmodify;
int update_needed;
int s;
- nmodify = 0;
update_needed = 0;
#if defined(PMAP_DIAGNOSTIC)
/*
@@ -3203,58 +3191,43 @@ pmap_ts_referenced(vm_offset_t pa)
int rtval = 0;
if (!pmap_is_managed(pa))
- return FALSE;
+ return (rtval);
s = splvm();
ppv = pa_to_pvh(pa);
- if (TAILQ_FIRST(&ppv->pv_list) == NULL) {
- splx(s);
- return 0;
- }
-
- /*
- * Not found, check current mappings returning immediately if found.
- */
- pvf = 0;
- for (pv = TAILQ_FIRST(&ppv->pv_list); pv && pv != pvf; pv = pvn) {
- if (!pvf)
- pvf = pv;
- pvn = TAILQ_NEXT(pv, pv_list);
+ if ((pv = TAILQ_FIRST(&ppv->pv_list)) != NULL) {
- TAILQ_REMOVE(&ppv->pv_list, pv, pv_list);
- /*
- * if the bit being tested is the modified bit, then
- * mark clean_map and ptes as never
- * modified.
- */
- if (!pmap_track_modified(pv->pv_va)) {
- TAILQ_INSERT_TAIL(&ppv->pv_list, pv, pv_list);
- continue;
- }
+ pvf = pv;
+
+ do {
+ pvn = TAILQ_NEXT(pv, pv_list);
+
+ TAILQ_REMOVE(&ppv->pv_list, pv, pv_list);
- pte = pmap_pte_quick(pv->pv_pmap, pv->pv_va);
- if (pte == NULL) {
TAILQ_INSERT_TAIL(&ppv->pv_list, pv, pv_list);
- continue;
- }
- if (*pte & PG_A) {
- rtval++;
- *pte &= ~PG_A;
- if (rtval > 4) {
- TAILQ_INSERT_TAIL(&ppv->pv_list, pv, pv_list);
- break;
+ if (!pmap_track_modified(pv->pv_va))
+ continue;
+
+ pte = pmap_pte_quick(pv->pv_pmap, pv->pv_va);
+
+ if (pte && *pte & PG_A) {
+ *pte &= ~PG_A;
+ rtval++;
+ if (rtval > 4) {
+ break;
+ }
}
+ } while ((pv = pvn) != NULL && pv != pvf);
+
+ if (rtval) {
+ invltlb();
}
- TAILQ_INSERT_TAIL(&ppv->pv_list, pv, pv_list);
}
-
splx(s);
- if (rtval) {
- invltlb();
- }
+
return (rtval);
}
diff --git a/sys/i386/i386/pmap.c b/sys/i386/i386/pmap.c
index 498f653..92d56ef 100644
--- a/sys/i386/i386/pmap.c
+++ b/sys/i386/i386/pmap.c
@@ -39,7 +39,7 @@
* SUCH DAMAGE.
*
* from: @(#)pmap.c 7.7 (Berkeley) 5/12/91
- * $Id: pmap.c,v 1.223 1999/02/19 14:25:33 luoqi Exp $
+ * $Id: pmap.c,v 1.224 1999/03/05 08:05:44 alc Exp $
*/
/*
@@ -851,6 +851,41 @@ pmap_is_managed(pa)
***************************************************/
/*
+ * add a wired page to the kva
+ * note that in order for the mapping to take effect -- you
+ * should do a invltlb after doing the pmap_kenter...
+ */
+PMAP_INLINE void
+pmap_kenter(va, pa)
+ vm_offset_t va;
+ register vm_offset_t pa;
+{
+ register unsigned *pte;
+ unsigned npte, opte;
+
+ npte = pa | PG_RW | PG_V | pgeflag;
+ pte = (unsigned *)vtopte(va);
+ opte = *pte;
+ *pte = npte;
+ if (opte)
+ invltlb_1pg(va);
+}
+
+/*
+ * remove a page from the kernel pagetables
+ */
+PMAP_INLINE void
+pmap_kremove(va)
+ vm_offset_t va;
+{
+ register unsigned *pte;
+
+ pte = (unsigned *)vtopte(va);
+ *pte = 0;
+ invltlb_1pg(va);
+}
+
+/*
* Add a list of wired pages to the kva
* this routine is only used for temporary
* kernel mappings that do not need to have
@@ -865,17 +900,10 @@ pmap_qenter(va, m, count)
int count;
{
int i;
- register unsigned *pte;
for (i = 0; i < count; i++) {
vm_offset_t tva = va + i * PAGE_SIZE;
- unsigned npte = VM_PAGE_TO_PHYS(m[i]) | PG_RW | PG_V | pgeflag;
- unsigned opte;
- pte = (unsigned *)vtopte(tva);
- opte = *pte;
- *pte = npte;
- if (opte)
- invltlb_1pg(tva);
+ pmap_kenter(tva, VM_PAGE_TO_PHYS(m[i]));
}
}
@@ -889,51 +917,13 @@ pmap_qremove(va, count)
int count;
{
int i;
- register unsigned *pte;
for (i = 0; i < count; i++) {
- pte = (unsigned *)vtopte(va);
- *pte = 0;
- invltlb_1pg(va);
+ pmap_kremove(va);
va += PAGE_SIZE;
}
}
-/*
- * add a wired page to the kva
- * note that in order for the mapping to take effect -- you
- * should do a invltlb after doing the pmap_kenter...
- */
-PMAP_INLINE void
-pmap_kenter(va, pa)
- vm_offset_t va;
- register vm_offset_t pa;
-{
- register unsigned *pte;
- unsigned npte, opte;
-
- npte = pa | PG_RW | PG_V | pgeflag;
- pte = (unsigned *)vtopte(va);
- opte = *pte;
- *pte = npte;
- if (opte)
- invltlb_1pg(va);
-}
-
-/*
- * remove a page from the kernel pagetables
- */
-PMAP_INLINE void
-pmap_kremove(va)
- vm_offset_t va;
-{
- register unsigned *pte;
-
- pte = (unsigned *)vtopte(va);
- *pte = 0;
- invltlb_1pg(va);
-}
-
static vm_page_t
pmap_page_lookup(object, pindex)
vm_object_t object;
@@ -1946,11 +1936,9 @@ pmap_remove_all(pa)
register pv_entry_t pv;
pv_table_t *ppv;
register unsigned *pte, tpte;
- int nmodify;
int update_needed;
int s;
- nmodify = 0;
update_needed = 0;
#if defined(PMAP_DIAGNOSTIC)
/*
@@ -3203,58 +3191,43 @@ pmap_ts_referenced(vm_offset_t pa)
int rtval = 0;
if (!pmap_is_managed(pa))
- return FALSE;
+ return (rtval);
s = splvm();
ppv = pa_to_pvh(pa);
- if (TAILQ_FIRST(&ppv->pv_list) == NULL) {
- splx(s);
- return 0;
- }
-
- /*
- * Not found, check current mappings returning immediately if found.
- */
- pvf = 0;
- for (pv = TAILQ_FIRST(&ppv->pv_list); pv && pv != pvf; pv = pvn) {
- if (!pvf)
- pvf = pv;
- pvn = TAILQ_NEXT(pv, pv_list);
+ if ((pv = TAILQ_FIRST(&ppv->pv_list)) != NULL) {
- TAILQ_REMOVE(&ppv->pv_list, pv, pv_list);
- /*
- * if the bit being tested is the modified bit, then
- * mark clean_map and ptes as never
- * modified.
- */
- if (!pmap_track_modified(pv->pv_va)) {
- TAILQ_INSERT_TAIL(&ppv->pv_list, pv, pv_list);
- continue;
- }
+ pvf = pv;
+
+ do {
+ pvn = TAILQ_NEXT(pv, pv_list);
+
+ TAILQ_REMOVE(&ppv->pv_list, pv, pv_list);
- pte = pmap_pte_quick(pv->pv_pmap, pv->pv_va);
- if (pte == NULL) {
TAILQ_INSERT_TAIL(&ppv->pv_list, pv, pv_list);
- continue;
- }
- if (*pte & PG_A) {
- rtval++;
- *pte &= ~PG_A;
- if (rtval > 4) {
- TAILQ_INSERT_TAIL(&ppv->pv_list, pv, pv_list);
- break;
+ if (!pmap_track_modified(pv->pv_va))
+ continue;
+
+ pte = pmap_pte_quick(pv->pv_pmap, pv->pv_va);
+
+ if (pte && *pte & PG_A) {
+ *pte &= ~PG_A;
+ rtval++;
+ if (rtval > 4) {
+ break;
+ }
}
+ } while ((pv = pvn) != NULL && pv != pvf);
+
+ if (rtval) {
+ invltlb();
}
- TAILQ_INSERT_TAIL(&ppv->pv_list, pv, pv_list);
}
-
splx(s);
- if (rtval) {
- invltlb();
- }
+
return (rtval);
}
OpenPOWER on IntegriCloud