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 /* 228475SDave.Plauger@Sun.COM * Copyright 2009 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 37*9449Sxiuyan.wang@Sun.COM extern __inline__ void ht_pause(void)38*9449Sxiuyan.wang@Sun.COMht_pause(void) 390Sstevel@tonic-gate { 400Sstevel@tonic-gate __asm__ __volatile__( 410Sstevel@tonic-gate "pause"); 420Sstevel@tonic-gate } 430Sstevel@tonic-gate 449171Sxiuyan.wang@Sun.COM /* 459171Sxiuyan.wang@Sun.COM * prefetch 64 bytes 469171Sxiuyan.wang@Sun.COM * 479171Sxiuyan.wang@Sun.COM * prefetch is an SSE extension which is not supported on 489171Sxiuyan.wang@Sun.COM * older 32-bit processors, so define this as a no-op for now 499171Sxiuyan.wang@Sun.COM */ 509171Sxiuyan.wang@Sun.COM 51*9449Sxiuyan.wang@Sun.COM extern __inline__ void prefetch_read_many(void * addr)52*9449Sxiuyan.wang@Sun.COMprefetch_read_many(void *addr) 539171Sxiuyan.wang@Sun.COM { 549171Sxiuyan.wang@Sun.COM #if defined(__amd64) 559171Sxiuyan.wang@Sun.COM __asm__( 569171Sxiuyan.wang@Sun.COM "prefetcht0 (%0);" 579171Sxiuyan.wang@Sun.COM "prefetcht0 32(%0);" 589171Sxiuyan.wang@Sun.COM : /* no output */ 599171Sxiuyan.wang@Sun.COM : "r" (addr)); 609171Sxiuyan.wang@Sun.COM #endif /* __amd64 */ 619171Sxiuyan.wang@Sun.COM } 629171Sxiuyan.wang@Sun.COM 63*9449Sxiuyan.wang@Sun.COM extern __inline__ void prefetch_read_once(void * addr)64*9449Sxiuyan.wang@Sun.COMprefetch_read_once(void *addr) 659171Sxiuyan.wang@Sun.COM { 669171Sxiuyan.wang@Sun.COM #if defined(__amd64) 679171Sxiuyan.wang@Sun.COM __asm__( 689171Sxiuyan.wang@Sun.COM "prefetchnta (%0);" 699171Sxiuyan.wang@Sun.COM "prefetchnta 32(%0);" 709171Sxiuyan.wang@Sun.COM : /* no output */ 719171Sxiuyan.wang@Sun.COM : "r" (addr)); 729171Sxiuyan.wang@Sun.COM #endif /* __amd64 */ 739171Sxiuyan.wang@Sun.COM } 749171Sxiuyan.wang@Sun.COM 75*9449Sxiuyan.wang@Sun.COM extern __inline__ void prefetch_write_many(void * addr)76*9449Sxiuyan.wang@Sun.COMprefetch_write_many(void *addr) 779171Sxiuyan.wang@Sun.COM { 789171Sxiuyan.wang@Sun.COM #if defined(__amd64) 799171Sxiuyan.wang@Sun.COM __asm__( 809171Sxiuyan.wang@Sun.COM "prefetcht0 (%0);" 819171Sxiuyan.wang@Sun.COM "prefetcht0 32(%0);" 829171Sxiuyan.wang@Sun.COM : /* no output */ 839171Sxiuyan.wang@Sun.COM : "r" (addr)); 849171Sxiuyan.wang@Sun.COM #endif /* __amd64 */ 859171Sxiuyan.wang@Sun.COM } 869171Sxiuyan.wang@Sun.COM 87*9449Sxiuyan.wang@Sun.COM extern __inline__ void prefetch_write_once(void * addr)88*9449Sxiuyan.wang@Sun.COMprefetch_write_once(void *addr) 899171Sxiuyan.wang@Sun.COM { 909171Sxiuyan.wang@Sun.COM #if defined(__amd64) 919171Sxiuyan.wang@Sun.COM __asm__( 929171Sxiuyan.wang@Sun.COM "prefetcht0 (%0);" 939171Sxiuyan.wang@Sun.COM "prefetcht0 32(%0);" 949171Sxiuyan.wang@Sun.COM : /* no output */ 959171Sxiuyan.wang@Sun.COM : "r" (addr)); 969171Sxiuyan.wang@Sun.COM #endif /* __amd64 */ 979171Sxiuyan.wang@Sun.COM } 989171Sxiuyan.wang@Sun.COM 995084Sjohnlev #if !defined(__xpv) 1005084Sjohnlev 101*9449Sxiuyan.wang@Sun.COM extern __inline__ void cli(void)102*9449Sxiuyan.wang@Sun.COMcli(void) 1030Sstevel@tonic-gate { 1040Sstevel@tonic-gate __asm__ __volatile__( 1050Sstevel@tonic-gate "cli" : : : "memory"); 1060Sstevel@tonic-gate } 1070Sstevel@tonic-gate 108*9449Sxiuyan.wang@Sun.COM extern __inline__ void sti(void)109*9449Sxiuyan.wang@Sun.COMsti(void) 1100Sstevel@tonic-gate { 1110Sstevel@tonic-gate __asm__ __volatile__( 1120Sstevel@tonic-gate "sti"); 1130Sstevel@tonic-gate } 1140Sstevel@tonic-gate 115*9449Sxiuyan.wang@Sun.COM extern __inline__ void i86_halt(void)116*9449Sxiuyan.wang@Sun.COMi86_halt(void) 1170Sstevel@tonic-gate { 1180Sstevel@tonic-gate __asm__ __volatile__( 1190Sstevel@tonic-gate "sti; hlt"); 1200Sstevel@tonic-gate } 1210Sstevel@tonic-gate 1225084Sjohnlev #endif /* !__xpv */ 1235084Sjohnlev 1240Sstevel@tonic-gate #endif /* __i386 || defined(__amd64) */ 1250Sstevel@tonic-gate 1263451Smrj #if defined(__amd64) 1273451Smrj 128*9449Sxiuyan.wang@Sun.COM extern __inline__ void __set_ds(selector_t value)129*9449Sxiuyan.wang@Sun.COM__set_ds(selector_t value) 1303451Smrj { 1313451Smrj __asm__ __volatile__( 1325084Sjohnlev "movw %0, %%ds" 1335084Sjohnlev : /* no output */ 1345084Sjohnlev : "r" (value)); 1353451Smrj } 1363451Smrj 137*9449Sxiuyan.wang@Sun.COM extern __inline__ void __set_es(selector_t value)138*9449Sxiuyan.wang@Sun.COM__set_es(selector_t value) 1393451Smrj { 1403451Smrj __asm__ __volatile__( 1415084Sjohnlev "movw %0, %%es" 1425084Sjohnlev : /* no output */ 1435084Sjohnlev : "r" (value)); 1443451Smrj } 1453451Smrj 146*9449Sxiuyan.wang@Sun.COM extern __inline__ void __set_fs(selector_t value)147*9449Sxiuyan.wang@Sun.COM__set_fs(selector_t value) 1483451Smrj { 1493451Smrj __asm__ __volatile__( 1505084Sjohnlev "movw %0, %%fs" 1515084Sjohnlev : /* no output */ 1525084Sjohnlev : "r" (value)); 1533451Smrj } 1543451Smrj 155*9449Sxiuyan.wang@Sun.COM extern __inline__ void __set_gs(selector_t value)156*9449Sxiuyan.wang@Sun.COM__set_gs(selector_t value) 1573451Smrj { 1583451Smrj __asm__ __volatile__( 1595084Sjohnlev "movw %0, %%gs" 1605084Sjohnlev : /* no output */ 1615084Sjohnlev : "r" (value)); 1623451Smrj } 1633451Smrj 1645084Sjohnlev #if !defined(__xpv) 1655084Sjohnlev 166*9449Sxiuyan.wang@Sun.COM extern __inline__ void __swapgs(void)167*9449Sxiuyan.wang@Sun.COM__swapgs(void) 1683451Smrj { 1693451Smrj __asm__ __volatile__( 1705084Sjohnlev "mfence; swapgs"); 1713451Smrj } 1723451Smrj 1735084Sjohnlev #endif /* !__xpv */ 1745084Sjohnlev 1753451Smrj #endif /* __amd64 */ 1763451Smrj 1770Sstevel@tonic-gate #endif /* !__lint && __GNUC__ */ 1780Sstevel@tonic-gate 1790Sstevel@tonic-gate #ifdef __cplusplus 1800Sstevel@tonic-gate } 1810Sstevel@tonic-gate #endif 1820Sstevel@tonic-gate 1830Sstevel@tonic-gate #endif /* _ASM_CPU_H */ 184