10Sstevel@tonic-gate /* 20Sstevel@tonic-gate * CDDL HEADER START 30Sstevel@tonic-gate * 40Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*5084Sjohnlev * Common Development and Distribution License (the "License"). 6*5084Sjohnlev * You may not use this file except in compliance with the License. 70Sstevel@tonic-gate * 80Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 90Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 100Sstevel@tonic-gate * See the License for the specific language governing permissions 110Sstevel@tonic-gate * and limitations under the License. 120Sstevel@tonic-gate * 130Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 140Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 150Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 160Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 170Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 180Sstevel@tonic-gate * 190Sstevel@tonic-gate * CDDL HEADER END 200Sstevel@tonic-gate */ 210Sstevel@tonic-gate /* 22*5084Sjohnlev * Copyright 2007 Sun Microsystems, Inc. All rights reserved. 230Sstevel@tonic-gate * Use is subject to license terms. 240Sstevel@tonic-gate */ 250Sstevel@tonic-gate 260Sstevel@tonic-gate #ifndef _ASM_MMU_H 270Sstevel@tonic-gate #define _ASM_MMU_H 280Sstevel@tonic-gate 290Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 300Sstevel@tonic-gate 310Sstevel@tonic-gate #include <sys/types.h> 320Sstevel@tonic-gate 330Sstevel@tonic-gate #ifdef __cplusplus 340Sstevel@tonic-gate extern "C" { 350Sstevel@tonic-gate #endif 360Sstevel@tonic-gate 37*5084Sjohnlev #if defined(__GNUC__) && !defined(__xpv) 380Sstevel@tonic-gate 390Sstevel@tonic-gate #if defined(__amd64) 400Sstevel@tonic-gate getcr3(void)410Sstevel@tonic-gateextern __inline__ ulong_t getcr3(void) 420Sstevel@tonic-gate { 430Sstevel@tonic-gate uint64_t value; 440Sstevel@tonic-gate 450Sstevel@tonic-gate __asm__ __volatile__( 46*5084Sjohnlev "movq %%cr3, %0" 47*5084Sjohnlev : "=r" (value)); 480Sstevel@tonic-gate return (value); 490Sstevel@tonic-gate } 500Sstevel@tonic-gate setcr3(ulong_t value)510Sstevel@tonic-gateextern __inline__ void setcr3(ulong_t value) 520Sstevel@tonic-gate { 530Sstevel@tonic-gate __asm__ __volatile__( 54*5084Sjohnlev "movq %0, %%cr3" 55*5084Sjohnlev : /* no output */ 56*5084Sjohnlev : "r" (value)); 570Sstevel@tonic-gate } 580Sstevel@tonic-gate reload_cr3(void)590Sstevel@tonic-gateextern __inline__ void reload_cr3(void) 600Sstevel@tonic-gate { 610Sstevel@tonic-gate setcr3(getcr3()); 620Sstevel@tonic-gate } 630Sstevel@tonic-gate 640Sstevel@tonic-gate #elif defined(__i386) 650Sstevel@tonic-gate 660Sstevel@tonic-gate extern __inline__ ulong_t getcr3(void) 670Sstevel@tonic-gate { 680Sstevel@tonic-gate uint32_t value; 690Sstevel@tonic-gate 700Sstevel@tonic-gate __asm__ __volatile__( 71*5084Sjohnlev "movl %%cr3, %0" 72*5084Sjohnlev : "=r" (value)); 730Sstevel@tonic-gate return (value); 740Sstevel@tonic-gate } 750Sstevel@tonic-gate 760Sstevel@tonic-gate extern __inline__ void setcr3(ulong_t value) 770Sstevel@tonic-gate { 780Sstevel@tonic-gate __asm__ __volatile__( 79*5084Sjohnlev "movl %0, %%cr3" 80*5084Sjohnlev : /* no output */ 81*5084Sjohnlev : "r" (value)); 820Sstevel@tonic-gate } 830Sstevel@tonic-gate 840Sstevel@tonic-gate extern __inline__ void reload_cr3(void) 850Sstevel@tonic-gate { 860Sstevel@tonic-gate setcr3(getcr3()); 870Sstevel@tonic-gate } 880Sstevel@tonic-gate 890Sstevel@tonic-gate #endif 900Sstevel@tonic-gate 91*5084Sjohnlev #endif /* __GNUC__ && !__xpv */ 920Sstevel@tonic-gate 930Sstevel@tonic-gate #ifdef __cplusplus 940Sstevel@tonic-gate } 950Sstevel@tonic-gate #endif 960Sstevel@tonic-gate 970Sstevel@tonic-gate #endif /* _ASM_MMU_H */ 98