asm.h revision 1.43 1 1.43 joerg /* $NetBSD: asm.h,v 1.43 2010/12/20 21:11:25 joerg Exp $ */
2 1.4 cgd
3 1.1 deraadt /*
4 1.2 glass * Copyright (c) 1992, 1993
5 1.2 glass * The Regents of the University of California. All rights reserved.
6 1.1 deraadt *
7 1.1 deraadt * This code is derived from software contributed to Berkeley by
8 1.1 deraadt * Ralph Campbell.
9 1.1 deraadt *
10 1.1 deraadt * Redistribution and use in source and binary forms, with or without
11 1.1 deraadt * modification, are permitted provided that the following conditions
12 1.1 deraadt * are met:
13 1.1 deraadt * 1. Redistributions of source code must retain the above copyright
14 1.1 deraadt * notice, this list of conditions and the following disclaimer.
15 1.1 deraadt * 2. Redistributions in binary form must reproduce the above copyright
16 1.1 deraadt * notice, this list of conditions and the following disclaimer in the
17 1.1 deraadt * documentation and/or other materials provided with the distribution.
18 1.35 agc * 3. Neither the name of the University nor the names of its contributors
19 1.1 deraadt * may be used to endorse or promote products derived from this software
20 1.1 deraadt * without specific prior written permission.
21 1.1 deraadt *
22 1.1 deraadt * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
23 1.1 deraadt * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24 1.1 deraadt * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 1.1 deraadt * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
26 1.1 deraadt * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27 1.1 deraadt * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28 1.1 deraadt * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29 1.1 deraadt * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 1.1 deraadt * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31 1.1 deraadt * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 1.1 deraadt * SUCH DAMAGE.
33 1.1 deraadt *
34 1.4 cgd * @(#)machAsmDefs.h 8.1 (Berkeley) 6/10/93
35 1.1 deraadt */
36 1.1 deraadt
37 1.1 deraadt /*
38 1.1 deraadt * machAsmDefs.h --
39 1.1 deraadt *
40 1.1 deraadt * Macros used when writing assembler programs.
41 1.1 deraadt *
42 1.1 deraadt * Copyright (C) 1989 Digital Equipment Corporation.
43 1.1 deraadt * Permission to use, copy, modify, and distribute this software and
44 1.1 deraadt * its documentation for any purpose and without fee is hereby granted,
45 1.1 deraadt * provided that the above copyright notice appears in all copies.
46 1.1 deraadt * Digital Equipment Corporation makes no representations about the
47 1.1 deraadt * suitability of this software for any purpose. It is provided "as is"
48 1.1 deraadt * without express or implied warranty.
49 1.1 deraadt *
50 1.1 deraadt * from: Header: /sprite/src/kernel/mach/ds3100.md/RCS/machAsmDefs.h,
51 1.2 glass * v 1.2 89/08/15 18:28:24 rab Exp SPRITE (DECWRL)
52 1.1 deraadt */
53 1.1 deraadt
54 1.8 jonathan #ifndef _MIPS_ASM_H
55 1.41 matt #define _MIPS_ASM_H
56 1.1 deraadt
57 1.30 simonb #include <machine/cdefs.h> /* for API selection */
58 1.21 soda #include <mips/regdef.h>
59 1.1 deraadt
60 1.1 deraadt /*
61 1.1 deraadt * Define -pg profile entry code.
62 1.23 castor * Must always be noreorder, must never use a macro instruction
63 1.23 castor * Final addiu to t9 must always equal the size of this _KERN_MCOUNT
64 1.1 deraadt */
65 1.41 matt #define _KERN_MCOUNT \
66 1.23 castor .set push; \
67 1.23 castor .set noreorder; \
68 1.23 castor .set noat; \
69 1.27 jeffs subu sp,sp,16; \
70 1.27 jeffs sw t9,12(sp); \
71 1.23 castor move AT,ra; \
72 1.23 castor lui t9,%hi(_mcount); \
73 1.23 castor addiu t9,t9,%lo(_mcount); \
74 1.23 castor jalr t9; \
75 1.27 jeffs nop; \
76 1.23 castor lw t9,4(sp); \
77 1.23 castor addiu sp,sp,8; \
78 1.28 jeffs addiu t9,t9,40; \
79 1.23 castor .set pop;
80 1.13 jonathan
81 1.11 jtc #ifdef GPROF
82 1.41 matt #define MCOUNT _KERN_MCOUNT
83 1.1 deraadt #else
84 1.1 deraadt #define MCOUNT
85 1.2 glass #endif
86 1.1 deraadt
87 1.7 mellon #ifdef __NO_LEADING_UNDERSCORES__
88 1.6 mycroft # define _C_LABEL(x) x
89 1.6 mycroft #else
90 1.6 mycroft # ifdef __STDC__
91 1.6 mycroft # define _C_LABEL(x) _ ## x
92 1.6 mycroft # else
93 1.6 mycroft # define _C_LABEL(x) _/**/x
94 1.6 mycroft # endif
95 1.6 mycroft #endif
96 1.14 thorpej
97 1.15 castor #ifdef USE_AENT
98 1.41 matt #define AENT(x) \
99 1.15 castor .aent x, 0
100 1.15 castor #else
101 1.41 matt #define AENT(x)
102 1.24 kleink #endif
103 1.24 kleink
104 1.31 simonb /*
105 1.31 simonb * WEAK_ALIAS: create a weak alias.
106 1.31 simonb */
107 1.24 kleink #define WEAK_ALIAS(alias,sym) \
108 1.24 kleink .weak alias; \
109 1.24 kleink alias = sym
110 1.37 christos /*
111 1.37 christos * STRONG_ALIAS: create a strong alias.
112 1.37 christos */
113 1.41 matt #define STRONG_ALIAS(alias,sym) \
114 1.37 christos .globl alias; \
115 1.37 christos alias = sym
116 1.15 castor
117 1.14 thorpej /*
118 1.33 simonb * WARN_REFERENCES: create a warning if the specified symbol is referenced.
119 1.14 thorpej */
120 1.14 thorpej #ifdef __STDC__
121 1.43 joerg #define WARN_REFERENCES(sym,msg) \
122 1.43 joerg .pushsection .gnu.warning. ## sym; \
123 1.43 joerg .ascii msg; \
124 1.43 joerg .popsection
125 1.43 joerg #else
126 1.43 joerg #define WARN_REFERENCES(sym,msg) \
127 1.43 joerg .pushsection .gnu.warning./**/sym; \
128 1.43 joerg .ascii msg; \
129 1.43 joerg .popsection
130 1.14 thorpej #endif /* __STDC__ */
131 1.6 mycroft
132 1.1 deraadt /*
133 1.15 castor * LEAF
134 1.15 castor * A leaf routine does
135 1.15 castor * - call no other function,
136 1.15 castor * - never use any register that callee-saved (S0-S8), and
137 1.15 castor * - not use any local stack storage.
138 1.15 castor */
139 1.41 matt #define LEAF(x) \
140 1.15 castor .globl _C_LABEL(x); \
141 1.15 castor .ent _C_LABEL(x), 0; \
142 1.15 castor _C_LABEL(x): ; \
143 1.15 castor .frame sp, 0, ra; \
144 1.1 deraadt MCOUNT
145 1.1 deraadt
146 1.1 deraadt /*
147 1.15 castor * LEAF_NOPROFILE
148 1.15 castor * No profilable leaf routine.
149 1.1 deraadt */
150 1.41 matt #define LEAF_NOPROFILE(x) \
151 1.15 castor .globl _C_LABEL(x); \
152 1.15 castor .ent _C_LABEL(x), 0; \
153 1.15 castor _C_LABEL(x): ; \
154 1.15 castor .frame sp, 0, ra
155 1.15 castor
156 1.15 castor /*
157 1.34 simonb * STATIC_LEAF
158 1.34 simonb * Declare a local leaf function.
159 1.34 simonb */
160 1.41 matt #define STATIC_LEAF(x) \
161 1.34 simonb .ent _C_LABEL(x), 0; \
162 1.34 simonb _C_LABEL(x): ; \
163 1.34 simonb .frame sp, 0, ra; \
164 1.34 simonb MCOUNT
165 1.34 simonb
166 1.34 simonb /*
167 1.15 castor * XLEAF
168 1.15 castor * declare alternate entry to leaf routine
169 1.15 castor */
170 1.41 matt #define XLEAF(x) \
171 1.15 castor .globl _C_LABEL(x); \
172 1.34 simonb AENT (_C_LABEL(x)); \
173 1.34 simonb _C_LABEL(x):
174 1.34 simonb
175 1.34 simonb /*
176 1.34 simonb * STATIC_XLEAF
177 1.34 simonb * declare alternate entry to a static leaf routine
178 1.34 simonb */
179 1.41 matt #define STATIC_XLEAF(x) \
180 1.20 soda AENT (_C_LABEL(x)); \
181 1.15 castor _C_LABEL(x):
182 1.15 castor
183 1.15 castor /*
184 1.15 castor * NESTED
185 1.15 castor * A function calls other functions and needs
186 1.15 castor * therefore stack space to save/restore registers.
187 1.15 castor */
188 1.41 matt #define NESTED(x, fsize, retpc) \
189 1.15 castor .globl _C_LABEL(x); \
190 1.15 castor .ent _C_LABEL(x), 0; \
191 1.15 castor _C_LABEL(x): ; \
192 1.15 castor .frame sp, fsize, retpc; \
193 1.15 castor MCOUNT
194 1.1 deraadt
195 1.1 deraadt /*
196 1.15 castor * NESTED_NOPROFILE(x)
197 1.15 castor * No profilable nested routine.
198 1.1 deraadt */
199 1.41 matt #define NESTED_NOPROFILE(x, fsize, retpc) \
200 1.15 castor .globl _C_LABEL(x); \
201 1.15 castor .ent _C_LABEL(x), 0; \
202 1.15 castor _C_LABEL(x): ; \
203 1.15 castor .frame sp, fsize, retpc
204 1.15 castor
205 1.15 castor /*
206 1.15 castor * XNESTED
207 1.15 castor * declare alternate entry point to nested routine.
208 1.15 castor */
209 1.41 matt #define XNESTED(x) \
210 1.15 castor .globl _C_LABEL(x); \
211 1.20 soda AENT (_C_LABEL(x)); \
212 1.6 mycroft _C_LABEL(x):
213 1.1 deraadt
214 1.1 deraadt /*
215 1.15 castor * END
216 1.15 castor * Mark end of a procedure.
217 1.1 deraadt */
218 1.41 matt #define END(x) \
219 1.41 matt .end _C_LABEL(x); \
220 1.41 matt .size _C_LABEL(x), . - _C_LABEL(x)
221 1.2 glass
222 1.2 glass /*
223 1.15 castor * IMPORT -- import external symbol
224 1.2 glass */
225 1.41 matt #define IMPORT(sym, size) \
226 1.20 soda .extern _C_LABEL(sym),size
227 1.1 deraadt
228 1.1 deraadt /*
229 1.15 castor * EXPORT -- export definition of symbol
230 1.1 deraadt */
231 1.41 matt #define EXPORT(x) \
232 1.15 castor .globl _C_LABEL(x); \
233 1.15 castor _C_LABEL(x):
234 1.1 deraadt
235 1.15 castor /*
236 1.17 jonathan * VECTOR
237 1.17 jonathan * exception vector entrypoint
238 1.20 soda * XXX: regmask should be used to generate .mask
239 1.17 jonathan */
240 1.41 matt #define VECTOR(x, regmask) \
241 1.17 jonathan .ent _C_LABEL(x),0; \
242 1.17 jonathan EXPORT(x); \
243 1.17 jonathan
244 1.19 soda #ifdef __STDC__
245 1.41 matt #define VECTOR_END(x) \
246 1.20 soda EXPORT(x ## End); \
247 1.20 soda END(x)
248 1.19 soda #else
249 1.41 matt #define VECTOR_END(x) \
250 1.20 soda EXPORT(x/**/End); \
251 1.20 soda END(x)
252 1.19 soda #endif
253 1.1 deraadt
254 1.1 deraadt /*
255 1.10 christos * Macros to panic and printf from assembly language.
256 1.1 deraadt */
257 1.41 matt #define PANIC(msg) \
258 1.41 matt PTR_LA a0, 9f; \
259 1.15 castor jal _C_LABEL(panic); \
260 1.26 cgd nop; \
261 1.1 deraadt MSG(msg)
262 1.1 deraadt
263 1.15 castor #define PRINTF(msg) \
264 1.41 matt PTR_LA a0, 9f; \
265 1.15 castor jal _C_LABEL(printf); \
266 1.26 cgd nop; \
267 1.1 deraadt MSG(msg)
268 1.1 deraadt
269 1.15 castor #define MSG(msg) \
270 1.15 castor .rdata; \
271 1.15 castor 9: .asciiz msg; \
272 1.1 deraadt .text
273 1.1 deraadt
274 1.41 matt #define ASMSTR(str) \
275 1.15 castor .asciiz str; \
276 1.12 jonathan .align 3
277 1.15 castor
278 1.41 matt #define RCSID(name) .pushsection ".ident"; .asciz name; .popsection
279 1.41 matt
280 1.15 castor /*
281 1.15 castor * XXX retain dialects XXX
282 1.15 castor */
283 1.41 matt #define ALEAF(x) XLEAF(x)
284 1.41 matt #define NLEAF(x) LEAF_NOPROFILE(x)
285 1.41 matt #define NON_LEAF(x, fsize, retpc) NESTED(x, fsize, retpc)
286 1.41 matt #define NNON_LEAF(x, fsize, retpc) NESTED_NOPROFILE(x, fsize, retpc)
287 1.41 matt
288 1.41 matt #if defined(__mips_o32)
289 1.41 matt #define SZREG 4
290 1.41 matt #else
291 1.41 matt #define SZREG 8
292 1.41 matt #endif
293 1.41 matt
294 1.41 matt #if defined(__mips_o32) || defined(__mips_o64)
295 1.41 matt #define ALSK 7 /* stack alignment */
296 1.41 matt #define ALMASK -7 /* stack alignment */
297 1.41 matt #define SZFPREG 4
298 1.41 matt #define FP_L lwc1
299 1.41 matt #define FP_S swc1
300 1.41 matt #else
301 1.41 matt #define ALSK 15 /* stack alignment */
302 1.41 matt #define ALMASK -15 /* stack alignment */
303 1.41 matt #define SZFPREG 8
304 1.41 matt #define FP_L ldc1
305 1.41 matt #define FP_S sdc1
306 1.41 matt #endif
307 1.15 castor
308 1.22 simonb /*
309 1.16 castor * standard callframe {
310 1.41 matt * register_t cf_pad[N]; o32/64 (N=0), n32 (N=1) n64 (N=1)
311 1.41 matt * register_t cf_args[4]; arg0 - arg3 (only on o32 and o64)
312 1.41 matt * register_t cf_gp; global pointer (only on n32 and n64)
313 1.16 castor * register_t cf_sp; frame pointer
314 1.16 castor * register_t cf_ra; return address
315 1.16 castor * };
316 1.16 castor */
317 1.41 matt #if defined(__mips_o32) || defined(__mips_o64)
318 1.41 matt #define CALLFRAME_SIZ (SZREG * (4 + 2))
319 1.41 matt #define CALLFRAME_S0 0
320 1.41 matt #elif defined(__mips_n32) || defined(__mips_n64)
321 1.41 matt #define CALLFRAME_SIZ (SZREG * 4)
322 1.41 matt #define CALLFRAME_S0 (CALLFRAME_SIZ - 4 * SZREG)
323 1.41 matt #endif
324 1.41 matt #ifndef _KERNEL
325 1.41 matt #define CALLFRAME_GP (CALLFRAME_SIZ - 3 * SZREG)
326 1.41 matt #endif
327 1.41 matt #define CALLFRAME_SP (CALLFRAME_SIZ - 2 * SZREG)
328 1.41 matt #define CALLFRAME_RA (CALLFRAME_SIZ - 1 * SZREG)
329 1.16 castor
330 1.15 castor /*
331 1.22 simonb * While it would be nice to be compatible with the SGI
332 1.15 castor * REG_L and REG_S macros, because they do not take parameters, it
333 1.15 castor * is impossible to use them with the _MIPS_SIM_ABIX32 model.
334 1.15 castor *
335 1.22 simonb * These macros hide the use of mips3 instructions from the
336 1.15 castor * assembler to prevent the assembler from generating 64-bit style
337 1.15 castor * ABI calls.
338 1.15 castor */
339 1.41 matt #if _MIPS_SZPTR == 32
340 1.41 matt #define PTR_ADD add
341 1.41 matt #define PTR_ADDI addi
342 1.41 matt #define PTR_ADDU addu
343 1.41 matt #define PTR_ADDIU addiu
344 1.41 matt #define PTR_SUB add
345 1.41 matt #define PTR_SUBI subi
346 1.41 matt #define PTR_SUBU subu
347 1.41 matt #define PTR_SUBIU subu
348 1.41 matt #define PTR_L lw
349 1.41 matt #define PTR_LA la
350 1.41 matt #define PTR_S sw
351 1.41 matt #define PTR_SLL sll
352 1.41 matt #define PTR_SLLV sllv
353 1.41 matt #define PTR_SRL srl
354 1.41 matt #define PTR_SRLV srlv
355 1.41 matt #define PTR_SRA sra
356 1.41 matt #define PTR_SRAV srav
357 1.41 matt #define PTR_LL ll
358 1.41 matt #define PTR_SC sc
359 1.41 matt #define PTR_WORD .word
360 1.41 matt #define PTR_SCALESHIFT 2
361 1.41 matt #else /* _MIPS_SZPTR == 64 */
362 1.41 matt #define PTR_ADD dadd
363 1.41 matt #define PTR_ADDI daddi
364 1.41 matt #define PTR_ADDU daddu
365 1.41 matt #define PTR_ADDIU daddiu
366 1.41 matt #define PTR_SUB dadd
367 1.41 matt #define PTR_SUBI dsubi
368 1.41 matt #define PTR_SUBU dsubu
369 1.41 matt #define PTR_SUBIU dsubu
370 1.41 matt #define PTR_L ld
371 1.41 matt #define PTR_LA dla
372 1.41 matt #define PTR_S sd
373 1.41 matt #define PTR_SLL dsll
374 1.41 matt #define PTR_SLLV dsllv
375 1.41 matt #define PTR_SRL dsrl
376 1.41 matt #define PTR_SRLV dsrlv
377 1.41 matt #define PTR_SRA dsra
378 1.41 matt #define PTR_SRAV dsrav
379 1.41 matt #define PTR_LL lld
380 1.41 matt #define PTR_SC scd
381 1.41 matt #define PTR_WORD .dword
382 1.41 matt #define PTR_SCALESHIFT 3
383 1.41 matt #endif /* _MIPS_SZPTR == 64 */
384 1.41 matt
385 1.41 matt #if _MIPS_SZINT == 32
386 1.41 matt #define INT_ADD add
387 1.41 matt #define INT_ADDI addi
388 1.41 matt #define INT_ADDU addu
389 1.41 matt #define INT_ADDIU addiu
390 1.41 matt #define INT_SUB add
391 1.41 matt #define INT_SUBI subi
392 1.41 matt #define INT_SUBU subu
393 1.41 matt #define INT_SUBIU subu
394 1.41 matt #define INT_L lw
395 1.41 matt #define INT_LA la
396 1.41 matt #define INT_S sw
397 1.41 matt #define INT_SLL sll
398 1.41 matt #define INT_SLLV sllv
399 1.41 matt #define INT_SRL srl
400 1.41 matt #define INT_SRLV srlv
401 1.41 matt #define INT_SRA sra
402 1.41 matt #define INT_SRAV srav
403 1.41 matt #define INT_LL ll
404 1.41 matt #define INT_SC sc
405 1.41 matt #define INT_WORD .word
406 1.41 matt #define INT_SCALESHIFT 2
407 1.41 matt #else
408 1.41 matt #define INT_ADD dadd
409 1.41 matt #define INT_ADDI daddi
410 1.41 matt #define INT_ADDU daddu
411 1.41 matt #define INT_ADDIU daddiu
412 1.41 matt #define INT_SUB dadd
413 1.41 matt #define INT_SUBI dsubi
414 1.41 matt #define INT_SUBU dsubu
415 1.41 matt #define INT_SUBIU dsubu
416 1.41 matt #define INT_L ld
417 1.41 matt #define INT_LA dla
418 1.41 matt #define INT_S sd
419 1.41 matt #define INT_SLL dsll
420 1.41 matt #define INT_SLLV dsllv
421 1.41 matt #define INT_SRL dsrl
422 1.41 matt #define INT_SRLV dsrlv
423 1.41 matt #define INT_SRA dsra
424 1.41 matt #define INT_SRAV dsrav
425 1.41 matt #define INT_LL lld
426 1.41 matt #define INT_SC scd
427 1.41 matt #define INT_WORD .dword
428 1.41 matt #define INT_SCALESHIFT 3
429 1.41 matt #endif
430 1.15 castor
431 1.41 matt #if _MIPS_SZLONG == 32
432 1.41 matt #define LONG_ADD add
433 1.41 matt #define LONG_ADDI addi
434 1.41 matt #define LONG_ADDU addu
435 1.41 matt #define LONG_ADDIU addiu
436 1.41 matt #define LONG_SUB add
437 1.41 matt #define LONG_SUBI subi
438 1.41 matt #define LONG_SUBU subu
439 1.41 matt #define LONG_SUBIU subu
440 1.41 matt #define LONG_L lw
441 1.41 matt #define LONG_LA la
442 1.41 matt #define LONG_S sw
443 1.41 matt #define LONG_SLL sll
444 1.41 matt #define LONG_SLLV sllv
445 1.41 matt #define LONG_SRL srl
446 1.41 matt #define LONG_SRLV srlv
447 1.41 matt #define LONG_SRA sra
448 1.41 matt #define LONG_SRAV srav
449 1.41 matt #define LONG_LL ll
450 1.41 matt #define LONG_SC sc
451 1.41 matt #define LONG_WORD .word
452 1.41 matt #define LONG_SCALESHIFT 2
453 1.41 matt #else
454 1.41 matt #define LONG_ADD dadd
455 1.41 matt #define LONG_ADDI daddi
456 1.41 matt #define LONG_ADDU daddu
457 1.41 matt #define LONG_ADDIU daddiu
458 1.41 matt #define LONG_SUB dadd
459 1.41 matt #define LONG_SUBI dsubi
460 1.41 matt #define LONG_SUBU dsubu
461 1.41 matt #define LONG_SUBIU dsubu
462 1.41 matt #define LONG_L ld
463 1.41 matt #define LONG_LA dla
464 1.41 matt #define LONG_S sd
465 1.41 matt #define LONG_SLL dsll
466 1.41 matt #define LONG_SLLV dsllv
467 1.41 matt #define LONG_SRL dsrl
468 1.41 matt #define LONG_SRLV dsrlv
469 1.41 matt #define LONG_SRA dsra
470 1.41 matt #define LONG_SRAV dsrav
471 1.41 matt #define LONG_LL lld
472 1.41 matt #define LONG_SC scd
473 1.41 matt #define LONG_WORD .dword
474 1.41 matt #define LONG_SCALESHIFT 3
475 1.41 matt #endif
476 1.41 matt
477 1.41 matt #if SZREG == 4
478 1.41 matt #define REG_L lw
479 1.41 matt #define REG_S sw
480 1.41 matt #define REG_LI li
481 1.41 matt #define REG_ADDU addu
482 1.41 matt #define REG_SLL sll
483 1.41 matt #define REG_SLLV sllv
484 1.41 matt #define REG_SRL srl
485 1.41 matt #define REG_SRLV srlv
486 1.41 matt #define REG_SRA sra
487 1.41 matt #define REG_SRAV srav
488 1.41 matt #define REG_LL ll
489 1.41 matt #define REG_SC sc
490 1.41 matt #define REG_SCALESHIFT 2
491 1.41 matt #else
492 1.41 matt #define REG_L ld
493 1.41 matt #define REG_S sd
494 1.41 matt #define REG_LI dli
495 1.41 matt #define REG_ADDU daddu
496 1.41 matt #define REG_SLL dsll
497 1.41 matt #define REG_SLLV dsllv
498 1.41 matt #define REG_SRL dsrl
499 1.41 matt #define REG_SRLV dsrlv
500 1.41 matt #define REG_SRA dsra
501 1.41 matt #define REG_SRAV dsrav
502 1.41 matt #define REG_LL lld
503 1.41 matt #define REG_SC scd
504 1.41 matt #define REG_SCALESHIFT 3
505 1.41 matt #endif
506 1.41 matt
507 1.41 matt #if _MIPS_ISA == _MIPS_ISA_MIPS1 || _MIPS_ISA == _MIPS_ISA_MIPS2 || \
508 1.41 matt _MIPS_ISA == _MIPS_ISA_MIPS32
509 1.41 matt #define MFC0 mfc0
510 1.41 matt #define MTC0 mtc0
511 1.41 matt #endif
512 1.41 matt #if _MIPS_ISA == _MIPS_ISA_MIPS3 || _MIPS_ISA == _MIPS_ISA_MIPS4 || \
513 1.41 matt _MIPS_ISA == _MIPS_ISA_MIPS64
514 1.41 matt #define MFC0 dmfc0
515 1.41 matt #define MTC0 dmtc0
516 1.41 matt #endif
517 1.41 matt
518 1.41 matt #if defined(__mips_o32) || defined(__mips_o64)
519 1.41 matt
520 1.41 matt #ifdef __ABICALLS__
521 1.41 matt #define CPRESTORE(r) .cprestore r
522 1.41 matt #define CPLOAD(r) .cpload r
523 1.41 matt #else
524 1.41 matt #define CPRESTORE(r) /* not needed */
525 1.41 matt #define CPLOAD(r) /* not needed */
526 1.41 matt #endif
527 1.41 matt
528 1.41 matt #define SETUP_GP \
529 1.41 matt .set push; \
530 1.41 matt .set noreorder; \
531 1.41 matt .cpload t9; \
532 1.41 matt .set pop
533 1.41 matt #define SETUP_GPX(r) \
534 1.41 matt .set push; \
535 1.41 matt .set noreorder; \
536 1.41 matt move r,ra; /* save old ra */ \
537 1.41 matt bal 7f; \
538 1.41 matt nop; \
539 1.41 matt 7: .cpload ra; \
540 1.41 matt move ra,r; \
541 1.41 matt .set pop
542 1.41 matt #define SETUP_GPX_L(r,lbl) \
543 1.41 matt .set push; \
544 1.41 matt .set noreorder; \
545 1.41 matt move r,ra; /* save old ra */ \
546 1.41 matt bal lbl; \
547 1.41 matt nop; \
548 1.41 matt lbl: .cpload ra; \
549 1.41 matt move ra,r; \
550 1.41 matt .set pop
551 1.41 matt #define SAVE_GP(x) .cprestore x
552 1.41 matt
553 1.41 matt #define SETUP_GP64(a,b) /* n32/n64 specific */
554 1.41 matt #define SETUP_GP64_R(a,b) /* n32/n64 specific */
555 1.41 matt #define SETUP_GPX64(a,b) /* n32/n64 specific */
556 1.41 matt #define SETUP_GPX64_L(a,b,c) /* n32/n64 specific */
557 1.41 matt #define RESTORE_GP64 /* n32/n64 specific */
558 1.41 matt #define USE_ALT_CP(a) /* n32/n64 specific */
559 1.41 matt #endif /* __mips_o32 || __mips_o64 */
560 1.41 matt
561 1.41 matt #if defined(__mips_o32) || defined(__mips_o64)
562 1.22 simonb #define REG_PROLOGUE .set push
563 1.16 castor #define REG_EPILOGUE .set pop
564 1.41 matt #endif
565 1.41 matt #if defined(__mips_n32) || defined(__mips_n64)
566 1.15 castor #define REG_PROLOGUE .set push ; .set mips3
567 1.15 castor #define REG_EPILOGUE .set pop
568 1.41 matt #endif
569 1.41 matt
570 1.41 matt #if defined(__mips_n32) || defined(__mips_n64)
571 1.41 matt #define SETUP_GP /* o32 specific */
572 1.41 matt #define SETUP_GPX(r) /* o32 specific */
573 1.41 matt #define SETUP_GPX_L(r,lbl) /* o32 specific */
574 1.41 matt #define SAVE_GP(x) /* o32 specific */
575 1.41 matt #define SETUP_GP64(a,b) .cpsetup $25, a, b
576 1.41 matt #define SETUP_GPX64(a,b) \
577 1.41 matt .set push; \
578 1.41 matt move b,ra; \
579 1.41 matt .set noreorder; \
580 1.41 matt bal 7f; \
581 1.41 matt nop; \
582 1.41 matt 7: .set pop; \
583 1.41 matt .cpsetup ra, a, 7b; \
584 1.41 matt move ra,b
585 1.41 matt #define SETUP_GPX64_L(a,b,c) \
586 1.41 matt .set push; \
587 1.41 matt move b,ra; \
588 1.41 matt .set noreorder; \
589 1.41 matt bal c; \
590 1.41 matt nop; \
591 1.41 matt c: .set pop; \
592 1.41 matt .cpsetup ra, a, c; \
593 1.41 matt move ra,b
594 1.41 matt #define RESTORE_GP64 .cpreturn
595 1.41 matt #define USE_ALT_CP(a) .cplocal a
596 1.41 matt #endif /* __mips_n32 || __mips_n64 */
597 1.25 jeffs
598 1.25 jeffs /*
599 1.25 jeffs * The DYNAMIC_STATUS_MASK option adds an additional masking operation
600 1.25 jeffs * when updating the hardware interrupt mask in the status register.
601 1.25 jeffs *
602 1.25 jeffs * This is useful for platforms that need to at run-time mask
603 1.25 jeffs * interrupts based on motherboard configuration or to handle
604 1.25 jeffs * slowly clearing interrupts.
605 1.25 jeffs *
606 1.25 jeffs * XXX this is only currently implemented for mips3.
607 1.25 jeffs */
608 1.25 jeffs #ifdef MIPS_DYNAMIC_STATUS_MASK
609 1.41 matt #define DYNAMIC_STATUS_MASK(sr,scratch) \
610 1.25 jeffs lw scratch, mips_dynamic_status_mask; \
611 1.25 jeffs and sr, sr, scratch
612 1.29 jeffs
613 1.41 matt #define DYNAMIC_STATUS_MASK_TOUSER(sr,scratch1) \
614 1.29 jeffs ori sr, (MIPS_INT_MASK | MIPS_SR_INT_IE); \
615 1.29 jeffs DYNAMIC_STATUS_MASK(sr,scratch1)
616 1.25 jeffs #else
617 1.41 matt #define DYNAMIC_STATUS_MASK(sr,scratch)
618 1.41 matt #define DYNAMIC_STATUS_MASK_TOUSER(sr,scratch1)
619 1.25 jeffs #endif
620 1.1 deraadt
621 1.38 ad /* See lock_stubs.S. */
622 1.42 chs #define MIPS_LOCK_RAS_SIZE 256
623 1.38 ad
624 1.41 matt #define CPUVAR(off) _C_LABEL(cpu_info_store)+__CONCAT(CPU_INFO_,off)
625 1.39 yamt
626 1.8 jonathan #endif /* _MIPS_ASM_H */
627