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