2 * include/asm-ppc/ppc_asm.h
4 * Definitions used by various bits of low-level assembly code on PowerPC.
6 * Copyright (C) 1995-1999 Gary Thomas, Paul Mackerras, Cort Dougan.
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * as published by the Free Software Foundation; either version
11 * 2 of the License, or (at your option) any later version.
14 #include <linux/config.h>
17 * Macros for storing registers into and loading registers from
20 #define SAVE_GPR(n, base) stw n,GPR0+4*(n)(base)
21 #define SAVE_2GPRS(n, base) SAVE_GPR(n, base); SAVE_GPR(n+1, base)
22 #define SAVE_4GPRS(n, base) SAVE_2GPRS(n, base); SAVE_2GPRS(n+2, base)
23 #define SAVE_8GPRS(n, base) SAVE_4GPRS(n, base); SAVE_4GPRS(n+4, base)
24 #define SAVE_10GPRS(n, base) SAVE_8GPRS(n, base); SAVE_2GPRS(n+8, base)
25 #define REST_GPR(n, base) lwz n,GPR0+4*(n)(base)
26 #define REST_2GPRS(n, base) REST_GPR(n, base); REST_GPR(n+1, base)
27 #define REST_4GPRS(n, base) REST_2GPRS(n, base); REST_2GPRS(n+2, base)
28 #define REST_8GPRS(n, base) REST_4GPRS(n, base); REST_4GPRS(n+4, base)
29 #define REST_10GPRS(n, base) REST_8GPRS(n, base); REST_2GPRS(n+8, base)
31 #define SAVE_NVGPRS(base) SAVE_GPR(13, base); SAVE_8GPRS(14, base); \
33 #define REST_NVGPRS(base) REST_GPR(13, base); REST_8GPRS(14, base); \
36 #define SAVE_FPR(n, base) stfd n,THREAD_FPR0+8*(n)(base)
37 #define SAVE_2FPRS(n, base) SAVE_FPR(n, base); SAVE_FPR(n+1, base)
38 #define SAVE_4FPRS(n, base) SAVE_2FPRS(n, base); SAVE_2FPRS(n+2, base)
39 #define SAVE_8FPRS(n, base) SAVE_4FPRS(n, base); SAVE_4FPRS(n+4, base)
40 #define SAVE_16FPRS(n, base) SAVE_8FPRS(n, base); SAVE_8FPRS(n+8, base)
41 #define SAVE_32FPRS(n, base) SAVE_16FPRS(n, base); SAVE_16FPRS(n+16, base)
42 #define REST_FPR(n, base) lfd n,THREAD_FPR0+8*(n)(base)
43 #define REST_2FPRS(n, base) REST_FPR(n, base); REST_FPR(n+1, base)
44 #define REST_4FPRS(n, base) REST_2FPRS(n, base); REST_2FPRS(n+2, base)
45 #define REST_8FPRS(n, base) REST_4FPRS(n, base); REST_4FPRS(n+4, base)
46 #define REST_16FPRS(n, base) REST_8FPRS(n, base); REST_8FPRS(n+8, base)
47 #define REST_32FPRS(n, base) REST_16FPRS(n, base); REST_16FPRS(n+16, base)
49 #define SAVE_VR(n,b,base) li b,THREAD_VR0+(16*(n)); stvx n,b,base
50 #define SAVE_2VR(n,b,base) SAVE_VR(n,b,base); SAVE_VR(n+1,b,base)
51 #define SAVE_4VR(n,b,base) SAVE_2VR(n,b,base); SAVE_2VR(n+2,b,base)
52 #define SAVE_8VR(n,b,base) SAVE_4VR(n,b,base); SAVE_4VR(n+4,b,base)
53 #define SAVE_16VR(n,b,base) SAVE_8VR(n,b,base); SAVE_8VR(n+8,b,base)
54 #define SAVE_32VR(n,b,base) SAVE_16VR(n,b,base); SAVE_16VR(n+16,b,base)
55 #define REST_VR(n,b,base) li b,THREAD_VR0+(16*(n)); lvx n,b,base
56 #define REST_2VR(n,b,base) REST_VR(n,b,base); REST_VR(n+1,b,base)
57 #define REST_4VR(n,b,base) REST_2VR(n,b,base); REST_2VR(n+2,b,base)
58 #define REST_8VR(n,b,base) REST_4VR(n,b,base); REST_4VR(n+4,b,base)
59 #define REST_16VR(n,b,base) REST_8VR(n,b,base); REST_8VR(n+8,b,base)
60 #define REST_32VR(n,b,base) REST_16VR(n,b,base); REST_16VR(n+16,b,base)
62 #define SAVE_EVR(n,s,base) evmergehi s,s,n; stw s,THREAD_EVR0+4*(n)(base)
63 #define SAVE_2EVR(n,s,base) SAVE_EVR(n,s,base); SAVE_EVR(n+1,s,base)
64 #define SAVE_4EVR(n,s,base) SAVE_2EVR(n,s,base); SAVE_2EVR(n+2,s,base)
65 #define SAVE_8EVR(n,s,base) SAVE_4EVR(n,s,base); SAVE_4EVR(n+4,s,base)
66 #define SAVE_16EVR(n,s,base) SAVE_8EVR(n,s,base); SAVE_8EVR(n+8,s,base)
67 #define SAVE_32EVR(n,s,base) SAVE_16EVR(n,s,base); SAVE_16EVR(n+16,s,base)
69 #define REST_EVR(n,s,base) lwz s,THREAD_EVR0+4*(n)(base); evmergelo n,s,n
70 #define REST_2EVR(n,s,base) REST_EVR(n,s,base); REST_EVR(n+1,s,base)
71 #define REST_4EVR(n,s,base) REST_2EVR(n,s,base); REST_2EVR(n+2,s,base)
72 #define REST_8EVR(n,s,base) REST_4EVR(n,s,base); REST_4EVR(n+4,s,base)
73 #define REST_16EVR(n,s,base) REST_8EVR(n,s,base); REST_8EVR(n+8,s,base)
74 #define REST_32EVR(n,s,base) REST_16EVR(n,s,base); REST_16EVR(n+16,s,base)
76 #ifdef CONFIG_PPC601_SYNC_FIX
81 END_FTR_SECTION_IFSET(CPU_FTR_601)
85 END_FTR_SECTION_IFSET(CPU_FTR_601)
89 END_FTR_SECTION_IFSET(CPU_FTR_601)
98 #else /* CONFIG_SMP */
99 /* tlbsync is not implemented on 601 */
104 END_FTR_SECTION_IFCLR(CPU_FTR_601)
108 * This instruction is not implemented on the PPC 603 or 601; however, on
109 * the 403GCX and 405GP tlbia IS defined and tlbie is not.
110 * All of these instructions exist in the 8xx, they have magical powers,
111 * and they must be used.
114 #if !defined(CONFIG_4xx) && !defined(CONFIG_8xx)
118 lis r4,KERNELBASE@h; \
125 #define tophys(rd,rs) \
128 #define tovirt(rd,rs) \
131 #else /* CONFIG_BOOKE */
133 * On APUS (Amiga PowerPC cpu upgrade board), we don't know the
134 * physical base address of RAM at compile time.
136 #define tophys(rd,rs) \
137 0: addis rd,rs,-KERNELBASE@h; \
138 .section ".vtop_fixup","aw"; \
143 #define tovirt(rd,rs) \
144 0: addis rd,rs,KERNELBASE@h; \
145 .section ".ptov_fixup","aw"; \
149 #endif /* CONFIG_BOOKE */
152 * On 64-bit cpus, we use the rfid instruction instead of rfi, but
153 * we then have to make sure we preserve the top 32 bits except for
154 * the 64-bit mode bit, which we clear.
156 #ifdef CONFIG_PPC64BRIDGE
157 #define FIX_SRR1(ra, rb) \
160 clrldi ra,ra,1; /* turn off 64-bit mode */ \
162 #define RFI .long 0x4c000024 /* rfid instruction */
163 #define MTMSRD(r) .long (0x7c000164 + ((r) << 21)) /* mtmsrd */
164 #define CLR_TOP32(r) rlwinm (r),(r),0,0,31 /* clear top 32 bits */
167 #define FIX_SRR1(ra, rb)
171 #define RFI rfi; b . /* Prevent prefetch past rfi */
173 #define MTMSRD(r) mtmsr r
175 #endif /* CONFIG_PPC64BRIDGE */
177 #define RFCI .long 0x4c000066 /* rfci instruction */
178 #define RFDI .long 0x4c00004e /* rfdi instruction */
179 #define RFMCI .long 0x4c00004c /* rfmci instruction */
181 #ifdef CONFIG_IBM405_ERR77
182 #define PPC405_ERR77(ra,rb) dcbt ra, rb;
183 #define PPC405_ERR77_SYNC sync;
185 #define PPC405_ERR77(ra,rb)
186 #define PPC405_ERR77_SYNC
189 #ifdef CONFIG_IBM440EP_ERR42
190 #define PPC440EP_ERR42 isync
192 #define PPC440EP_ERR42
195 /* The boring bits... */
197 /* Condition Register Bit Fields */
209 /* General Purpose Registers (GPRs) */
245 /* Floating Point Registers (FPRs) */
346 /* some stab codes */