xref: /freebsd/sys/amd64/include/asmacros.h (revision 6605d9f3dbf3138698d30151e0ca21f0417cc657)
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  *
336605d9f3SJordan K. Hubbard  *	$Id: asmacros.h,v 1.3 1994/08/02 07:38:40 davidg Exp $
343c4dd356SDavid Greenman  */
353c4dd356SDavid Greenman 
366605d9f3SJordan K. Hubbard #ifndef _ASMACROS_H_
376605d9f3SJordan K. Hubbard #define _ASMACROS_H_	1
386605d9f3SJordan K. Hubbard 
390967373eSDavid Greenman #define ALIGN_DATA	.align	2	/* 4 byte alignment, zero filled */
400967373eSDavid Greenman #define ALIGN_TEXT	.align	2,0x90	/* 4-byte alignment, nop filled */
410967373eSDavid Greenman #define SUPERALIGN_TEXT	.align	4,0x90	/* 16-byte alignment (better for 486), nop filled */
420967373eSDavid Greenman 
430967373eSDavid Greenman #define GEN_ENTRY(name)		ALIGN_TEXT;	.globl name; name:
440967373eSDavid Greenman #define NON_GPROF_ENTRY(name)	GEN_ENTRY(_/**/name)
450967373eSDavid Greenman 
46d2306226SDavid Greenman /* These three are place holders for future changes to the profiling code */
47d2306226SDavid Greenman #define MCOUNT_LABEL(name)
48d2306226SDavid Greenman #define MEXITCOUNT
49d2306226SDavid Greenman #define FAKE_MCOUNT(caller)
50d2306226SDavid Greenman 
510967373eSDavid Greenman #ifdef GPROF
520967373eSDavid Greenman /*
530967373eSDavid Greenman  * ALTENTRY() must be before a corresponding ENTRY() so that it can jump
540967373eSDavid Greenman  * over the mcounting.
550967373eSDavid Greenman  */
560967373eSDavid Greenman #define ALTENTRY(name)	GEN_ENTRY(_/**/name); MCOUNT; jmp 2f
570967373eSDavid Greenman #define ENTRY(name)	GEN_ENTRY(_/**/name); MCOUNT; 2:
580967373eSDavid Greenman /*
590967373eSDavid Greenman  * The call to mcount supports the usual (bad) conventions.  We allocate
600967373eSDavid Greenman  * some data and pass a pointer to it although the FreeBSD doesn't use
610967373eSDavid Greenman  * the data.  We set up a frame before calling mcount because that is
620967373eSDavid Greenman  * the standard convention although it makes work for both mcount and
630967373eSDavid Greenman  * callers.
640967373eSDavid Greenman  */
650967373eSDavid Greenman #define MCOUNT		.data; ALIGN_DATA; 1:; .long 0; .text; \
660967373eSDavid Greenman 			pushl %ebp; movl %esp,%ebp; \
670967373eSDavid Greenman 			movl $1b,%eax; call mcount; popl %ebp
680967373eSDavid Greenman #else
690967373eSDavid Greenman /*
700967373eSDavid Greenman  * ALTENTRY() has to align because it is before a corresponding ENTRY().
710967373eSDavid Greenman  * ENTRY() has to align to because there may be no ALTENTRY() before it.
720967373eSDavid Greenman  * If there is a previous ALTENTRY() then the alignment code is empty.
730967373eSDavid Greenman  */
740967373eSDavid Greenman #define ALTENTRY(name)	GEN_ENTRY(_/**/name)
750967373eSDavid Greenman #define ENTRY(name)	GEN_ENTRY(_/**/name)
76d2306226SDavid Greenman #define MCOUNT
770967373eSDavid Greenman 
780967373eSDavid Greenman #endif
790967373eSDavid Greenman 
800967373eSDavid Greenman #ifdef DUMMY_NOPS			/* this will break some older machines */
810967373eSDavid Greenman #define FASTER_NOP
820967373eSDavid Greenman #define NOP
830967373eSDavid Greenman #else
840967373eSDavid Greenman #define FASTER_NOP	pushl %eax ; inb $0x84,%al ; popl %eax
850967373eSDavid Greenman #define NOP		pushl %eax ; inb $0x84,%al ; inb $0x84,%al ; popl %eax
860967373eSDavid Greenman #endif
870967373eSDavid Greenman 
886605d9f3SJordan K. Hubbard #ifndef RCSID
896605d9f3SJordan K. Hubbard #define RCSID(a)
906605d9f3SJordan K. Hubbard #endif
916605d9f3SJordan K. Hubbard 
926605d9f3SJordan K. Hubbard #endif	/* _ASMACROS_H_ */
93