pte.h revision 1.7
1/*	$NetBSD: pte.h,v 1.7 1994/10/27 04:16:21 cgd Exp $	*/
2
3/*-
4 * Copyright (c) 1990 The Regents of the University of California.
5 * All rights reserved.
6 *
7 * This code is derived from software contributed to Berkeley by
8 * William Jolitz.
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 *	@(#)pte.h	5.5 (Berkeley) 5/9/91
39 */
40
41/*
42 * 386 page table entry and page table directory
43 * W.Jolitz, 8/89
44 *
45 * There are two major kinds of pte's: those which have ever existed (and are
46 * thus either now in core or on the swap device), and those which have
47 * never existed, but which will be filled on demand at first reference.
48 * There is a structure describing each.  There is also an ancillary
49 * structure used in page clustering.
50 */
51
52#ifndef _I386_PTE_H_
53#define _I386_PTE_H_
54
55#define	PDSHIFT		22		/* LOG2(NBPDR) */
56#define	NBPD		(1 << PDSHIFT)	/* bytes/page dir */
57#define	PDOFSET		(NBPD-1)	/* byte offset into page dir */
58#define	NPTEPD		(NBPD / NBPG)
59
60#ifndef LOCORE
61typedef int	pd_entry_t;		/* page directory entry */
62typedef int	pt_entry_t;		/* Mach page table entry */
63#endif
64
65#define	PD_MASK		0xffc00000	/* page directory address bits */
66#define	PT_MASK		0x003ff000	/* page table address bits */
67
68#define	PG_V		0x00000001	/* present */
69#define	PG_RO		0x00000000	/* read-only by user (and kernel if 486) */
70#define	PG_RW		0x00000002	/* read-write by user */
71#define	PG_u		0x00000004	/* accessible by user */
72#define	PG_PROT		0x00000006	/* all protection bits */
73#define	PG_N		0x00000018	/* non-cacheable */
74#define	PG_U		0x00000020	/* has been used */
75#define	PG_M		0x00000040	/* has been modified */
76#define	PG_W            0x00000200	/* page is wired */
77#define	PG_FRAME	0xfffff000	/* page frame mask */
78
79#define	PG_FZERO	0
80#define	PG_FTEXT	1
81#define	PG_FMAX		(PG_FTEXT)
82
83#define	PG_NOACC	0
84#define	PG_KR		0x00000000
85#define	PG_KW		0x00000002
86#define	PG_URKR		0x00000004
87#define	PG_URKW		0x00000004
88#define	PG_UW		0x00000006
89
90/*
91 * Page Protection Exception bits
92 */
93#define PGEX_P		0x01	/* Protection violation vs. not present */
94#define PGEX_W		0x02	/* during a Write cycle */
95#define PGEX_U		0x04	/* access from User mode (UPL) */
96
97#ifndef LOCORE
98#ifdef KERNEL
99/* utilities defined in pmap.c */
100extern	pt_entry_t *Sysmap;
101#endif
102#endif
103
104#endif /* _I386_PTE_H_ */
105