diff options
author | Miod Vallat <miod@cvs.openbsd.org> | 2007-10-18 04:32:10 +0000 |
---|---|---|
committer | Miod Vallat <miod@cvs.openbsd.org> | 2007-10-18 04:32:10 +0000 |
commit | f54bdffaafbd65e3f9f7fd592c56dd2923f435e3 (patch) | |
tree | cf8d62f7bee37e321dac4124b998b27cf55d735a | |
parent | 15af23b31c06cdf896b27a5291cbe8ddba0a9398 (diff) |
Get rid of the silly union for mips pte. No functional change except
pmap.h now includes pte.h.
-rw-r--r-- | lib/libkvm/kvm_mips64.c | 7 | ||||
-rw-r--r-- | sys/arch/mips64/include/pmap.h | 8 | ||||
-rw-r--r-- | sys/arch/mips64/include/pte.h | 10 | ||||
-rw-r--r-- | sys/arch/mips64/mips64/pmap.c | 92 | ||||
-rw-r--r-- | sys/arch/mips64/mips64/trap.c | 17 |
5 files changed, 58 insertions, 76 deletions
diff --git a/lib/libkvm/kvm_mips64.c b/lib/libkvm/kvm_mips64.c index b0a59886495..4e6b52063a2 100644 --- a/lib/libkvm/kvm_mips64.c +++ b/lib/libkvm/kvm_mips64.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kvm_mips64.c,v 1.6 2007/05/03 19:33:58 miod Exp $ */ +/* $OpenBSD: kvm_mips64.c,v 1.7 2007/10/18 04:32:05 miod Exp $ */ /* $NetBSD: kvm_mips.c,v 1.3 1996/03/18 22:33:44 thorpej Exp $ */ /*- @@ -38,7 +38,7 @@ #if 0 static char sccsid[] = "@(#)kvm_mips.c 8.1 (Berkeley) 6/4/93"; #else -static char *rcsid = "$OpenBSD: kvm_mips64.c,v 1.6 2007/05/03 19:33:58 miod Exp $"; +static char *rcsid = "$OpenBSD: kvm_mips64.c,v 1.7 2007/10/18 04:32:05 miod Exp $"; #endif #endif /* LIBC_SCCS and not lint */ @@ -117,7 +117,8 @@ int _kvm_kvatop(kvm_t *kd, u_long va, paddr_t *pa) { struct vmstate *vm; - u_long pte, idx, addr, offset; + pt_entry_t pte; + u_long idx, addr, offset; if (ISALIVE(kd)) { _kvm_err(kd, 0, "vatop called in live kernel!"); diff --git a/sys/arch/mips64/include/pmap.h b/sys/arch/mips64/include/pmap.h index 4adfe5b30ce..42acde5fd7c 100644 --- a/sys/arch/mips64/include/pmap.h +++ b/sys/arch/mips64/include/pmap.h @@ -1,4 +1,4 @@ -/* $OpenBSD: pmap.h,v 1.13 2007/09/10 18:49:45 miod Exp $ */ +/* $OpenBSD: pmap.h,v 1.14 2007/10/18 04:32:09 miod Exp $ */ /* * Copyright (c) 1987 Carnegie-Mellon University @@ -40,6 +40,8 @@ #ifdef _KERNEL +#include <machine/pte.h> + /* * The user address space is 2Gb (0x0 - 0x80000000). * User programs are laid out in memory as follows: @@ -68,10 +70,8 @@ #define PMAP_SEGTABSIZE 512 -union pt_entry; - struct segtab { - union pt_entry *seg_tab[PMAP_SEGTABSIZE]; + pt_entry_t *seg_tab[PMAP_SEGTABSIZE]; }; /* diff --git a/sys/arch/mips64/include/pte.h b/sys/arch/mips64/include/pte.h index d11e71c983c..cc3f6166141 100644 --- a/sys/arch/mips64/include/pte.h +++ b/sys/arch/mips64/include/pte.h @@ -1,4 +1,4 @@ -/* $OpenBSD: pte.h,v 1.5 2007/04/27 18:15:55 miod Exp $ */ +/* $OpenBSD: pte.h,v 1.6 2007/10/18 04:32:09 miod Exp $ */ /* * Copyright (c) 1988 University of Utah. @@ -54,13 +54,9 @@ struct tlb_entry { u_int64_t tlb_lo1; }; -typedef union pt_entry { - unsigned int pt_entry; /* for copying, etc. */ - unsigned int pt_pte; /* XXX void */ -} pt_entry_t; /* Mips page table entry */ -#endif /* _LOCORE */ +typedef u_int32_t pt_entry_t; /* Mips page table entry */ -#define PT_ENTRY_NULL ((pt_entry_t *) 0) +#endif /* _LOCORE */ #define PG_RO 0x40000000 /* SW */ diff --git a/sys/arch/mips64/mips64/pmap.c b/sys/arch/mips64/mips64/pmap.c index 5c3fbd92622..bfad0f39079 100644 --- a/sys/arch/mips64/mips64/pmap.c +++ b/sys/arch/mips64/mips64/pmap.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pmap.c,v 1.29 2007/07/18 20:06:07 miod Exp $ */ +/* $OpenBSD: pmap.c,v 1.30 2007/10/18 04:32:08 miod Exp $ */ /* * Copyright (c) 2001-2004 Opsycon AB (www.opsycon.se / www.opsycon.com) @@ -38,7 +38,6 @@ #include <sys/shm.h> #endif -#include <machine/pte.h> #include <machine/cpu.h> #include <machine/autoconf.h> #include <machine/memconf.h> @@ -176,7 +175,7 @@ pmap_bootstrap() * a global bit to store in the tlb. */ for (i = 0, spte = Sysmap; i < Sysmapsize; i++, spte++) - spte->pt_entry = PG_G; + *spte = PG_G; } /* @@ -342,7 +341,7 @@ pmap_destroy(pmap_t pmap) continue; #ifdef PARANOIA for (j = 0; j < NPTEPG; j++) { - if ((pte+j)->pt_entry) + if (pte[j] != PG_NV) panic("pmap_destroy: segmap not empty"); } #endif @@ -409,8 +408,7 @@ void pmap_remove(pmap_t pmap, vaddr_t sva, vaddr_t eva) { vaddr_t nssva; - pt_entry_t *pte; - unsigned entry; + pt_entry_t *pte, entry; DPRINTF(PDB_FOLLOW|PDB_REMOVE|PDB_PROTECT, ("pmap_remove(%x, %x, %x)\n", pmap, sva, eva)); @@ -421,8 +419,6 @@ pmap_remove(pmap_t pmap, vaddr_t sva, vaddr_t eva) return; if (pmap == pmap_kernel()) { - pt_entry_t *pte; - /* remove entries from kernel pmap */ #ifdef DIAGNOSTIC if (sva < VM_MIN_KERNEL_ADDRESS || eva < sva) @@ -430,12 +426,12 @@ pmap_remove(pmap_t pmap, vaddr_t sva, vaddr_t eva) #endif pte = kvtopte(sva); for(; sva < eva; sva += NBPG, pte++) { - entry = pte->pt_entry; + entry = *pte; if (!(entry & PG_V)) continue; pmap->pm_stats.resident_count--; pmap_remove_pv(pmap, sva, pfn_to_pad(entry)); - pte->pt_entry = PG_NV | PG_G; + *pte = PG_NV | PG_G; /* * Flush the TLB for the given address. */ @@ -466,12 +462,12 @@ pmap_remove(pmap_t pmap, vaddr_t sva, vaddr_t eva) */ pte += uvtopte(sva); for (; sva < nssva; sva += NBPG, pte++) { - entry = pte->pt_entry; + entry = *pte; if (!(entry & PG_V)) continue; pmap->pm_stats.resident_count--; pmap_remove_pv(pmap, sva, pfn_to_pad(entry)); - pte->pt_entry = PG_NV; + *pte = PG_NV; /* * Flush the TLB for the given address. */ @@ -546,8 +542,7 @@ void pmap_protect(pmap_t pmap, vaddr_t sva, vaddr_t eva, vm_prot_t prot) { vaddr_t nssva; - pt_entry_t *pte; - u_int entry; + pt_entry_t *pte, entry; u_int p; DPRINTF(PDB_FOLLOW|PDB_PROTECT, @@ -575,11 +570,11 @@ pmap_protect(pmap_t pmap, vaddr_t sva, vaddr_t eva, vm_prot_t prot) #endif pte = kvtopte(sva); for (; sva < eva; sva += NBPG, pte++) { - entry = pte->pt_entry; + entry = *pte; if (!(entry & PG_V)) continue; entry = (entry & ~(PG_M | PG_RO)) | p; - pte->pt_entry = entry; + *pte = entry; /* * Update the TLB if the given address is in the cache. */ @@ -609,11 +604,11 @@ pmap_protect(pmap_t pmap, vaddr_t sva, vaddr_t eva, vm_prot_t prot) */ pte += uvtopte(sva); for (; sva < nssva; sva += NBPG, pte++) { - entry = pte->pt_entry; + entry = *pte; if (!(entry & PG_V)) continue; entry = (entry & ~(PG_M | PG_RO)) | p; - pte->pt_entry = entry; + *pte = entry; if (pmap->pm_tlbgen == tlbpid_gen) tlb_update(sva | (pmap->pm_tlbpid << VMTLB_PID_SHIFT), entry); @@ -633,8 +628,7 @@ pmap_protect(pmap_t pmap, vaddr_t sva, vaddr_t eva, vm_prot_t prot) int pmap_enter(pmap_t pmap, vaddr_t va, paddr_t pa, vm_prot_t prot, int flags) { - pt_entry_t *pte; - u_int npte; + pt_entry_t *pte, npte; vm_page_t pg; DPRINTF(PDB_FOLLOW|PDB_ENTER, @@ -705,10 +699,10 @@ pmap_enter(pmap_t pmap, vaddr_t va, paddr_t pa, vm_prot_t prot, int flags) pte = kvtopte(va); npte |= vad_to_pfn(pa) | PG_G; - if (!(pte->pt_entry & PG_V)) { + if ((*pte & PG_V) == 0) { pmap->pm_stats.resident_count++; } - if ((pte->pt_entry & PG_V) && pa != pfn_to_pad(pte->pt_entry)) { + if ((*pte & PG_V) && pa != pfn_to_pad(*pte)) { pmap_remove(pmap, va, va + NBPG); stat_count(enter_stats.mchange); } @@ -716,7 +710,7 @@ pmap_enter(pmap_t pmap, vaddr_t va, paddr_t pa, vm_prot_t prot, int flags) /* * Update the same virtual address entry. */ - pte->pt_entry = npte; + *pte = npte; tlb_update(va, npte); return 0; } @@ -759,15 +753,15 @@ pmap_enter(pmap_t pmap, vaddr_t va, paddr_t pa, vm_prot_t prot, int flags) DPRINTF(PDB_ENTER, ("pmap_enter: new pte 0x%08x\n", npte)); } - if ((pte->pt_entry & PG_V) && pa != pfn_to_pad(pte->pt_entry)) { + if ((*pte & PG_V) && pa != pfn_to_pad(*pte)) { pmap_remove(pmap, va, va + NBPG); stat_count(enter_stats.mchange); } - if (!(pte->pt_entry & PG_V)) { + if ((*pte & PG_V) == 0) { pmap->pm_stats.resident_count++; } - pte->pt_entry = npte; + *pte = npte; if (pmap->pm_tlbgen == tlbpid_gen) { tlb_update(va | (pmap->pm_tlbpid << VMTLB_PID_SHIFT), npte); } @@ -784,8 +778,7 @@ pmap_enter(pmap_t pmap, vaddr_t va, paddr_t pa, vm_prot_t prot, int flags) void pmap_kenter_pa(vaddr_t va, paddr_t pa, vm_prot_t prot) { - pt_entry_t *pte; - u_int npte; + pt_entry_t *pte, npte; DPRINTF(PDB_FOLLOW|PDB_ENTER, ("pmap_kenter_pa(%p, %p, 0x%x)\n", va, pa, prot)); @@ -796,7 +789,7 @@ pmap_kenter_pa(vaddr_t va, paddr_t pa, vm_prot_t prot) else npte |= PG_ROPAGE; pte = kvtopte(va); - pte->pt_entry = npte; + *pte = npte; tlb_update(va, npte); } @@ -808,20 +801,19 @@ pmap_kenter_pa(vaddr_t va, paddr_t pa, vm_prot_t prot) void pmap_kremove(vaddr_t va, vsize_t len) { - pt_entry_t *pte; + pt_entry_t *pte, entry; vaddr_t eva; - u_int entry; DPRINTF(PDB_FOLLOW|PDB_REMOVE, ("pmap_kremove(%p, %p)\n", va, len)); pte = kvtopte(va); eva = va + len; for (; va < eva; va += PAGE_SIZE, pte++) { - entry = pte->pt_entry; + entry = *pte; if (!(entry & PG_V)) continue; Mips_HitSyncDCache(va, PAGE_SIZE); - pte->pt_entry = PG_NV | PG_G; + *pte = PG_NV | PG_G; tlb_flush_addr(va); } } @@ -861,9 +853,8 @@ pmap_extract(pmap_t pmap, vaddr_t va, paddr_t *pap) panic("pmap_extract(%p, %p)", pmap, va); #endif pte = kvtopte(va); - if (pte->pt_entry & PG_V) - pa = pfn_to_pad(pte->pt_entry) | - (va & PAGE_MASK); + if (*pte & PG_V) + pa = pfn_to_pad(*pte) | (va & PAGE_MASK); else rv = FALSE; } @@ -872,7 +863,7 @@ pmap_extract(pmap_t pmap, vaddr_t va, paddr_t *pap) rv = FALSE; else { pte += uvtopte(va); - pa = pfn_to_pad(pte->pt_entry) | (va & PAGE_MASK); + pa = pfn_to_pad(*pte) | (va & PAGE_MASK); } } if (rv != FALSE) @@ -989,8 +980,7 @@ boolean_t pmap_clear_modify(struct vm_page *pg) { pv_entry_t pv; - pt_entry_t *pte; - unsigned entry; + pt_entry_t *pte, entry; boolean_t rv = FALSE; int s; @@ -1008,22 +998,22 @@ pmap_clear_modify(struct vm_page *pg) for (; pv != NULL; pv = pv->pv_next) { if (pv->pv_pmap == pmap_kernel()) { pte = kvtopte(pv->pv_va); - entry = pte->pt_entry; + entry = *pte; if ((entry & PG_V) != 0 && (entry & PG_M) != 0) { rv = TRUE; entry &= ~PG_M; - pte->pt_entry = entry; + *pte = entry; tlb_update(pv->pv_va, entry); } } else if (pv->pv_pmap != NULL) { if ((pte = pmap_segmap(pv->pv_pmap, pv->pv_va)) == NULL) continue; pte += uvtopte(pv->pv_va); - entry = pte->pt_entry; + entry = *pte; if ((entry & PG_V) != 0 && (entry & PG_M) != 0) { rv = TRUE; entry &= ~PG_M; - pte->pt_entry = entry; + *pte = entry; if (pv->pv_pmap->pm_tlbgen == tlbpid_gen) tlb_update(pv->pv_va | (pv->pv_pmap->pm_tlbpid << VMTLB_PID_SHIFT), entry); @@ -1104,8 +1094,7 @@ void pmap_page_cache(vm_page_t pg, int mode) { pv_entry_t pv; - pt_entry_t *pte; - u_int entry; + pt_entry_t *pte, entry; u_int newmode; int s; @@ -1118,19 +1107,19 @@ pmap_page_cache(vm_page_t pg, int mode) for (; pv != NULL; pv = pv->pv_next) { if (pv->pv_pmap == pmap_kernel()) { pte = kvtopte(pv->pv_va); - entry = pte->pt_entry; + entry = *pte; if (entry & PG_V) { entry = (entry & ~PG_CACHEMODE) | newmode; - pte->pt_entry = entry; + *pte = entry; tlb_update(pv->pv_va, entry); } } else { if ((pte = pmap_segmap(pv->pv_pmap, pv->pv_va))) { pte += uvtopte(pv->pv_va); - entry = pte->pt_entry; + entry = *pte; if (entry & PG_V) { entry = (entry & ~PG_CACHEMODE) | newmode; - pte->pt_entry = entry; + *pte = entry; if (pv->pv_pmap->pm_tlbgen == tlbpid_gen) tlb_update(pv->pv_va | (pv->pv_pmap->pm_tlbpid << VMTLB_PID_SHIFT), entry); @@ -1389,13 +1378,12 @@ bus_mem_add_mapping(bus_addr_t bpa, bus_size_t size, int cacheable, printf("map bus %x size %x to %x vbase %x\n", bpa, size, *bshp, spa); #endif for (; len > 0; len -= NBPG) { - pt_entry_t *pte; - u_int npte; + pt_entry_t *pte, npte; npte = vad_to_pfn(spa) | PG_G; npte |= PG_V | PG_M | PG_IOPAGE; pte = kvtopte(vaddr); - pte->pt_entry = npte; + *pte = npte; tlb_update(vaddr, npte); spa += NBPG; diff --git a/sys/arch/mips64/mips64/trap.c b/sys/arch/mips64/mips64/trap.c index 23bf0317870..50ed45098ae 100644 --- a/sys/arch/mips64/mips64/trap.c +++ b/sys/arch/mips64/mips64/trap.c @@ -1,4 +1,4 @@ -/* $OpenBSD: trap.c,v 1.37 2007/07/16 20:21:20 miod Exp $ */ +/* $OpenBSD: trap.c,v 1.38 2007/10/18 04:32:08 miod Exp $ */ /* tracked to 1.23 */ /* @@ -73,7 +73,6 @@ #include <machine/pio.h> #include <machine/intr.h> #include <machine/autoconf.h> -#include <machine/pte.h> #include <machine/pmap.h> #include <machine/mips_opcode.h> #include <machine/frame.h> @@ -214,13 +213,12 @@ trap(trapframe) case T_TLB_MOD: /* check for kernel address */ if (trapframe->badvaddr < 0) { - pt_entry_t *pte; - unsigned int entry; + pt_entry_t *pte, entry; paddr_t pa; vm_page_t pg; pte = kvtopte(trapframe->badvaddr); - entry = pte->pt_entry; + entry = *pte; #ifdef DIAGNOSTIC if (!(entry & PG_V) || (entry & PG_M)) panic("trap: ktlbmod: invalid pte"); @@ -232,7 +230,7 @@ trap(trapframe) goto kernel_fault; } entry |= PG_M; - pte->pt_entry = entry; + *pte = entry; tlb_update(trapframe->badvaddr & ~PGOFSET, entry); pa = pfn_to_pad(entry); pg = PHYS_TO_VM_PAGE(pa); @@ -245,8 +243,7 @@ trap(trapframe) case T_TLB_MOD+T_USER: { - pt_entry_t *pte; - unsigned int entry; + pt_entry_t *pte, entry; paddr_t pa; vm_page_t pg; pmap_t pmap = p->p_vmspace->vm_map.pmap; @@ -254,7 +251,7 @@ trap(trapframe) if (!(pte = pmap_segmap(pmap, trapframe->badvaddr))) panic("trap: utlbmod: invalid segmap"); pte += uvtopte(trapframe->badvaddr); - entry = pte->pt_entry; + entry = *pte; #ifdef DIAGNOSTIC if (!(entry & PG_V) || (entry & PG_M)) panic("trap: utlbmod: invalid pte"); @@ -266,7 +263,7 @@ trap(trapframe) goto fault_common; } entry |= PG_M; - pte->pt_entry = entry; + *pte = entry; tlb_update((trapframe->badvaddr & ~PGOFSET) | (pmap->pm_tlbpid << VMTLB_PID_SHIFT), entry); pa = pfn_to_pad(entry); |