asm.h revision 1.1
11.1Sfvdl/*	$NetBSD: asm.h,v 1.1 2003/04/26 18:39:37 fvdl Exp $	*/
21.1Sfvdl
31.1Sfvdl/*-
41.1Sfvdl * Copyright (c) 1990 The Regents of the University of California.
51.1Sfvdl * All rights reserved.
61.1Sfvdl *
71.1Sfvdl * This code is derived from software contributed to Berkeley by
81.1Sfvdl * William Jolitz.
91.1Sfvdl *
101.1Sfvdl * Redistribution and use in source and binary forms, with or without
111.1Sfvdl * modification, are permitted provided that the following conditions
121.1Sfvdl * are met:
131.1Sfvdl * 1. Redistributions of source code must retain the above copyright
141.1Sfvdl *    notice, this list of conditions and the following disclaimer.
151.1Sfvdl * 2. Redistributions in binary form must reproduce the above copyright
161.1Sfvdl *    notice, this list of conditions and the following disclaimer in the
171.1Sfvdl *    documentation and/or other materials provided with the distribution.
181.1Sfvdl * 3. All advertising materials mentioning features or use of this software
191.1Sfvdl *    must display the following acknowledgement:
201.1Sfvdl *	This product includes software developed by the University of
211.1Sfvdl *	California, Berkeley and its contributors.
221.1Sfvdl * 4. Neither the name of the University nor the names of its contributors
231.1Sfvdl *    may be used to endorse or promote products derived from this software
241.1Sfvdl *    without specific prior written permission.
251.1Sfvdl *
261.1Sfvdl * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
271.1Sfvdl * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
281.1Sfvdl * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
291.1Sfvdl * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
301.1Sfvdl * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
311.1Sfvdl * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
321.1Sfvdl * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
331.1Sfvdl * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
341.1Sfvdl * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
351.1Sfvdl * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
361.1Sfvdl * SUCH DAMAGE.
371.1Sfvdl *
381.1Sfvdl *	@(#)asm.h	5.5 (Berkeley) 5/7/91
391.1Sfvdl */
401.1Sfvdl
411.1Sfvdl#ifndef _AMD64_ASM_H_
421.1Sfvdl#define _AMD64_ASM_H_
431.1Sfvdl
441.1Sfvdl#ifdef PIC
451.1Sfvdl#define PIC_PLT(x)	x@PLT
461.1Sfvdl#define PIC_GOT(x)	x@GOTPCREL(%rip)
471.1Sfvdl#else
481.1Sfvdl#define PIC_PLT(x)	x
491.1Sfvdl#define PIC_GOT(x)	x
501.1Sfvdl#endif
511.1Sfvdl
521.1Sfvdl# define _C_LABEL(x)	x
531.1Sfvdl#define	_ASM_LABEL(x)	x
541.1Sfvdl
551.1Sfvdl#define CVAROFF(x,y)		(_C_LABEL(x)+y)(%rip)
561.1Sfvdl
571.1Sfvdl#ifdef __STDC__
581.1Sfvdl# define __CONCAT(x,y)	x ## y
591.1Sfvdl# define __STRING(x)	#x
601.1Sfvdl#else
611.1Sfvdl# define __CONCAT(x,y)	x/**/y
621.1Sfvdl# define __STRING(x)	"x"
631.1Sfvdl#endif
641.1Sfvdl
651.1Sfvdl/* let kernels and others override entrypoint alignment */
661.1Sfvdl#ifndef _ALIGN_TEXT
671.1Sfvdl#define _ALIGN_TEXT .align 4
681.1Sfvdl#endif
691.1Sfvdl
701.1Sfvdl#define _ENTRY(x) \
711.1Sfvdl	.text; _ALIGN_TEXT; .globl x; .type x,@function; x:
721.1Sfvdl
731.1Sfvdl#ifdef _KERNEL
741.1Sfvdl/* XXX Can't use __CONCAT() here, as it would be evaluated incorrectly. */
751.1Sfvdl#ifdef __STDC__
761.1Sfvdl#define IDTVEC(name)    ALIGN_TEXT; .globl X ## name; X ## name:
771.1Sfvdl#else
781.1Sfvdl#define IDTVEC(name)    ALIGN_TEXT; .globl X/**/name; X/**/name:
791.1Sfvdl#endif /* __STDC__ */
801.1Sfvdl#endif /* _KERNEL */
811.1Sfvdl
821.1Sfvdl#ifdef __STDC__
831.1Sfvdl#define CPUVAR(off)	%gs:CPU_INFO_ ## off
841.1Sfvdl#else
851.1Sfvdl#define CPUVAR(off)     %gs:CPU_INFO_/**/off
861.1Sfvdl#endif
871.1Sfvdl
881.1Sfvdl
891.1Sfvdl#ifdef GPROF
901.1Sfvdl# define _PROF_PROLOGUE	\
911.1Sfvdl	pushq %rbp; leaq (%rsp),%rbp; call PIC_PLT(__mcount); popq %rbp
921.1Sfvdl#else
931.1Sfvdl# define _PROF_PROLOGUE
941.1Sfvdl#endif
951.1Sfvdl
961.1Sfvdl#define	ENTRY(y)	_ENTRY(_C_LABEL(y)); _PROF_PROLOGUE
971.1Sfvdl#define	NENTRY(y)	_ENTRY(_C_LABEL(y))
981.1Sfvdl#define	ASENTRY(y)	_ENTRY(_ASM_LABEL(y)); _PROF_PROLOGUE
991.1Sfvdl
1001.1Sfvdl#define	ASMSTR		.asciz
1011.1Sfvdl
1021.1Sfvdl#define RCSID(x)	.text; .asciz x
1031.1Sfvdl
1041.1Sfvdl#define	WEAK_ALIAS(alias,sym)						\
1051.1Sfvdl	.weak alias;							\
1061.1Sfvdl	alias = sym
1071.1Sfvdl
1081.1Sfvdl/* XXXfvdl do not use stabs here */
1091.1Sfvdl#ifdef __STDC__
1101.1Sfvdl#define	WARN_REFERENCES(sym,msg)					\
1111.1Sfvdl	.stabs msg ## ,30,0,0,0 ;					\
1121.1Sfvdl	.stabs __STRING(_C_LABEL(sym)) ## ,1,0,0,0
1131.1Sfvdl#else
1141.1Sfvdl#define	WARN_REFERENCES(sym,msg)					\
1151.1Sfvdl	.stabs msg,30,0,0,0 ;						\
1161.1Sfvdl	.stabs __STRING(sym),1,0,0,0
1171.1Sfvdl#endif /* __STDC__ */
1181.1Sfvdl
1191.1Sfvdl#endif /* !_AMD64_ASM_H_ */
120