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