diff options
author | Artur Grabowski <art@cvs.openbsd.org> | 1999-12-08 15:16:13 +0000 |
---|---|---|
committer | Artur Grabowski <art@cvs.openbsd.org> | 1999-12-08 15:16:13 +0000 |
commit | cf98b6e1992e9eb8bd7089d134db3aa09f6257c5 (patch) | |
tree | 958431097be9ca868e006bf0707dda0cba8172fc /sys | |
parent | 66650669986e5f51717d76ff394f752ed92ea287 (diff) |
Readd the PMAP_NEW code, this time with the missing ifdef.
Diffstat (limited to 'sys')
-rw-r--r-- | sys/arch/sparc/sparc/pmap.c | 228 |
1 files changed, 227 insertions, 1 deletions
diff --git a/sys/arch/sparc/sparc/pmap.c b/sys/arch/sparc/sparc/pmap.c index e42fbada193..4d8f444937f 100644 --- a/sys/arch/sparc/sparc/pmap.c +++ b/sys/arch/sparc/sparc/pmap.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pmap.c,v 1.50 1999/12/08 12:27:17 deraadt Exp $ */ +/* $OpenBSD: pmap.c,v 1.51 1999/12/08 15:16:12 art Exp $ */ /* $NetBSD: pmap.c,v 1.118 1998/05/19 19:00:18 thorpej Exp $ */ /* @@ -597,15 +597,29 @@ static void mmu_setup4m_L3 __P((int, struct segmap *)); /* function pointer declarations */ /* from pmap.h: */ +#ifdef PMAP_NEW +boolean_t (*pmap_clear_modify_p) __P((struct vm_page *)); +boolean_t (*pmap_clear_reference_p) __P((struct vm_page *)); +#else void (*pmap_clear_modify_p) __P((paddr_t pa)); void (*pmap_clear_reference_p) __P((paddr_t pa)); +#endif void (*pmap_copy_page_p) __P((paddr_t, paddr_t)); void (*pmap_enter_p) __P((pmap_t, vaddr_t, paddr_t, vm_prot_t, boolean_t, vm_prot_t)); paddr_t (*pmap_extract_p) __P((pmap_t, vaddr_t)); +#ifdef PMAP_NEW +boolean_t (*pmap_is_modified_p) __P((struct vm_page *)); +boolean_t (*pmap_is_referenced_p) __P((struct vm_page *)); +void (*pmap_kenter_pa_p) __P((vaddr_t, paddr_t, vm_prot_t)); +void (*pmap_kenter_pgs_p) __P((vaddr_t, struct vm_page **, int)); +void (*pmap_kremove_p) __P((vaddr_t, vsize_t)); +void (*pmap_page_protect_p) __P((struct vm_page *, vm_prot_t)); +#else boolean_t (*pmap_is_modified_p) __P((paddr_t pa)); boolean_t (*pmap_is_referenced_p) __P((paddr_t pa)); void (*pmap_page_protect_p) __P((paddr_t, vm_prot_t)); +#endif void (*pmap_protect_p) __P((pmap_t, vaddr_t, vaddr_t, vm_prot_t)); void (*pmap_zero_page_p) __P((paddr_t)); void (*pmap_changeprot_p) __P((pmap_t, vaddr_t, vm_prot_t, int)); @@ -2779,6 +2793,11 @@ pmap_bootstrap4_4c(nctx, nregion, nsegment) pmap_extract_p = pmap_extract4_4c; pmap_is_modified_p = pmap_is_modified4_4c; pmap_is_referenced_p = pmap_is_referenced4_4c; +#ifdef PMAP_NEW + pmap_kenter_pa_p = pmap_kenter_pa4_4c; + pmap_kenter_pgs_p = pmap_kenter_pgs4_4c; + pmap_kremove_p = pmap_kremove4_4c; +#endif pmap_page_protect_p = pmap_page_protect4_4c; pmap_protect_p = pmap_protect4_4c; pmap_zero_page_p = pmap_zero_page4_4c; @@ -3091,6 +3110,11 @@ pmap_bootstrap4m(void) pmap_extract_p = pmap_extract4m; pmap_is_modified_p = pmap_is_modified4m; pmap_is_referenced_p = pmap_is_referenced4m; +#ifdef PMAP_NEW + pmap_kenter_pa_p = pmap_kenter_pa4m; + pmap_kenter_pgs_p = pmap_kenter_pgs4m; + pmap_kremove_p = pmap_kremove4m; +#endif pmap_page_protect_p = pmap_page_protect4m; pmap_protect_p = pmap_protect4m; pmap_zero_page_p = pmap_zero_page4m; @@ -3527,13 +3551,19 @@ pmap_map(va, pa, endpa, prot) * If size is nonzero, the map is useless. (ick) */ struct pmap * +#ifdef PMAP_NEW +pmap_create() +#else pmap_create(size) vsize_t size; +#endif { struct pmap *pm; +#ifndef PMAP_NEW if (size) return (NULL); +#endif pm = (struct pmap *)malloc(sizeof *pm, M_VMPMAP, M_WAITOK); #ifdef DEBUG if (pmapdebug & PDB_CREATE) @@ -4296,8 +4326,13 @@ pmap_rmu4m(pm, va, endva, vr, vs) #if defined(SUN4) || defined(SUN4C) void +#ifdef PMAP_NEW +pmap_page_protect4_4c(pg, prot) + struct vm_page *pg; +#else pmap_page_protect4_4c(pa, prot) paddr_t pa; +#endif vm_prot_t prot; { struct pvlist *pv, *pv0, *npv; @@ -4306,6 +4341,9 @@ pmap_page_protect4_4c(pa, prot) int flags, nleft, i, s, ctx; struct regmap *rp; struct segmap *sp; +#ifdef PMAP_NEW + paddr_t pa = VM_PAGE_TO_PHYS(pg); +#endif #ifdef DEBUG if (!pmap_pa_exists(pa)) @@ -4694,8 +4732,13 @@ useless: * to read-only (in which case pv_changepte does the trick). */ void +#ifdef PMAP_NEW +pmap_page_protect4m(pg, prot) + struct vm_page *pg; +#else pmap_page_protect4m(pa, prot) paddr_t pa; +#endif vm_prot_t prot; { struct pvlist *pv, *pv0, *npv; @@ -4704,6 +4747,9 @@ pmap_page_protect4m(pa, prot) int flags, nleft, s, ctx; struct regmap *rp; struct segmap *sp; +#ifdef PMAP_NEW + paddr_t pa = VM_PAGE_TO_PHYS(pg); +#endif #ifdef DEBUG if (!pmap_pa_exists(pa)) @@ -5334,6 +5380,41 @@ printf("%s[%d]: pmap_enu: changing existing va(0x%x)=>pa entry\n", splx(s); } +#ifdef PMAP_NEW +void +pmap_kenter_pa4_4c(va, pa, prot) + vaddr_t va; + paddr_t pa; + vm_prot_t prot; +{ + pmap_enter4_4c(pmap_kernel(), va, pa, prot, TRUE, 0); +} + +void +pmap_kenter_pgs4_4c(va, pgs, npgs) + vaddr_t va; + struct vm_page **pgs; + int npgs; +{ + int i; + + for (i = 0; i < npgs; i++, va += PAGE_SIZE) { + pmap_enter4_4c(pmap_kernel(), va, VM_PAGE_TO_PHYS(pgs[i]), + VM_PROT_READ|VM_PROT_WRITE, TRUE, 0); + } +} + +void +pmap_kremove4_4c(va, len) + vaddr_t va; + vsize_t len; +{ + for (len >>= PAGE_SHIFT; len > 0; len--, va += PAGE_SIZE) { + pmap_remove(pmap_kernel(), va, va + PAGE_SIZE); + } +} +#endif + #endif /*sun4,4c*/ #if defined(SUN4M) /* Sun4M versions of enter routines */ @@ -5649,6 +5730,51 @@ printf("%s[%d]: pmap_enu: changing existing va(0x%x)=>pa(pte=0x%x) entry\n", splx(s); } + +#ifdef PMAP_NEW +void +pmap_kenter_pa4m(va, pa, prot) + vaddr_t va; + paddr_t pa; + vm_prot_t prot; +{ + struct pvlist *pv; + int pteproto, ctx; + + pteproto = ((pa & PMAP_NC) == 0 ? SRMMU_PG_C : 0) | + PMAP_T2PTE_SRMMU(pa) | SRMMU_TEPTE | PPROT_RX_RX | PPROT_S | + (atop(pa) << SRMMU_PPNSHIFT) | + ((prot & VM_PROT_WRITE) ? PPROT_WRITE : 0); + pv = pvhead(atop(pa)); + + ctx = getcontext4m(); + pmap_enk4m(pmap_kernel(), va, prot, TRUE, pv, pteproto); +} + +void +pmap_kenter_pgs4m(va, pgs, npgs) + vaddr_t va; + struct vm_page **pgs; + int npgs; +{ + int i; + + for (i = 0; i < npgs; i++, va += PAGE_SIZE) + pmap_kenter_pa4m(va, VM_PAGE_TO_PHYS(pgs[i]), + VM_PROT_READ|VM_PROT_WRITE); +} + +void +pmap_kremove4m(va, len) + vaddr_t va; + vsize_t len; +{ + for (len >>= PAGE_SHIFT; len > 0; len--, va += PAGE_SIZE) { + pmap_remove(pmap_kernel(), va, va + PAGE_SIZE); + } +} +#endif /* PMAP_NEW */ + #endif /* sun4m */ /* @@ -5904,27 +6030,52 @@ pmap_collect(pm) /* * Clear the modify bit for the given physical page. */ +#ifdef PMAP_NEW +boolean_t +pmap_clear_modify4_4c(pg) + struct vm_page *pg; +#else void pmap_clear_modify4_4c(pa) paddr_t pa; +#endif { struct pvlist *pv; +#ifdef PMAP_NEW + paddr_t pa; + boolean_t ret = 0; +#endif pv = pvhead(atop(pa)); if ((pa & (PMAP_TNC_4 & ~PMAP_NC)) == 0 && pv) { (void) pv_syncflags4_4c(pv); +#ifdef PMAP_NEW + ret = pv->pv_flags & PV_MOD; +#endif pv->pv_flags &= ~PV_MOD; } +#ifdef PMAP_NEW + return ret; +#endif } /* * Tell whether the given physical page has been modified. */ +#ifdef PMAP_NEW +boolean_t +pmap_is_modified4_4c(pg) + struct vm_page *pg; +#else int pmap_is_modified4_4c(pa) paddr_t pa; +#endif { struct pvlist *pv; +#ifdef PMAP_NEW + paddr_t pa = VM_PAGE_TO_PHYS(pg); +#endif pv = pvhead(atop(pa)); if ((pa & (PMAP_TNC_4 & ~PMAP_NC)) == 0 && pv) { @@ -5937,27 +6088,52 @@ pmap_is_modified4_4c(pa) /* * Clear the reference bit for the given physical page. */ +#ifdef PMAP_NEW +boolean_t +pmap_clear_reference4_4c(pg) + struct vm_page *pg; +#else void pmap_clear_reference4_4c(pa) paddr_t pa; +#endif { struct pvlist *pv; +#ifdef PMAP_NEW + paddr_t pa = VM_PAGE_TO_PHYS(pg); + boolean_t ret = 0; +#endif pv = pvhead(atop(pa)); if ((pa & (PMAP_TNC_4 & ~PMAP_NC)) == 0 && pv) { (void) pv_syncflags4_4c(pv); +#ifdef PMAP_NEW + ret = pv->pv_flags & PV_REF; +#endif pv->pv_flags &= ~PV_REF; } +#ifdef PMAP_NEW + return ret; +#endif } /* * Tell whether the given physical page has been referenced. */ +#ifdef PMAP_NEW +boolean_t +pmap_is_referenced4_4c(pg) + struct vm_page *pg; +#else int pmap_is_referenced4_4c(pa) paddr_t pa; +#endif { struct pvlist *pv; +#ifdef PMAP_NEW + paddr_t pa = VM_PAGE_TO_PHYS(pg); +#endif pv = pvhead(atop(pa)); if ((pa & (PMAP_TNC_4 & ~PMAP_NC)) == 0 && pv) { @@ -5982,27 +6158,52 @@ pmap_is_referenced4_4c(pa) /* * Clear the modify bit for the given physical page. */ +#ifdef PMAP_NEW +boolean_t +pmap_clear_modify4m(pg) + struct vm_page *pg; +#else void pmap_clear_modify4m(pa) /* XXX %%%: Should service from swpagetbl for 4m */ paddr_t pa; +#endif { struct pvlist *pv; +#ifdef PMAP_NEW + paddr_t pa = VM_PAGE_TO_PHYS(pg); + boolean_t ret = 0; +#endif pv = pvhead(atop(pa)); if ((pa & (PMAP_TNC_SRMMU & ~PMAP_NC)) == 0 && pv) { (void) pv_syncflags4m(pv); +#ifdef PMAP_NEW + ret = pv->pv_flags & PV_MOD4M; +#endif pv->pv_flags &= ~PV_MOD4M; } +#ifdef PMAP_NEW + return ret; +#endif } /* * Tell whether the given physical page has been modified. */ +#ifdef PMAP_NEW +boolean_t +pmap_is_modified4m(pg) + struct vm_page *pg; +#else int pmap_is_modified4m(pa) /* Test performance with SUN4M && SUN4/4C. XXX */ paddr_t pa; +#endif { struct pvlist *pv; +#ifdef PMAP_NEW + paddr_t pa = VM_PAGE_TO_PHYS(pg); +#endif pv = pvhead(atop(pa)); if ((pa & (PMAP_TNC_SRMMU & ~PMAP_NC)) == 0 && pv) { @@ -6015,27 +6216,52 @@ pmap_is_modified4m(pa) /* Test performance with SUN4M && SUN4/4C. XXX */ /* * Clear the reference bit for the given physical page. */ +#ifdef PMAP_NEW +boolean_t +pmap_clear_reference4m(pg) + struct vm_page *pg; +#else void pmap_clear_reference4m(pa) paddr_t pa; +#endif { struct pvlist *pv; +#ifdef PMAP_NEW + paddr_t pa = VM_PAGE_TO_PHYS(pg); + boolean_t ret = 0; +#endif pv = pvhead(atop(pa)); if ((pa & (PMAP_TNC_SRMMU & ~PMAP_NC)) == 0 && pv) { (void) pv_syncflags4m(pv); +#ifdef PMAP_NEW + ret = pv->pv_flags & PV_REF4M; +#endif pv->pv_flags &= ~PV_REF4M; } +#ifdef PMAP_NEW + return ret; +#endif } /* * Tell whether the given physical page has been referenced. */ +#ifdef PMAP_NEW +boolean_t +pmap_is_referenced4m(pg) + struct vm_page *pg; +#else int pmap_is_referenced4m(pa) paddr_t pa; +#endif { struct pvlist *pv; +#ifdef PMAP_NEW + paddr_t pa = VM_PAGE_TO_PHYS(pg); +#endif pv = pvhead(atop(pa)); if ((pa & (PMAP_TNC_SRMMU & ~PMAP_NC)) == 0 && pv) { |