Home | History | Annotate | Line # | Download | only in include
asm.h revision 1.35.6.1
      1  1.35.6.1  perseant /*	$NetBSD: asm.h,v 1.35.6.1 2025/08/02 05:55:48 perseant Exp $	*/
      2      1.15   thorpej 
      3      1.15   thorpej /*-
      4      1.15   thorpej  * Copyright (c) 1997 The NetBSD Foundation, Inc.
      5      1.15   thorpej  * All rights reserved.
      6      1.15   thorpej  *
      7      1.15   thorpej  * This code is derived from software contributed to The NetBSD Foundation
      8      1.15   thorpej  * by Jason R. Thorpe.
      9      1.15   thorpej  *
     10      1.15   thorpej  * Redistribution and use in source and binary forms, with or without
     11      1.15   thorpej  * modification, are permitted provided that the following conditions
     12      1.15   thorpej  * are met:
     13      1.15   thorpej  * 1. Redistributions of source code must retain the above copyright
     14      1.15   thorpej  *    notice, this list of conditions and the following disclaimer.
     15      1.15   thorpej  * 2. Redistributions in binary form must reproduce the above copyright
     16      1.15   thorpej  *    notice, this list of conditions and the following disclaimer in the
     17      1.15   thorpej  *    documentation and/or other materials provided with the distribution.
     18      1.15   thorpej  *
     19      1.15   thorpej  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     20      1.15   thorpej  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     21      1.15   thorpej  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     22      1.15   thorpej  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     23      1.15   thorpej  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     24      1.15   thorpej  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     25      1.15   thorpej  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     26      1.15   thorpej  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     27      1.15   thorpej  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     28      1.15   thorpej  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     29      1.15   thorpej  * POSSIBILITY OF SUCH DAMAGE.
     30      1.15   thorpej  */
     31       1.9       cgd 
     32       1.1    briggs /*
     33       1.1    briggs  * Copyright (c) 1994 Allen Briggs
     34       1.1    briggs  * All rights reserved.
     35       1.1    briggs  *
     36       1.1    briggs  * Gleaned from locore.s and sun3 asm.h which had the following copyrights:
     37       1.1    briggs  * locore.s:
     38       1.1    briggs  * Copyright (c) 1988 University of Utah.
     39       1.1    briggs  * Copyright (c) 1982, 1990 The Regents of the University of California.
     40       1.1    briggs  * sun3/include/asm.h:
     41       1.1    briggs  * Copyright (c) 1993 Adam Glass
     42       1.1    briggs  * Copyright (c) 1990 The Regents of the University of California.
     43       1.1    briggs  *
     44       1.1    briggs  * Redistribution and use in source and binary forms, with or without
     45       1.1    briggs  * modification, are permitted provided that the following conditions
     46       1.1    briggs  * are met:
     47       1.1    briggs  * 1. Redistributions of source code must retain the above copyright
     48       1.1    briggs  *    notice, this list of conditions and the following disclaimer.
     49       1.1    briggs  * 2. Redistributions in binary form must reproduce the above copyright
     50       1.1    briggs  *    notice, this list of conditions and the following disclaimer in the
     51       1.1    briggs  *    documentation and/or other materials provided with the distribution.
     52       1.1    briggs  * 3. All advertising materials mentioning features or use of this software
     53       1.1    briggs  *    must display the following acknowledgement:
     54       1.1    briggs  *	This product includes software developed by the University of
     55       1.1    briggs  *	California, Berkeley and its contributors.
     56       1.1    briggs  * 4. Neither the name of the University nor the names of its contributors
     57       1.1    briggs  *    may be used to endorse or promote products derived from this software
     58       1.1    briggs  *    without specific prior written permission.
     59       1.1    briggs  *
     60       1.1    briggs  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
     61       1.1    briggs  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     62       1.1    briggs  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     63       1.1    briggs  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
     64       1.1    briggs  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     65       1.1    briggs  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     66       1.1    briggs  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     67       1.1    briggs  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     68       1.1    briggs  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     69       1.1    briggs  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     70       1.1    briggs  * SUCH DAMAGE.
     71       1.1    briggs  */
     72       1.1    briggs 
     73      1.18    kleink #ifndef _M68K_ASM_H_
     74      1.18    kleink #define _M68K_ASM_H_
     75       1.1    briggs 
     76      1.32      matt #define __IMMEDIATE		#
     77      1.32      matt 
     78      1.33     joerg #ifdef __PIC__
     79      1.30      matt #define PIC_PLT(name)		name@PLTPC
     80      1.32      matt #ifdef __mcoldfire__
     81      1.32      matt #define LEA_LCL(name,reg) \
     82      1.32      matt 	movl	__IMMEDIATE name - .,reg ; \
     83      1.32      matt 	lea	(-6,%pc,reg),reg
     84      1.32      matt #define GOT_SETUP(reg) \
     85      1.32      matt 	movl	__IMMEDIATE _GLOBAL_OFFSET_TABLE_@GOTPC,reg ; \
     86      1.32      matt 	lea	(-6,%pc,reg),reg
     87      1.32      matt #else
     88      1.30      matt #define LEA_LCL(name,reg)	lea	(name,%pc),reg
     89      1.30      matt #define GOT_SETUP(reg)		lea	(_GLOBAL_OFFSET_TABLE_@GOTPC,%pc),reg
     90      1.32      matt #endif
     91       1.1    briggs #else
     92      1.30      matt #define PIC_PLT(name)		name
     93      1.30      matt #define LEA_LCL(name,reg)	movl	__IMMEDIATE name,reg
     94      1.30      matt #define GOT_SETUP(reg)		/* nothing */
     95      1.18    kleink #endif
     96      1.18    kleink 
     97      1.30      matt #if __STDC__
     98      1.30      matt # define _C_LABEL(name)	name
     99      1.30      matt #else
    100      1.30      matt # define _C_LABEL(name)	name
    101      1.13   thorpej #endif /* __STDC__ */
    102      1.13   thorpej 
    103       1.2   mycroft #define	_ASM_LABEL(name)	name
    104       1.2   mycroft 
    105       1.2   mycroft #define	_ENTRY(name) \
    106       1.8    brezak 	.text; .even; .globl name; .type name,@function; name:
    107      1.29      matt #define	END(name)	.size name,.-name
    108       1.1    briggs 
    109      1.23       chs #define	MCOUNT_ENTRY	__mcount
    110      1.23       chs 
    111      1.12       jtc #ifdef GPROF
    112      1.23       chs #define _PROF_PROLOG	link %a6,#0; jbsr MCOUNT_ENTRY; unlk %a6
    113      1.11       jtc #else
    114      1.11       jtc #define _PROF_PROLOG
    115      1.11       jtc #endif
    116      1.11       jtc 
    117      1.11       jtc #define ENTRY(name)		_ENTRY(_C_LABEL(name)) _PROF_PROLOG
    118      1.11       jtc #define	ASENTRY(name)		_ENTRY(_ASM_LABEL(name)) _PROF_PROLOG
    119      1.11       jtc 
    120      1.13   thorpej #define	ENTRY_NOPROFILE(name)	_ENTRY(_C_LABEL(name))
    121      1.13   thorpej #define	ASENTRY_NOPROFILE(name)	_ENTRY(_ASM_LABEL(name))
    122      1.13   thorpej 
    123      1.11       jtc /*
    124      1.11       jtc  * The m68k ALTENTRY macro is very different than the traditional
    125      1.35   tsutsui  * implementation used by other NetBSD ports.  Usually ALTENTRY
    126      1.11       jtc  * simply provides an alternate function entry point.  The m68k
    127      1.11       jtc  * definition takes a second argument and jumps inside the second
    128      1.11       jtc  * function when profiling is enabled.
    129      1.11       jtc  *
    130      1.11       jtc  * The m68k behavior is similar to the ENTRY2 macro found in
    131      1.11       jtc  * solaris' asm_linkage.h.
    132      1.11       jtc  *
    133      1.11       jtc  * Providing ENTRY2 and changing all the code that uses ALTENTRY
    134      1.11       jtc  * to use it would be a desirable change.
    135      1.11       jtc  */
    136      1.11       jtc #ifdef PROF
    137      1.11       jtc #define ALTENTRY(name, rname)	ENTRY(name); jra rname+12
    138       1.1    briggs #else
    139       1.2   mycroft #define ALTENTRY(name, rname)	_ENTRY(_C_LABEL(name))
    140       1.1    briggs #endif
    141       1.8    brezak 
    142  1.35.6.1  perseant #ifdef _NETBSD_REVISIONID
    143      1.34     joerg #define RCSID(x)	.pushsection ".ident","MS",@progbits,1;		\
    144      1.34     joerg 			.asciz x;					\
    145  1.35.6.1  perseant 			.ascii "$"; .ascii "NetBSD: "; .ascii __FILE__;	\
    146  1.35.6.1  perseant 			.ascii " "; .ascii _NETBSD_REVISIONID;		\
    147  1.35.6.1  perseant 			.asciz " $";					\
    148      1.28      matt 			.popsection
    149  1.35.6.1  perseant #else
    150  1.35.6.1  perseant #define RCSID(x)	.pushsection ".ident","MS",@progbits,1;		\
    151  1.35.6.1  perseant 			.asciz x;					\
    152  1.35.6.1  perseant 			.popsection
    153  1.35.6.1  perseant #endif
    154      1.13   thorpej 
    155      1.13   thorpej /*
    156      1.13   thorpej  * Global variables of whatever sort.
    157      1.13   thorpej  */
    158      1.13   thorpej #define	GLOBAL(x)					\
    159      1.13   thorpej 		.globl	_C_LABEL(x)		;	\
    160      1.13   thorpej 	_C_LABEL(x):
    161      1.13   thorpej 
    162      1.13   thorpej #define	ASGLOBAL(x)					\
    163      1.13   thorpej 		.globl	_ASM_LABEL(x)		;	\
    164      1.13   thorpej 	_ASM_LABEL(x):
    165      1.13   thorpej 
    166      1.13   thorpej /*
    167      1.13   thorpej  * ...and local variables.
    168      1.13   thorpej  */
    169      1.13   thorpej #define	LOCAL(x)					\
    170      1.13   thorpej 	_C_LABEL(x):
    171      1.13   thorpej 
    172      1.13   thorpej #define	ASLOCAL(x)					\
    173      1.13   thorpej 	_ASM_LABEL(x):
    174      1.13   thorpej 
    175      1.13   thorpej /*
    176      1.13   thorpej  * Items in the BSS segment.
    177      1.13   thorpej  */
    178      1.13   thorpej #define	BSS(name, size)					\
    179      1.13   thorpej 	.comm	_C_LABEL(name),size
    180      1.13   thorpej 
    181      1.13   thorpej #define	ASBSS(name, size)				\
    182      1.13   thorpej 	.comm	_ASM_LABEL(name),size
    183      1.13   thorpej 
    184      1.31      matt /*
    185      1.31      matt  * Need a better place for these but these are common across
    186      1.31      matt  * all m68k ports so let's define just once.
    187      1.31      matt  */
    188      1.32      matt #ifdef __mcoldfire__
    189      1.32      matt #define INTERRUPT_SAVEREG	lea -16(%sp),%sp; moveml #0xC0C0,(%sp)
    190      1.32      matt #define INTERRUPT_RESTOREREG	moveml (%sp),#0x0303; lea 16(%sp),%sp
    191      1.32      matt #else
    192      1.32      matt #define INTERRUPT_SAVEREG	moveml	#0xC0C0,-(%sp)
    193      1.32      matt #define INTERRUPT_RESTOREREG	moveml	(%sp)+,#0x0303
    194      1.32      matt #endif
    195      1.31      matt 
    196      1.13   thorpej #ifdef _KERNEL
    197      1.13   thorpej /*
    198      1.13   thorpej  * Shorthand for calling panic().
    199      1.13   thorpej  * Note the side-effect: it uses up the 9: label, so be careful!
    200      1.13   thorpej  */
    201      1.13   thorpej #define	PANIC(x)					\
    202      1.13   thorpej 		pea	9f			;	\
    203      1.13   thorpej 		jbsr	_C_LABEL(panic)		;	\
    204      1.13   thorpej 	9:	.asciz	x			;	\
    205      1.13   thorpej 		.even
    206      1.13   thorpej 
    207      1.26      matt /* 64-bit counter increments */
    208      1.26      matt #define CPUINFO_INCREMENT(n)					\
    209      1.26      matt 	lea	_C_LABEL(cpu_info_store)+(n)+4,%a1;		\
    210      1.26      matt 	addq.l	#1,(%a1);					\
    211      1.26      matt 	clr.l	%d0;		/* doesn't change CCR[X] */	\
    212      1.26      matt 	move.l	-(%a1),%d1;	/* doesn't change CCR[X] */	\
    213      1.26      matt 	addx.l	%d0,%d1;					\
    214      1.26      matt 	move.l	%d1,(%a1)
    215      1.26      matt 
    216      1.26      matt /* 64-bit counter increments */
    217      1.26      matt #define CPUINFO_ADD(n, addend)					\
    218      1.26      matt 	lea	_C_LABEL(cpu_info_store)+(n)+4,%a1;		\
    219      1.26      matt 	add.l	addend,(%a1);					\
    220      1.26      matt 	clr.l	%d0;		/* doesn't change CCR[X] */	\
    221      1.26      matt 	move.l	-(%a1),%d1;	/* doesn't change CCR[X] */	\
    222      1.26      matt 	addx.l	%d0,%d1;					\
    223      1.26      matt 	move.l	%d1,(%a1)
    224      1.26      matt 
    225      1.22       chs #endif /* _KERNEL */
    226      1.22       chs 
    227      1.13   thorpej /*
    228      1.13   thorpej  * Shorthand for defining vectors for the vector table.
    229      1.13   thorpej  */
    230      1.13   thorpej #define	VECTOR(x)					\
    231      1.13   thorpej 	.long	_C_LABEL(x)
    232      1.13   thorpej 
    233      1.13   thorpej #define	ASVECTOR(x)					\
    234      1.13   thorpej 	.long	_ASM_LABEL(x)
    235      1.13   thorpej 
    236      1.13   thorpej #define	VECTOR_UNUSED					\
    237      1.13   thorpej 	.long	0
    238      1.20    kleink 
    239      1.20    kleink #define	WEAK_ALIAS(alias,sym)						\
    240      1.20    kleink 	.weak alias;							\
    241      1.20    kleink 	alias = sym
    242      1.30      matt 
    243      1.24  christos /*
    244      1.24  christos  * STRONG_ALIAS: create a strong alias.
    245      1.24  christos  */
    246      1.24  christos #define STRONG_ALIAS(alias,sym)						\
    247      1.24  christos 	.globl alias;							\
    248      1.24  christos 	alias = sym
    249      1.16   thorpej 
    250      1.16   thorpej #ifdef __STDC__
    251      1.16   thorpej #define	WARN_REFERENCES(sym,msg)					\
    252      1.27     joerg 	.pushsection .gnu.warning. ## sym;				\
    253      1.27     joerg 	.ascii msg;							\
    254      1.27     joerg 	.popsection
    255      1.16   thorpej #else
    256      1.16   thorpej #define	WARN_REFERENCES(sym,msg)					\
    257      1.27     joerg 	.pushsection .gnu.warning./**/sym;				\
    258      1.27     joerg 	.ascii msg;							\
    259      1.27     joerg 	.popsection
    260      1.16   thorpej #endif /* __STDC__ */
    261      1.21  fredette 
    262      1.21  fredette /*
    263      1.21  fredette  * Macros to hide shortcomings in the 68010.
    264      1.21  fredette  */
    265      1.29      matt #ifdef __mc68010__
    266      1.21  fredette #define	EXTBL(reg)					\
    267      1.29      matt 	extw	reg		;			\
    268      1.29      matt 	extl	reg
    269      1.21  fredette #else	/* __mc68010__ */
    270      1.21  fredette #define	EXTBL(reg)					\
    271      1.29      matt 	extbl	reg
    272      1.21  fredette #endif	/* __mc68010__ */
    273       1.1    briggs 
    274      1.18    kleink #endif /* _M68K_ASM_H_ */
    275