xref: /freebsd/sys/powerpc/include/pte.h (revision 7bd6fde3)
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 
43 /* 32-bit PTE */
44 struct pte {
45 	u_int32_t pte_hi;
46 	u_int32_t pte_lo;
47 };
48 
49 struct pteg {
50 	struct	pte pt[8];
51 };
52 
53 /* 64-bit (long) PTE */
54 struct lpte {
55 	u_int64_t pte_hi;
56 	u_int64_t pte_lo;
57 };
58 
59 struct lpteg {
60 	struct lpte pt[8];
61 };
62 
63 #endif	/* LOCORE */
64 
65 /* 32-bit PTE definitions */
66 
67 /* High word: */
68 #define	PTE_VALID	0x80000000
69 #define	PTE_VSID_SHFT	7
70 #define	PTE_HID		0x00000040
71 #define	PTE_API		0x0000003f
72 /* Low word: */
73 #define	PTE_RPGN	0xfffff000
74 #define	PTE_REF		0x00000100
75 #define	PTE_CHG		0x00000080
76 #define	PTE_WIMG	0x00000078
77 #define	PTE_W		0x00000040
78 #define	PTE_I		0x00000020
79 #define	PTE_M		0x00000010
80 #define	PTE_G		0x00000008
81 #define	PTE_PP		0x00000003
82 #define	PTE_SO		0x00000000	/* Super. Only       (U: XX, S: RW) */
83 #define PTE_SW		0x00000001	/* Super. Write-Only (U: RO, S: RW) */
84 #define	PTE_BW		0x00000002	/* Supervisor        (U: RW, S: RW) */
85 #define	PTE_BR		0x00000003	/* Both Read Only    (U: RO, S: RO) */
86 #define	PTE_RW		PTE_BW
87 #define	PTE_RO		PTE_BR
88 
89 #define	PTE_EXEC	0x00000200	/* pseudo bit in attrs; page is exec */
90 
91 /* 64-bit PTE definitions */
92 
93 /* High quadword: */
94 #define LPTE_VSID_SHIFT		12
95 #define LPTE_API		0x0000000000000F80ULL
96 #define LPTE_BIG		0x0000000000000004ULL	/* 4kb/16Mb page */
97 #define LPTE_HID		0x0000000000000002ULL
98 #define LPTE_VALID		0x0000000000000001ULL
99 
100 /* Low quadword: */
101 #define EXTEND_PTE(x)	UINT64_C(x)	/* make constants 64-bit */
102 #define	LPTE_RPGN	0xfffffffffffff000ULL
103 #define	LPTE_REF	EXTEND_PTE( PTE_REF )
104 #define	LPTE_CHG	EXTEND_PTE( PTE_CHG )
105 #define	LPTE_WIMG	EXTEND_PTE( PTE_WIMG )
106 #define	LPTE_W		EXTEND_PTE( PTE_W )
107 #define	LPTE_I		EXTEND_PTE( PTE_I )
108 #define	LPTE_M		EXTEND_PTE( PTE_M )
109 #define	LPTE_G		EXTEND_PTE( PTE_G )
110 #define	LPTE_NOEXEC	0x0000000000000004ULL
111 #define	LPTE_PP		EXTEND_PTE( PTE_PP )
112 
113 #define	LPTE_SO		EXTEND_PTE( PTE_SO )	/* Super. Only */
114 #define	LPTE_SW		EXTEND_PTE( PTE_SW )	/* Super. Write-Only */
115 #define	LPTE_BW		EXTEND_PTE( PTE_BW )	/* Supervisor */
116 #define	LPTE_BR		EXTEND_PTE( PTE_BR )	/* Both Read Only */
117 #define	LPTE_RW		LPTE_BW
118 #define	LPTE_RO		LPTE_BR
119 
120 #ifndef	LOCORE
121 typedef	struct pte pte_t;
122 typedef	struct lpte lpte_t;
123 #endif	/* LOCORE */
124 
125 /*
126  * Extract bits from address
127  */
128 #define	ADDR_SR_SHFT	28
129 #define	ADDR_PIDX	0x0ffff000
130 #define	ADDR_PIDX_SHFT	12
131 #define	ADDR_API_SHFT	22
132 #define	ADDR_POFF	0x00000fff
133 
134 /*
135  * Bits in DSISR:
136  */
137 #define	DSISR_DIRECT	0x80000000
138 #define	DSISR_NOTFOUND	0x40000000
139 #define	DSISR_PROTECT	0x08000000
140 #define	DSISR_INVRX	0x04000000
141 #define	DSISR_STORE	0x02000000
142 #define	DSISR_DABR	0x00400000
143 #define	DSISR_SEGMENT	0x00200000
144 #define	DSISR_EAR	0x00100000
145 
146 /*
147  * Bits in SRR1 on ISI:
148  */
149 #define	ISSRR1_NOTFOUND	0x40000000
150 #define	ISSRR1_DIRECT	0x10000000
151 #define	ISSRR1_PROTECT	0x08000000
152 #define	ISSRR1_SEGMENT	0x00200000
153 
154 #ifdef	_KERNEL
155 #ifndef	LOCORE
156 extern u_int dsisr(void);
157 #endif	/* _KERNEL */
158 #endif	/* LOCORE */
159 #endif	/* _MACHINE_PTE_H_ */
160