xref: /freebsd/sys/amd64/include/asmacros.h (revision 3c4dd3568f411b4f00f795929afb77ca972c2325)
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  *
333c4dd356SDavid Greenman  *	$Id$
343c4dd356SDavid Greenman  */
353c4dd356SDavid Greenman 
360967373eSDavid Greenman #define ALIGN_DATA	.align	2	/* 4 byte alignment, zero filled */
370967373eSDavid Greenman #define ALIGN_TEXT	.align	2,0x90	/* 4-byte alignment, nop filled */
380967373eSDavid Greenman #define SUPERALIGN_TEXT	.align	4,0x90	/* 16-byte alignment (better for 486), nop filled */
390967373eSDavid Greenman 
400967373eSDavid Greenman #define GEN_ENTRY(name)		ALIGN_TEXT;	.globl name; name:
410967373eSDavid Greenman #define NON_GPROF_ENTRY(name)	GEN_ENTRY(_/**/name)
420967373eSDavid Greenman 
43d2306226SDavid Greenman /* These three are place holders for future changes to the profiling code */
44d2306226SDavid Greenman #define MCOUNT_LABEL(name)
45d2306226SDavid Greenman #define MEXITCOUNT
46d2306226SDavid Greenman #define FAKE_MCOUNT(caller)
47d2306226SDavid Greenman 
480967373eSDavid Greenman #ifdef GPROF
490967373eSDavid Greenman /*
500967373eSDavid Greenman  * ALTENTRY() must be before a corresponding ENTRY() so that it can jump
510967373eSDavid Greenman  * over the mcounting.
520967373eSDavid Greenman  */
530967373eSDavid Greenman #define ALTENTRY(name)	GEN_ENTRY(_/**/name); MCOUNT; jmp 2f
540967373eSDavid Greenman #define ENTRY(name)	GEN_ENTRY(_/**/name); MCOUNT; 2:
550967373eSDavid Greenman /*
560967373eSDavid Greenman  * The call to mcount supports the usual (bad) conventions.  We allocate
570967373eSDavid Greenman  * some data and pass a pointer to it although the FreeBSD doesn't use
580967373eSDavid Greenman  * the data.  We set up a frame before calling mcount because that is
590967373eSDavid Greenman  * the standard convention although it makes work for both mcount and
600967373eSDavid Greenman  * callers.
610967373eSDavid Greenman  */
620967373eSDavid Greenman #define MCOUNT		.data; ALIGN_DATA; 1:; .long 0; .text; \
630967373eSDavid Greenman 			pushl %ebp; movl %esp,%ebp; \
640967373eSDavid Greenman 			movl $1b,%eax; call mcount; popl %ebp
650967373eSDavid Greenman #else
660967373eSDavid Greenman /*
670967373eSDavid Greenman  * ALTENTRY() has to align because it is before a corresponding ENTRY().
680967373eSDavid Greenman  * ENTRY() has to align to because there may be no ALTENTRY() before it.
690967373eSDavid Greenman  * If there is a previous ALTENTRY() then the alignment code is empty.
700967373eSDavid Greenman  */
710967373eSDavid Greenman #define ALTENTRY(name)	GEN_ENTRY(_/**/name)
720967373eSDavid Greenman #define ENTRY(name)	GEN_ENTRY(_/**/name)
73d2306226SDavid Greenman #define MCOUNT
740967373eSDavid Greenman 
750967373eSDavid Greenman #endif
760967373eSDavid Greenman 
770967373eSDavid Greenman #ifdef DUMMY_NOPS			/* this will break some older machines */
780967373eSDavid Greenman #define FASTER_NOP
790967373eSDavid Greenman #define NOP
800967373eSDavid Greenman #else
810967373eSDavid Greenman #define FASTER_NOP	pushl %eax ; inb $0x84,%al ; popl %eax
820967373eSDavid Greenman #define NOP		pushl %eax ; inb $0x84,%al ; inb $0x84,%al ; popl %eax
830967373eSDavid Greenman #endif
840967373eSDavid Greenman 
85