]>
git.proxmox.com Git - mirror_edk2.git/blob - StdLib/Include/Ia32/machine/asm.h
1 /* $NetBSD: asm.h,v 1.30 2006/01/20 22:02:40 christos Exp $ */
4 * Copyright (c) 1990 The Regents of the University of California.
7 * This code is derived from software contributed to Berkeley by
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
18 * 3. Neither the name of the University nor the names of its contributors
19 * may be used to endorse or promote products derived from this software
20 * without specific prior written permission.
22 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
23 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
26 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 * @(#)asm.h 5.5 (Berkeley) 5/7/91
41 #include "opt_multiprocessor.h"
45 #define PIC_PROLOGUE \
50 addl $_GLOBAL_OFFSET_TABLE_+[.-1b], %ebx
51 #define PIC_EPILOGUE \
53 #define PIC_PLT(x) x@PLT
54 #define PIC_GOT(x) x@GOT(%ebx)
55 #define PIC_GOTOFF(x) x@GOTOFF(%ebx)
61 #define PIC_GOTOFF(x) x
65 # define _C_LABEL(x) x
68 # define _C_LABEL(x) _ ## x
70 # define _C_LABEL(x) _/**/x
73 #define _ASM_LABEL(x) x
75 #define CVAROFF(x, y) _C_LABEL(x) + y
78 # define __CONCAT(x,y) x ## y
79 # define __STRING(x) #x
81 # define __CONCAT(x,y) x/**/y
82 # define __STRING(x) "x"
85 /* let kernels and others override entrypoint alignment */
86 #if !defined(_ALIGN_TEXT) && !defined(_KERNEL)
88 # define _ALIGN_TEXT .align 4
90 # define _ALIGN_TEXT .align 2
95 .text; _ALIGN_TEXT; .globl x; .type x,@function; x:
99 #if defined(MULTIPROCESSOR)
100 #define CPUVAR(off) %fs:__CONCAT(CPU_INFO_,off)
102 #define CPUVAR(off) _C_LABEL(cpu_info_primary)+__CONCAT(CPU_INFO_,off)
103 #endif /* MULTIPROCESSOR */
105 /* XXX Can't use __CONCAT() here, as it would be evaluated incorrectly. */
108 #define IDTVEC(name) \
109 ALIGN_TEXT; .globl X ## name; .type X ## name,@function; X ## name:
111 #define IDTVEC(name) \
112 ALIGN_TEXT; .globl X/**/name; .type X/**/name,@function; X/**/name:
113 #endif /* __STDC__ */
116 #define IDTVEC(name) \
117 ALIGN_TEXT; .globl _X ## name; .type _X ## name,@function; _X ## name:
119 #define IDTVEC(name) \
120 ALIGN_TEXT; .globl _X/**/name; .type _X/**/name,@function; _X/**/name:
121 #endif /* __STDC__ */
125 #define ALIGN_DATA .align 4
126 #define ALIGN_TEXT .align 4,0x90 /* 4-byte boundaries, NOP-filled */
127 #define SUPERALIGN_TEXT .align 16,0x90 /* 16-byte boundaries better for 486 */
129 #define ALIGN_DATA .align 2
130 #define ALIGN_TEXT .align 2,0x90 /* 4-byte boundaries, NOP-filled */
131 #define SUPERALIGN_TEXT .align 4,0x90 /* 16-byte boundaries better for 486 */
134 #define _ALIGN_TEXT ALIGN_TEXT
138 #define MCOUNT_ASM call _C_LABEL(__mcount)
140 #define MCOUNT_ASM call _C_LABEL(mcount)
143 #define MCOUNT_ASM /* nothing */
152 # define _PROF_PROLOGUE \
153 pushl %ebp; movl %esp,%ebp; call PIC_PLT(__mcount); popl %ebp
155 # define _PROF_PROLOGUE \
156 pushl %ebp; movl %esp,%ebp; call PIC_PLT(mcount); popl %ebp
159 # define _PROF_PROLOGUE
162 #define ENTRY(y) _ENTRY(_C_LABEL(y)); _PROF_PROLOGUE
163 #define NENTRY(y) _ENTRY(_C_LABEL(y))
164 #define ASENTRY(y) _ENTRY(_ASM_LABEL(y)); _PROF_PROLOGUE
166 #define ASMSTR .asciz
169 #define RCSID(x) .section ".ident"; .asciz x
171 #define RCSID(x) .text; .asciz x
174 #ifdef NO_KERNEL_RCSIDS
175 #define __KERNEL_RCSID(_n, _s) /* nothing */
177 #define __KERNEL_RCSID(_n, _s) RCSID(_s)
181 #define WEAK_ALIAS(alias,sym) \
186 * STRONG_ALIAS: create a strong alias.
188 #define STRONG_ALIAS(alias,sym) \
193 #define WARN_REFERENCES(sym,msg) \
194 .stabs msg ## ,30,0,0,0 ; \
195 .stabs __STRING(_C_LABEL(sym)) ## ,1,0,0,0
196 #elif defined(__ELF__)
197 #define WARN_REFERENCES(sym,msg) \
198 .stabs msg,30,0,0,0 ; \
199 .stabs __STRING(sym),1,0,0,0
201 #define WARN_REFERENCES(sym,msg) \
202 .stabs msg,30,0,0,0 ; \
203 .stabs __STRING(_/**/sym),1,0,0,0
204 #endif /* __STDC__ */
208 #endif /* !_I386_ASM_H_ */