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