asm.h revision 1.14 1 1.14 thorpej /* $NetBSD: asm.h,v 1.14 1997/07/14 07:44:56 thorpej Exp $ */
2 1.9 cgd
3 1.1 briggs /*
4 1.13 thorpej * Copyright (c) 1997 Jason R. Thorpe. All rights reserved.
5 1.1 briggs * Copyright (c) 1994 Allen Briggs
6 1.1 briggs * All rights reserved.
7 1.1 briggs *
8 1.1 briggs * Gleaned from locore.s and sun3 asm.h which had the following copyrights:
9 1.1 briggs * locore.s:
10 1.1 briggs * Copyright (c) 1988 University of Utah.
11 1.1 briggs * Copyright (c) 1982, 1990 The Regents of the University of California.
12 1.1 briggs * sun3/include/asm.h:
13 1.1 briggs * Copyright (c) 1993 Adam Glass
14 1.1 briggs * Copyright (c) 1990 The Regents of the University of California.
15 1.1 briggs *
16 1.1 briggs * Redistribution and use in source and binary forms, with or without
17 1.1 briggs * modification, are permitted provided that the following conditions
18 1.1 briggs * are met:
19 1.1 briggs * 1. Redistributions of source code must retain the above copyright
20 1.1 briggs * notice, this list of conditions and the following disclaimer.
21 1.1 briggs * 2. Redistributions in binary form must reproduce the above copyright
22 1.1 briggs * notice, this list of conditions and the following disclaimer in the
23 1.1 briggs * documentation and/or other materials provided with the distribution.
24 1.1 briggs * 3. All advertising materials mentioning features or use of this software
25 1.1 briggs * must display the following acknowledgement:
26 1.1 briggs * This product includes software developed by the University of
27 1.1 briggs * California, Berkeley and its contributors.
28 1.1 briggs * 4. Neither the name of the University nor the names of its contributors
29 1.1 briggs * may be used to endorse or promote products derived from this software
30 1.1 briggs * without specific prior written permission.
31 1.1 briggs *
32 1.1 briggs * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
33 1.1 briggs * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
34 1.1 briggs * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
35 1.1 briggs * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
36 1.1 briggs * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
37 1.1 briggs * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
38 1.1 briggs * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
39 1.1 briggs * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
40 1.1 briggs * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
41 1.1 briggs * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
42 1.1 briggs * SUCH DAMAGE.
43 1.1 briggs */
44 1.1 briggs
45 1.1 briggs #ifndef _ASM_H_
46 1.1 briggs #define _ASM_H_
47 1.1 briggs
48 1.1 briggs #ifdef __STDC__
49 1.13 thorpej #define _C_LABEL(name) _ ## name
50 1.1 briggs #else
51 1.13 thorpej #define _C_LABEL(name) _/**/name
52 1.13 thorpej #endif /* __STDC__ */
53 1.13 thorpej
54 1.2 mycroft #define _ASM_LABEL(name) name
55 1.2 mycroft
56 1.2 mycroft #define _ENTRY(name) \
57 1.8 brezak .text; .even; .globl name; .type name,@function; name:
58 1.1 briggs
59 1.12 jtc #ifdef GPROF
60 1.11 jtc #define _PROF_PROLOG link a6,#0; jbsr mcount; unlk a6
61 1.11 jtc #else
62 1.11 jtc #define _PROF_PROLOG
63 1.11 jtc #endif
64 1.11 jtc
65 1.11 jtc #define ENTRY(name) _ENTRY(_C_LABEL(name)) _PROF_PROLOG
66 1.11 jtc #define ASENTRY(name) _ENTRY(_ASM_LABEL(name)) _PROF_PROLOG
67 1.11 jtc
68 1.13 thorpej #define ENTRY_NOPROFILE(name) _ENTRY(_C_LABEL(name))
69 1.13 thorpej #define ASENTRY_NOPROFILE(name) _ENTRY(_ASM_LABEL(name))
70 1.13 thorpej
71 1.11 jtc /*
72 1.11 jtc * The m68k ALTENTRY macro is very different than the traditional
73 1.11 jtc * implementation used by other NetBSD ports. Usually ALTENTRY
74 1.11 jtc * simply provides an alternate function entry point. The m68k
75 1.11 jtc * definition takes a second argument and jumps inside the second
76 1.11 jtc * function when profiling is enabled.
77 1.11 jtc *
78 1.11 jtc * The m68k behavior is similar to the ENTRY2 macro found in
79 1.11 jtc * solaris' asm_linkage.h.
80 1.11 jtc *
81 1.11 jtc * Providing ENTRY2 and changing all the code that uses ALTENTRY
82 1.11 jtc * to use it would be a desirable change.
83 1.11 jtc */
84 1.11 jtc #ifdef PROF
85 1.11 jtc #define ALTENTRY(name, rname) ENTRY(name); jra rname+12
86 1.1 briggs #else
87 1.2 mycroft #define ALTENTRY(name, rname) _ENTRY(_C_LABEL(name))
88 1.1 briggs #endif
89 1.8 brezak
90 1.13 thorpej #define RCSID(x) .text ; \
91 1.13 thorpej .asciz x ; \
92 1.13 thorpej .even
93 1.13 thorpej
94 1.13 thorpej /*
95 1.13 thorpej * Global variables of whatever sort.
96 1.13 thorpej */
97 1.13 thorpej #define GLOBAL(x) \
98 1.13 thorpej .globl _C_LABEL(x) ; \
99 1.13 thorpej _C_LABEL(x):
100 1.13 thorpej
101 1.13 thorpej #define ASGLOBAL(x) \
102 1.13 thorpej .globl _ASM_LABEL(x) ; \
103 1.13 thorpej _ASM_LABEL(x):
104 1.13 thorpej
105 1.13 thorpej /*
106 1.13 thorpej * ...and local variables.
107 1.13 thorpej */
108 1.13 thorpej #define LOCAL(x) \
109 1.13 thorpej _C_LABEL(x):
110 1.13 thorpej
111 1.13 thorpej #define ASLOCAL(x) \
112 1.13 thorpej _ASM_LABEL(x):
113 1.13 thorpej
114 1.13 thorpej /*
115 1.13 thorpej * Items in the BSS segment.
116 1.13 thorpej */
117 1.13 thorpej #define BSS(name, size) \
118 1.13 thorpej .comm _C_LABEL(name),size
119 1.13 thorpej
120 1.13 thorpej #define ASBSS(name, size) \
121 1.13 thorpej .comm _ASM_LABEL(name),size
122 1.13 thorpej
123 1.13 thorpej #ifdef _KERNEL
124 1.13 thorpej /*
125 1.13 thorpej * Shorthand for calling panic().
126 1.13 thorpej * Note the side-effect: it uses up the 9: label, so be careful!
127 1.13 thorpej */
128 1.13 thorpej #define PANIC(x) \
129 1.13 thorpej pea 9f ; \
130 1.13 thorpej jbsr _C_LABEL(panic) ; \
131 1.13 thorpej 9: .asciz x ; \
132 1.13 thorpej .even
133 1.13 thorpej
134 1.13 thorpej /*
135 1.13 thorpej * Shorthand for defining vectors for the vector table.
136 1.13 thorpej */
137 1.13 thorpej #define VECTOR(x) \
138 1.13 thorpej .long _C_LABEL(x)
139 1.13 thorpej
140 1.13 thorpej #define ASVECTOR(x) \
141 1.13 thorpej .long _ASM_LABEL(x)
142 1.13 thorpej
143 1.13 thorpej #define VECTOR_UNUSED \
144 1.13 thorpej .long 0
145 1.13 thorpej
146 1.13 thorpej #endif /* _KERNEL */
147 1.1 briggs
148 1.1 briggs #endif /* _ASM_H_ */
149