1 /** $MirOS: src/sys/arch/i386/include/asm.h,v 1.11 2014/03/23 20:36:09 tg Exp $ */ 2 /* $OpenBSD: asm.h,v 1.7 2003/06/02 23:27:47 millert Exp $ */ 3 /* $NetBSD: asm.h,v 1.7 1994/10/27 04:15:56 cgd Exp $ */ 4 5 /*- 6 * Copyright (c) 1990 The Regents of the University of California. 7 * All rights reserved. 8 * 9 * This code is derived from software contributed to Berkeley by 10 * William Jolitz. 11 * 12 * Redistribution and use in source and binary forms, with or without 13 * modification, are permitted provided that the following conditions 14 * are met: 15 * 1. Redistributions of source code must retain the above copyright 16 * notice, this list of conditions and the following disclaimer. 17 * 2. Redistributions in binary form must reproduce the above copyright 18 * notice, this list of conditions and the following disclaimer in the 19 * documentation and/or other materials provided with the distribution. 20 * 3. Neither the name of the University nor the names of its contributors 21 * may be used to endorse or promote products derived from this software 22 * without specific prior written permission. 23 * 24 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 25 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 27 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 30 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 31 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 34 * SUCH DAMAGE. 35 * 36 * @(#)asm.h 5.5 (Berkeley) 5/7/91 37 */ 38 39 #ifndef _I386_ASM_H_ 40 #define _I386_ASM_H_ 41 42 #ifdef PIC 43 #ifdef __ELF__ 44 #define PIC_PROLOGUE \ 45 pushl %ebx; \ 46 call 666f; \ 47 666: \ 48 popl %ebx; \ 49 addl $_GLOBAL_OFFSET_TABLE_+[.-666b], %ebx 50 #else 51 #define PIC_PROLOGUE \ 52 pushl %ebx; \ 53 call 666f; \ 54 666: \ 55 popl %ebx; \ 56 addl $__GLOBAL_OFFSET_TABLE_+[.-666b], %ebx 57 #endif 58 #define PIC_EPILOGUE \ 59 popl %ebx 60 #define PIC_PLT(x) x@PLT 61 #define PIC_GOT(x) x@GOT(%ebx) 62 #define PIC_GOTOFF(x) x@GOTOFF(%ebx) 63 #else 64 #define PIC_PROLOGUE 65 #define PIC_EPILOGUE 66 #define PIC_PLT(x) x 67 #define PIC_GOT(x) x 68 #define PIC_GOTOFF(x) x 69 #endif 70 71 #ifdef __ELF__ 72 #define _C_LABEL(name) name 73 #else 74 #ifdef __STDC__ 75 #define _C_LABEL(name) _ ## name 76 #else 77 #define _C_LABEL(name) _/**/name 78 #endif 79 #endif 80 #define _ASM_LABEL(x) x 81 82 /* 83 * WEAK_ALIAS: create a weak alias (ELF only) 84 */ 85 #ifdef __ELF__ 86 #define WEAK_ALIAS(alias,sym) \ 87 .weak alias; \ 88 alias = sym 89 #endif 90 91 /* 92 * WARN_REFERENCES: create a warning if the specified symbol is referenced 93 * (ELF only). 94 */ 95 #ifdef __ELF__ 96 #define WARN_REFERENCES(_sym,_msg) \ 97 .section .gnu.warning. ## _sym ; .ascii "REF! " _msg ; .previous 98 #endif /* __ELF__ */ 99 100 /* let kernels and others override entrypoint alignment */ 101 #ifndef _ALIGN_TEXT 102 #ifdef SMALL 103 #define _ALIGN_TEXT /* nothing */ 104 #else 105 #define _ALIGN_TEXT .p2align 2, 0x90 106 #endif 107 #endif 108 109 #define FTYPE(x) .type x,@function 110 #define OTYPE(x) .type x,@object 111 112 #define _ENTRY(name) \ 113 .text; _ALIGN_TEXT; .globl name; FTYPE(name); name: 114 115 /* no profiling */ 116 #define _PROF_PROLOGUE 117 118 #define ENTRY(name) _ENTRY(_C_LABEL(name)); _PROF_PROLOGUE 119 #define NENTRY(name) _ENTRY(_C_LABEL(name)) 120 #define ASENTRY(name) _ENTRY(_ASM_LABEL(name)); _PROF_PROLOGUE 121 122 #define ALTENTRY(name) \ 123 .globl _C_LABEL(name); FTYPE(_C_LABEL(name)); _C_LABEL(name): 124 #define DENTRY(name) \ 125 .globl _C_LABEL(name); OTYPE(_C_LABEL(name)); _C_LABEL(name): 126 127 #define ASMSTR .asciz 128 129 #define RCSID(x) .section .comment; \ 130 .ascii "@(""#)rcsid: "; \ 131 .asciz x; \ 132 .previous 133 134 #endif /* !_I386_ASM_H_ */ 135