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 https://opensource.org/licenses/CDDL-1.0.
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 /*
23  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #ifndef _IA32_SYS_ASM_LINKAGE_H
28 #define	_IA32_SYS_ASM_LINKAGE_H
29 
30 #if defined(__linux__) && defined(CONFIG_SLS)
31 #define	RET	ret; int3
32 #else
33 #define	RET	ret
34 #endif
35 
36 /* Tell compiler to call assembler like Unix */
37 #undef ASMABI
38 #define	ASMABI	__attribute__((sysv_abi))
39 
40 #define	ENDBR
41 
42 #define	SECTION_TEXT .text
43 #define	SECTION_STATIC .data
44 
45 #ifdef	__cplusplus
46 extern "C" {
47 #endif
48 
49 #ifdef _ASM	/* The remainder of this file is only for assembly files */
50 
51 /*
52  * make annoying differences in assembler syntax go away
53  */
54 
55 /*
56  * D16 and A16 are used to insert instructions prefixes; the
57  * macros help the assembler code be slightly more portable.
58  */
59 #if !defined(__GNUC_AS__)
60 /*
61  * /usr/ccs/bin/as prefixes are parsed as separate instructions
62  */
63 #define	D16	data16;
64 #define	A16	addr16;
65 
66 /*
67  * (There are some weird constructs in constant expressions)
68  */
69 #define	_CONST(const)		[const]
70 #define	_BITNOT(const)		-1!_CONST(const)
71 #define	_MUL(a, b)		_CONST(a \* b)
72 
73 #else
74 /*
75  * Why not use the 'data16' and 'addr16' prefixes .. well, the
76  * assembler doesn't quite believe in real mode, and thus argues with
77  * us about what we're trying to do.
78  */
79 #define	D16	.byte	0x66;
80 #define	A16	.byte	0x67;
81 
82 #define	_CONST(const)		(const)
83 #define	_BITNOT(const)		~_CONST(const)
84 #define	_MUL(a, b)		_CONST(a * b)
85 
86 #endif
87 
88 /*
89  * C pointers are different sizes between i386 and amd64.
90  * These constants can be used to compute offsets into pointer arrays.
91  */
92 #if defined(__amd64)
93 #define	CLONGSHIFT	3
94 #define	CLONGSIZE	8
95 #define	CLONGMASK	7
96 #elif defined(__i386)
97 #define	CLONGSHIFT	2
98 #define	CLONGSIZE	4
99 #define	CLONGMASK	3
100 #endif
101 
102 /*
103  * Since we know we're either ILP32 or LP64 ..
104  */
105 #define	CPTRSHIFT	CLONGSHIFT
106 #define	CPTRSIZE	CLONGSIZE
107 #define	CPTRMASK	CLONGMASK
108 
109 #if CPTRSIZE != (1 << CPTRSHIFT) || CLONGSIZE != (1 << CLONGSHIFT)
110 #error	"inconsistent shift constants"
111 #endif
112 
113 #if CPTRMASK != (CPTRSIZE - 1) || CLONGMASK != (CLONGSIZE - 1)
114 #error	"inconsistent mask constants"
115 #endif
116 
117 #define	ASM_ENTRY_ALIGN	16
118 
119 /*
120  * SSE register alignment and save areas
121  */
122 
123 #define	XMM_SIZE	16
124 #define	XMM_ALIGN	16
125 
126 /*
127  * ENTRY provides the standard procedure entry code and an easy way to
128  * insert the calls to mcount for profiling. ENTRY_NP is identical, but
129  * never calls mcount.
130  */
131 #define	ENTRY(x) \
132 	.text; \
133 	.balign	ASM_ENTRY_ALIGN; \
134 	.globl	x; \
135 x:	MCOUNT(x)
136 
137 #define	ENTRY_NP(x) \
138 	.text; \
139 	.balign	ASM_ENTRY_ALIGN; \
140 	.globl	x; \
141 x:
142 
143 #define	ENTRY_ALIGN(x, a) \
144 	.text; \
145 	.balign	a; \
146 	.globl	x; \
147 x:
148 
149 #define	FUNCTION(x) \
150 	.type   x, @function; \
151 x:
152 
153 /*
154  * ENTRY2 is identical to ENTRY but provides two labels for the entry point.
155  */
156 #define	ENTRY2(x, y) \
157 	.text;	\
158 	.balign	ASM_ENTRY_ALIGN; \
159 	.globl	x, y; \
160 x:; \
161 y:	MCOUNT(x)
162 
163 #define	ENTRY_NP2(x, y) \
164 	.text; \
165 	.balign	ASM_ENTRY_ALIGN; \
166 	.globl	x, y; \
167 x:; \
168 y:
169 
170 
171 /*
172  * SET_SIZE trails a function and set the size for the ELF symbol table.
173  */
174 #define	SET_SIZE(x)
175 
176 #define	SET_OBJ(x)
177 
178 #endif /* _ASM */
179 
180 #ifdef	__cplusplus
181 }
182 #endif
183 
184 #endif	/* _IA32_SYS_ASM_LINKAGE_H */
185