4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License, Version 1.0 only
6 * (the "License"). You may not use this file except in compliance
9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 * or http://www.opensolaris.org/os/licensing.
11 * See the License for the specific language governing permissions
12 * and limitations under the License.
14 * When distributing Covered Code, include this CDDL HEADER in each
15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 * If applicable, add the following below this CDDL HEADER, with the
17 * fields enclosed by brackets "[]" replaced with your own identifying
18 * information: Portions Copyright [yyyy] [name of copyright owner]
23 * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
27 #ifndef _IA32_SYS_ASM_LINKAGE_H
28 #define _IA32_SYS_ASM_LINKAGE_H
32 #include <sys/stack.h>
39 #ifdef _ASM /* The remainder of this file is only for assembly files */
42 * make annoying differences in assembler syntax go away
46 * D16 and A16 are used to insert instructions prefixes; the
47 * macros help the assembler code be slightly more portable.
49 #if !defined(__GNUC_AS__)
51 * /usr/ccs/bin/as prefixes are parsed as separate instructions
57 * (There are some weird constructs in constant expressions)
59 #define _CONST(const) [const]
60 #define _BITNOT(const) -1!_CONST(const)
61 #define _MUL(a, b) _CONST(a \* b)
65 * Why not use the 'data16' and 'addr16' prefixes .. well, the
66 * assembler doesn't quite believe in real mode, and thus argues with
67 * us about what we're trying to do.
69 #define D16 .byte 0x66;
70 #define A16 .byte 0x67;
72 #define _CONST(const) (const)
73 #define _BITNOT(const) ~_CONST(const)
74 #define _MUL(a, b) _CONST(a * b)
79 * C pointers are different sizes between i386 and amd64.
80 * These constants can be used to compute offsets into pointer arrays.
93 * Since we know we're either ILP32 or LP64 ..
95 #define CPTRSHIFT CLONGSHIFT
96 #define CPTRSIZE CLONGSIZE
97 #define CPTRMASK CLONGMASK
99 #if CPTRSIZE != (1 << CPTRSHIFT) || CLONGSIZE != (1 << CLONGSHIFT)
100 #error "inconsistent shift constants"
103 #if CPTRMASK != (CPTRSIZE - 1) || CLONGMASK != (CLONGSIZE - 1)
104 #error "inconsistent mask constants"
107 #define ASM_ENTRY_ALIGN 16
110 * SSE register alignment and save areas
118 #define SAVE_XMM_PROLOG(sreg, nreg) \
119 subq $_CONST(_MUL(XMM_SIZE, nreg)), %rsp; \
122 #define RSTOR_XMM_EPILOG(sreg, nreg) \
123 addq $_CONST(_MUL(XMM_SIZE, nreg)), %rsp
125 #elif defined(__i386)
127 #define SAVE_XMM_PROLOG(sreg, nreg) \
128 subl $_CONST(_MUL(XMM_SIZE, nreg) + XMM_ALIGN), %esp; \
130 addl $XMM_ALIGN, sreg; \
131 andl $_BITNOT(XMM_ALIGN-1), sreg
133 #define RSTOR_XMM_EPILOG(sreg, nreg) \
134 addl $_CONST(_MUL(XMM_SIZE, nreg) + XMM_ALIGN), %esp;
139 * profiling causes definitions of the MCOUNT and RTMCOUNT
140 * particular to the type
156 .lcomm .L_/**/x/**/1, 4, 4; \
160 movl $.L_/**/x/**/1, %edx; \
167 * if we are not profiling, MCOUNT should be defined to nothing
169 #if !defined(PROF) && !defined(GPROF)
171 #endif /* !defined(PROF) && !defined(GPROF) */
173 #define RTMCOUNT(x) MCOUNT(x)
176 * Macro to define weak symbol aliases. These are similar to the ANSI-C
177 * #pragma weak name = _name
178 * except a compiler can determine type. The assembler must be told. Hence,
179 * the second parameter must be the type of the symbol (i.e.: function,...)
181 #define ANSI_PRAGMA_WEAK(sym, stype) \
188 * Like ANSI_PRAGMA_WEAK(), but for unrelated names, as in:
189 * #pragma weak sym1 = sym2
191 #define ANSI_PRAGMA_WEAK2(sym1, sym2, stype) \
193 .type sym1, @stype; \
197 * ENTRY provides the standard procedure entry code and an easy way to
198 * insert the calls to mcount for profiling. ENTRY_NP is identical, but
199 * never calls mcount.
203 .align ASM_ENTRY_ALIGN; \
205 .type x, @function; \
208 #define ENTRY_NP(x) \
210 .align ASM_ENTRY_ALIGN; \
212 .type x, @function; \
217 .align ASM_ENTRY_ALIGN; \
219 .type x, @function; \
223 * ENTRY2 is identical to ENTRY but provides two labels for the entry point.
225 #define ENTRY2(x, y) \
227 .align ASM_ENTRY_ALIGN; \
229 .type x, @function; \
230 .type y, @function; \
235 #define ENTRY_NP2(x, y) \
237 .align ASM_ENTRY_ALIGN; \
239 .type x, @function; \
240 .type y, @function; \
247 * ALTENTRY provides for additional entry points.
249 #define ALTENTRY(x) \
251 .type x, @function; \
255 * DGDEF and DGDEF2 provide global data declarations.
257 * DGDEF provides a word aligned word of storage.
259 * DGDEF2 allocates "sz" bytes of storage with **NO** alignment. This
260 * implies this macro is best used for byte arrays.
262 * DGDEF3 allocates "sz" bytes of storage with "algn" alignment.
264 #define DGDEF2(name, sz) \
267 .type name, @object; \
271 #define DGDEF3(name, sz, algn) \
275 .type name, @object; \
279 #define DGDEF(name) DGDEF3(name, 4, 4)
282 * SET_SIZE trails a function and set the size for the ELF symbol table.
284 #define SET_SIZE(x) \
288 * NWORD provides native word value.
295 #elif defined(__i386)
307 #endif /* _IA32_SYS_ASM_LINKAGE_H */