Home | History | Annotate | Line # | Download | only in include
mips3_pte.h revision 1.4
      1  1.4  jonathan /*	$NetBSD: mips3_pte.h,v 1.4 1996/10/13 09:28:55 jonathan Exp $	*/
      2  1.2   thorpej 
      3  1.1  jonathan /*
      4  1.1  jonathan  * Copyright (c) 1988 University of Utah.
      5  1.1  jonathan  * Copyright (c) 1992, 1993
      6  1.1  jonathan  *	The Regents of the University of California.  All rights reserved.
      7  1.1  jonathan  *
      8  1.1  jonathan  * This code is derived from software contributed to Berkeley by
      9  1.1  jonathan  * the Systems Programming Group of the University of Utah Computer
     10  1.1  jonathan  * Science Department and Ralph Campbell.
     11  1.1  jonathan  *
     12  1.1  jonathan  * Redistribution and use in source and binary forms, with or without
     13  1.1  jonathan  * modification, are permitted provided that the following conditions
     14  1.1  jonathan  * are met:
     15  1.1  jonathan  * 1. Redistributions of source code must retain the above copyright
     16  1.1  jonathan  *    notice, this list of conditions and the following disclaimer.
     17  1.1  jonathan  * 2. Redistributions in binary form must reproduce the above copyright
     18  1.1  jonathan  *    notice, this list of conditions and the following disclaimer in the
     19  1.1  jonathan  *    documentation and/or other materials provided with the distribution.
     20  1.1  jonathan  * 3. All advertising materials mentioning features or use of this software
     21  1.1  jonathan  *    must display the following acknowledgement:
     22  1.1  jonathan  *	This product includes software developed by the University of
     23  1.1  jonathan  *	California, Berkeley and its contributors.
     24  1.1  jonathan  * 4. Neither the name of the University nor the names of its contributors
     25  1.1  jonathan  *    may be used to endorse or promote products derived from this software
     26  1.1  jonathan  *    without specific prior written permission.
     27  1.1  jonathan  *
     28  1.1  jonathan  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
     29  1.1  jonathan  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     30  1.1  jonathan  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     31  1.1  jonathan  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
     32  1.1  jonathan  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     33  1.1  jonathan  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     34  1.1  jonathan  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     35  1.1  jonathan  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     36  1.1  jonathan  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     37  1.1  jonathan  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     38  1.1  jonathan  * SUCH DAMAGE.
     39  1.1  jonathan  *
     40  1.1  jonathan  * from: Utah Hdr: pte.h 1.11 89/09/03
     41  1.1  jonathan  *
     42  1.1  jonathan  *	from: @(#)pte.h	8.1 (Berkeley) 6/10/93
     43  1.1  jonathan  */
     44  1.1  jonathan 
     45  1.1  jonathan /*
     46  1.1  jonathan  * R4000 hardware page table entry
     47  1.1  jonathan  */
     48  1.1  jonathan 
     49  1.3  jonathan #ifndef _LOCORE
     50  1.1  jonathan struct pte {
     51  1.1  jonathan #if BYTE_ORDER == BIG_ENDIAN
     52  1.1  jonathan unsigned int	pg_prot:2,		/* SW: access control */
     53  1.1  jonathan 		pg_pfnum:24,		/* HW: core page frame number or 0 */
     54  1.1  jonathan 		pg_attr:3,		/* HW: cache attribute */
     55  1.1  jonathan 		pg_m:1,			/* HW: modified (dirty) bit */
     56  1.1  jonathan 		pg_v:1,			/* HW: valid bit */
     57  1.1  jonathan 		pg_g:1;			/* HW: ignore pid bit */
     58  1.1  jonathan #endif
     59  1.1  jonathan #if BYTE_ORDER == LITTLE_ENDIAN
     60  1.1  jonathan unsigned int 	pg_g:1,			/* HW: ignore pid bit */
     61  1.1  jonathan 		pg_v:1,			/* HW: valid bit */
     62  1.1  jonathan 		pg_m:1,			/* HW: modified (dirty) bit */
     63  1.1  jonathan 		pg_attr:3,			/* HW: cache attribute */
     64  1.1  jonathan 		pg_pfnum:24,		/* HW: core page frame number or 0 */
     65  1.1  jonathan 		pg_prot:2;		/* SW: access control */
     66  1.1  jonathan #endif
     67  1.1  jonathan };
     68  1.1  jonathan 
     69  1.1  jonathan /*
     70  1.1  jonathan  * Structure defining an tlb entry data set.
     71  1.1  jonathan  */
     72  1.1  jonathan 
     73  1.1  jonathan struct tlb {
     74  1.1  jonathan 	int	tlb_mask;
     75  1.1  jonathan 	int	tlb_hi;
     76  1.1  jonathan 	int	tlb_lo0;
     77  1.1  jonathan 	int	tlb_lo1;
     78  1.1  jonathan };
     79  1.1  jonathan 
     80  1.1  jonathan typedef union pt_entry {
     81  1.1  jonathan 	unsigned int	pt_entry;	/* for copying, etc. */
     82  1.1  jonathan 	struct pte	pt_pte;		/* for getting to bits by name */
     83  1.1  jonathan } pt_entry_t;	/* Mach page table entry */
     84  1.3  jonathan #endif /* _LOCORE */
     85  1.1  jonathan 
     86  1.1  jonathan #define	PT_ENTRY_NULL	((pt_entry_t *) 0)
     87  1.1  jonathan 
     88  1.1  jonathan #define PG_WIRED	0x80000000	/* SW */
     89  1.1  jonathan #define PG_RO		0x40000000	/* SW */
     90  1.1  jonathan 
     91  1.1  jonathan #define	PG_SVPN		0xfffff000	/* Software page no mask */
     92  1.1  jonathan #define	PG_HVPN		0xffffe000	/* Hardware page no mask */
     93  1.1  jonathan #define	PG_ODDPG	0x00001000	/* Odd even pte entry */
     94  1.1  jonathan #define	PG_ASID		0x000000ff	/* Address space ID */
     95  1.1  jonathan #define	PG_G		0x00000001	/* HW */
     96  1.1  jonathan #define	PG_V		0x00000002
     97  1.1  jonathan #define	PG_NV		0x00000000
     98  1.1  jonathan #define	PG_M		0x00000004
     99  1.1  jonathan #define	PG_ATTR		0x0000003f
    100  1.1  jonathan #define	PG_UNCACHED	0x00000010
    101  1.1  jonathan #define	PG_CACHED	0x00000018
    102  1.1  jonathan #define	PG_CACHEMODE	0x00000038
    103  1.1  jonathan #define	PG_ROPAGE	(PG_V | PG_RO | PG_CACHED) /* Write protected */
    104  1.1  jonathan #define	PG_RWPAGE	(PG_V | PG_M | PG_CACHED)  /* Not wr-prot not clean */
    105  1.1  jonathan #define	PG_CWPAGE	(PG_V | PG_CACHED)	   /* Not wr-prot but clean */
    106  1.1  jonathan #define	PG_IOPAGE	(PG_G | PG_V | PG_M | PG_UNCACHED)
    107  1.1  jonathan #define	PG_FRAME	0x3fffffc0
    108  1.1  jonathan #define PG_SHIFT	6
    109  1.4  jonathan 
    110  1.4  jonathan /* pte accessor macros */
    111  1.4  jonathan 
    112  1.1  jonathan #define vad_to_pfn(x) (((unsigned)(x) >> PG_SHIFT) & PG_FRAME)
    113  1.1  jonathan #define pfn_to_vad(x) (((x) & PG_FRAME) << PG_SHIFT)
    114  1.1  jonathan #define vad_to_vpn(x) ((unsigned)(x) & PG_SVPN)
    115  1.1  jonathan #define vpn_to_vad(x) ((x) & PG_SVPN)
    116  1.4  jonathan 
    117  1.4  jonathan #define PTE_TO_PADDR(x) (pfn_to_vad((x))
    118  1.4  jonathan 
    119  1.4  jonathan /* User virtual to pte page entry */
    120  1.1  jonathan #define uvtopte(adr) (((adr) >> PGSHIFT) & (NPTEPG -1))
    121  1.1  jonathan 
    122  1.1  jonathan #define	PG_SIZE_4K	0x00000000
    123  1.1  jonathan #define	PG_SIZE_16K	0x00006000
    124  1.1  jonathan #define	PG_SIZE_64K	0x0001e000
    125  1.1  jonathan #define	PG_SIZE_256K	0x0007e000
    126  1.1  jonathan #define	PG_SIZE_1M	0x001fe000
    127  1.1  jonathan #define	PG_SIZE_4M	0x007fe000
    128  1.1  jonathan #define	PG_SIZE_16M	0x01ffe000
    129  1.1  jonathan 
    130