xref: /freebsd/sys/powerpc/include/pte.h (revision 74bf4e164ba5851606a27d4feff27717452583e5)
1 /*-
2  * Copyright (C) 1995, 1996 Wolfgang Solfrank.
3  * Copyright (C) 1995, 1996 TooLs GmbH.
4  * All rights reserved.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions
8  * are met:
9  * 1. Redistributions of source code must retain the above copyright
10  *    notice, this list of conditions and the following disclaimer.
11  * 2. Redistributions in binary form must reproduce the above copyright
12  *    notice, this list of conditions and the following disclaimer in the
13  *    documentation and/or other materials provided with the distribution.
14  * 3. All advertising materials mentioning features or use of this software
15  *    must display the following acknowledgement:
16  *	This product includes software developed by TooLs GmbH.
17  * 4. The name of TooLs GmbH may not be used to endorse or promote products
18  *    derived from this software without specific prior written permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``AS IS'' AND ANY EXPRESS OR
21  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
22  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
23  * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
26  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
27  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
28  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
29  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30  *
31  *	$NetBSD: pte.h,v 1.2 1998/08/31 14:43:40 tsubai Exp $
32  * $FreeBSD$
33  */
34 
35 #ifndef	_MACHINE_PTE_H_
36 #define	_MACHINE_PTE_H_
37 
38 /*
39  * Page Table Entries
40  */
41 #ifndef	LOCORE
42 #include <sys/queue.h>
43 
44 struct pte {
45 	u_int pte_hi;
46 	u_int pte_lo;
47 };
48 
49 struct pteg {
50 	struct	pte pt[8];
51 };
52 #endif	/* LOCORE */
53 /* High word: */
54 #define	PTE_VALID	0x80000000
55 #define	PTE_VSID_SHFT	7
56 #define	PTE_HID		0x00000040
57 #define	PTE_API		0x0000003f
58 /* Low word: */
59 #define	PTE_RPGN	0xfffff000
60 #define	PTE_REF		0x00000100
61 #define	PTE_CHG		0x00000080
62 #define	PTE_WIMG	0x00000078
63 #define	PTE_W		0x00000040
64 #define	PTE_I		0x00000020
65 #define	PTE_M		0x00000010
66 #define	PTE_G		0x00000008
67 #define	PTE_PP		0x00000003
68 #define	PTE_SO		0x00000000	/* Super. Only       (U: XX, S: RW) */
69 #define PTE_SW		0x00000001	/* Super. Write-Only (U: RO, S: RW) */
70 #define	PTE_BW		0x00000002	/* Supervisor        (U: RW, S: RW) */
71 #define	PTE_BR		0x00000003	/* Both Read Only    (U: RO, S: RO) */
72 #define	PTE_RW		PTE_BW
73 #define	PTE_RO		PTE_BR
74 
75 #define	PTE_EXEC	0x00000200	/* pseudo bit in attrs; page is exec */
76 
77 #ifndef	LOCORE
78 typedef	struct pte pte_t;
79 #endif	/* LOCORE */
80 
81 /*
82  * Extract bits from address
83  */
84 #define	ADDR_SR_SHFT	28
85 #define	ADDR_PIDX	0x0ffff000
86 #define	ADDR_PIDX_SHFT	12
87 #define	ADDR_API_SHFT	22
88 #define	ADDR_POFF	0x00000fff
89 
90 #ifndef	LOCORE
91 #ifdef	_KERNEL
92 extern pte_t *ptable;
93 extern int ptab_cnt;
94 #endif	/* _KERNEL */
95 #endif	/* LOCORE */
96 
97 /*
98  * Bits in DSISR:
99  */
100 #define	DSISR_DIRECT	0x80000000
101 #define	DSISR_NOTFOUND	0x40000000
102 #define	DSISR_PROTECT	0x08000000
103 #define	DSISR_INVRX	0x04000000
104 #define	DSISR_STORE	0x02000000
105 #define	DSISR_DABR	0x00400000
106 #define	DSISR_SEGMENT	0x00200000
107 #define	DSISR_EAR	0x00100000
108 
109 /*
110  * Bits in SRR1 on ISI:
111  */
112 #define	ISSRR1_NOTFOUND	0x40000000
113 #define	ISSRR1_DIRECT	0x10000000
114 #define	ISSRR1_PROTECT	0x08000000
115 #define	ISSRR1_SEGMENT	0x00200000
116 
117 #ifdef	_KERNEL
118 #ifndef	LOCORE
119 extern u_int dsisr(void);
120 #endif	/* _KERNEL */
121 #endif	/* LOCORE */
122 #endif	/* _MACHINE_PTE_H_ */
123