17c478bd9Sstevel@tonic-gate /* 27c478bd9Sstevel@tonic-gate * CDDL HEADER START 37c478bd9Sstevel@tonic-gate * 47c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 52f0fcb93SJason Beloro * Common Development and Distribution License (the "License"). 62f0fcb93SJason Beloro * You may not use this file except in compliance with the License. 77c478bd9Sstevel@tonic-gate * 87c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 97c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 107c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 117c478bd9Sstevel@tonic-gate * and limitations under the License. 127c478bd9Sstevel@tonic-gate * 137c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 147c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 157c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 167c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 177c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 187c478bd9Sstevel@tonic-gate * 197c478bd9Sstevel@tonic-gate * CDDL HEADER END 207c478bd9Sstevel@tonic-gate */ 217c478bd9Sstevel@tonic-gate /* 22*9d0d62adSJason Beloro * Copyright 2009 Sun Microsystems, Inc. All rights reserved. 237c478bd9Sstevel@tonic-gate * Use is subject to license terms. 247c478bd9Sstevel@tonic-gate */ 257c478bd9Sstevel@tonic-gate 267c478bd9Sstevel@tonic-gate #ifndef _SYS_PTE_H 277c478bd9Sstevel@tonic-gate #define _SYS_PTE_H 287c478bd9Sstevel@tonic-gate 297c478bd9Sstevel@tonic-gate #ifndef _ASM 307c478bd9Sstevel@tonic-gate #include <sys/types.h> 317c478bd9Sstevel@tonic-gate #endif /* _ASM */ 327c478bd9Sstevel@tonic-gate 337c478bd9Sstevel@tonic-gate #ifdef __cplusplus 347c478bd9Sstevel@tonic-gate extern "C" { 357c478bd9Sstevel@tonic-gate #endif 367c478bd9Sstevel@tonic-gate 377c478bd9Sstevel@tonic-gate #ifndef _ASM 387c478bd9Sstevel@tonic-gate /* 397c478bd9Sstevel@tonic-gate * The tte struct is a 64 bit data type. Since we currently plan to 407c478bd9Sstevel@tonic-gate * use a V8 compiler all manipulations in C will be done using the bit fields 417c478bd9Sstevel@tonic-gate * or as 2 integers. In assembly code we will deal with it as a double (using 427c478bd9Sstevel@tonic-gate * ldx and stx). The structure is defined to force a double alignment. 437c478bd9Sstevel@tonic-gate */ 447c478bd9Sstevel@tonic-gate typedef union { 457c478bd9Sstevel@tonic-gate struct tte { 467c478bd9Sstevel@tonic-gate unsigned int v:1; /* <63> valid */ 477c478bd9Sstevel@tonic-gate unsigned int nfo:1; /* <62> non-fault only */ 487c478bd9Sstevel@tonic-gate unsigned int hmenum:3; /* <61:59> sw hmenum */ 497c478bd9Sstevel@tonic-gate unsigned int no_sync:1; /* <58> sw - ghost unload */ 507c478bd9Sstevel@tonic-gate unsigned int lock:1; /* <57> sw - locked */ 517c478bd9Sstevel@tonic-gate unsigned int susp:1; /* <56> sw - suspend? */ 527c478bd9Sstevel@tonic-gate unsigned int pahi:24; /* <55:32> pa */ 537c478bd9Sstevel@tonic-gate /* ------------------- */ 547c478bd9Sstevel@tonic-gate unsigned int palo:19; /* <31:13> pa */ 557c478bd9Sstevel@tonic-gate unsigned int ie:1; /* <12> 1=invert endianness */ 567c478bd9Sstevel@tonic-gate unsigned int e:1; /* <11> side effect */ 577c478bd9Sstevel@tonic-gate unsigned int cp:1; /* <10> physically cache */ 587c478bd9Sstevel@tonic-gate unsigned int cv:1; /* <9> virtually cache */ 597c478bd9Sstevel@tonic-gate unsigned int p:1; /* <8> privilege required */ 607c478bd9Sstevel@tonic-gate unsigned int x:1; /* <7> execute perm */ 617c478bd9Sstevel@tonic-gate unsigned int w:1; /* <6> write perm */ 627c478bd9Sstevel@tonic-gate unsigned int ref:1; /* <5> sw - ref */ 637c478bd9Sstevel@tonic-gate unsigned int wr_perm:1; /* <4> sw - write perm */ 64*9d0d62adSJason Beloro unsigned int rsvd:1; /* <3> reserved */ 657c478bd9Sstevel@tonic-gate unsigned int sz:3; /* <2:0> pagesize */ 667c478bd9Sstevel@tonic-gate } tte_bit; 677c478bd9Sstevel@tonic-gate struct { 687c478bd9Sstevel@tonic-gate int32_t inthi; 697c478bd9Sstevel@tonic-gate uint32_t intlo; 707c478bd9Sstevel@tonic-gate } tte_int; 717c478bd9Sstevel@tonic-gate uint64_t ll; 727c478bd9Sstevel@tonic-gate } tte_t; 737c478bd9Sstevel@tonic-gate 747c478bd9Sstevel@tonic-gate #define tte_val tte_bit.v /* use < 0 check in asm */ 757c478bd9Sstevel@tonic-gate #define tte_size tte_bit.sz 767c478bd9Sstevel@tonic-gate #define tte_nfo tte_bit.nfo 777c478bd9Sstevel@tonic-gate #define tte_ie tte_bit.ie /* XXX? */ 787c478bd9Sstevel@tonic-gate #define tte_hmenum tte_bit.hmenum 797c478bd9Sstevel@tonic-gate #define tte_pahi tte_bit.pahi 807c478bd9Sstevel@tonic-gate #define tte_palo tte_bit.palo 817c478bd9Sstevel@tonic-gate #define tte_ref tte_bit.ref 827c478bd9Sstevel@tonic-gate #define tte_wr_perm tte_bit.wr_perm 837c478bd9Sstevel@tonic-gate #define tte_no_sync tte_bit.no_sync 847c478bd9Sstevel@tonic-gate #define tte_suspend tte_bit.susp 857c478bd9Sstevel@tonic-gate #define tte_exec_perm tte_bit.x 867c478bd9Sstevel@tonic-gate #define tte_lock tte_bit.lock 877c478bd9Sstevel@tonic-gate #define tte_cp tte_bit.cp 887c478bd9Sstevel@tonic-gate #define tte_cv tte_bit.cv 897c478bd9Sstevel@tonic-gate #define tte_se tte_bit.e 907c478bd9Sstevel@tonic-gate #define tte_priv tte_bit.p 917c478bd9Sstevel@tonic-gate #define tte_hwwr tte_bit.w 927c478bd9Sstevel@tonic-gate 937c478bd9Sstevel@tonic-gate #define tte_inthi tte_int.inthi 947c478bd9Sstevel@tonic-gate #define tte_intlo tte_int.intlo 957c478bd9Sstevel@tonic-gate 967c478bd9Sstevel@tonic-gate #endif /* !_ASM */ 977c478bd9Sstevel@tonic-gate 987c478bd9Sstevel@tonic-gate /* Defines for sz field in tte */ 997c478bd9Sstevel@tonic-gate #define TTE8K 0x0 1007c478bd9Sstevel@tonic-gate #define TTE64K 0x1 1017c478bd9Sstevel@tonic-gate #define TTE512K 0x2 1027c478bd9Sstevel@tonic-gate #define TTE4M 0x3 1037c478bd9Sstevel@tonic-gate #define TTE32M 0x4 1047c478bd9Sstevel@tonic-gate #define TTE256M 0x5 1057c478bd9Sstevel@tonic-gate #define TTE2G 0x6 1067c478bd9Sstevel@tonic-gate #define TTE16G 0x7 1077c478bd9Sstevel@tonic-gate 1087c478bd9Sstevel@tonic-gate #define TTE_SZ_SHFT 0 1097c478bd9Sstevel@tonic-gate #define TTE_SZ_BITS 0x7 1107c478bd9Sstevel@tonic-gate 1117c478bd9Sstevel@tonic-gate #define TTE_CSZ(ttep) ((ttep)->tte_size) 1127c478bd9Sstevel@tonic-gate 1137c478bd9Sstevel@tonic-gate #define TTE_BSZS_SHIFT(sz) ((sz) * 3) 1147c478bd9Sstevel@tonic-gate #define TTEBYTES(sz) (MMU_PAGESIZE << TTE_BSZS_SHIFT(sz)) 1157c478bd9Sstevel@tonic-gate #define TTEPAGES(sz) (1 << TTE_BSZS_SHIFT(sz)) 1167c478bd9Sstevel@tonic-gate #define TTE_PAGE_SHIFT(sz) (MMU_PAGESHIFT + TTE_BSZS_SHIFT(sz)) 1177c478bd9Sstevel@tonic-gate #define TTE_PAGE_OFFSET(sz) (TTEBYTES(sz) - 1) 1187c478bd9Sstevel@tonic-gate #define TTE_PAGEMASK(sz) (~TTE_PAGE_OFFSET(sz)) 1197c478bd9Sstevel@tonic-gate #define TTE_PFNMASK(sz) (~(TTE_PAGE_OFFSET(sz) >> MMU_PAGESHIFT)) 1207c478bd9Sstevel@tonic-gate 1217c478bd9Sstevel@tonic-gate #define TTE_PA_LSHIFT 8 /* used to do sllx on tte to get pa */ 1227c478bd9Sstevel@tonic-gate 1237c478bd9Sstevel@tonic-gate #ifndef _ASM 1247c478bd9Sstevel@tonic-gate 1257c478bd9Sstevel@tonic-gate #define TTE_PASHIFT 19 /* used to manage pahi and palo */ 1267c478bd9Sstevel@tonic-gate #define TTE_PALOMASK ((1 << TTE_PASHIFT) -1) 1277c478bd9Sstevel@tonic-gate /* PFN is defined as bits [40-13] of the physical address */ 1287c478bd9Sstevel@tonic-gate #define TTE_TO_TTEPFN(ttep) \ 1297c478bd9Sstevel@tonic-gate ((((ttep)->tte_pahi << TTE_PASHIFT) | (ttep)->tte_palo) & \ 1307c478bd9Sstevel@tonic-gate TTE_PFNMASK(TTE_CSZ(ttep))) 1317c478bd9Sstevel@tonic-gate /* 1327c478bd9Sstevel@tonic-gate * This define adds the vaddr page offset to obtain a correct pfn 1337c478bd9Sstevel@tonic-gate */ 1347c478bd9Sstevel@tonic-gate #define TTE_TO_PFN(vaddr, ttep) \ 1357c478bd9Sstevel@tonic-gate (sfmmu_ttetopfn(ttep, vaddr)) 1367c478bd9Sstevel@tonic-gate 1377c478bd9Sstevel@tonic-gate #define PFN_TO_TTE(entry, pfn) { \ 1387c478bd9Sstevel@tonic-gate entry.tte_pahi = pfn >> TTE_PASHIFT; \ 1397c478bd9Sstevel@tonic-gate entry.tte_palo = pfn & TTE_PALOMASK; \ 1407c478bd9Sstevel@tonic-gate } 1417c478bd9Sstevel@tonic-gate 1427c478bd9Sstevel@tonic-gate #endif /* !_ASM */ 1437c478bd9Sstevel@tonic-gate 1447c478bd9Sstevel@tonic-gate /* 1457c478bd9Sstevel@tonic-gate * The tte defines are separated into integers because the compiler doesn't 1467c478bd9Sstevel@tonic-gate * support 64bit defines. 1477c478bd9Sstevel@tonic-gate */ 1487c478bd9Sstevel@tonic-gate /* Defines for tte using inthi */ 1497c478bd9Sstevel@tonic-gate #define TTE_VALID_INT 0x80000000 1507c478bd9Sstevel@tonic-gate #define TTE_NFO_INT 0x40000000 1517c478bd9Sstevel@tonic-gate #define TTE_NOSYNC_INT 0x04000000 1527c478bd9Sstevel@tonic-gate #define TTE_SUSPEND 0x01000000 1537c478bd9Sstevel@tonic-gate #define TTE_SUSPEND_SHIFT 32 1547c478bd9Sstevel@tonic-gate 1557c478bd9Sstevel@tonic-gate /* Defines for tte using intlo */ 1567c478bd9Sstevel@tonic-gate #define TTE_IE_INT 0x00001000 1577c478bd9Sstevel@tonic-gate #define TTE_SIDEFF_INT 0x00000800 1587c478bd9Sstevel@tonic-gate #define TTE_CP_INT 0x00000400 1597c478bd9Sstevel@tonic-gate #define TTE_CV_INT 0x00000200 1607c478bd9Sstevel@tonic-gate #define TTE_PRIV_INT 0x00000100 1617c478bd9Sstevel@tonic-gate #define TTE_EXECPRM_INT 0x00000080 1627c478bd9Sstevel@tonic-gate #define TTE_HWWR_INT 0x00000040 1637c478bd9Sstevel@tonic-gate #define TTE_REF_INT 0x00000020 1647c478bd9Sstevel@tonic-gate #define TTE_WRPRM_INT 0x00000010 1657c478bd9Sstevel@tonic-gate 1667c478bd9Sstevel@tonic-gate #define TTE_PROT_INT (TTE_WRPRM_INT | TTE_PRIV_INT) 1677c478bd9Sstevel@tonic-gate 1687c478bd9Sstevel@tonic-gate #ifndef ASM 1697c478bd9Sstevel@tonic-gate 1707c478bd9Sstevel@tonic-gate /* Defines to help build ttes using inthi */ 1717c478bd9Sstevel@tonic-gate #define TTE_SZ_INTLO(sz) ((sz) & TTE_SZ_BITS) 1727c478bd9Sstevel@tonic-gate #define TTE_HMENUM_INT(hmenum) ((hmenum) << 27) 1737c478bd9Sstevel@tonic-gate 1747c478bd9Sstevel@tonic-gate /* PFN is defined as bits [40-13] of the physical address */ 1757c478bd9Sstevel@tonic-gate #define TTE_PFN_INTHI(pfn) ((pfn) >> TTE_PASHIFT) 1767c478bd9Sstevel@tonic-gate #define TTE_VALID_CHECK(attr) \ 1777c478bd9Sstevel@tonic-gate (((attr) & PROT_ALL) ? TTE_VALID_INT : 0) 1787c478bd9Sstevel@tonic-gate #define TTE_NFO_CHECK(attr) \ 1797c478bd9Sstevel@tonic-gate (((attr) & HAT_NOFAULT) ? TTE_NFO_INT : 0) 1807c478bd9Sstevel@tonic-gate 1817c478bd9Sstevel@tonic-gate /* Defines to help build ttes using intlo */ 1827c478bd9Sstevel@tonic-gate #define TTE_PFN_INTLO(pfn) (((pfn) & TTE_PALOMASK) << 13) 1837c478bd9Sstevel@tonic-gate #define TTE_IE_CHECK(attr) \ 1847c478bd9Sstevel@tonic-gate (((attr) & HAT_STRUCTURE_LE) ? TTE_IE_INT : 0) 1857c478bd9Sstevel@tonic-gate #define TTE_WRPRM_CHECK(attr) \ 1867c478bd9Sstevel@tonic-gate (((attr) & PROT_WRITE) ? TTE_WRPRM_INT : 0) 1877c478bd9Sstevel@tonic-gate #define TTE_EXECPRM_CHECK(attr) \ 1887c478bd9Sstevel@tonic-gate (((attr) & PROT_EXEC) ? TTE_EXECPRM_INT : 0) 1897c478bd9Sstevel@tonic-gate #define TTE_NOSYNC_CHECK(attr) \ 1907c478bd9Sstevel@tonic-gate (((attr) & HAT_NOSYNC) ? TTE_NOSYNC_INT : 0) 1917c478bd9Sstevel@tonic-gate #define TTE_CP_CHECK(attr) \ 1927c478bd9Sstevel@tonic-gate (((attr) & SFMMU_UNCACHEPTTE) ? 0: TTE_CP_INT) 1937c478bd9Sstevel@tonic-gate #define TTE_CV_CHECK(attr) \ 1947c478bd9Sstevel@tonic-gate (((attr) & SFMMU_UNCACHEVTTE) ? 0: TTE_CV_INT) 1957c478bd9Sstevel@tonic-gate #define TTE_SE_CHECK(attr) \ 1967c478bd9Sstevel@tonic-gate (((attr) & SFMMU_SIDEFFECT) ? TTE_SIDEFF_INT : 0) 1977c478bd9Sstevel@tonic-gate #define TTE_PRIV_CHECK(attr) \ 1987c478bd9Sstevel@tonic-gate (((attr) & PROT_USER) ? 0 : TTE_PRIV_INT) 1997c478bd9Sstevel@tonic-gate 2007c478bd9Sstevel@tonic-gate #define MAKE_TTEATTR_INTHI(attr) \ 2017c478bd9Sstevel@tonic-gate (TTE_VALID_CHECK(attr) | TTE_NFO_CHECK(attr)) 2027c478bd9Sstevel@tonic-gate 2037c478bd9Sstevel@tonic-gate #define MAKE_TTE_INTHI(pfn, attr, sz, hmenum) \ 2047c478bd9Sstevel@tonic-gate (MAKE_TTEATTR_INTHI(attr) | TTE_HMENUM_INT(hmenum) | \ 2057c478bd9Sstevel@tonic-gate TTE_NOSYNC_CHECK(attr) | TTE_PFN_INTHI(pfn)) 2067c478bd9Sstevel@tonic-gate 2077c478bd9Sstevel@tonic-gate #define MAKE_TTEATTR_INTLO(attr) \ 2087c478bd9Sstevel@tonic-gate (TTE_WRPRM_CHECK(attr) | TTE_CP_CHECK(attr) | TTE_CV_CHECK(attr) | \ 2097c478bd9Sstevel@tonic-gate TTE_SE_CHECK(attr) | TTE_PRIV_CHECK(attr) | TTE_EXECPRM_CHECK(attr) | \ 2107c478bd9Sstevel@tonic-gate TTE_IE_CHECK(attr)) 2117c478bd9Sstevel@tonic-gate 2127c478bd9Sstevel@tonic-gate #define MAKE_TTE_INTLO(pfn, attr, sz, hmenum) \ 2137c478bd9Sstevel@tonic-gate (TTE_PFN_INTLO(pfn) | TTE_REF_INT | MAKE_TTEATTR_INTLO(attr) | \ 2147c478bd9Sstevel@tonic-gate TTE_SZ_INTLO(sz)) 2157c478bd9Sstevel@tonic-gate 2167c478bd9Sstevel@tonic-gate #define TTEINTHI_ATTR (TTE_VALID_INT | TTE_NFO_INT | TTE_NOSYNC_INT) 2177c478bd9Sstevel@tonic-gate 2187c478bd9Sstevel@tonic-gate #define TTEINTLO_ATTR \ 2197c478bd9Sstevel@tonic-gate (TTE_IE_INT | TTE_WRPRM_INT | TTE_CP_INT | TTE_CV_INT | \ 2207c478bd9Sstevel@tonic-gate TTE_SIDEFF_INT | TTE_PRIV_INT | TTE_EXECPRM_INT) 2217c478bd9Sstevel@tonic-gate 2227c478bd9Sstevel@tonic-gate #define MAKE_TTE_MASK(ttep) \ 2237c478bd9Sstevel@tonic-gate { \ 2247c478bd9Sstevel@tonic-gate (ttep)->tte_bit.v = 1; \ 2257c478bd9Sstevel@tonic-gate (ttep)->tte_bit.nfo = 1; \ 2267c478bd9Sstevel@tonic-gate (ttep)->tte_bit.pahi = 0xffffff; \ 2277c478bd9Sstevel@tonic-gate (ttep)->tte_bit.palo = 0x7ffff; \ 2287c478bd9Sstevel@tonic-gate (ttep)->tte_bit.ie = 1; \ 2297c478bd9Sstevel@tonic-gate (ttep)->tte_bit.e = 1; \ 2307c478bd9Sstevel@tonic-gate (ttep)->tte_bit.cp = 1; \ 2317c478bd9Sstevel@tonic-gate (ttep)->tte_bit.cv = 1; \ 2327c478bd9Sstevel@tonic-gate (ttep)->tte_bit.p = 1; \ 2337c478bd9Sstevel@tonic-gate (ttep)->tte_bit.x = 1; \ 2347c478bd9Sstevel@tonic-gate (ttep)->tte_bit.w = 1; \ 2357c478bd9Sstevel@tonic-gate (ttep)->tte_bit.sz = 7; \ 2367c478bd9Sstevel@tonic-gate } 2377c478bd9Sstevel@tonic-gate 2387c478bd9Sstevel@tonic-gate /* 2397c478bd9Sstevel@tonic-gate * Defines to check/set TTE bits. 2407c478bd9Sstevel@tonic-gate */ 2417c478bd9Sstevel@tonic-gate #define TTE_IS_VALID(ttep) ((ttep)->tte_inthi < 0) 2427c478bd9Sstevel@tonic-gate #define TTE_SET_INVALID(ttep) ((ttep)->tte_val = 0) 2437c478bd9Sstevel@tonic-gate #define TTE_IS_8K(ttep) (TTE_CSZ(ttep) == TTE8K) 2447c478bd9Sstevel@tonic-gate #define TTE_IS_WRITABLE(ttep) ((ttep)->tte_wr_perm) 2457c478bd9Sstevel@tonic-gate #define TTE_IS_EXECUTABLE(ttep) ((ttep)->tte_exec_perm) 2467c478bd9Sstevel@tonic-gate #define TTE_IS_PRIVILEGED(ttep) ((ttep)->tte_priv) 2477c478bd9Sstevel@tonic-gate #define TTE_IS_NOSYNC(ttep) ((ttep)->tte_no_sync) 2487c478bd9Sstevel@tonic-gate #define TTE_IS_LOCKED(ttep) ((ttep)->tte_lock) 2497c478bd9Sstevel@tonic-gate #define TTE_IS_SIDEFFECT(ttep) ((ttep)->tte_se) 2507c478bd9Sstevel@tonic-gate #define TTE_IS_NFO(ttep) ((ttep)->tte_nfo) 2517c478bd9Sstevel@tonic-gate 2527c478bd9Sstevel@tonic-gate #define TTE_IS_REF(ttep) ((ttep)->tte_ref) 2537c478bd9Sstevel@tonic-gate #define TTE_IS_MOD(ttep) ((ttep)->tte_hwwr) 2547c478bd9Sstevel@tonic-gate #define TTE_IS_IE(ttep) ((ttep)->tte_ie) 2557c478bd9Sstevel@tonic-gate #define TTE_SET_SUSPEND(ttep) ((ttep)->tte_suspend = 1) 2567c478bd9Sstevel@tonic-gate #define TTE_CLR_SUSPEND(ttep) ((ttep)->tte_suspend = 0) 2577c478bd9Sstevel@tonic-gate #define TTE_IS_SUSPEND(ttep) ((ttep)->tte_suspend) 2587c478bd9Sstevel@tonic-gate #define TTE_SET_REF(ttep) ((ttep)->tte_ref = 1) 2597c478bd9Sstevel@tonic-gate #define TTE_CLR_REF(ttep) ((ttep)->tte_ref = 0) 2607c478bd9Sstevel@tonic-gate #define TTE_SET_LOCKED(ttep) ((ttep)->tte_lock = 1) 2617c478bd9Sstevel@tonic-gate #define TTE_CLR_LOCKED(ttep) ((ttep)->tte_lock = 0) 2627c478bd9Sstevel@tonic-gate #define TTE_SET_MOD(ttep) ((ttep)->tte_hwwr = 1) 2637c478bd9Sstevel@tonic-gate #define TTE_CLR_MOD(ttep) ((ttep)->tte_hwwr = 0) 2647c478bd9Sstevel@tonic-gate #define TTE_SET_RM(ttep) \ 2657c478bd9Sstevel@tonic-gate (((ttep)->tte_intlo) = \ 2667c478bd9Sstevel@tonic-gate (ttep)->tte_intlo | TTE_HWWR_INT | TTE_REF_INT) 2677c478bd9Sstevel@tonic-gate #define TTE_CLR_RM(ttep) \ 2687c478bd9Sstevel@tonic-gate (((ttep)->tte_intlo) = \ 2697c478bd9Sstevel@tonic-gate (ttep)->tte_intlo & ~(TTE_HWWR_INT | TTE_REF_INT)) 2707c478bd9Sstevel@tonic-gate 2717c478bd9Sstevel@tonic-gate #define TTE_SET_WRT(ttep) ((ttep)->tte_wr_perm = 1) 2727c478bd9Sstevel@tonic-gate #define TTE_CLR_WRT(ttep) ((ttep)->tte_wr_perm = 0) 2737c478bd9Sstevel@tonic-gate #define TTE_SET_EXEC(ttep) ((ttep)->tte_exec_perm = 1) 2747c478bd9Sstevel@tonic-gate #define TTE_CLR_EXEC(ttep) ((ttep)->tte_exec_perm = 0) 2757c478bd9Sstevel@tonic-gate #define TTE_SET_PRIV(ttep) ((ttep)->tte_priv = 1) 2767c478bd9Sstevel@tonic-gate #define TTE_CLR_PRIV(ttep) ((ttep)->tte_priv = 0) 2777c478bd9Sstevel@tonic-gate 2787c478bd9Sstevel@tonic-gate #define TTE_IS_VCACHEABLE(ttep) ((ttep)->tte_cv) 2797c478bd9Sstevel@tonic-gate #define TTE_SET_VCACHEABLE(ttep) ((ttep)->tte_cv = 1) 2807c478bd9Sstevel@tonic-gate #define TTE_CLR_VCACHEABLE(ttep) ((ttep)->tte_cv = 0) 2817c478bd9Sstevel@tonic-gate #define TTE_IS_PCACHEABLE(ttep) ((ttep)->tte_cp) 2827c478bd9Sstevel@tonic-gate #define TTE_SET_PCACHEABLE(ttep) ((ttep)->tte_cp = 1) 2837c478bd9Sstevel@tonic-gate #define TTE_CLR_PCACHEABLE(ttep) ((ttep)->tte_cp = 0) 2847c478bd9Sstevel@tonic-gate 2857c478bd9Sstevel@tonic-gate 2867c478bd9Sstevel@tonic-gate #define KPM_TTE_VCACHED(tte64, pfn, tte_sz) \ 2877c478bd9Sstevel@tonic-gate tte64 = ((uint64_t)TTE_VALID_INT << 32) | \ 2887c478bd9Sstevel@tonic-gate ((uint64_t)((tte_sz) << TTE_SZ_SHFT)) | \ 2897c478bd9Sstevel@tonic-gate (((pfn) >> TTE_BSZS_SHIFT(tte_sz)) << \ 2907c478bd9Sstevel@tonic-gate (TTE_BSZS_SHIFT(tte_sz) + MMU_PAGESHIFT)) | \ 2917c478bd9Sstevel@tonic-gate (TTE_CP_INT | TTE_CV_INT | TTE_PRIV_INT | TTE_HWWR_INT) 2927c478bd9Sstevel@tonic-gate 2937c478bd9Sstevel@tonic-gate #define KPM_TTE_VUNCACHED(tte64, pfn, tte_sz) \ 2947c478bd9Sstevel@tonic-gate tte64 = ((uint64_t)TTE_VALID_INT << 32) | \ 2957c478bd9Sstevel@tonic-gate ((uint64_t)((tte_sz) << TTE_SZ_SHFT)) | \ 2967c478bd9Sstevel@tonic-gate (((pfn) >> TTE_BSZS_SHIFT(tte_sz)) << \ 2977c478bd9Sstevel@tonic-gate (TTE_BSZS_SHIFT(tte_sz) + MMU_PAGESHIFT)) | \ 2987c478bd9Sstevel@tonic-gate (TTE_CP_INT | TTE_PRIV_INT | TTE_HWWR_INT) 2997c478bd9Sstevel@tonic-gate 3007c478bd9Sstevel@tonic-gate 3017c478bd9Sstevel@tonic-gate /* 3027c478bd9Sstevel@tonic-gate * This define provides a generic method to set and clear multiple tte flags. 3037c478bd9Sstevel@tonic-gate * A bitmask of all flags to be affected is passed in "flags" and a bitmask 3047c478bd9Sstevel@tonic-gate * of the new values is passed in "newflags". 3057c478bd9Sstevel@tonic-gate */ 3067c478bd9Sstevel@tonic-gate #define TTE_SET_LOFLAGS(ttep, flags, newflags) \ 3077c478bd9Sstevel@tonic-gate ((ttep)->tte_intlo = ((ttep)->tte_intlo & ~(flags)) | (newflags)) 3087c478bd9Sstevel@tonic-gate 3097c478bd9Sstevel@tonic-gate #define TTE_GET_LOFLAGS(ttep, flags) ((ttep)->tte_intlo & flags) 3107c478bd9Sstevel@tonic-gate 3117c478bd9Sstevel@tonic-gate #endif /* !_ASM */ 3127c478bd9Sstevel@tonic-gate 3137c478bd9Sstevel@tonic-gate #ifdef __cplusplus 3147c478bd9Sstevel@tonic-gate } 3157c478bd9Sstevel@tonic-gate #endif 3167c478bd9Sstevel@tonic-gate 3177c478bd9Sstevel@tonic-gate #endif /* !_SYS_PTE_H */ 318