17c478bd9Sstevel@tonic-gate /* 27c478bd9Sstevel@tonic-gate * CDDL HEADER START 37c478bd9Sstevel@tonic-gate * 47c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 56e541dddSmrj * Common Development and Distribution License (the "License"). 66e541dddSmrj * You may not use this file except in compliance with the License. 77c478bd9Sstevel@tonic-gate * 87c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 97c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 107c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 117c478bd9Sstevel@tonic-gate * and limitations under the License. 127c478bd9Sstevel@tonic-gate * 137c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 147c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 157c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 167c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 177c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 187c478bd9Sstevel@tonic-gate * 197c478bd9Sstevel@tonic-gate * CDDL HEADER END 207c478bd9Sstevel@tonic-gate */ 217c478bd9Sstevel@tonic-gate /* 2226a04d67SDave Plauger * Copyright 2009 Sun Microsystems, Inc. All rights reserved. 237c478bd9Sstevel@tonic-gate * Use is subject to license terms. 247c478bd9Sstevel@tonic-gate */ 257c478bd9Sstevel@tonic-gate 267c478bd9Sstevel@tonic-gate #ifndef _ASM_CPU_H 277c478bd9Sstevel@tonic-gate #define _ASM_CPU_H 287c478bd9Sstevel@tonic-gate 29*6b7143d7SRichard Lowe #include <sys/ccompile.h> 30*6b7143d7SRichard Lowe 317c478bd9Sstevel@tonic-gate #ifdef __cplusplus 327c478bd9Sstevel@tonic-gate extern "C" { 337c478bd9Sstevel@tonic-gate #endif 347c478bd9Sstevel@tonic-gate 357c478bd9Sstevel@tonic-gate #if !defined(__lint) && defined(__GNUC__) 367c478bd9Sstevel@tonic-gate 377c478bd9Sstevel@tonic-gate #if defined(__i386) || defined(__amd64) 387c478bd9Sstevel@tonic-gate 39*6b7143d7SRichard Lowe extern __GNU_INLINE void ht_pause(void)40aca118b7Slucy wang - Sun Microsystems - Beijing Chinaht_pause(void) 417c478bd9Sstevel@tonic-gate { 427c478bd9Sstevel@tonic-gate __asm__ __volatile__( 437c478bd9Sstevel@tonic-gate "pause"); 447c478bd9Sstevel@tonic-gate } 457c478bd9Sstevel@tonic-gate 4694e7edb1Slucy wang - Sun Microsystems - Beijing China /* 4794e7edb1Slucy wang - Sun Microsystems - Beijing China * prefetch 64 bytes 4894e7edb1Slucy wang - Sun Microsystems - Beijing China * 4994e7edb1Slucy wang - Sun Microsystems - Beijing China * prefetch is an SSE extension which is not supported on 5094e7edb1Slucy wang - Sun Microsystems - Beijing China * older 32-bit processors, so define this as a no-op for now 5194e7edb1Slucy wang - Sun Microsystems - Beijing China */ 5294e7edb1Slucy wang - Sun Microsystems - Beijing China 53*6b7143d7SRichard Lowe extern __GNU_INLINE void prefetch_read_many(void * addr)54aca118b7Slucy wang - Sun Microsystems - Beijing Chinaprefetch_read_many(void *addr) 5594e7edb1Slucy wang - Sun Microsystems - Beijing China { 5694e7edb1Slucy wang - Sun Microsystems - Beijing China #if defined(__amd64) 5794e7edb1Slucy wang - Sun Microsystems - Beijing China __asm__( 5894e7edb1Slucy wang - Sun Microsystems - Beijing China "prefetcht0 (%0);" 5994e7edb1Slucy wang - Sun Microsystems - Beijing China "prefetcht0 32(%0);" 6094e7edb1Slucy wang - Sun Microsystems - Beijing China : /* no output */ 6194e7edb1Slucy wang - Sun Microsystems - Beijing China : "r" (addr)); 6294e7edb1Slucy wang - Sun Microsystems - Beijing China #endif /* __amd64 */ 6394e7edb1Slucy wang - Sun Microsystems - Beijing China } 6494e7edb1Slucy wang - Sun Microsystems - Beijing China 65*6b7143d7SRichard Lowe extern __GNU_INLINE void refetch_read_once(void * addr)66*6b7143d7SRichard Lowerefetch_read_once(void *addr) 6794e7edb1Slucy wang - Sun Microsystems - Beijing China { 6894e7edb1Slucy wang - Sun Microsystems - Beijing China #if defined(__amd64) 6994e7edb1Slucy wang - Sun Microsystems - Beijing China __asm__( 7094e7edb1Slucy wang - Sun Microsystems - Beijing China "prefetchnta (%0);" 7194e7edb1Slucy wang - Sun Microsystems - Beijing China "prefetchnta 32(%0);" 7294e7edb1Slucy wang - Sun Microsystems - Beijing China : /* no output */ 7394e7edb1Slucy wang - Sun Microsystems - Beijing China : "r" (addr)); 7494e7edb1Slucy wang - Sun Microsystems - Beijing China #endif /* __amd64 */ 7594e7edb1Slucy wang - Sun Microsystems - Beijing China } 7694e7edb1Slucy wang - Sun Microsystems - Beijing China 77*6b7143d7SRichard Lowe extern __GNU_INLINE void prefetch_write_many(void * addr)78aca118b7Slucy wang - Sun Microsystems - Beijing Chinaprefetch_write_many(void *addr) 7994e7edb1Slucy wang - Sun Microsystems - Beijing China { 8094e7edb1Slucy wang - Sun Microsystems - Beijing China #if defined(__amd64) 8194e7edb1Slucy wang - Sun Microsystems - Beijing China __asm__( 8294e7edb1Slucy wang - Sun Microsystems - Beijing China "prefetcht0 (%0);" 8394e7edb1Slucy wang - Sun Microsystems - Beijing China "prefetcht0 32(%0);" 8494e7edb1Slucy wang - Sun Microsystems - Beijing China : /* no output */ 8594e7edb1Slucy wang - Sun Microsystems - Beijing China : "r" (addr)); 8694e7edb1Slucy wang - Sun Microsystems - Beijing China #endif /* __amd64 */ 8794e7edb1Slucy wang - Sun Microsystems - Beijing China } 8894e7edb1Slucy wang - Sun Microsystems - Beijing China 89*6b7143d7SRichard Lowe extern __GNU_INLINE void prefetch_write_once(void * addr)90aca118b7Slucy wang - Sun Microsystems - Beijing Chinaprefetch_write_once(void *addr) 9194e7edb1Slucy wang - Sun Microsystems - Beijing China { 9294e7edb1Slucy wang - Sun Microsystems - Beijing China #if defined(__amd64) 9394e7edb1Slucy wang - Sun Microsystems - Beijing China __asm__( 9494e7edb1Slucy wang - Sun Microsystems - Beijing China "prefetcht0 (%0);" 9594e7edb1Slucy wang - Sun Microsystems - Beijing China "prefetcht0 32(%0);" 9694e7edb1Slucy wang - Sun Microsystems - Beijing China : /* no output */ 9794e7edb1Slucy wang - Sun Microsystems - Beijing China : "r" (addr)); 9894e7edb1Slucy wang - Sun Microsystems - Beijing China #endif /* __amd64 */ 9994e7edb1Slucy wang - Sun Microsystems - Beijing China } 10094e7edb1Slucy wang - Sun Microsystems - Beijing China 101843e1988Sjohnlev #if !defined(__xpv) 102843e1988Sjohnlev 103*6b7143d7SRichard Lowe extern __GNU_INLINE void cli(void)104aca118b7Slucy wang - Sun Microsystems - Beijing Chinacli(void) 1057c478bd9Sstevel@tonic-gate { 1067c478bd9Sstevel@tonic-gate __asm__ __volatile__( 1077c478bd9Sstevel@tonic-gate "cli" : : : "memory"); 1087c478bd9Sstevel@tonic-gate } 1097c478bd9Sstevel@tonic-gate 110*6b7143d7SRichard Lowe extern __GNU_INLINE void sti(void)111aca118b7Slucy wang - Sun Microsystems - Beijing Chinasti(void) 1127c478bd9Sstevel@tonic-gate { 1137c478bd9Sstevel@tonic-gate __asm__ __volatile__( 1147c478bd9Sstevel@tonic-gate "sti"); 1157c478bd9Sstevel@tonic-gate } 1167c478bd9Sstevel@tonic-gate 117*6b7143d7SRichard Lowe extern __GNU_INLINE void i86_halt(void)118aca118b7Slucy wang - Sun Microsystems - Beijing Chinai86_halt(void) 1197c478bd9Sstevel@tonic-gate { 1207c478bd9Sstevel@tonic-gate __asm__ __volatile__( 1217c478bd9Sstevel@tonic-gate "sti; hlt"); 1227c478bd9Sstevel@tonic-gate } 1237c478bd9Sstevel@tonic-gate 124843e1988Sjohnlev #endif /* !__xpv */ 125843e1988Sjohnlev 1267c478bd9Sstevel@tonic-gate #endif /* __i386 || defined(__amd64) */ 1277c478bd9Sstevel@tonic-gate 1286e541dddSmrj #if defined(__amd64) 1296e541dddSmrj 130*6b7143d7SRichard Lowe extern __GNU_INLINE void __set_ds(selector_t value)131aca118b7Slucy wang - Sun Microsystems - Beijing China__set_ds(selector_t value) 1326e541dddSmrj { 1336e541dddSmrj __asm__ __volatile__( 1346e541dddSmrj "movw %0, %%ds" 1356e541dddSmrj : /* no output */ 1366e541dddSmrj : "r" (value)); 1376e541dddSmrj } 1386e541dddSmrj 139*6b7143d7SRichard Lowe extern __GNU_INLINE void __set_es(selector_t value)140aca118b7Slucy wang - Sun Microsystems - Beijing China__set_es(selector_t value) 1416e541dddSmrj { 1426e541dddSmrj __asm__ __volatile__( 1436e541dddSmrj "movw %0, %%es" 1446e541dddSmrj : /* no output */ 1456e541dddSmrj : "r" (value)); 1466e541dddSmrj } 1476e541dddSmrj 148*6b7143d7SRichard Lowe extern __GNU_INLINE void __set_fs(selector_t value)149aca118b7Slucy wang - Sun Microsystems - Beijing China__set_fs(selector_t value) 1506e541dddSmrj { 1516e541dddSmrj __asm__ __volatile__( 1526e541dddSmrj "movw %0, %%fs" 1536e541dddSmrj : /* no output */ 1546e541dddSmrj : "r" (value)); 1556e541dddSmrj } 1566e541dddSmrj 157*6b7143d7SRichard Lowe extern __GNU_INLINE void __set_gs(selector_t value)158aca118b7Slucy wang - Sun Microsystems - Beijing China__set_gs(selector_t value) 1596e541dddSmrj { 1606e541dddSmrj __asm__ __volatile__( 1616e541dddSmrj "movw %0, %%gs" 1626e541dddSmrj : /* no output */ 1636e541dddSmrj : "r" (value)); 1646e541dddSmrj } 1656e541dddSmrj 166843e1988Sjohnlev #if !defined(__xpv) 167843e1988Sjohnlev 168*6b7143d7SRichard Lowe extern __GNU_INLINE void __swapgs(void)169aca118b7Slucy wang - Sun Microsystems - Beijing China__swapgs(void) 1706e541dddSmrj { 1716e541dddSmrj __asm__ __volatile__( 1726e541dddSmrj "mfence; swapgs"); 1736e541dddSmrj } 1746e541dddSmrj 175843e1988Sjohnlev #endif /* !__xpv */ 176843e1988Sjohnlev 1776e541dddSmrj #endif /* __amd64 */ 1786e541dddSmrj 1797c478bd9Sstevel@tonic-gate #endif /* !__lint && __GNUC__ */ 1807c478bd9Sstevel@tonic-gate 1817c478bd9Sstevel@tonic-gate #ifdef __cplusplus 1827c478bd9Sstevel@tonic-gate } 1837c478bd9Sstevel@tonic-gate #endif 1847c478bd9Sstevel@tonic-gate 1857c478bd9Sstevel@tonic-gate #endif /* _ASM_CPU_H */ 186