xref: /titanic_41/usr/src/uts/intel/asm/cpu.h (revision c0c79a3f09914f35651895ffc111883455b7f62d)
1 /*
2  * CDDL HEADER START
3  *
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.
7  *
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.
12  *
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]
18  *
19  * CDDL HEADER END
20  */
21 /*
22  * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 
26 #ifndef _ASM_CPU_H
27 #define	_ASM_CPU_H
28 
29 #pragma ident	"%Z%%M%	%I%	%E% SMI"
30 
31 #ifdef	__cplusplus
32 extern "C" {
33 #endif
34 
35 #if !defined(__lint) && defined(__GNUC__)
36 
37 #if defined(__i386) || defined(__amd64)
38 
39 extern __inline__ void ht_pause(void)
40 {
41 	__asm__ __volatile__(
42 	    "pause");
43 }
44 
45 extern __inline__ void cli(void)
46 {
47 	__asm__ __volatile__(
48 	    "cli" : : : "memory");
49 }
50 
51 extern __inline__ void sti(void)
52 {
53 	__asm__ __volatile__(
54 	    "sti");
55 }
56 
57 extern __inline__ void i86_halt(void)
58 {
59 	__asm__ __volatile__(
60 	    "sti; hlt");
61 }
62 
63 #endif	/* __i386 || defined(__amd64) */
64 
65 #if defined(__amd64)
66 
67 extern __inline__ void __set_ds(selector_t value)
68 {
69 	__asm__ __volatile__(
70 	"movw	%0, %%ds"
71 	: /* no output */
72 	: "r" (value));
73 }
74 
75 extern __inline__ void __set_es(selector_t value)
76 {
77 	__asm__ __volatile__(
78 	"movw	%0, %%es"
79 	: /* no output */
80 	: "r" (value));
81 }
82 
83 extern __inline__ void __set_fs(selector_t value)
84 {
85 	__asm__ __volatile__(
86 	"movw	%0, %%fs"
87 	: /* no output */
88 	: "r" (value));
89 }
90 
91 extern __inline__ void __set_gs(selector_t value)
92 {
93 	__asm__ __volatile__(
94 	"movw	%0, %%gs"
95 	: /* no output */
96 	: "r" (value));
97 }
98 
99 extern __inline__ void __swapgs(void)
100 {
101 	__asm__ __volatile__(
102 	"mfence; swapgs");
103 }
104 
105 #endif	/* __amd64 */
106 
107 #endif	/* !__lint && __GNUC__ */
108 
109 #ifdef	__cplusplus
110 }
111 #endif
112 
113 #endif	/* _ASM_CPU_H */
114