pte.h revision 1.4.2.2 1 1.4.2.2 mycroft /*-
2 1.4.2.2 mycroft * Copyright (c) 1990 The Regents of the University of California.
3 1.4.2.2 mycroft * All rights reserved.
4 1.4.2.2 mycroft *
5 1.4.2.2 mycroft * This code is derived from software contributed to Berkeley by
6 1.4.2.2 mycroft * William Jolitz.
7 1.4.2.2 mycroft *
8 1.4.2.2 mycroft * Redistribution and use in source and binary forms, with or without
9 1.4.2.2 mycroft * modification, are permitted provided that the following conditions
10 1.4.2.2 mycroft * are met:
11 1.4.2.2 mycroft * 1. Redistributions of source code must retain the above copyright
12 1.4.2.2 mycroft * notice, this list of conditions and the following disclaimer.
13 1.4.2.2 mycroft * 2. Redistributions in binary form must reproduce the above copyright
14 1.4.2.2 mycroft * notice, this list of conditions and the following disclaimer in the
15 1.4.2.2 mycroft * documentation and/or other materials provided with the distribution.
16 1.4.2.2 mycroft * 3. All advertising materials mentioning features or use of this software
17 1.4.2.2 mycroft * must display the following acknowledgement:
18 1.4.2.2 mycroft * This product includes software developed by the University of
19 1.4.2.2 mycroft * California, Berkeley and its contributors.
20 1.4.2.2 mycroft * 4. Neither the name of the University nor the names of its contributors
21 1.4.2.2 mycroft * may be used to endorse or promote products derived from this software
22 1.4.2.2 mycroft * without specific prior written permission.
23 1.4.2.2 mycroft *
24 1.4.2.2 mycroft * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
25 1.4.2.2 mycroft * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26 1.4.2.2 mycroft * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27 1.4.2.2 mycroft * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
28 1.4.2.2 mycroft * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29 1.4.2.2 mycroft * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30 1.4.2.2 mycroft * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31 1.4.2.2 mycroft * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32 1.4.2.2 mycroft * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33 1.4.2.2 mycroft * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 1.4.2.2 mycroft * SUCH DAMAGE.
35 1.4.2.2 mycroft *
36 1.4.2.2 mycroft * from: @(#)pte.h 5.5 (Berkeley) 5/9/91
37 1.4.2.2 mycroft * $Id: pte.h,v 1.4.2.2 1993/12/14 05:31:41 mycroft Exp $
38 1.4.2.2 mycroft */
39 1.4.2.2 mycroft
40 1.4.2.2 mycroft /*
41 1.4.2.2 mycroft * 386 page table entry and page table directory
42 1.4.2.2 mycroft * W.Jolitz, 8/89
43 1.4.2.2 mycroft *
44 1.4.2.2 mycroft * There are two major kinds of pte's: those which have ever existed (and are
45 1.4.2.2 mycroft * thus either now in core or on the swap device), and those which have
46 1.4.2.2 mycroft * never existed, but which will be filled on demand at first reference.
47 1.4.2.2 mycroft * There is a structure describing each. There is also an ancillary
48 1.4.2.2 mycroft * structure used in page clustering.
49 1.4.2.2 mycroft */
50 1.4.2.2 mycroft
51 1.4.2.2 mycroft #ifndef _I386_PTE_H_
52 1.4.2.2 mycroft #define _I386_PTE_H_
53 1.4.2.2 mycroft
54 1.4.2.2 mycroft #define PDSHIFT 22 /* LOG2(NBPDR) */
55 1.4.2.2 mycroft #define NBPD (1 << PDSHIFT) /* bytes/page dir */
56 1.4.2.2 mycroft #define PDOFSET (NBPD-1) /* byte offset into page dir */
57 1.4.2.2 mycroft #define NPTEPD (NBPD / NBPG)
58 1.4.2.2 mycroft
59 1.4.2.2 mycroft #ifndef LOCORE
60 1.4.2.2 mycroft
61 1.4.2.2 mycroft struct pde {
62 1.4.2.2 mycroft unsigned int
63 1.4.2.2 mycroft pd_v:1, /* valid bit */
64 1.4.2.2 mycroft pd_prot:2, /* access control */
65 1.4.2.2 mycroft pg_nc:2, /* cache disable and write-through */
66 1.4.2.2 mycroft pd_u:1, /* hardware maintained 'used' bit */
67 1.4.2.2 mycroft pd_mbz:3, /* reserved, must be zero */
68 1.4.2.2 mycroft pg_w:1, /* is wired */
69 1.4.2.2 mycroft :2, /* reserved for software */
70 1.4.2.2 mycroft pd_pfnum:20; /* physical page frame number of pte's*/
71 1.4.2.2 mycroft };
72 1.4.2.2 mycroft
73 1.4.2.2 mycroft struct pte {
74 1.4.2.2 mycroft unsigned int
75 1.4.2.2 mycroft pg_v:1, /* valid bit */
76 1.4.2.2 mycroft pg_prot:2, /* access control */
77 1.4.2.2 mycroft pg_nc:2, /* cache disable and write-through */
78 1.4.2.2 mycroft pg_u:1, /* hardware maintained 'used' bit */
79 1.4.2.2 mycroft pg_m:1, /* hardware maintained modified bit */
80 1.4.2.2 mycroft pg_mbz:2, /* reserved, must be zero */
81 1.4.2.2 mycroft pg_w:1, /* is wired */
82 1.4.2.2 mycroft :2, /* must write back to swap (unused) */
83 1.4.2.2 mycroft pg_pfnum:20; /* physical page frame number */
84 1.4.2.2 mycroft };
85 1.4.2.2 mycroft
86 1.4.2.2 mycroft typedef struct pde pd_entry_t; /* page directory entry */
87 1.4.2.2 mycroft typedef struct pte pt_entry_t; /* Mach page table entry */
88 1.4.2.2 mycroft
89 1.4.2.2 mycroft #endif
90 1.4.2.2 mycroft
91 1.4.2.2 mycroft #define PD_MASK 0xffc00000 /* page directory address bits */
92 1.4.2.2 mycroft #define PT_MASK 0x003ff000 /* page table address bits */
93 1.4.2.2 mycroft
94 1.4.2.2 mycroft #define PG_V 0x00000001 /* present */
95 1.4.2.2 mycroft #define PG_RO 0x00000000 /* read-only by user (and kernel if 486) */
96 1.4.2.2 mycroft #define PG_RW 0x00000002 /* read-write by user */
97 1.4.2.2 mycroft #define PG_u 0x00000004 /* accessible by user */
98 1.4.2.2 mycroft #define PG_PROT 0x00000006 /* all protection bits */
99 1.4.2.2 mycroft #define PG_N 0x00000018 /* non-cacheable */
100 1.4.2.2 mycroft #define PG_U 0x00000020 /* has been used */
101 1.4.2.2 mycroft #define PG_M 0x00000040 /* has been modified */
102 1.4.2.2 mycroft #define PG_W 0x00000200 /* page is wired */
103 1.4.2.2 mycroft #define PG_FRAME 0xfffff000 /* page frame mask */
104 1.4.2.2 mycroft
105 1.4.2.2 mycroft #define PG_FZERO 0
106 1.4.2.2 mycroft #define PG_FTEXT 1
107 1.4.2.2 mycroft #define PG_FMAX (PG_FTEXT)
108 1.4.2.2 mycroft
109 1.4.2.2 mycroft #define PG_NOACC 0
110 1.4.2.2 mycroft #define PG_KR 0x00000000
111 1.4.2.2 mycroft #define PG_KW 0x00000002
112 1.4.2.2 mycroft #define PG_URKR 0x00000004
113 1.4.2.2 mycroft #define PG_URKW 0x00000004
114 1.4.2.2 mycroft #define PG_UW 0x00000006
115 1.4.2.2 mycroft
116 1.4.2.2 mycroft /*
117 1.4.2.2 mycroft * Page Protection Exception bits
118 1.4.2.2 mycroft */
119 1.4.2.2 mycroft #define PGEX_P 0x01 /* Protection violation vs. not present */
120 1.4.2.2 mycroft #define PGEX_W 0x02 /* during a Write cycle */
121 1.4.2.2 mycroft #define PGEX_U 0x04 /* access from User mode (UPL) */
122 1.4.2.2 mycroft
123 1.4.2.2 mycroft /*
124 1.4.2.2 mycroft * Pte related macros
125 1.4.2.2 mycroft */
126 1.4.2.2 mycroft #define dirty(pte) ((pte)->pg_m)
127 1.4.2.2 mycroft
128 1.4.2.2 mycroft #ifndef LOCORE
129 1.4.2.2 mycroft #ifdef KERNEL
130 1.4.2.2 mycroft /* utilities defined in pmap.c */
131 1.4.2.2 mycroft extern struct pte *Sysmap;
132 1.4.2.2 mycroft #endif
133 1.4.2.2 mycroft #endif
134 1.4.2.2 mycroft
135 1.4.2.2 mycroft #endif /* _I386_PTE_H_ */
136