13c4dd356SDavid Greenman /*- 23c4dd356SDavid Greenman * Copyright (c) 1993 The Regents of the University of California. 33c4dd356SDavid Greenman * All rights reserved. 43c4dd356SDavid Greenman * 53c4dd356SDavid Greenman * Redistribution and use in source and binary forms, with or without 63c4dd356SDavid Greenman * modification, are permitted provided that the following conditions 73c4dd356SDavid Greenman * are met: 83c4dd356SDavid Greenman * 1. Redistributions of source code must retain the above copyright 93c4dd356SDavid Greenman * notice, this list of conditions and the following disclaimer. 103c4dd356SDavid Greenman * 2. Redistributions in binary form must reproduce the above copyright 113c4dd356SDavid Greenman * notice, this list of conditions and the following disclaimer in the 123c4dd356SDavid Greenman * documentation and/or other materials provided with the distribution. 133c4dd356SDavid Greenman * 3. All advertising materials mentioning features or use of this software 143c4dd356SDavid Greenman * must display the following acknowledgement: 153c4dd356SDavid Greenman * This product includes software developed by the University of 163c4dd356SDavid Greenman * California, Berkeley and its contributors. 173c4dd356SDavid Greenman * 4. Neither the name of the University nor the names of its contributors 183c4dd356SDavid Greenman * may be used to endorse or promote products derived from this software 193c4dd356SDavid Greenman * without specific prior written permission. 203c4dd356SDavid Greenman * 213c4dd356SDavid Greenman * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 223c4dd356SDavid Greenman * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 233c4dd356SDavid Greenman * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 243c4dd356SDavid Greenman * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 253c4dd356SDavid Greenman * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 263c4dd356SDavid Greenman * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 273c4dd356SDavid Greenman * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 283c4dd356SDavid Greenman * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 293c4dd356SDavid Greenman * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 303c4dd356SDavid Greenman * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 313c4dd356SDavid Greenman * SUCH DAMAGE. 323c4dd356SDavid Greenman * 33ab9678acSBruce Evans * $Id: asmacros.h,v 1.4 1994/08/19 11:20:11 jkh Exp $ 343c4dd356SDavid Greenman */ 353c4dd356SDavid Greenman 36ab9678acSBruce Evans #ifndef _MACHINE_ASMACROS_H_ 37ab9678acSBruce Evans #define _MACHINE_ASMACROS_H_ 38ab9678acSBruce Evans 39ab9678acSBruce Evans #ifdef KERNEL 406605d9f3SJordan K. Hubbard 410967373eSDavid Greenman #define ALIGN_DATA .align 2 /* 4 byte alignment, zero filled */ 420967373eSDavid Greenman #define ALIGN_TEXT .align 2,0x90 /* 4-byte alignment, nop filled */ 430967373eSDavid Greenman #define SUPERALIGN_TEXT .align 4,0x90 /* 16-byte alignment (better for 486), nop filled */ 440967373eSDavid Greenman 450967373eSDavid Greenman #define GEN_ENTRY(name) ALIGN_TEXT; .globl name; name: 460967373eSDavid Greenman #define NON_GPROF_ENTRY(name) GEN_ENTRY(_/**/name) 470967373eSDavid Greenman 48d2306226SDavid Greenman /* These three are place holders for future changes to the profiling code */ 49d2306226SDavid Greenman #define MCOUNT_LABEL(name) 50d2306226SDavid Greenman #define MEXITCOUNT 51d2306226SDavid Greenman #define FAKE_MCOUNT(caller) 52d2306226SDavid Greenman 530967373eSDavid Greenman #ifdef GPROF 540967373eSDavid Greenman /* 550967373eSDavid Greenman * ALTENTRY() must be before a corresponding ENTRY() so that it can jump 560967373eSDavid Greenman * over the mcounting. 570967373eSDavid Greenman */ 580967373eSDavid Greenman #define ALTENTRY(name) GEN_ENTRY(_/**/name); MCOUNT; jmp 2f 590967373eSDavid Greenman #define ENTRY(name) GEN_ENTRY(_/**/name); MCOUNT; 2: 600967373eSDavid Greenman /* 610967373eSDavid Greenman * The call to mcount supports the usual (bad) conventions. We allocate 620967373eSDavid Greenman * some data and pass a pointer to it although the FreeBSD doesn't use 630967373eSDavid Greenman * the data. We set up a frame before calling mcount because that is 640967373eSDavid Greenman * the standard convention although it makes work for both mcount and 650967373eSDavid Greenman * callers. 660967373eSDavid Greenman */ 670967373eSDavid Greenman #define MCOUNT .data; ALIGN_DATA; 1:; .long 0; .text; \ 680967373eSDavid Greenman pushl %ebp; movl %esp,%ebp; \ 690967373eSDavid Greenman movl $1b,%eax; call mcount; popl %ebp 700967373eSDavid Greenman #else 710967373eSDavid Greenman /* 720967373eSDavid Greenman * ALTENTRY() has to align because it is before a corresponding ENTRY(). 730967373eSDavid Greenman * ENTRY() has to align to because there may be no ALTENTRY() before it. 740967373eSDavid Greenman * If there is a previous ALTENTRY() then the alignment code is empty. 750967373eSDavid Greenman */ 760967373eSDavid Greenman #define ALTENTRY(name) GEN_ENTRY(_/**/name) 770967373eSDavid Greenman #define ENTRY(name) GEN_ENTRY(_/**/name) 78d2306226SDavid Greenman #define MCOUNT 790967373eSDavid Greenman 800967373eSDavid Greenman #endif 810967373eSDavid Greenman 820967373eSDavid Greenman #ifdef DUMMY_NOPS /* this will break some older machines */ 830967373eSDavid Greenman #define FASTER_NOP 840967373eSDavid Greenman #define NOP 850967373eSDavid Greenman #else 860967373eSDavid Greenman #define FASTER_NOP pushl %eax ; inb $0x84,%al ; popl %eax 870967373eSDavid Greenman #define NOP pushl %eax ; inb $0x84,%al ; inb $0x84,%al ; popl %eax 880967373eSDavid Greenman #endif 890967373eSDavid Greenman 90ab9678acSBruce Evans #else /* !KERNEL */ 91ab9678acSBruce Evans 92ab9678acSBruce Evans #include "/usr/src/lib/libc/i386/DEFS.h" /* XXX blech */ 93ab9678acSBruce Evans 946605d9f3SJordan K. Hubbard #ifndef RCSID 956605d9f3SJordan K. Hubbard #define RCSID(a) 966605d9f3SJordan K. Hubbard #endif 976605d9f3SJordan K. Hubbard 98ab9678acSBruce Evans #endif /* KERNEL */ 99ab9678acSBruce Evans 100ab9678acSBruce Evans #endif /* !_MACHINE_ASMACROS_H_ */ 101