Merge mips1 and mips3 pte/pmap code, pass 0;

* Move mips-I pte (TLBlo) definitions from pmax/include/pte.h
      to mips/include/mips1_pte.h

    * Move mips-III pte (TLBlo) definitions from  pica/include/pte.h
      to mips/include/mips3_pte.h

    * Add new mips/include/pte.h, which includes exactly one of
      mips1_pte.h or mips3_pte.h (which still have namespace collisions),
      depending on "options MIPS1" or "options MIPS3". (hack).
      Move soft kvtopte(), ptetovk() definitions to mips/include/pte.h

    * Add macro PTE_TO_PADDR() to hide the different hardware TLB formats
      when mapping from pte to physical address.

   * Add macro PTE_READONLY() to hide lack of SW read-only bit in mips-III
     tlb. (mips1 pmap uses a sw bit in the PTE, mips3 looks up RO bit in
     the kernel pmap.)

   * Use macros (not direct TLB frobbing) in mips/trap.c, to make it
     mips-1/mips-III indepenndet.

    * Change {pmax,pica}/include/pte.h to just do #include <mips/pte.h>.
This commit is contained in:
jonathan 1996-10-13 09:28:53 +00:00
parent a179b23932
commit 6ac1fdec40
6 changed files with 69 additions and 271 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: mips1_pte.h,v 1.6 1996/02/01 22:32:15 mycroft Exp $ */ /* $NetBSD: mips1_pte.h,v 1.7 1996/10/13 09:28:53 jonathan Exp $ */
/* /*
* Copyright (c) 1988 University of Utah. * Copyright (c) 1988 University of Utah.
@ -93,15 +93,5 @@ typedef union pt_entry {
#define PG_SHIFT 12 #define PG_SHIFT 12
#define PG_PFNUM(x) (((x) & PG_FRAME) >> PG_SHIFT) #define PG_PFNUM(x) (((x) & PG_FRAME) >> PG_SHIFT)
#if defined(_KERNEL) && !defined(_LOCORE) #define PTE_TO_PADDR(x) ((unsigned)(x) & PG_FRAME)
/*
* Kernel virtual address to page table entry and visa versa.
*/
#define kvtopte(va) \
(Sysmap + (((vm_offset_t)(va) - VM_MIN_KERNEL_ADDRESS) >> PGSHIFT))
#define ptetokv(pte) \
((((pt_entry_t *)(pte) - Sysmap) << PGSHIFT) + VM_MIN_KERNEL_ADDRESS)
extern pt_entry_t *Sysmap; /* kernel pte table */
extern u_int Sysmapsize; /* number of pte's in Sysmap */
#endif

View File

@ -1,4 +1,4 @@
/* $NetBSD: mips3_pte.h,v 1.3 1996/08/11 23:30:22 jonathan Exp $ */ /* $NetBSD: mips3_pte.h,v 1.4 1996/10/13 09:28:55 jonathan Exp $ */
/* /*
* Copyright (c) 1988 University of Utah. * Copyright (c) 1988 University of Utah.
@ -106,11 +106,17 @@ typedef union pt_entry {
#define PG_IOPAGE (PG_G | PG_V | PG_M | PG_UNCACHED) #define PG_IOPAGE (PG_G | PG_V | PG_M | PG_UNCACHED)
#define PG_FRAME 0x3fffffc0 #define PG_FRAME 0x3fffffc0
#define PG_SHIFT 6 #define PG_SHIFT 6
/* pte accessor macros */
#define vad_to_pfn(x) (((unsigned)(x) >> PG_SHIFT) & PG_FRAME) #define vad_to_pfn(x) (((unsigned)(x) >> PG_SHIFT) & PG_FRAME)
#define pfn_to_vad(x) (((x) & PG_FRAME) << PG_SHIFT) #define pfn_to_vad(x) (((x) & PG_FRAME) << PG_SHIFT)
#define vad_to_vpn(x) ((unsigned)(x) & PG_SVPN) #define vad_to_vpn(x) ((unsigned)(x) & PG_SVPN)
#define vpn_to_vad(x) ((x) & PG_SVPN) #define vpn_to_vad(x) ((x) & PG_SVPN)
/* User viritual to pte page entry */
#define PTE_TO_PADDR(x) (pfn_to_vad((x))
/* User virtual to pte page entry */
#define uvtopte(adr) (((adr) >> PGSHIFT) & (NPTEPG -1)) #define uvtopte(adr) (((adr) >> PGSHIFT) & (NPTEPG -1))
#define PG_SIZE_4K 0x00000000 #define PG_SIZE_4K 0x00000000
@ -121,15 +127,3 @@ typedef union pt_entry {
#define PG_SIZE_4M 0x007fe000 #define PG_SIZE_4M 0x007fe000
#define PG_SIZE_16M 0x01ffe000 #define PG_SIZE_16M 0x01ffe000
#if defined(_KERNEL) && !defined(_LOCORE)
/*
* Kernel virtual address to page table entry and visa versa.
*/
#define kvtopte(va) \
(Sysmap + (((vm_offset_t)(va) - VM_MIN_KERNEL_ADDRESS) >> PGSHIFT))
#define ptetokv(pte) \
((((pt_entry_t *)(pte) - Sysmap) << PGSHIFT) + VM_MIN_KERNEL_ADDRESS)
extern pt_entry_t *Sysmap; /* kernel pte table */
extern u_int Sysmapsize; /* number of pte's in Sysmap */
#endif /* defined(_KERNEL) && !defined(_LOCORE) */

View File

@ -0,0 +1,46 @@
/* $NetBSD: pte.h,v 1.1 1996/10/13 09:28:56 jonathan Exp $ */
/*
* Copyright 1996 The Board of Trustees of The Leland Stanford
* Junior University. All Rights Reserved.
*
* Permission to use, copy, modify, and distribute this
* software and its documentation for any purpose and without
* fee is hereby granted, provided that the above copyright
* notice appear in all copies. Stanford University
* makes no representations about the suitability of this
* software for any purpose. It is provided "as is" without
* express or implied warranty.
*/
#ifndef __MIPS_PTE_H__
#define __MIPS_PTE_H__
#if defined(MIPS1) && defined(MIPS3)
#error Cannot yet upport both "MIPS1" (r2000 family) and "MIP3" (r4000 family) in the same kernel.
#endif
#ifdef MIPS1
#include <mips/mips1_pte.h>
#endif
#ifdef MIPS3
#include <mips/mips3_pte.h>
#endif
#if defined(_KERNEL) && !defined(_LOCORE)
/*
* Kernel virtual address to page table entry and visa versa.
*/
#define kvtopte(va) \
(Sysmap + (((vm_offset_t)(va) - VM_MIN_KERNEL_ADDRESS) >> PGSHIFT))
#define ptetokv(pte) \
((((pt_entry_t *)(pte) - Sysmap) << PGSHIFT) + VM_MIN_KERNEL_ADDRESS)
extern pt_entry_t *Sysmap; /* kernel pte table */
extern u_int Sysmapsize; /* number of pte's in Sysmap */
#endif /* defined(_KERNEL) && !defined(_LOCORE) */
#endif /* __MIPS_PTE_H__ */

View File

@ -1,4 +1,4 @@
/* $NetBSD: trap.c,v 1.47 1996/10/13 07:09:33 jonathan Exp $ */ /* $NetBSD: trap.c,v 1.48 1996/10/13 09:29:07 jonathan Exp $ */
/* /*
* Copyright (c) 1988 University of Utah. * Copyright (c) 1988 University of Utah.
@ -108,8 +108,10 @@ extern void mips_r2000_UserGenException __P((void));
extern void mips_r2000_KernIntr __P((void)); extern void mips_r2000_KernIntr __P((void));
extern void mips_r2000_UserIntr __P((void)); extern void mips_r2000_UserIntr __P((void));
extern void mips_r2000_TLBModException __P((void)); extern void mips_r2000_TLBModException __P((void));
extern void mips_r2000_TLBMissException __P((void)); extern void mips_r2000_TLBMissException __P((void));
/* marks end of vector code */ /* marks end of vector code */
extern void mips_R2000_UTLBMiss __P((void));
extern void mips1_exceptionentry_end __P((void)); extern void mips1_exceptionentry_end __P((void));
extern void mips_r4000_KernGenException __P((void)); extern void mips_r4000_KernGenException __P((void));
@ -118,7 +120,9 @@ extern void mips_r4000_KernIntr __P((void));
extern void mips_r4000_UserIntr __P((void)); extern void mips_r4000_UserIntr __P((void));
extern void mips_r4000_TLBModException __P((void)); extern void mips_r4000_TLBModException __P((void));
extern void mips_r4000_TLBMissException __P((void)); extern void mips_r4000_TLBMissException __P((void));
/* marks end of vector code */ /* marks end of vector code */
extern void mips_r4000_TLBMiss __P((void));
extern void mips3_exceptionentry_end __P((void)); extern void mips3_exceptionentry_end __P((void));
@ -454,7 +458,7 @@ trap(statusReg, causeReg, vadr, pc, args)
pte->pt_entry = entry; pte->pt_entry = entry;
vadr &= ~PGOFSET; vadr &= ~PGOFSET;
MachTLBUpdate(vadr, entry); MachTLBUpdate(vadr, entry);
pa = entry & PG_FRAME; pa = PTE_TO_PADDR(entry);
#ifdef ATTR #ifdef ATTR
pmap_attributes[atop(pa)] |= PMAP_ATTR_MOD; pmap_attributes[atop(pa)] |= PMAP_ATTR_MOD;
#else #else
@ -492,7 +496,7 @@ trap(statusReg, causeReg, vadr, pc, args)
vadr = (vadr & ~PGOFSET) | vadr = (vadr & ~PGOFSET) |
(pmap->pm_tlbpid << VMMACH_TLB_PID_SHIFT); (pmap->pm_tlbpid << VMMACH_TLB_PID_SHIFT);
MachTLBUpdate(vadr, entry); MachTLBUpdate(vadr, entry);
pa = entry & PG_FRAME; pa = PTE_TO_PADDR(entry);
#ifdef ATTR #ifdef ATTR
pmap_attributes[atop(pa)] |= PMAP_ATTR_MOD; pmap_attributes[atop(pa)] |= PMAP_ATTR_MOD;
#else #else
@ -1556,7 +1560,7 @@ specialframe:
else if (pcBetween(mips_r2000_UserIntr, mips_r2000_TLBMissException)) else if (pcBetween(mips_r2000_UserIntr, mips_r2000_TLBMissException))
subr = (unsigned) mips_r2000_UserIntr; subr = (unsigned) mips_r2000_UserIntr;
else if (pcbetween(mips_r2000_UTLBMiss, mips1_exceptionentry_end) { else if (pcBetween(mips_R2000_UTLBMiss, mips1_exceptionentry_end)) {
(*printfn)("<<mips1 locore>>"); (*printfn)("<<mips1 locore>>");
goto done; goto done;
} }
@ -1576,7 +1580,7 @@ specialframe:
else if (pcBetween(mips_r4000_UserIntr, mips_r4000_TLBMissException)) else if (pcBetween(mips_r4000_UserIntr, mips_r4000_TLBMissException))
subr = (unsigned) mips_r4000_UserIntr; subr = (unsigned) mips_r4000_UserIntr;
else if (pcbetween(mips_r4000_UTLBMiss, mips3_exceptionentry_end) { else if (pcBetween(mips_R4000_TLBMiss, mips3_exceptionentry_end)) {
(*printfn)("<<mips3 locore>>"); (*printfn)("<<mips3 locore>>");
goto done; goto done;
} else } else

View File

@ -1,135 +1,3 @@
/* $NetBSD: pte.h,v 1.3 1996/08/11 23:30:22 jonathan Exp $ */ /* $NetBSD: pte.h,v 1.4 1996/10/13 09:29:03 jonathan Exp $ */
/* #include <mips/pte.h>
* Copyright (c) 1988 University of Utah.
* Copyright (c) 1992, 1993
* The Regents of the University of California. All rights reserved.
*
* This code is derived from software contributed to Berkeley by
* the Systems Programming Group of the University of Utah Computer
* Science Department and Ralph Campbell.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* from: Utah Hdr: pte.h 1.11 89/09/03
*
* from: @(#)pte.h 8.1 (Berkeley) 6/10/93
*/
/*
* R4000 hardware page table entry
*/
#ifndef _LOCORE
struct pte {
#if BYTE_ORDER == BIG_ENDIAN
unsigned int pg_prot:2, /* SW: access control */
pg_pfnum:24, /* HW: core page frame number or 0 */
pg_attr:3, /* HW: cache attribute */
pg_m:1, /* HW: modified (dirty) bit */
pg_v:1, /* HW: valid bit */
pg_g:1; /* HW: ignore pid bit */
#endif
#if BYTE_ORDER == LITTLE_ENDIAN
unsigned int pg_g:1, /* HW: ignore pid bit */
pg_v:1, /* HW: valid bit */
pg_m:1, /* HW: modified (dirty) bit */
pg_attr:3, /* HW: cache attribute */
pg_pfnum:24, /* HW: core page frame number or 0 */
pg_prot:2; /* SW: access control */
#endif
};
/*
* Structure defining an tlb entry data set.
*/
struct tlb {
int tlb_mask;
int tlb_hi;
int tlb_lo0;
int tlb_lo1;
};
typedef union pt_entry {
unsigned int pt_entry; /* for copying, etc. */
struct pte pt_pte; /* for getting to bits by name */
} pt_entry_t; /* Mach page table entry */
#endif /* _LOCORE */
#define PT_ENTRY_NULL ((pt_entry_t *) 0)
#define PG_WIRED 0x80000000 /* SW */
#define PG_RO 0x40000000 /* SW */
#define PG_SVPN 0xfffff000 /* Software page no mask */
#define PG_HVPN 0xffffe000 /* Hardware page no mask */
#define PG_ODDPG 0x00001000 /* Odd even pte entry */
#define PG_ASID 0x000000ff /* Address space ID */
#define PG_G 0x00000001 /* HW */
#define PG_V 0x00000002
#define PG_NV 0x00000000
#define PG_M 0x00000004
#define PG_ATTR 0x0000003f
#define PG_UNCACHED 0x00000010
#define PG_CACHED 0x00000018
#define PG_CACHEMODE 0x00000038
#define PG_ROPAGE (PG_V | PG_RO | PG_CACHED) /* Write protected */
#define PG_RWPAGE (PG_V | PG_M | PG_CACHED) /* Not wr-prot not clean */
#define PG_CWPAGE (PG_V | PG_CACHED) /* Not wr-prot but clean */
#define PG_IOPAGE (PG_G | PG_V | PG_M | PG_UNCACHED)
#define PG_FRAME 0x3fffffc0
#define PG_SHIFT 6
#define vad_to_pfn(x) (((unsigned)(x) >> PG_SHIFT) & PG_FRAME)
#define pfn_to_vad(x) (((x) & PG_FRAME) << PG_SHIFT)
#define vad_to_vpn(x) ((unsigned)(x) & PG_SVPN)
#define vpn_to_vad(x) ((x) & PG_SVPN)
/* User viritual to pte page entry */
#define uvtopte(adr) (((adr) >> PGSHIFT) & (NPTEPG -1))
#define PG_SIZE_4K 0x00000000
#define PG_SIZE_16K 0x00006000
#define PG_SIZE_64K 0x0001e000
#define PG_SIZE_256K 0x0007e000
#define PG_SIZE_1M 0x001fe000
#define PG_SIZE_4M 0x007fe000
#define PG_SIZE_16M 0x01ffe000
#if defined(_KERNEL) && !defined(_LOCORE)
/*
* Kernel virtual address to page table entry and visa versa.
*/
#define kvtopte(va) \
(Sysmap + (((vm_offset_t)(va) - VM_MIN_KERNEL_ADDRESS) >> PGSHIFT))
#define ptetokv(pte) \
((((pt_entry_t *)(pte) - Sysmap) << PGSHIFT) + VM_MIN_KERNEL_ADDRESS)
extern pt_entry_t *Sysmap; /* kernel pte table */
extern u_int Sysmapsize; /* number of pte's in Sysmap */
#endif /* defined(_KERNEL) && !defined(_LOCORE) */

View File

@ -1,107 +1,3 @@
/* $NetBSD: pte.h,v 1.6 1996/02/01 22:32:15 mycroft Exp $ */ /* $NetBSD: pte.h,v 1.7 1996/10/13 09:29:00 jonathan Exp $ */
/* #include <mips/pte.h>
* Copyright (c) 1988 University of Utah.
* Copyright (c) 1992, 1993
* The Regents of the University of California. All rights reserved.
*
* This code is derived from software contributed to Berkeley by
* the Systems Programming Group of the University of Utah Computer
* Science Department and Ralph Campbell.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* from: Utah Hdr: pte.h 1.11 89/09/03
*
* @(#)pte.h 8.1 (Berkeley) 6/10/93
*/
/*
* R2000 hardware page table entry
*/
#ifndef _LOCORE
struct pte {
#if BYTE_ORDER == BIG_ENDIAN
unsigned int pg_pfnum:20, /* HW: core page frame number or 0 */
pg_n:1, /* HW: non-cacheable bit */
pg_m:1, /* HW: modified (dirty) bit */
pg_v:1, /* HW: valid bit */
pg_g:1, /* HW: ignore pid bit */
:4,
pg_swapm:1, /* SW: page must be forced to swap */
pg_fod:1, /* SW: is fill on demand (=0) */
pg_prot:2; /* SW: access control */
#endif
#if BYTE_ORDER == LITTLE_ENDIAN
unsigned int pg_prot:2, /* SW: access control */
pg_fod:1, /* SW: is fill on demand (=0) */
pg_swapm:1, /* SW: page must be forced to swap */
:4,
pg_g:1, /* HW: ignore pid bit */
pg_v:1, /* HW: valid bit */
pg_m:1, /* HW: modified (dirty) bit */
pg_n:1, /* HW: non-cacheable bit */
pg_pfnum:20; /* HW: core page frame number or 0 */
#endif
};
typedef union pt_entry {
unsigned int pt_entry; /* for copying, etc. */
struct pte pt_pte; /* for getting to bits by name */
} pt_entry_t; /* Mach page table entry */
#endif /* _LOCORE */
#define PT_ENTRY_NULL ((pt_entry_t *) 0)
#define PG_PROT 0x00000003
#define PG_RW 0x00000000
#define PG_RO 0x00000001
#define PG_WIRED 0x00000002
#define PG_G 0x00000100
#define PG_V 0x00000200
#define PG_NV 0x00000000
#define PG_M 0x00000400
#define PG_N 0x00000800
#define PG_FRAME 0xfffff000
#define PG_SHIFT 12
#define PG_PFNUM(x) (((x) & PG_FRAME) >> PG_SHIFT)
#if defined(_KERNEL) && !defined(_LOCORE)
/*
* Kernel virtual address to page table entry and visa versa.
*/
#define kvtopte(va) \
(Sysmap + (((vm_offset_t)(va) - VM_MIN_KERNEL_ADDRESS) >> PGSHIFT))
#define ptetokv(pte) \
((((pt_entry_t *)(pte) - Sysmap) << PGSHIFT) + VM_MIN_KERNEL_ADDRESS)
extern pt_entry_t *Sysmap; /* kernel pte table */
extern u_int Sysmapsize; /* number of pte's in Sysmap */
#endif