xref: /illumos-gate/usr/src/uts/intel/sys/pte.h (revision f0089e39)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 /*
22  * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 
26 #ifndef _SYS_PTE_H
27 #define	_SYS_PTE_H
28 
29 #ifndef _ASM
30 #include <sys/types.h>
31 #endif /* _ASM */
32 
33 #ifdef	__cplusplus
34 extern "C" {
35 #endif
36 
37 #ifndef _ASM
38 
39 #ifdef	PTE36			/* PTE36 ---------------------------- */
40 
41 typedef uint64_t	pteval_t;
42 typedef	pteval_t	*pteptr_t;
43 
44 #define	PRPTEx		"llx"
45 
46 typedef struct pte32 {
47 	uint32_t Present:1;
48 	uint32_t AccessPermissions:2;
49 	uint32_t WriteThru:1;
50 	uint32_t NonCacheable:1;
51 	uint32_t Referenced:1;
52 	uint32_t Modified:1;
53 	uint32_t MustBeZero:1;
54 	uint32_t GlobalEnable:1;
55 	uint32_t OSReserved:3;
56 	uint32_t PhysicalPageNumber:20;
57 } pte32_t;
58 
59 
60 typedef struct pte {
61 	uint32_t Present:1;
62 	uint32_t AccessPermissions:2;
63 	uint32_t WriteThru:1;
64 	uint32_t NonCacheable:1;
65 	uint32_t Referenced:1;
66 	uint32_t Modified:1;
67 	uint32_t MustBeZero:1;
68 	uint32_t GlobalEnable:1;
69 	uint32_t OSReserved:3;
70 	uint32_t PhysicalPageNumberL:20;
71 	uint32_t PhysicalPageNumberH;
72 					/*
73 					 * An easy way to ensure that
74 					 * reserved bits are zero.
75 					 */
76 } pte_t;
77 
78 struct  pte64 {
79 	uint32_t	pte64_0_31;
80 	uint32_t	pte64_32_64;
81 };
82 
83 #define	NPTESHIFT	9
84 #define	NPTEPERPT	512	/* entries in page table */
85 #define	PTSIZE		(NPTEPERPT * MMU_PAGESIZE)	/* bytes mapped */
86 
87 
88 #else		/* PTE36 */
89 				/* PTE32 ---------------------------- */
90 
91 
92 typedef uint32_t	pteval_t;
93 typedef	pteval_t	*pteptr_t;
94 
95 #define	PRPTEx		"x"
96 
97 typedef struct pte {
98 	uint_t Present:1;
99 	uint_t AccessPermissions:2;
100 	uint_t WriteThru:1;
101 	uint_t NonCacheable:1;
102 	uint_t Referenced:1;
103 	uint_t Modified:1;
104 	uint_t MustBeZero:1;
105 	uint_t GlobalEnable:1;
106 	uint_t OSReserved:3;
107 	uint_t PhysicalPageNumber:20;
108 } pte_t;
109 
110 #define	pte32_t		pte_t
111 
112 #define	NPTESHIFT	10
113 #define	NPTEPERPT	1024	/* entries in page table */
114 #define	PTSIZE		(NPTEPERPT * MMU_PAGESIZE)	/* bytes mapped */
115 
116 #endif	/* PTE36 */
117 
118 #define	PTE_VALID	0x01
119 #define	PTE_LARGEPAGE	0x80
120 #define	PTE_SRWX	0x02
121 
122 #endif /* !_ASM */
123 
124 
125 #ifdef	__cplusplus
126 }
127 #endif
128 
129 #endif /* !_SYS_PTE_H */
130