1 /* $NetBSD: asm.h,v 1.27 2009/11/26 00:19:20 matt Exp $ */
4 * Copyright (C) 1995, 1996 Wolfgang Solfrank.
5 * Copyright (C) 1995, 1996 TooLs GmbH.
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 * 3. All advertising materials mentioning features or use of this software
17 * must display the following acknowledgement:
18 * This product includes software developed by TooLs GmbH.
19 * 4. The name of TooLs GmbH may not be used to endorse or promote products
20 * derived from this software without specific prior written permission.
22 * THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``AS IS'' AND ANY EXPRESS OR
23 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
24 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
25 * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
27 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
28 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
29 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
30 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
31 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
39 /* ppc64 is always PIC, r2 is always the TOC */
46 #define PIC_PROLOGUE XXX
47 #define PIC_EPILOGUE XXX
48 #define PIC_PLT(x) x@plt
50 #define PIC_GOT(x) XXX
51 #define PIC_GOTOFF(x) XXX
52 #else /* not __STDC__ */
53 #define PIC_GOT(x) XXX
54 #define PIC_GOTOFF(x) XXX
61 #define PIC_GOTOFF(x) x
67 #define _ASM_LABEL(x) x
70 .data; .align 2; .globl x; x:
73 # define _PROF_PROLOGUE mflr 0; stw 0,4(1); bl _mcount
75 # define _PROF_PROLOGUE
80 #define SF_HEADER_SZ 48
81 #define SF_PARAM_SZ 64
82 #define SF_SZ (SF_HEADER_SZ + SF_PARAM_SZ)
87 #define SF_PARAM SF_HEADER_SZ
91 .section ".opd","aw"; \
93 y: .quad .y,.TOC.@tocbase,0; \
105 #define ENTRY_NOPROFILE(y) ENTRY(y)
106 #define ASENTRY(y) ENTRY(y)
110 .text; .align 2; .globl x; .type x,@function; x:
112 #define ENTRY(y) _ENTRY(_C_LABEL(y)); _PROF_PROLOGUE
114 #define ENTRY_NOPROFILE(y) _ENTRY(_C_LABEL(y))
119 #define ASENTRY(y) _ENTRY(_ASM_LABEL(y)); _PROF_PROLOGUE
122 #define GLOBAL(y) _GLOBAL(_C_LABEL(y))
124 #define ASMSTR .asciz
126 #define RCSID(x) .text; .asciz x
129 #define WEAK_ALIAS(alias,sym) \
134 * STRONG_ALIAS: create a strong alias.
136 #define STRONG_ALIAS(alias,sym) \
141 #define WARN_REFERENCES(_sym,_msg) \
142 .section .gnu.warning. ## _sym ; .ascii _msg ; .text
144 #define WARN_REFERENCES(_sym,_msg) \
145 .section .gnu.warning./**/_sym ; .ascii _msg ; .text
146 #endif /* __STDC__ */
150 * Get cpu_info pointer for current processor. Always in SPRG0. *ALWAYS*
152 #define GET_CPUINFO(r) mfsprg r,0
155 * R4[er] = first free byte beyond end/esym.
158 * R1[sp] = new kernel stack
162 #define INIT_CPUINFO(er,sp,tmp1,tmp2) \
165 andc er,er,tmp1; /* page align */ \
166 lis tmp1,_C_LABEL(cpu_info)@ha; \
167 addi tmp1,tmp1,_C_LABEL(cpu_info)@l; \
168 mtsprg0 tmp1; /* save for later use */ \
170 stptr er,CI_INTSTK(tmp1); \
171 lis tmp2,_C_LABEL(emptyidlespin)@h; \
172 ori tmp2,tmp2,_C_LABEL(emptyidlespin)@l; \
173 stptr tmp2,CI_IDLESPIN(tmp1); \
175 stint tmp2,CI_INTRDEPTH(tmp1); \
177 stptr tmp2,-CALLFRAMELEN(er); /* terminate idle stack chain */\
178 lis tmp1,_C_LABEL(lwp0)+L_PCB@ha; /* XXXuvm_lwp_getuarea */ \
179 stptr er,_C_LABEL(lwp0)+L_PCB@l(tmp1); \
180 addi er,er,USPACE; /* stackpointer for proc0 */ \
181 addi sp,er,-FRAMELEN; /* stackpointer for proc0 */ \
182 /* er = end of mem reserved for kernel */ \
183 stptru tmp2,-CALLFRAMELEN(sp) /* end of stack chain */
187 /* Condition Register Bit Fields */
189 #if !defined(_NOREGNAMES)
190 #if defined(_KERNEL) || defined(_STANDALONE)
201 /* General Purpose Registers (GPRs) */
203 #if defined(_KERNEL) || defined(_STANDALONE)
238 /* Floating Point Registers (FPRs) */
240 #if defined(_KERNEL) || defined(_STANDALONE)
274 #endif /* !_NOREGNAMES */
277 * Add some psuedo instructions to made sharing of assembly versions of
278 * ILP32 and LP64 code possible.
280 #define ldint lwz /* not needed but for completeness */
281 #define ldintu lwzu /* not needed but for completeness */
282 #define stint stw /* not needed but for completeness */
283 #define stintu stwu /* not needed but for completeness */
287 #define ldlong lwz /* load "C" long */
288 #define ldlongu lwzu /* load "C" long with udpate */
289 #define stlong stw /* load "C" long */
290 #define stlongu stwu /* load "C" long with udpate */
291 #define ldptr lwz /* load "C" pointer */
292 #define ldptru lwzu /* load "C" pointer with udpate */
293 #define stptr stw /* load "C" pointer */
294 #define stptru stwu /* load "C" pointer with udpate */
295 #define ldreg lwz /* load PPC general register */
296 #define ldregu lwzu /* load PPC general register with udpate */
297 #define streg stw /* load PPC general register */
298 #define stregu stwu /* load PPC general register with udpate */
299 #define SZREG 4 /* 4 byte registers */
301 #define lptrarx lwarx /* load "C" pointer with reservation */
302 #define llongarx lwarx /* load "C" long with reservation */
303 #define lregarx lwarx /* load PPC general register with reservation */
305 #define stptrcx stwcx /* store "C" pointer conditional */
306 #define stlongcx stwcx /* store "C" long conditional */
307 #define stregcx stwcx /* store PPC general register conditional */
309 #define clrrptri clrrwi /* clear right "C" pointer immediate */
310 #define clrrlongi clrrwi /* clear right "C" long immediate */
311 #define clrrregi clrrwi /* clear right PPC general register immediate */
315 #define ldlong ld /* load "C" long */
316 #define ldlongu ldu /* load "C" long with update */
317 #define stlong std /* store "C" long */
318 #define stlongu stdu /* store "C" long with update */
319 #define ldptr ld /* load "C" pointer */
320 #define ldptru ldu /* load "C" pointer with update */
321 #define stptr std /* store "C" pointer */
322 #define stptru stdu /* store "C" pointer with update */
323 #define ldreg ld /* load PPC general register */
324 #define ldregu ldu /* load PPC general register with update */
325 #define streg std /* store PPC general register */
326 #define stregu stdu /* store PPC general register with update */
327 /* redefined this to force an error on PPC64 to catch their use. */
328 #define lmw lmd /* load multiple PPC general registers */
329 #define stmw stmd /* store multiple PPC general registers */
330 #define SZREG 8 /* 8 byte registers */
332 #define lptrarx ldarx /* load "C" pointer with reservation */
333 #define llongarx ldarx /* load "C" long with reservation */
334 #define lregarx ldarx /* load PPC general register with reservation */
336 #define stptrcx stdcx /* store "C" pointer conditional */
337 #define stlongcx stdcx /* store "C" long conditional */
338 #define stregax stdcx /* store PPC general register conditional */
340 #define clrrptri clrrdi /* clear right "C" pointer immediate */
341 #define clrrlongi clrrdi /* clear right "C" long immediate */
342 #define clrrregi clrrdi /* clear right PPC general register immediate */
364 #endif /* !_PPC_ASM_H_ */