12296Sae112802 /* 22296Sae112802 * CDDL HEADER START 32296Sae112802 * 42296Sae112802 * The contents of this file are subject to the terms of the 52296Sae112802 * Common Development and Distribution License (the "License"). 62296Sae112802 * You may not use this file except in compliance with the License. 72296Sae112802 * 82296Sae112802 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 92296Sae112802 * or http://www.opensolaris.org/os/licensing. 102296Sae112802 * See the License for the specific language governing permissions 112296Sae112802 * and limitations under the License. 122296Sae112802 * 132296Sae112802 * When distributing Covered Code, include this CDDL HEADER in each 142296Sae112802 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 152296Sae112802 * If applicable, add the following below this CDDL HEADER, with the 162296Sae112802 * fields enclosed by brackets "[]" replaced with your own identifying 172296Sae112802 * information: Portions Copyright [yyyy] [name of copyright owner] 182296Sae112802 * 192296Sae112802 * CDDL HEADER END 202296Sae112802 */ 212296Sae112802 /* 22*7393SDonghai.Qiao@Sun.COM * Copyright 2008 Sun Microsystems, Inc. All rights reserved. 232296Sae112802 * Use is subject to license terms. 242296Sae112802 */ 252296Sae112802 262296Sae112802 #ifndef _MACH_KPM_H 272296Sae112802 #define _MACH_KPM_H 282296Sae112802 292296Sae112802 #ifdef __cplusplus 302296Sae112802 extern "C" { 312296Sae112802 #endif 322296Sae112802 332296Sae112802 /* kpm prototypes : routines defined in uts/sfmmu/vm/hat_sfmmu.c file */ 342296Sae112802 extern kmutex_t *sfmmu_page_enter(page_t *); 352296Sae112802 extern void sfmmu_page_exit(kmutex_t *); 362296Sae112802 extern void sfmmu_cache_flush(pfn_t, int); 372296Sae112802 extern void sfmmu_page_cache_array(page_t *, int, int, pgcnt_t); 382296Sae112802 extern cpuset_t sfmmu_pageunload(page_t *, struct sf_hment *, int); 392296Sae112802 extern int tst_tnc(page_t *pp, pgcnt_t); 402296Sae112802 extern void conv_tnc(page_t *pp, int); 412296Sae112802 extern int fnd_mapping_sz(page_t *); 422296Sae112802 extern int sfmmu_page_spl_held(struct page *); 432296Sae112802 442296Sae112802 /* kpm prototypes : routines defined in uts/sun4[uv]/vm/mach_kpm.c file */ 452296Sae112802 extern void sfmmu_kpm_pageunload(page_t *); 462296Sae112802 extern void sfmmu_kpm_vac_unload(page_t *, caddr_t); 472296Sae112802 extern void sfmmu_kpm_hme_unload(page_t *); 482296Sae112802 extern kpm_hlk_t *sfmmu_kpm_kpmp_enter(page_t *, pgcnt_t); 492296Sae112802 extern void sfmmu_kpm_kpmp_exit(kpm_hlk_t *kpmp); 502296Sae112802 extern void sfmmu_kpm_page_cache(page_t *, int, int); 512296Sae112802 522296Sae112802 /* flags for hat_pagecachectl */ 532296Sae112802 #define HAT_CACHE 0x1 542296Sae112802 #define HAT_UNCACHE 0x2 552296Sae112802 #define HAT_TMPNC 0x4 562296Sae112802 572296Sae112802 /* 582296Sae112802 * kstat data 592296Sae112802 */ 602296Sae112802 struct sfmmu_global_stat sfmmu_global_stat; 612296Sae112802 622296Sae112802 /* kpm globals */ 632296Sae112802 #ifdef DEBUG 642296Sae112802 /* 652296Sae112802 * Flush the TLB on kpm mapout. Note: Xcalls are used (again) for the 662296Sae112802 * required TLB shootdowns in this case, so handle w/ care. Off by default. 672296Sae112802 */ 682296Sae112802 int kpm_tlb_flush; 692296Sae112802 #endif /* DEBUG */ 702296Sae112802 712296Sae112802 /* 722296Sae112802 * kpm_page lock hash. 732296Sae112802 * All slots should be used equally and 2 adjacent kpm_page_t's 742296Sae112802 * shouldn't have their mutexes in the same cache line. 752296Sae112802 */ 762296Sae112802 #ifdef DEBUG 772296Sae112802 int kpmp_hash_debug; 782296Sae112802 #define KPMP_HASH(kpp) (kpmp_hash_debug ? &kpmp_table[0] : &kpmp_table[ \ 792296Sae112802 ((uintptr_t)(kpp) + ((uintptr_t)(kpp) >> kpmp_shift)) \ 802296Sae112802 & (kpmp_table_sz - 1)]) 812296Sae112802 #else /* !DEBUG */ 822296Sae112802 #define KPMP_HASH(kpp) &kpmp_table[ \ 832296Sae112802 ((uintptr_t)(kpp) + ((uintptr_t)(kpp) >> kpmp_shift)) \ 842296Sae112802 & (kpmp_table_sz - 1)] 852296Sae112802 #endif /* DEBUG */ 862296Sae112802 872296Sae112802 #ifdef DEBUG 882296Sae112802 #define KPMP_SHASH(kpp) (kpmp_hash_debug ? &kpmp_stable[0] : &kpmp_stable[ \ 892296Sae112802 (((uintptr_t)(kpp) << kpmp_shift) + (uintptr_t)(kpp)) \ 902296Sae112802 & (kpmp_stable_sz - 1)]) 912296Sae112802 #else /* !DEBUG */ 922296Sae112802 #define KPMP_SHASH(kpp) &kpmp_stable[ \ 932296Sae112802 (((uintptr_t)(kpp) << kpmp_shift) + (uintptr_t)(kpp)) \ 942296Sae112802 & (kpmp_stable_sz - 1)] 952296Sae112802 #endif /* DEBUG */ 962296Sae112802 972296Sae112802 /* 98*7393SDonghai.Qiao@Sun.COM * kpm virtual address to physical address. Any changes in this macro must 99*7393SDonghai.Qiao@Sun.COM * also be ported to the assembly implementation in sfmmu_asm.s 1002296Sae112802 */ 1012296Sae112802 #ifdef VAC 1022296Sae112802 #define SFMMU_KPM_VTOP(vaddr, paddr) { \ 1032296Sae112802 uintptr_t r, v; \ 1042296Sae112802 \ 1052296Sae112802 r = ((vaddr) - kpm_vbase) >> (uintptr_t)kpm_size_shift; \ 1062296Sae112802 (paddr) = (vaddr) - kpm_vbase; \ 1072296Sae112802 if (r != 0) { \ 1082296Sae112802 v = ((uintptr_t)(vaddr) >> MMU_PAGESHIFT) & \ 1092296Sae112802 vac_colors_mask; \ 1102296Sae112802 (paddr) -= r << kpm_size_shift; \ 1112296Sae112802 if (r > v) \ 1122296Sae112802 (paddr) += (r - v) << MMU_PAGESHIFT; \ 1132296Sae112802 else \ 1142296Sae112802 (paddr) -= r << MMU_PAGESHIFT; \ 1152296Sae112802 } \ 1162296Sae112802 } 1172296Sae112802 #else /* VAC */ 1182296Sae112802 #define SFMMU_KPM_VTOP(vaddr, paddr) { \ 1192296Sae112802 (paddr) = (vaddr) - kpm_vbase; \ 1202296Sae112802 } 1212296Sae112802 #endif /* VAC */ 1222296Sae112802 1232296Sae112802 #ifdef __cplusplus 1242296Sae112802 } 1252296Sae112802 #endif 1262296Sae112802 1272296Sae112802 #endif /* _MACH_KPM_H */ 128