Merge commit 'b1e7e97d3b60469b243b3b2e22c7d8cbd11c7c90'
[unleashed.git] / usr / src / uts / intel / asm / cpu.h
bloba09807398852b6b8ae91b5458fc4fe665aacf13a
1 /*
2 * CDDL HEADER START
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
19 * CDDL HEADER END
22 * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
26 #ifndef _ASM_CPU_H
27 #define _ASM_CPU_H
29 #include <sys/ccompile.h>
31 #ifdef __cplusplus
32 extern "C" {
33 #endif
36 #if defined(__i386) || defined(__amd64)
38 extern __GNU_INLINE void
39 ht_pause(void)
41 __asm__ __volatile__(
42 "pause");
46 * prefetch 64 bytes
48 * prefetch is an SSE extension which is not supported on
49 * older 32-bit processors, so define this as a no-op for now
52 extern __GNU_INLINE void
53 prefetch_read_many(void *addr)
55 #if defined(__amd64)
56 __asm__(
57 "prefetcht0 (%0);"
58 "prefetcht0 32(%0);"
59 : /* no output */
60 : "r" (addr));
61 #endif /* __amd64 */
64 extern __GNU_INLINE void
65 prefetch_read_once(void *addr)
67 #if defined(__amd64)
68 __asm__(
69 "prefetchnta (%0);"
70 "prefetchnta 32(%0);"
71 : /* no output */
72 : "r" (addr));
73 #endif /* __amd64 */
76 extern __GNU_INLINE void
77 prefetch_write_many(void *addr)
79 #if defined(__amd64)
80 __asm__(
81 "prefetcht0 (%0);"
82 "prefetcht0 32(%0);"
83 : /* no output */
84 : "r" (addr));
85 #endif /* __amd64 */
88 extern __GNU_INLINE void
89 prefetch_write_once(void *addr)
91 #if defined(__amd64)
92 __asm__(
93 "prefetcht0 (%0);"
94 "prefetcht0 32(%0);"
95 : /* no output */
96 : "r" (addr));
97 #endif /* __amd64 */
100 #if !defined(__xpv)
102 extern __GNU_INLINE void
103 cli(void)
105 __asm__ __volatile__(
106 "cli" : : : "memory");
109 extern __GNU_INLINE void
110 sti(void)
112 __asm__ __volatile__(
113 "sti");
116 extern __GNU_INLINE void
117 i86_halt(void)
119 __asm__ __volatile__(
120 "sti; hlt");
123 #endif /* !__xpv */
125 #endif /* __i386 || defined(__amd64) */
127 #if defined(__amd64)
129 extern __GNU_INLINE void
130 __set_ds(selector_t value)
132 __asm__ __volatile__(
133 "movw %0, %%ds"
134 : /* no output */
135 : "r" (value));
138 extern __GNU_INLINE void
139 __set_es(selector_t value)
141 __asm__ __volatile__(
142 "movw %0, %%es"
143 : /* no output */
144 : "r" (value));
147 extern __GNU_INLINE void
148 __set_fs(selector_t value)
150 __asm__ __volatile__(
151 "movw %0, %%fs"
152 : /* no output */
153 : "r" (value));
156 extern __GNU_INLINE void
157 __set_gs(selector_t value)
159 __asm__ __volatile__(
160 "movw %0, %%gs"
161 : /* no output */
162 : "r" (value));
165 #if !defined(__xpv)
167 extern __GNU_INLINE void
168 __swapgs(void)
170 __asm__ __volatile__(
171 "mfence; swapgs");
174 #endif /* !__xpv */
176 #endif /* __amd64 */
179 #ifdef __cplusplus
181 #endif
183 #endif /* _ASM_CPU_H */