mips1_pte.h revision 1.2 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: mips1_pte.h,v 1.2 1994/05/27 08:41:01 glass Exp $
42 */
43
44 /*
45 * R2000 hardware page table entry
46 */
47
48 #ifndef LOCORE
49 struct pte {
50 #if BYTE_ORDER == BIG_ENDIAN
51 unsigned int pg_pfnum:20, /* HW: core page frame number or 0 */
52 pg_n:1, /* HW: non-cacheable bit */
53 pg_m:1, /* HW: modified (dirty) bit */
54 pg_v:1, /* HW: valid bit */
55 pg_g:1, /* HW: ignore pid bit */
56 :4,
57 pg_swapm:1, /* SW: page must be forced to swap */
58 pg_fod:1, /* SW: is fill on demand (=0) */
59 pg_prot:2; /* SW: access control */
60 #endif
61 #if BYTE_ORDER == LITTLE_ENDIAN
62 unsigned int pg_prot:2, /* SW: access control */
63 pg_fod:1, /* SW: is fill on demand (=0) */
64 pg_swapm:1, /* SW: page must be forced to swap */
65 :4,
66 pg_g:1, /* HW: ignore pid bit */
67 pg_v:1, /* HW: valid bit */
68 pg_m:1, /* HW: modified (dirty) bit */
69 pg_n:1, /* HW: non-cacheable bit */
70 pg_pfnum:20; /* HW: core page frame number or 0 */
71 #endif
72 };
73
74 typedef union pt_entry {
75 unsigned int pt_entry; /* for copying, etc. */
76 struct pte pt_pte; /* for getting to bits by name */
77 } pt_entry_t; /* Mach page table entry */
78 #endif /* LOCORE */
79
80 #define PT_ENTRY_NULL ((pt_entry_t *) 0)
81
82 #define PG_PROT 0x00000003
83 #define PG_RW 0x00000000
84 #define PG_RO 0x00000001
85 #define PG_WIRED 0x00000002
86 #define PG_G 0x00000100
87 #define PG_V 0x00000200
88 #define PG_NV 0x00000000
89 #define PG_M 0x00000400
90 #define PG_N 0x00000800
91 #define PG_FRAME 0xfffff000
92 #define PG_SHIFT 12
93 #define PG_PFNUM(x) (((x) & PG_FRAME) >> PG_SHIFT)
94
95 #if defined(KERNEL) && !defined(LOCORE)
96 /*
97 * Kernel virtual address to page table entry and visa versa.
98 */
99 #define kvtopte(va) \
100 (Sysmap + (((vm_offset_t)(va) - VM_MIN_KERNEL_ADDRESS) >> PGSHIFT))
101 #define ptetokv(pte) \
102 ((((pt_entry_t *)(pte) - Sysmap) << PGSHIFT) + VM_MIN_KERNEL_ADDRESS)
103
104 extern pt_entry_t *Sysmap; /* kernel pte table */
105 extern u_int Sysmapsize; /* number of pte's in Sysmap */
106 #endif
107