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 53451Smrj * Common Development and Distribution License (the "License"). 63451Smrj * 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 /* 228286SDave.Plauger@Sun.COM * Copyright 2008 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_CPU_H 270Sstevel@tonic-gate #define _ASM_CPU_H 280Sstevel@tonic-gate 290Sstevel@tonic-gate #ifdef __cplusplus 300Sstevel@tonic-gate extern "C" { 310Sstevel@tonic-gate #endif 320Sstevel@tonic-gate 330Sstevel@tonic-gate #if !defined(__lint) && defined(__GNUC__) 340Sstevel@tonic-gate 350Sstevel@tonic-gate #if defined(__i386) || defined(__amd64) 360Sstevel@tonic-gate 370Sstevel@tonic-gate extern __inline__ void ht_pause(void) 380Sstevel@tonic-gate { 390Sstevel@tonic-gate __asm__ __volatile__( 400Sstevel@tonic-gate "pause"); 410Sstevel@tonic-gate } 420Sstevel@tonic-gate 435084Sjohnlev #if !defined(__xpv) 445084Sjohnlev 450Sstevel@tonic-gate extern __inline__ void cli(void) 460Sstevel@tonic-gate { 470Sstevel@tonic-gate __asm__ __volatile__( 480Sstevel@tonic-gate "cli" : : : "memory"); 490Sstevel@tonic-gate } 500Sstevel@tonic-gate 510Sstevel@tonic-gate extern __inline__ void sti(void) 520Sstevel@tonic-gate { 530Sstevel@tonic-gate __asm__ __volatile__( 540Sstevel@tonic-gate "sti"); 550Sstevel@tonic-gate } 560Sstevel@tonic-gate 570Sstevel@tonic-gate extern __inline__ void i86_halt(void) 580Sstevel@tonic-gate { 590Sstevel@tonic-gate __asm__ __volatile__( 600Sstevel@tonic-gate "sti; hlt"); 610Sstevel@tonic-gate } 620Sstevel@tonic-gate 635084Sjohnlev #endif /* !__xpv */ 645084Sjohnlev 650Sstevel@tonic-gate #endif /* __i386 || defined(__amd64) */ 660Sstevel@tonic-gate 673451Smrj #if defined(__amd64) 683451Smrj 693451Smrj extern __inline__ void __set_ds(selector_t value) 703451Smrj { 713451Smrj __asm__ __volatile__( 725084Sjohnlev "movw %0, %%ds" 735084Sjohnlev : /* no output */ 745084Sjohnlev : "r" (value)); 753451Smrj } 763451Smrj 773451Smrj extern __inline__ void __set_es(selector_t value) 783451Smrj { 793451Smrj __asm__ __volatile__( 805084Sjohnlev "movw %0, %%es" 815084Sjohnlev : /* no output */ 825084Sjohnlev : "r" (value)); 833451Smrj } 843451Smrj 853451Smrj extern __inline__ void __set_fs(selector_t value) 863451Smrj { 873451Smrj __asm__ __volatile__( 885084Sjohnlev "movw %0, %%fs" 895084Sjohnlev : /* no output */ 905084Sjohnlev : "r" (value)); 913451Smrj } 923451Smrj 933451Smrj extern __inline__ void __set_gs(selector_t value) 943451Smrj { 953451Smrj __asm__ __volatile__( 965084Sjohnlev "movw %0, %%gs" 975084Sjohnlev : /* no output */ 985084Sjohnlev : "r" (value)); 993451Smrj } 1003451Smrj 1015084Sjohnlev #if !defined(__xpv) 1025084Sjohnlev 1033451Smrj extern __inline__ void __swapgs(void) 1043451Smrj { 1053451Smrj __asm__ __volatile__( 1065084Sjohnlev "mfence; swapgs"); 1073451Smrj } 1083451Smrj 1095084Sjohnlev #endif /* !__xpv */ 1105084Sjohnlev 1113451Smrj #endif /* __amd64 */ 1123451Smrj 1130Sstevel@tonic-gate #endif /* !__lint && __GNUC__ */ 1140Sstevel@tonic-gate 1158286SDave.Plauger@Sun.COM #if !defined(__lint) && defined(__GNUC__) 1168286SDave.Plauger@Sun.COM 1178286SDave.Plauger@Sun.COM #if defined(__i386) || defined(__amd64) 1188286SDave.Plauger@Sun.COM 1198286SDave.Plauger@Sun.COM /* 1208286SDave.Plauger@Sun.COM * prefetch 64 bytes 1218286SDave.Plauger@Sun.COM */ 1228286SDave.Plauger@Sun.COM 1238286SDave.Plauger@Sun.COM extern __inline__ void prefetch64(caddr_t addr) 1248286SDave.Plauger@Sun.COM { 1258286SDave.Plauger@Sun.COM __asm__ __volatile__( 126*8314SDave.Plauger@Sun.COM "prefetcht0 (%0);" 1278286SDave.Plauger@Sun.COM "prefetcht0 32(%0)" 1288286SDave.Plauger@Sun.COM : /* no output */ 1298286SDave.Plauger@Sun.COM : "r" (addr)); 1308286SDave.Plauger@Sun.COM } 1318286SDave.Plauger@Sun.COM 1328286SDave.Plauger@Sun.COM #endif /* __i386 || __amd64 */ 1338286SDave.Plauger@Sun.COM 1348286SDave.Plauger@Sun.COM #endif /* !__lint && __GNUC__ */ 1358286SDave.Plauger@Sun.COM 1360Sstevel@tonic-gate #ifdef __cplusplus 1370Sstevel@tonic-gate } 1380Sstevel@tonic-gate #endif 1390Sstevel@tonic-gate 1400Sstevel@tonic-gate #endif /* _ASM_CPU_H */ 141