1fedab560Sae112802 /* 2fedab560Sae112802 * CDDL HEADER START 3fedab560Sae112802 * 4fedab560Sae112802 * The contents of this file are subject to the terms of the 5fedab560Sae112802 * Common Development and Distribution License (the "License"). 6fedab560Sae112802 * You may not use this file except in compliance with the License. 7fedab560Sae112802 * 8fedab560Sae112802 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9fedab560Sae112802 * or http://www.opensolaris.org/os/licensing. 10fedab560Sae112802 * See the License for the specific language governing permissions 11fedab560Sae112802 * and limitations under the License. 12fedab560Sae112802 * 13fedab560Sae112802 * When distributing Covered Code, include this CDDL HEADER in each 14fedab560Sae112802 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15fedab560Sae112802 * If applicable, add the following below this CDDL HEADER, with the 16fedab560Sae112802 * fields enclosed by brackets "[]" replaced with your own identifying 17fedab560Sae112802 * information: Portions Copyright [yyyy] [name of copyright owner] 18fedab560Sae112802 * 19fedab560Sae112802 * CDDL HEADER END 20fedab560Sae112802 */ 21fedab560Sae112802 /* 22*444ce08eSDonghai Qiao * Copyright 2008 Sun Microsystems, Inc. All rights reserved. 23fedab560Sae112802 * Use is subject to license terms. 24fedab560Sae112802 */ 25fedab560Sae112802 26fedab560Sae112802 #ifndef _MACH_KPM_H 27fedab560Sae112802 #define _MACH_KPM_H 28fedab560Sae112802 29fedab560Sae112802 #ifdef __cplusplus 30fedab560Sae112802 extern "C" { 31fedab560Sae112802 #endif 32fedab560Sae112802 33fedab560Sae112802 /* kpm prototypes : routines defined in uts/sfmmu/vm/hat_sfmmu.c file */ 34fedab560Sae112802 extern kmutex_t *sfmmu_page_enter(page_t *); 35fedab560Sae112802 extern void sfmmu_page_exit(kmutex_t *); 36fedab560Sae112802 extern void sfmmu_cache_flush(pfn_t, int); 37fedab560Sae112802 extern void sfmmu_page_cache_array(page_t *, int, int, pgcnt_t); 38fedab560Sae112802 extern cpuset_t sfmmu_pageunload(page_t *, struct sf_hment *, int); 39fedab560Sae112802 extern int tst_tnc(page_t *pp, pgcnt_t); 40fedab560Sae112802 extern void conv_tnc(page_t *pp, int); 41fedab560Sae112802 extern int fnd_mapping_sz(page_t *); 42fedab560Sae112802 extern int sfmmu_page_spl_held(struct page *); 43fedab560Sae112802 44fedab560Sae112802 /* kpm prototypes : routines defined in uts/sun4[uv]/vm/mach_kpm.c file */ 45fedab560Sae112802 extern void sfmmu_kpm_pageunload(page_t *); 46fedab560Sae112802 extern void sfmmu_kpm_vac_unload(page_t *, caddr_t); 47fedab560Sae112802 extern void sfmmu_kpm_hme_unload(page_t *); 48fedab560Sae112802 extern kpm_hlk_t *sfmmu_kpm_kpmp_enter(page_t *, pgcnt_t); 49fedab560Sae112802 extern void sfmmu_kpm_kpmp_exit(kpm_hlk_t *kpmp); 50fedab560Sae112802 extern void sfmmu_kpm_page_cache(page_t *, int, int); 51fedab560Sae112802 52fedab560Sae112802 /* flags for hat_pagecachectl */ 53fedab560Sae112802 #define HAT_CACHE 0x1 54fedab560Sae112802 #define HAT_UNCACHE 0x2 55fedab560Sae112802 #define HAT_TMPNC 0x4 56fedab560Sae112802 57fedab560Sae112802 /* 58fedab560Sae112802 * kstat data 59fedab560Sae112802 */ 60fedab560Sae112802 struct sfmmu_global_stat sfmmu_global_stat; 61fedab560Sae112802 62fedab560Sae112802 /* kpm globals */ 63fedab560Sae112802 #ifdef DEBUG 64fedab560Sae112802 /* 65fedab560Sae112802 * Flush the TLB on kpm mapout. Note: Xcalls are used (again) for the 66fedab560Sae112802 * required TLB shootdowns in this case, so handle w/ care. Off by default. 67fedab560Sae112802 */ 68fedab560Sae112802 int kpm_tlb_flush; 69fedab560Sae112802 #endif /* DEBUG */ 70fedab560Sae112802 71fedab560Sae112802 /* 72fedab560Sae112802 * kpm_page lock hash. 73fedab560Sae112802 * All slots should be used equally and 2 adjacent kpm_page_t's 74fedab560Sae112802 * shouldn't have their mutexes in the same cache line. 75fedab560Sae112802 */ 76fedab560Sae112802 #ifdef DEBUG 77fedab560Sae112802 int kpmp_hash_debug; 78fedab560Sae112802 #define KPMP_HASH(kpp) (kpmp_hash_debug ? &kpmp_table[0] : &kpmp_table[ \ 79fedab560Sae112802 ((uintptr_t)(kpp) + ((uintptr_t)(kpp) >> kpmp_shift)) \ 80fedab560Sae112802 & (kpmp_table_sz - 1)]) 81fedab560Sae112802 #else /* !DEBUG */ 82fedab560Sae112802 #define KPMP_HASH(kpp) &kpmp_table[ \ 83fedab560Sae112802 ((uintptr_t)(kpp) + ((uintptr_t)(kpp) >> kpmp_shift)) \ 84fedab560Sae112802 & (kpmp_table_sz - 1)] 85fedab560Sae112802 #endif /* DEBUG */ 86fedab560Sae112802 87fedab560Sae112802 #ifdef DEBUG 88fedab560Sae112802 #define KPMP_SHASH(kpp) (kpmp_hash_debug ? &kpmp_stable[0] : &kpmp_stable[ \ 89fedab560Sae112802 (((uintptr_t)(kpp) << kpmp_shift) + (uintptr_t)(kpp)) \ 90fedab560Sae112802 & (kpmp_stable_sz - 1)]) 91fedab560Sae112802 #else /* !DEBUG */ 92fedab560Sae112802 #define KPMP_SHASH(kpp) &kpmp_stable[ \ 93fedab560Sae112802 (((uintptr_t)(kpp) << kpmp_shift) + (uintptr_t)(kpp)) \ 94fedab560Sae112802 & (kpmp_stable_sz - 1)] 95fedab560Sae112802 #endif /* DEBUG */ 96fedab560Sae112802 97fedab560Sae112802 /* 98*444ce08eSDonghai Qiao * kpm virtual address to physical address. Any changes in this macro must 99*444ce08eSDonghai Qiao * also be ported to the assembly implementation in sfmmu_asm.s 100fedab560Sae112802 */ 101fedab560Sae112802 #ifdef VAC 102fedab560Sae112802 #define SFMMU_KPM_VTOP(vaddr, paddr) { \ 103fedab560Sae112802 uintptr_t r, v; \ 104fedab560Sae112802 \ 105fedab560Sae112802 r = ((vaddr) - kpm_vbase) >> (uintptr_t)kpm_size_shift; \ 106fedab560Sae112802 (paddr) = (vaddr) - kpm_vbase; \ 107fedab560Sae112802 if (r != 0) { \ 108fedab560Sae112802 v = ((uintptr_t)(vaddr) >> MMU_PAGESHIFT) & \ 109fedab560Sae112802 vac_colors_mask; \ 110fedab560Sae112802 (paddr) -= r << kpm_size_shift; \ 111fedab560Sae112802 if (r > v) \ 112fedab560Sae112802 (paddr) += (r - v) << MMU_PAGESHIFT; \ 113fedab560Sae112802 else \ 114fedab560Sae112802 (paddr) -= r << MMU_PAGESHIFT; \ 115fedab560Sae112802 } \ 116fedab560Sae112802 } 117fedab560Sae112802 #else /* VAC */ 118fedab560Sae112802 #define SFMMU_KPM_VTOP(vaddr, paddr) { \ 119fedab560Sae112802 (paddr) = (vaddr) - kpm_vbase; \ 120fedab560Sae112802 } 121fedab560Sae112802 #endif /* VAC */ 122fedab560Sae112802 123fedab560Sae112802 #ifdef __cplusplus 124fedab560Sae112802 } 125fedab560Sae112802 #endif 126fedab560Sae112802 127fedab560Sae112802 #endif /* _MACH_KPM_H */ 128