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 #ifndef _PPC_ASM_PPC_H
15 #define _PPC_ASM_PPC_H
22 * Macros for storing registers into and loading registers from
25 #define SAVE_GPR(n, base) stw n,GPR0+4*(n)(base)
26 #define SAVE_2GPRS(n, base) SAVE_GPR(n, base); SAVE_GPR(n+1, base)
27 #define SAVE_4GPRS(n, base) SAVE_2GPRS(n, base); SAVE_2GPRS(n+2, base)
28 #define SAVE_8GPRS(n, base) SAVE_4GPRS(n, base); SAVE_4GPRS(n+4, base)
29 #define SAVE_10GPRS(n, base) SAVE_8GPRS(n, base); SAVE_2GPRS(n+8, base)
30 #define REST_GPR(n, base) lwz n,GPR0+4*(n)(base)
31 #define REST_2GPRS(n, base) REST_GPR(n, base); REST_GPR(n+1, base)
32 #define REST_4GPRS(n, base) REST_2GPRS(n, base); REST_2GPRS(n+2, base)
33 #define REST_8GPRS(n, base) REST_4GPRS(n, base); REST_4GPRS(n+4, base)
34 #define REST_10GPRS(n, base) REST_8GPRS(n, base); REST_2GPRS(n+8, base)
36 #define SAVE_NVGPRS(base) SAVE_GPR(13, base); SAVE_8GPRS(14, base); \
38 #define REST_NVGPRS(base) REST_GPR(13, base); REST_8GPRS(14, base); \
41 #define SAVE_FPR(n, base) stfd n,THREAD_FPR0+8*(n)(base)
42 #define SAVE_2FPRS(n, base) SAVE_FPR(n, base); SAVE_FPR(n+1, base)
43 #define SAVE_4FPRS(n, base) SAVE_2FPRS(n, base); SAVE_2FPRS(n+2, base)
44 #define SAVE_8FPRS(n, base) SAVE_4FPRS(n, base); SAVE_4FPRS(n+4, base)
45 #define SAVE_16FPRS(n, base) SAVE_8FPRS(n, base); SAVE_8FPRS(n+8, base)
46 #define SAVE_32FPRS(n, base) SAVE_16FPRS(n, base); SAVE_16FPRS(n+16, base)
47 #define REST_FPR(n, base) lfd n,THREAD_FPR0+8*(n)(base)
48 #define REST_2FPRS(n, base) REST_FPR(n, base); REST_FPR(n+1, base)
49 #define REST_4FPRS(n, base) REST_2FPRS(n, base); REST_2FPRS(n+2, base)
50 #define REST_8FPRS(n, base) REST_4FPRS(n, base); REST_4FPRS(n+4, base)
51 #define REST_16FPRS(n, base) REST_8FPRS(n, base); REST_8FPRS(n+8, base)
52 #define REST_32FPRS(n, base) REST_16FPRS(n, base); REST_16FPRS(n+16, base)
54 #define SAVE_VR(n,b,base) li b,THREAD_VR0+(16*(n)); stvx n,b,base
55 #define SAVE_2VR(n,b,base) SAVE_VR(n,b,base); SAVE_VR(n+1,b,base)
56 #define SAVE_4VR(n,b,base) SAVE_2VR(n,b,base); SAVE_2VR(n+2,b,base)
57 #define SAVE_8VR(n,b,base) SAVE_4VR(n,b,base); SAVE_4VR(n+4,b,base)
58 #define SAVE_16VR(n,b,base) SAVE_8VR(n,b,base); SAVE_8VR(n+8,b,base)
59 #define SAVE_32VR(n,b,base) SAVE_16VR(n,b,base); SAVE_16VR(n+16,b,base)
60 #define REST_VR(n,b,base) li b,THREAD_VR0+(16*(n)); lvx n,b,base
61 #define REST_2VR(n,b,base) REST_VR(n,b,base); REST_VR(n+1,b,base)
62 #define REST_4VR(n,b,base) REST_2VR(n,b,base); REST_2VR(n+2,b,base)
63 #define REST_8VR(n,b,base) REST_4VR(n,b,base); REST_4VR(n+4,b,base)
64 #define REST_16VR(n,b,base) REST_8VR(n,b,base); REST_8VR(n+8,b,base)
65 #define REST_32VR(n,b,base) REST_16VR(n,b,base); REST_16VR(n+16,b,base)
67 #define SAVE_EVR(n,s,base) evmergehi s,s,n; stw s,THREAD_EVR0+4*(n)(base)
68 #define SAVE_2EVR(n,s,base) SAVE_EVR(n,s,base); SAVE_EVR(n+1,s,base)
69 #define SAVE_4EVR(n,s,base) SAVE_2EVR(n,s,base); SAVE_2EVR(n+2,s,base)
70 #define SAVE_8EVR(n,s,base) SAVE_4EVR(n,s,base); SAVE_4EVR(n+4,s,base)
71 #define SAVE_16EVR(n,s,base) SAVE_8EVR(n,s,base); SAVE_8EVR(n+8,s,base)
72 #define SAVE_32EVR(n,s,base) SAVE_16EVR(n,s,base); SAVE_16EVR(n+16,s,base)
74 #define REST_EVR(n,s,base) lwz s,THREAD_EVR0+4*(n)(base); evmergelo n,s,n
75 #define REST_2EVR(n,s,base) REST_EVR(n,s,base); REST_EVR(n+1,s,base)
76 #define REST_4EVR(n,s,base) REST_2EVR(n,s,base); REST_2EVR(n+2,s,base)
77 #define REST_8EVR(n,s,base) REST_4EVR(n,s,base); REST_4EVR(n+4,s,base)
78 #define REST_16EVR(n,s,base) REST_8EVR(n,s,base); REST_8EVR(n+8,s,base)
79 #define REST_32EVR(n,s,base) REST_16EVR(n,s,base); REST_16EVR(n+16,s,base)
81 #ifdef CONFIG_PPC601_SYNC_FIX
86 END_FTR_SECTION_IFSET(CPU_FTR_601)
90 END_FTR_SECTION_IFSET(CPU_FTR_601)
94 END_FTR_SECTION_IFSET(CPU_FTR_601)
103 #else /* CONFIG_SMP */
104 /* tlbsync is not implemented on 601 */
109 END_FTR_SECTION_IFCLR(CPU_FTR_601)
113 * This instruction is not implemented on the PPC 603 or 601; however, on
114 * the 403GCX and 405GP tlbia IS defined and tlbie is not.
115 * All of these instructions exist in the 8xx, they have magical powers,
116 * and they must be used.
119 #if !defined(CONFIG_4xx) && !defined(CONFIG_8xx)
123 lis r4,KERNELBASE@h; \
130 #define tophys(rd,rs) \
133 #define tovirt(rd,rs) \
136 #else /* CONFIG_BOOKE */
138 * On APUS (Amiga PowerPC cpu upgrade board), we don't know the
139 * physical base address of RAM at compile time.
141 #define tophys(rd,rs) \
142 0: addis rd,rs,-KERNELBASE@h; \
143 .section ".vtop_fixup","aw"; \
148 #define tovirt(rd,rs) \
149 0: addis rd,rs,KERNELBASE@h; \
150 .section ".ptov_fixup","aw"; \
154 #endif /* CONFIG_BOOKE */
157 * On 64-bit cpus, we use the rfid instruction instead of rfi, but
158 * we then have to make sure we preserve the top 32 bits except for
159 * the 64-bit mode bit, which we clear.
161 #ifdef CONFIG_PPC64BRIDGE
162 #define FIX_SRR1(ra, rb) \
165 clrldi ra,ra,1; /* turn off 64-bit mode */ \
167 #define RFI .long 0x4c000024 /* rfid instruction */
168 #define MTMSRD(r) .long (0x7c000164 + ((r) << 21)) /* mtmsrd */
169 #define CLR_TOP32(r) rlwinm (r),(r),0,0,31 /* clear top 32 bits */
172 #define FIX_SRR1(ra, rb)
176 #define RFI rfi; b . /* Prevent prefetch past rfi */
178 #define MTMSRD(r) mtmsr r
180 #endif /* CONFIG_PPC64BRIDGE */
182 #define RFCI .long 0x4c000066 /* rfci instruction */
183 #define RFDI .long 0x4c00004e /* rfdi instruction */
184 #define RFMCI .long 0x4c00004c /* rfmci instruction */
186 #ifdef CONFIG_IBM405_ERR77
187 #define PPC405_ERR77(ra,rb) dcbt ra, rb;
188 #define PPC405_ERR77_SYNC sync;
190 #define PPC405_ERR77(ra,rb)
191 #define PPC405_ERR77_SYNC
194 /* The boring bits... */
196 /* Condition Register Bit Fields */
208 /* General Purpose Registers (GPRs) */
244 /* Floating Point Registers (FPRs) */
345 /* some stab codes */
352 } /* end of extern "C" */
355 #endif //_PPC_ASM_PPC_H
This page took 0.036341 seconds and 4 git commands to generate.