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