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
34 #ifdef _ASM /* The remainder of this file is only for assembly files */
37 * make annoying differences in assembler syntax go away
41 * D16 and A16 are used to insert instructions prefixes; the
42 * macros help the assembler code be slightly more portable.
44 #if !defined(__GNUC_AS__)
46 * /usr/ccs/bin/as prefixes are parsed as separate instructions
52 * (There are some weird constructs in constant expressions)
54 #define _CONST(const) [const]
55 #define _BITNOT(const) -1!_CONST(const)
56 #define _MUL(a, b) _CONST(a \* b)
60 * Why not use the 'data16' and 'addr16' prefixes .. well, the
61 * assembler doesn't quite believe in real mode, and thus argues with
62 * us about what we're trying to do.
64 #define D16 .byte 0x66;
65 #define A16 .byte 0x67;
67 #define _CONST(const) (const)
68 #define _BITNOT(const) ~_CONST(const)
69 #define _MUL(a, b) _CONST(a * b)
74 * C pointers are different sizes between i386 and amd64.
75 * These constants can be used to compute offsets into pointer arrays.
88 * Since we know we're either ILP32 or LP64 ..
90 #define CPTRSHIFT CLONGSHIFT
91 #define CPTRSIZE CLONGSIZE
92 #define CPTRMASK CLONGMASK
94 #if CPTRSIZE != (1 << CPTRSHIFT) || CLONGSIZE != (1 << CLONGSHIFT)
95 #error "inconsistent shift constants"
98 #if CPTRMASK != (CPTRSIZE - 1) || CLONGMASK != (CLONGSIZE - 1)
99 #error "inconsistent mask constants"
102 #define ASM_ENTRY_ALIGN 16
105 * SSE register alignment and save areas
113 #define SAVE_XMM_PROLOG(sreg, nreg) \
114 subq $_CONST(_MUL(XMM_SIZE, nreg)), %rsp; \
117 #define RSTOR_XMM_EPILOG(sreg, nreg) \
118 addq $_CONST(_MUL(XMM_SIZE, nreg)), %rsp
120 #elif defined(__i386)
122 #define SAVE_XMM_PROLOG(sreg, nreg) \
123 subl $_CONST(_MUL(XMM_SIZE, nreg) + XMM_ALIGN), %esp; \
125 addl $XMM_ALIGN, sreg; \
126 andl $_BITNOT(XMM_ALIGN-1), sreg
128 #define RSTOR_XMM_EPILOG(sreg, nreg) \
129 addl $_CONST(_MUL(XMM_SIZE, nreg) + XMM_ALIGN), %esp;
134 * profiling causes definitions of the MCOUNT and RTMCOUNT
135 * particular to the type
151 .lcomm .L_/**/x/**/1, 4, 4; \
155 movl $.L_/**/x/**/1, %edx; \
162 * if we are not profiling, MCOUNT should be defined to nothing
164 #if !defined(PROF) && !defined(GPROF)
166 #endif /* !defined(PROF) && !defined(GPROF) */
168 #define RTMCOUNT(x) MCOUNT(x)
171 * Macro to define weak symbol aliases. These are similar to the ANSI-C
172 * #pragma weak name = _name
173 * except a compiler can determine type. The assembler must be told. Hence,
174 * the second parameter must be the type of the symbol (i.e.: function,...)
176 #define ANSI_PRAGMA_WEAK(sym, stype) \
183 * Like ANSI_PRAGMA_WEAK(), but for unrelated names, as in:
184 * #pragma weak sym1 = sym2
186 #define ANSI_PRAGMA_WEAK2(sym1, sym2, stype) \
188 .type sym1, @stype; \
192 * ENTRY provides the standard procedure entry code and an easy way to
193 * insert the calls to mcount for profiling. ENTRY_NP is identical, but
194 * never calls mcount.
198 .align ASM_ENTRY_ALIGN; \
200 .type x, @function; \
203 #define ENTRY_NP(x) \
205 .align ASM_ENTRY_ALIGN; \
207 .type x, @function; \
212 .align ASM_ENTRY_ALIGN; \
214 .type x, @function; \
218 * ENTRY2 is identical to ENTRY but provides two labels for the entry point.
220 #define ENTRY2(x, y) \
222 .align ASM_ENTRY_ALIGN; \
224 .type x, @function; \
225 .type y, @function; \
230 #define ENTRY_NP2(x, y) \
232 .align ASM_ENTRY_ALIGN; \
234 .type x, @function; \
235 .type y, @function; \
242 * ALTENTRY provides for additional entry points.
244 #define ALTENTRY(x) \
246 .type x, @function; \
250 * DGDEF and DGDEF2 provide global data declarations.
252 * DGDEF provides a word aligned word of storage.
254 * DGDEF2 allocates "sz" bytes of storage with **NO** alignment. This
255 * implies this macro is best used for byte arrays.
257 * DGDEF3 allocates "sz" bytes of storage with "algn" alignment.
259 #define DGDEF2(name, sz) \
262 .type name, @object; \
266 #define DGDEF3(name, sz, algn) \
270 .type name, @object; \
274 #define DGDEF(name) DGDEF3(name, 4, 4)
277 * SET_SIZE trails a function and set the size for the ELF symbol table.
279 #define SET_SIZE(x) \
283 * NWORD provides native word value.
290 #elif defined(__i386)
302 #endif /* _IA32_SYS_ASM_LINKAGE_H */