xref: /titanic_53/usr/src/uts/sun4v/sys/pte.h (revision 7c478bd95313f5f23a4c958a745db2134aa03244)
1*7c478bd9Sstevel@tonic-gate /*
2*7c478bd9Sstevel@tonic-gate  * CDDL HEADER START
3*7c478bd9Sstevel@tonic-gate  *
4*7c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*7c478bd9Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
6*7c478bd9Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
7*7c478bd9Sstevel@tonic-gate  * with the License.
8*7c478bd9Sstevel@tonic-gate  *
9*7c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10*7c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
11*7c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
12*7c478bd9Sstevel@tonic-gate  * and limitations under the License.
13*7c478bd9Sstevel@tonic-gate  *
14*7c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
15*7c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16*7c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
17*7c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
18*7c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
19*7c478bd9Sstevel@tonic-gate  *
20*7c478bd9Sstevel@tonic-gate  * CDDL HEADER END
21*7c478bd9Sstevel@tonic-gate  */
22*7c478bd9Sstevel@tonic-gate /*
23*7c478bd9Sstevel@tonic-gate  * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
24*7c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
25*7c478bd9Sstevel@tonic-gate  */
26*7c478bd9Sstevel@tonic-gate 
27*7c478bd9Sstevel@tonic-gate #ifndef _SYS_PTE_H
28*7c478bd9Sstevel@tonic-gate #define	_SYS_PTE_H
29*7c478bd9Sstevel@tonic-gate 
30*7c478bd9Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
31*7c478bd9Sstevel@tonic-gate 
32*7c478bd9Sstevel@tonic-gate #ifndef _ASM
33*7c478bd9Sstevel@tonic-gate #include <sys/types.h>
34*7c478bd9Sstevel@tonic-gate #endif /* _ASM */
35*7c478bd9Sstevel@tonic-gate 
36*7c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
37*7c478bd9Sstevel@tonic-gate extern "C" {
38*7c478bd9Sstevel@tonic-gate #endif
39*7c478bd9Sstevel@tonic-gate 
40*7c478bd9Sstevel@tonic-gate #ifndef _ASM
41*7c478bd9Sstevel@tonic-gate /*
42*7c478bd9Sstevel@tonic-gate  * The tte struct is a 64 bit data type.  Since we currently plan to
43*7c478bd9Sstevel@tonic-gate  * use a V8 compiler all manipulations in C will be done using the bit fields
44*7c478bd9Sstevel@tonic-gate  * or as 2 integers.  In assembly code we will deal with it as a double (using
45*7c478bd9Sstevel@tonic-gate  * ldx and stx).  The structure is defined to force a double alignment.
46*7c478bd9Sstevel@tonic-gate  */
47*7c478bd9Sstevel@tonic-gate typedef union {
48*7c478bd9Sstevel@tonic-gate 	struct tte {
49*7c478bd9Sstevel@tonic-gate 		unsigned int	v:1;		/* <63> valid */
50*7c478bd9Sstevel@tonic-gate 		unsigned int	nfo:1;		/* <62> non-fault only */
51*7c478bd9Sstevel@tonic-gate 		unsigned int	hmenum:3;	/* <61:59> sw hmenum */
52*7c478bd9Sstevel@tonic-gate 		unsigned int	no_sync:1;	/* <58> sw - ghost unload */
53*7c478bd9Sstevel@tonic-gate 		unsigned int	lock:1;		/* <57> sw - locked */
54*7c478bd9Sstevel@tonic-gate 		unsigned int	susp:1;		/* <56> sw - suspend? */
55*7c478bd9Sstevel@tonic-gate 		unsigned int	pahi:24;	/* <55:32> pa */
56*7c478bd9Sstevel@tonic-gate 		/* ------------------- */
57*7c478bd9Sstevel@tonic-gate 		unsigned int	palo:19;	/* <31:13> pa */
58*7c478bd9Sstevel@tonic-gate 		unsigned int	ie:1;		/* <12> 1=invert endianness */
59*7c478bd9Sstevel@tonic-gate 		unsigned int	e:1;		/* <11> side effect */
60*7c478bd9Sstevel@tonic-gate 		unsigned int	cp:1;		/* <10> physically cache */
61*7c478bd9Sstevel@tonic-gate 		unsigned int	cv:1;		/* <9> virtually cache */
62*7c478bd9Sstevel@tonic-gate 		unsigned int	p:1;		/* <8> privilege required */
63*7c478bd9Sstevel@tonic-gate 		unsigned int	x:1;		/* <7> execute perm */
64*7c478bd9Sstevel@tonic-gate 		unsigned int	w:1;		/* <6> write perm */
65*7c478bd9Sstevel@tonic-gate 		unsigned int	ref:1;		/* <5> sw - ref */
66*7c478bd9Sstevel@tonic-gate 		unsigned int	wr_perm:1;	/* <4> sw - write perm */
67*7c478bd9Sstevel@tonic-gate 		unsigned int	rsvd:1;		/* <3> reserved */
68*7c478bd9Sstevel@tonic-gate 		unsigned int	sz:3;		/* <2:0> pagesize */
69*7c478bd9Sstevel@tonic-gate 	} tte_bit;
70*7c478bd9Sstevel@tonic-gate 	struct {
71*7c478bd9Sstevel@tonic-gate 		int32_t		inthi;
72*7c478bd9Sstevel@tonic-gate 		uint32_t	intlo;
73*7c478bd9Sstevel@tonic-gate 	} tte_int;
74*7c478bd9Sstevel@tonic-gate 	uint64_t		ll;
75*7c478bd9Sstevel@tonic-gate } tte_t;
76*7c478bd9Sstevel@tonic-gate 
77*7c478bd9Sstevel@tonic-gate #define	tte_val 	tte_bit.v		/* use < 0 check in asm */
78*7c478bd9Sstevel@tonic-gate #define	tte_size	tte_bit.sz
79*7c478bd9Sstevel@tonic-gate #define	tte_nfo		tte_bit.nfo
80*7c478bd9Sstevel@tonic-gate #define	tte_ie		tte_bit.ie		/* XXX? */
81*7c478bd9Sstevel@tonic-gate #define	tte_hmenum	tte_bit.hmenum
82*7c478bd9Sstevel@tonic-gate #define	tte_pahi	tte_bit.pahi
83*7c478bd9Sstevel@tonic-gate #define	tte_palo	tte_bit.palo
84*7c478bd9Sstevel@tonic-gate #define	tte_ref		tte_bit.ref
85*7c478bd9Sstevel@tonic-gate #define	tte_wr_perm	tte_bit.wr_perm
86*7c478bd9Sstevel@tonic-gate #define	tte_no_sync	tte_bit.no_sync
87*7c478bd9Sstevel@tonic-gate #define	tte_suspend	tte_bit.susp
88*7c478bd9Sstevel@tonic-gate #define	tte_exec_perm	tte_bit.x
89*7c478bd9Sstevel@tonic-gate #define	tte_lock	tte_bit.lock
90*7c478bd9Sstevel@tonic-gate #define	tte_cp		tte_bit.cp
91*7c478bd9Sstevel@tonic-gate #define	tte_cv		tte_bit.cv
92*7c478bd9Sstevel@tonic-gate #define	tte_se		tte_bit.e
93*7c478bd9Sstevel@tonic-gate #define	tte_priv	tte_bit.p
94*7c478bd9Sstevel@tonic-gate #define	tte_hwwr	tte_bit.w
95*7c478bd9Sstevel@tonic-gate 
96*7c478bd9Sstevel@tonic-gate #define	tte_inthi	tte_int.inthi
97*7c478bd9Sstevel@tonic-gate #define	tte_intlo	tte_int.intlo
98*7c478bd9Sstevel@tonic-gate 
99*7c478bd9Sstevel@tonic-gate #endif /* !_ASM */
100*7c478bd9Sstevel@tonic-gate 
101*7c478bd9Sstevel@tonic-gate /* Defines for sz field in tte */
102*7c478bd9Sstevel@tonic-gate #define	TTE8K			0x0
103*7c478bd9Sstevel@tonic-gate #define	TTE64K			0x1
104*7c478bd9Sstevel@tonic-gate #define	TTE512K			0x2
105*7c478bd9Sstevel@tonic-gate #define	TTE4M			0x3
106*7c478bd9Sstevel@tonic-gate #define	TTE32M			0x4
107*7c478bd9Sstevel@tonic-gate #define	TTE256M			0x5
108*7c478bd9Sstevel@tonic-gate #define	TTE2G			0x6
109*7c478bd9Sstevel@tonic-gate #define	TTE16G			0x7
110*7c478bd9Sstevel@tonic-gate 
111*7c478bd9Sstevel@tonic-gate #define	TTE_SZ_SHFT		0
112*7c478bd9Sstevel@tonic-gate #define	TTE_SZ_BITS		0x7
113*7c478bd9Sstevel@tonic-gate 
114*7c478bd9Sstevel@tonic-gate #define	TTE_CSZ(ttep)	((ttep)->tte_size)
115*7c478bd9Sstevel@tonic-gate 
116*7c478bd9Sstevel@tonic-gate #define	TTE_BSZS_SHIFT(sz)	((sz) * 3)
117*7c478bd9Sstevel@tonic-gate #define	TTEBYTES(sz)	(MMU_PAGESIZE << TTE_BSZS_SHIFT(sz))
118*7c478bd9Sstevel@tonic-gate #define	TTEPAGES(sz)	(1 << TTE_BSZS_SHIFT(sz))
119*7c478bd9Sstevel@tonic-gate #define	TTE_PAGE_SHIFT(sz)	(MMU_PAGESHIFT + TTE_BSZS_SHIFT(sz))
120*7c478bd9Sstevel@tonic-gate #define	TTE_PAGE_OFFSET(sz)	(TTEBYTES(sz) - 1)
121*7c478bd9Sstevel@tonic-gate #define	TTE_PAGEMASK(sz)	(~TTE_PAGE_OFFSET(sz))
122*7c478bd9Sstevel@tonic-gate #define	TTE_PFNMASK(sz)	(~(TTE_PAGE_OFFSET(sz) >> MMU_PAGESHIFT))
123*7c478bd9Sstevel@tonic-gate 
124*7c478bd9Sstevel@tonic-gate #define	TTE_PA_LSHIFT	8	/* used to do sllx on tte to get pa */
125*7c478bd9Sstevel@tonic-gate 
126*7c478bd9Sstevel@tonic-gate #ifndef _ASM
127*7c478bd9Sstevel@tonic-gate 
128*7c478bd9Sstevel@tonic-gate #define	TTE_PASHIFT	19	/* used to manage pahi and palo */
129*7c478bd9Sstevel@tonic-gate #define	TTE_PALOMASK	((1 << TTE_PASHIFT) -1)
130*7c478bd9Sstevel@tonic-gate /* PFN is defined as bits [40-13] of the physical address */
131*7c478bd9Sstevel@tonic-gate #define	TTE_TO_TTEPFN(ttep)						\
132*7c478bd9Sstevel@tonic-gate 	((((ttep)->tte_pahi << TTE_PASHIFT) | (ttep)->tte_palo) &	\
133*7c478bd9Sstevel@tonic-gate 	TTE_PFNMASK(TTE_CSZ(ttep)))
134*7c478bd9Sstevel@tonic-gate /*
135*7c478bd9Sstevel@tonic-gate  * This define adds the vaddr page offset to obtain a correct pfn
136*7c478bd9Sstevel@tonic-gate  */
137*7c478bd9Sstevel@tonic-gate #define	TTE_TO_PFN(vaddr, ttep)						\
138*7c478bd9Sstevel@tonic-gate 	(sfmmu_ttetopfn(ttep, vaddr))
139*7c478bd9Sstevel@tonic-gate 
140*7c478bd9Sstevel@tonic-gate #define	PFN_TO_TTE(entry, pfn) {			\
141*7c478bd9Sstevel@tonic-gate 	entry.tte_pahi = pfn >> TTE_PASHIFT;	\
142*7c478bd9Sstevel@tonic-gate 	entry.tte_palo = pfn & TTE_PALOMASK;	\
143*7c478bd9Sstevel@tonic-gate 	}
144*7c478bd9Sstevel@tonic-gate 
145*7c478bd9Sstevel@tonic-gate #endif /* !_ASM */
146*7c478bd9Sstevel@tonic-gate 
147*7c478bd9Sstevel@tonic-gate /*
148*7c478bd9Sstevel@tonic-gate  * The tte defines are separated into integers because the compiler doesn't
149*7c478bd9Sstevel@tonic-gate  * support 64bit defines.
150*7c478bd9Sstevel@tonic-gate  */
151*7c478bd9Sstevel@tonic-gate /* Defines for tte using inthi */
152*7c478bd9Sstevel@tonic-gate #define	TTE_VALID_INT			0x80000000
153*7c478bd9Sstevel@tonic-gate #define	TTE_NFO_INT			0x40000000
154*7c478bd9Sstevel@tonic-gate #define	TTE_NOSYNC_INT			0x04000000
155*7c478bd9Sstevel@tonic-gate #define	TTE_SUSPEND			0x01000000
156*7c478bd9Sstevel@tonic-gate #define	TTE_SUSPEND_SHIFT		32
157*7c478bd9Sstevel@tonic-gate 
158*7c478bd9Sstevel@tonic-gate /* Defines for tte using intlo */
159*7c478bd9Sstevel@tonic-gate #define	TTE_IE_INT			0x00001000
160*7c478bd9Sstevel@tonic-gate #define	TTE_SIDEFF_INT			0x00000800
161*7c478bd9Sstevel@tonic-gate #define	TTE_CP_INT			0x00000400
162*7c478bd9Sstevel@tonic-gate #define	TTE_CV_INT			0x00000200
163*7c478bd9Sstevel@tonic-gate #define	TTE_PRIV_INT			0x00000100
164*7c478bd9Sstevel@tonic-gate #define	TTE_EXECPRM_INT			0x00000080
165*7c478bd9Sstevel@tonic-gate #define	TTE_HWWR_INT			0x00000040
166*7c478bd9Sstevel@tonic-gate #define	TTE_REF_INT			0x00000020
167*7c478bd9Sstevel@tonic-gate #define	TTE_WRPRM_INT			0x00000010
168*7c478bd9Sstevel@tonic-gate 
169*7c478bd9Sstevel@tonic-gate #define	TTE_PROT_INT			(TTE_WRPRM_INT | TTE_PRIV_INT)
170*7c478bd9Sstevel@tonic-gate 
171*7c478bd9Sstevel@tonic-gate #ifndef ASM
172*7c478bd9Sstevel@tonic-gate 
173*7c478bd9Sstevel@tonic-gate /* Defines to help build ttes using inthi */
174*7c478bd9Sstevel@tonic-gate #define	TTE_SZ_INTLO(sz)		((sz) & TTE_SZ_BITS)
175*7c478bd9Sstevel@tonic-gate #define	TTE_HMENUM_INT(hmenum)		((hmenum) << 27)
176*7c478bd9Sstevel@tonic-gate 
177*7c478bd9Sstevel@tonic-gate /* PFN is defined as bits [40-13] of the physical address */
178*7c478bd9Sstevel@tonic-gate #define	TTE_PFN_INTHI(pfn)		((pfn) >> TTE_PASHIFT)
179*7c478bd9Sstevel@tonic-gate #define	TTE_VALID_CHECK(attr)	\
180*7c478bd9Sstevel@tonic-gate 	(((attr) & PROT_ALL) ? TTE_VALID_INT : 0)
181*7c478bd9Sstevel@tonic-gate #define	TTE_NFO_CHECK(attr)	\
182*7c478bd9Sstevel@tonic-gate 	(((attr) & HAT_NOFAULT) ? TTE_NFO_INT : 0)
183*7c478bd9Sstevel@tonic-gate 
184*7c478bd9Sstevel@tonic-gate /* Defines to help build ttes using intlo */
185*7c478bd9Sstevel@tonic-gate #define	TTE_PFN_INTLO(pfn)		(((pfn) & TTE_PALOMASK) << 13)
186*7c478bd9Sstevel@tonic-gate #define	TTE_IE_CHECK(attr)	\
187*7c478bd9Sstevel@tonic-gate 	(((attr) & HAT_STRUCTURE_LE) ? TTE_IE_INT : 0)
188*7c478bd9Sstevel@tonic-gate #define	TTE_WRPRM_CHECK(attr)	 \
189*7c478bd9Sstevel@tonic-gate 	(((attr) & PROT_WRITE) ? TTE_WRPRM_INT : 0)
190*7c478bd9Sstevel@tonic-gate #define	TTE_EXECPRM_CHECK(attr)	 \
191*7c478bd9Sstevel@tonic-gate 	(((attr) & PROT_EXEC) ? TTE_EXECPRM_INT : 0)
192*7c478bd9Sstevel@tonic-gate #define	TTE_NOSYNC_CHECK(attr)	 \
193*7c478bd9Sstevel@tonic-gate 	(((attr) & HAT_NOSYNC) ? TTE_NOSYNC_INT : 0)
194*7c478bd9Sstevel@tonic-gate #define	TTE_CP_CHECK(attr)	\
195*7c478bd9Sstevel@tonic-gate 	(((attr) & SFMMU_UNCACHEPTTE) ? 0: TTE_CP_INT)
196*7c478bd9Sstevel@tonic-gate #define	TTE_CV_CHECK(attr)	\
197*7c478bd9Sstevel@tonic-gate 	(((attr) & SFMMU_UNCACHEVTTE) ? 0: TTE_CV_INT)
198*7c478bd9Sstevel@tonic-gate #define	TTE_SE_CHECK(attr)	\
199*7c478bd9Sstevel@tonic-gate 	(((attr) & SFMMU_SIDEFFECT) ? TTE_SIDEFF_INT : 0)
200*7c478bd9Sstevel@tonic-gate #define	TTE_PRIV_CHECK(attr)	\
201*7c478bd9Sstevel@tonic-gate 	(((attr) & PROT_USER) ? 0 : TTE_PRIV_INT)
202*7c478bd9Sstevel@tonic-gate 
203*7c478bd9Sstevel@tonic-gate #define	MAKE_TTEATTR_INTHI(attr)				\
204*7c478bd9Sstevel@tonic-gate 	(TTE_VALID_CHECK(attr) | TTE_NFO_CHECK(attr))
205*7c478bd9Sstevel@tonic-gate 
206*7c478bd9Sstevel@tonic-gate #define	MAKE_TTE_INTHI(pfn, attr, sz, hmenum)			\
207*7c478bd9Sstevel@tonic-gate 	(MAKE_TTEATTR_INTHI(attr) | TTE_HMENUM_INT(hmenum) |	\
208*7c478bd9Sstevel@tonic-gate 	TTE_NOSYNC_CHECK(attr) | TTE_PFN_INTHI(pfn))
209*7c478bd9Sstevel@tonic-gate 
210*7c478bd9Sstevel@tonic-gate #define	MAKE_TTEATTR_INTLO(attr)					\
211*7c478bd9Sstevel@tonic-gate 	(TTE_WRPRM_CHECK(attr) | TTE_CP_CHECK(attr) | TTE_CV_CHECK(attr) | \
212*7c478bd9Sstevel@tonic-gate 	TTE_SE_CHECK(attr) | TTE_PRIV_CHECK(attr) | TTE_EXECPRM_CHECK(attr) | \
213*7c478bd9Sstevel@tonic-gate 	TTE_IE_CHECK(attr))
214*7c478bd9Sstevel@tonic-gate 
215*7c478bd9Sstevel@tonic-gate #define	MAKE_TTE_INTLO(pfn, attr, sz, hmenum)				\
216*7c478bd9Sstevel@tonic-gate 	(TTE_PFN_INTLO(pfn) | TTE_REF_INT | MAKE_TTEATTR_INTLO(attr) | \
217*7c478bd9Sstevel@tonic-gate 	TTE_SZ_INTLO(sz))
218*7c478bd9Sstevel@tonic-gate 
219*7c478bd9Sstevel@tonic-gate #define	TTEINTHI_ATTR	(TTE_VALID_INT | TTE_NFO_INT | TTE_NOSYNC_INT)
220*7c478bd9Sstevel@tonic-gate 
221*7c478bd9Sstevel@tonic-gate #define	TTEINTLO_ATTR							\
222*7c478bd9Sstevel@tonic-gate 	(TTE_IE_INT | TTE_WRPRM_INT | TTE_CP_INT | TTE_CV_INT |		\
223*7c478bd9Sstevel@tonic-gate 	TTE_SIDEFF_INT | TTE_PRIV_INT | TTE_EXECPRM_INT)
224*7c478bd9Sstevel@tonic-gate 
225*7c478bd9Sstevel@tonic-gate #define	MAKE_TTE_MASK(ttep)				\
226*7c478bd9Sstevel@tonic-gate 	{						\
227*7c478bd9Sstevel@tonic-gate 		(ttep)->tte_bit.v = 1;			\
228*7c478bd9Sstevel@tonic-gate 		(ttep)->tte_bit.nfo = 1;		\
229*7c478bd9Sstevel@tonic-gate 		(ttep)->tte_bit.pahi = 0xffffff;	\
230*7c478bd9Sstevel@tonic-gate 		(ttep)->tte_bit.palo = 0x7ffff;		\
231*7c478bd9Sstevel@tonic-gate 		(ttep)->tte_bit.ie = 1;			\
232*7c478bd9Sstevel@tonic-gate 		(ttep)->tte_bit.e = 1;			\
233*7c478bd9Sstevel@tonic-gate 		(ttep)->tte_bit.cp = 1;			\
234*7c478bd9Sstevel@tonic-gate 		(ttep)->tte_bit.cv = 1;			\
235*7c478bd9Sstevel@tonic-gate 		(ttep)->tte_bit.p = 1;			\
236*7c478bd9Sstevel@tonic-gate 		(ttep)->tte_bit.x = 1;			\
237*7c478bd9Sstevel@tonic-gate 		(ttep)->tte_bit.w = 1;			\
238*7c478bd9Sstevel@tonic-gate 		(ttep)->tte_bit.sz = 7;			\
239*7c478bd9Sstevel@tonic-gate 	}
240*7c478bd9Sstevel@tonic-gate 
241*7c478bd9Sstevel@tonic-gate /*
242*7c478bd9Sstevel@tonic-gate  * Defines to check/set TTE bits.
243*7c478bd9Sstevel@tonic-gate  */
244*7c478bd9Sstevel@tonic-gate #define	TTE_IS_VALID(ttep)	((ttep)->tte_inthi < 0)
245*7c478bd9Sstevel@tonic-gate #define	TTE_SET_INVALID(ttep)	((ttep)->tte_val = 0)
246*7c478bd9Sstevel@tonic-gate #define	TTE_IS_8K(ttep)		(TTE_CSZ(ttep) == TTE8K)
247*7c478bd9Sstevel@tonic-gate #define	TTE_IS_WRITABLE(ttep)	((ttep)->tte_wr_perm)
248*7c478bd9Sstevel@tonic-gate #define	TTE_IS_EXECUTABLE(ttep)	((ttep)->tte_exec_perm)
249*7c478bd9Sstevel@tonic-gate #define	TTE_IS_PRIVILEGED(ttep)	((ttep)->tte_priv)
250*7c478bd9Sstevel@tonic-gate #define	TTE_IS_NOSYNC(ttep)	((ttep)->tte_no_sync)
251*7c478bd9Sstevel@tonic-gate #define	TTE_IS_LOCKED(ttep)	((ttep)->tte_lock)
252*7c478bd9Sstevel@tonic-gate #define	TTE_IS_SIDEFFECT(ttep)	((ttep)->tte_se)
253*7c478bd9Sstevel@tonic-gate #define	TTE_IS_NFO(ttep)	((ttep)->tte_nfo)
254*7c478bd9Sstevel@tonic-gate 
255*7c478bd9Sstevel@tonic-gate #define	TTE_IS_REF(ttep)	((ttep)->tte_ref)
256*7c478bd9Sstevel@tonic-gate #define	TTE_IS_MOD(ttep)	((ttep)->tte_hwwr)
257*7c478bd9Sstevel@tonic-gate #define	TTE_IS_IE(ttep)		((ttep)->tte_ie)
258*7c478bd9Sstevel@tonic-gate #define	TTE_SET_SUSPEND(ttep)	((ttep)->tte_suspend = 1)
259*7c478bd9Sstevel@tonic-gate #define	TTE_CLR_SUSPEND(ttep)	((ttep)->tte_suspend = 0)
260*7c478bd9Sstevel@tonic-gate #define	TTE_IS_SUSPEND(ttep)	((ttep)->tte_suspend)
261*7c478bd9Sstevel@tonic-gate #define	TTE_SET_REF(ttep)	((ttep)->tte_ref = 1)
262*7c478bd9Sstevel@tonic-gate #define	TTE_CLR_REF(ttep)	((ttep)->tte_ref = 0)
263*7c478bd9Sstevel@tonic-gate #define	TTE_SET_LOCKED(ttep)	((ttep)->tte_lock = 1)
264*7c478bd9Sstevel@tonic-gate #define	TTE_CLR_LOCKED(ttep)	((ttep)->tte_lock = 0)
265*7c478bd9Sstevel@tonic-gate #define	TTE_SET_MOD(ttep)	((ttep)->tte_hwwr = 1)
266*7c478bd9Sstevel@tonic-gate #define	TTE_CLR_MOD(ttep)	((ttep)->tte_hwwr = 0)
267*7c478bd9Sstevel@tonic-gate #define	TTE_SET_RM(ttep)						\
268*7c478bd9Sstevel@tonic-gate 	(((ttep)->tte_intlo) =						\
269*7c478bd9Sstevel@tonic-gate 	(ttep)->tte_intlo | TTE_HWWR_INT | TTE_REF_INT)
270*7c478bd9Sstevel@tonic-gate #define	TTE_CLR_RM(ttep)						\
271*7c478bd9Sstevel@tonic-gate 	(((ttep)->tte_intlo) =						\
272*7c478bd9Sstevel@tonic-gate 	(ttep)->tte_intlo & ~(TTE_HWWR_INT | TTE_REF_INT))
273*7c478bd9Sstevel@tonic-gate 
274*7c478bd9Sstevel@tonic-gate #define	TTE_SET_WRT(ttep)	((ttep)->tte_wr_perm = 1)
275*7c478bd9Sstevel@tonic-gate #define	TTE_CLR_WRT(ttep)	((ttep)->tte_wr_perm = 0)
276*7c478bd9Sstevel@tonic-gate #define	TTE_SET_EXEC(ttep)	((ttep)->tte_exec_perm = 1)
277*7c478bd9Sstevel@tonic-gate #define	TTE_CLR_EXEC(ttep)	((ttep)->tte_exec_perm = 0)
278*7c478bd9Sstevel@tonic-gate #define	TTE_SET_PRIV(ttep)	((ttep)->tte_priv = 1)
279*7c478bd9Sstevel@tonic-gate #define	TTE_CLR_PRIV(ttep)	((ttep)->tte_priv = 0)
280*7c478bd9Sstevel@tonic-gate 
281*7c478bd9Sstevel@tonic-gate #define	TTE_IS_VCACHEABLE(ttep)		((ttep)->tte_cv)
282*7c478bd9Sstevel@tonic-gate #define	TTE_SET_VCACHEABLE(ttep)	((ttep)->tte_cv = 1)
283*7c478bd9Sstevel@tonic-gate #define	TTE_CLR_VCACHEABLE(ttep)	((ttep)->tte_cv = 0)
284*7c478bd9Sstevel@tonic-gate #define	TTE_IS_PCACHEABLE(ttep)		((ttep)->tte_cp)
285*7c478bd9Sstevel@tonic-gate #define	TTE_SET_PCACHEABLE(ttep)	((ttep)->tte_cp = 1)
286*7c478bd9Sstevel@tonic-gate #define	TTE_CLR_PCACHEABLE(ttep)	((ttep)->tte_cp = 0)
287*7c478bd9Sstevel@tonic-gate 
288*7c478bd9Sstevel@tonic-gate 
289*7c478bd9Sstevel@tonic-gate #define	KPM_TTE_VCACHED(tte64, pfn, tte_sz)				\
290*7c478bd9Sstevel@tonic-gate 	tte64 = ((uint64_t)TTE_VALID_INT << 32) |			\
291*7c478bd9Sstevel@tonic-gate 	    ((uint64_t)((tte_sz) << TTE_SZ_SHFT)) |			\
292*7c478bd9Sstevel@tonic-gate 	    (((pfn) >> TTE_BSZS_SHIFT(tte_sz)) <<			\
293*7c478bd9Sstevel@tonic-gate 	    (TTE_BSZS_SHIFT(tte_sz) + MMU_PAGESHIFT)) |			\
294*7c478bd9Sstevel@tonic-gate 	    (TTE_CP_INT | TTE_CV_INT | TTE_PRIV_INT | TTE_HWWR_INT)
295*7c478bd9Sstevel@tonic-gate 
296*7c478bd9Sstevel@tonic-gate #define	KPM_TTE_VUNCACHED(tte64, pfn, tte_sz)				\
297*7c478bd9Sstevel@tonic-gate 	tte64 = ((uint64_t)TTE_VALID_INT << 32) |			\
298*7c478bd9Sstevel@tonic-gate 	    ((uint64_t)((tte_sz) << TTE_SZ_SHFT)) |			\
299*7c478bd9Sstevel@tonic-gate 	    (((pfn) >> TTE_BSZS_SHIFT(tte_sz)) <<			\
300*7c478bd9Sstevel@tonic-gate 	    (TTE_BSZS_SHIFT(tte_sz) + MMU_PAGESHIFT)) |			\
301*7c478bd9Sstevel@tonic-gate 	    (TTE_CP_INT | TTE_PRIV_INT | TTE_HWWR_INT)
302*7c478bd9Sstevel@tonic-gate 
303*7c478bd9Sstevel@tonic-gate 
304*7c478bd9Sstevel@tonic-gate /*
305*7c478bd9Sstevel@tonic-gate  * This define provides a generic method to set and clear multiple tte flags.
306*7c478bd9Sstevel@tonic-gate  * A bitmask of all flags to be affected is passed in "flags" and a bitmask
307*7c478bd9Sstevel@tonic-gate  * of the new values is passed in "newflags".
308*7c478bd9Sstevel@tonic-gate  */
309*7c478bd9Sstevel@tonic-gate #define	TTE_SET_LOFLAGS(ttep, flags, newflags)				\
310*7c478bd9Sstevel@tonic-gate 	((ttep)->tte_intlo = ((ttep)->tte_intlo & ~(flags)) | (newflags))
311*7c478bd9Sstevel@tonic-gate 
312*7c478bd9Sstevel@tonic-gate #define	TTE_GET_LOFLAGS(ttep, flags)	((ttep)->tte_intlo & flags)
313*7c478bd9Sstevel@tonic-gate 
314*7c478bd9Sstevel@tonic-gate #endif /* !_ASM */
315*7c478bd9Sstevel@tonic-gate 
316*7c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
317*7c478bd9Sstevel@tonic-gate }
318*7c478bd9Sstevel@tonic-gate #endif
319*7c478bd9Sstevel@tonic-gate 
320*7c478bd9Sstevel@tonic-gate #endif /* !_SYS_PTE_H */
321