Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2 | * Copyright (C) 1995-1999 Gary Thomas, Paul Mackerras, Cort Dougan. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3 | */ |
Kumar Gala | 5f7c690 | 2005-09-09 15:02:25 -0500 | [diff] [blame] | 4 | #ifndef _ASM_POWERPC_PPC_ASM_H |
| 5 | #define _ASM_POWERPC_PPC_ASM_H |
| 6 | |
Paul Mackerras | 40ef8cb | 2005-10-10 22:50:37 +1000 | [diff] [blame] | 7 | #include <linux/stringify.h> |
David Gibson | 3ddfbcf | 2005-11-10 12:56:55 +1100 | [diff] [blame] | 8 | #include <asm/asm-compat.h> |
Michael Neuling | 9c75a31 | 2008-06-26 17:07:48 +1000 | [diff] [blame^] | 9 | #include <asm/processor.h> |
Paul Mackerras | 40ef8cb | 2005-10-10 22:50:37 +1000 | [diff] [blame] | 10 | |
David Gibson | 3ddfbcf | 2005-11-10 12:56:55 +1100 | [diff] [blame] | 11 | #ifndef __ASSEMBLY__ |
| 12 | #error __FILE__ should only be used in assembler files |
| 13 | #else |
| 14 | |
| 15 | #define SZL (BITS_PER_LONG/8) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 16 | |
| 17 | /* |
Paul Mackerras | c6622f6 | 2006-02-24 10:06:59 +1100 | [diff] [blame] | 18 | * Stuff for accurate CPU time accounting. |
| 19 | * These macros handle transitions between user and system state |
| 20 | * in exception entry and exit and accumulate time to the |
| 21 | * user_time and system_time fields in the paca. |
| 22 | */ |
| 23 | |
| 24 | #ifndef CONFIG_VIRT_CPU_ACCOUNTING |
| 25 | #define ACCOUNT_CPU_USER_ENTRY(ra, rb) |
| 26 | #define ACCOUNT_CPU_USER_EXIT(ra, rb) |
| 27 | #else |
| 28 | #define ACCOUNT_CPU_USER_ENTRY(ra, rb) \ |
| 29 | beq 2f; /* if from kernel mode */ \ |
| 30 | BEGIN_FTR_SECTION; \ |
| 31 | mfspr ra,SPRN_PURR; /* get processor util. reg */ \ |
| 32 | END_FTR_SECTION_IFSET(CPU_FTR_PURR); \ |
| 33 | BEGIN_FTR_SECTION; \ |
Benjamin Herrenschmidt | 859deea | 2006-10-20 14:37:05 +1000 | [diff] [blame] | 34 | MFTB(ra); /* or get TB if no PURR */ \ |
Paul Mackerras | c6622f6 | 2006-02-24 10:06:59 +1100 | [diff] [blame] | 35 | END_FTR_SECTION_IFCLR(CPU_FTR_PURR); \ |
Benjamin Herrenschmidt | 859deea | 2006-10-20 14:37:05 +1000 | [diff] [blame] | 36 | ld rb,PACA_STARTPURR(r13); \ |
Paul Mackerras | c6622f6 | 2006-02-24 10:06:59 +1100 | [diff] [blame] | 37 | std ra,PACA_STARTPURR(r13); \ |
| 38 | subf rb,rb,ra; /* subtract start value */ \ |
| 39 | ld ra,PACA_USER_TIME(r13); \ |
| 40 | add ra,ra,rb; /* add on to user time */ \ |
| 41 | std ra,PACA_USER_TIME(r13); \ |
| 42 | 2: |
| 43 | |
| 44 | #define ACCOUNT_CPU_USER_EXIT(ra, rb) \ |
| 45 | BEGIN_FTR_SECTION; \ |
| 46 | mfspr ra,SPRN_PURR; /* get processor util. reg */ \ |
| 47 | END_FTR_SECTION_IFSET(CPU_FTR_PURR); \ |
| 48 | BEGIN_FTR_SECTION; \ |
Benjamin Herrenschmidt | 859deea | 2006-10-20 14:37:05 +1000 | [diff] [blame] | 49 | MFTB(ra); /* or get TB if no PURR */ \ |
Paul Mackerras | c6622f6 | 2006-02-24 10:06:59 +1100 | [diff] [blame] | 50 | END_FTR_SECTION_IFCLR(CPU_FTR_PURR); \ |
Benjamin Herrenschmidt | 859deea | 2006-10-20 14:37:05 +1000 | [diff] [blame] | 51 | ld rb,PACA_STARTPURR(r13); \ |
Paul Mackerras | c6622f6 | 2006-02-24 10:06:59 +1100 | [diff] [blame] | 52 | std ra,PACA_STARTPURR(r13); \ |
| 53 | subf rb,rb,ra; /* subtract start value */ \ |
| 54 | ld ra,PACA_SYSTEM_TIME(r13); \ |
| 55 | add ra,ra,rb; /* add on to user time */ \ |
| 56 | std ra,PACA_SYSTEM_TIME(r13); |
| 57 | #endif |
| 58 | |
| 59 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 60 | * Macros for storing registers into and loading registers from |
| 61 | * exception frames. |
| 62 | */ |
Kumar Gala | 5f7c690 | 2005-09-09 15:02:25 -0500 | [diff] [blame] | 63 | #ifdef __powerpc64__ |
| 64 | #define SAVE_GPR(n, base) std n,GPR0+8*(n)(base) |
| 65 | #define REST_GPR(n, base) ld n,GPR0+8*(n)(base) |
| 66 | #define SAVE_NVGPRS(base) SAVE_8GPRS(14, base); SAVE_10GPRS(22, base) |
| 67 | #define REST_NVGPRS(base) REST_8GPRS(14, base); REST_10GPRS(22, base) |
| 68 | #else |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 69 | #define SAVE_GPR(n, base) stw n,GPR0+4*(n)(base) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 70 | #define REST_GPR(n, base) lwz n,GPR0+4*(n)(base) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 71 | #define SAVE_NVGPRS(base) SAVE_GPR(13, base); SAVE_8GPRS(14, base); \ |
| 72 | SAVE_10GPRS(22, base) |
| 73 | #define REST_NVGPRS(base) REST_GPR(13, base); REST_8GPRS(14, base); \ |
| 74 | REST_10GPRS(22, base) |
Kumar Gala | 5f7c690 | 2005-09-09 15:02:25 -0500 | [diff] [blame] | 75 | #endif |
| 76 | |
| 77 | |
| 78 | #define SAVE_2GPRS(n, base) SAVE_GPR(n, base); SAVE_GPR(n+1, base) |
| 79 | #define SAVE_4GPRS(n, base) SAVE_2GPRS(n, base); SAVE_2GPRS(n+2, base) |
| 80 | #define SAVE_8GPRS(n, base) SAVE_4GPRS(n, base); SAVE_4GPRS(n+4, base) |
| 81 | #define SAVE_10GPRS(n, base) SAVE_8GPRS(n, base); SAVE_2GPRS(n+8, base) |
| 82 | #define REST_2GPRS(n, base) REST_GPR(n, base); REST_GPR(n+1, base) |
| 83 | #define REST_4GPRS(n, base) REST_2GPRS(n, base); REST_2GPRS(n+2, base) |
| 84 | #define REST_8GPRS(n, base) REST_4GPRS(n, base); REST_4GPRS(n+4, base) |
| 85 | #define REST_10GPRS(n, base) REST_8GPRS(n, base); REST_2GPRS(n+8, base) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 86 | |
Michael Neuling | 9c75a31 | 2008-06-26 17:07:48 +1000 | [diff] [blame^] | 87 | #define SAVE_FPR(n, base) stfd n,THREAD_FPR0+8*TS_FPRWIDTH*(n)(base) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 88 | #define SAVE_2FPRS(n, base) SAVE_FPR(n, base); SAVE_FPR(n+1, base) |
| 89 | #define SAVE_4FPRS(n, base) SAVE_2FPRS(n, base); SAVE_2FPRS(n+2, base) |
| 90 | #define SAVE_8FPRS(n, base) SAVE_4FPRS(n, base); SAVE_4FPRS(n+4, base) |
| 91 | #define SAVE_16FPRS(n, base) SAVE_8FPRS(n, base); SAVE_8FPRS(n+8, base) |
| 92 | #define SAVE_32FPRS(n, base) SAVE_16FPRS(n, base); SAVE_16FPRS(n+16, base) |
Michael Neuling | 9c75a31 | 2008-06-26 17:07:48 +1000 | [diff] [blame^] | 93 | #define REST_FPR(n, base) lfd n,THREAD_FPR0+8*TS_FPRWIDTH*(n)(base) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 94 | #define REST_2FPRS(n, base) REST_FPR(n, base); REST_FPR(n+1, base) |
| 95 | #define REST_4FPRS(n, base) REST_2FPRS(n, base); REST_2FPRS(n+2, base) |
| 96 | #define REST_8FPRS(n, base) REST_4FPRS(n, base); REST_4FPRS(n+4, base) |
| 97 | #define REST_16FPRS(n, base) REST_8FPRS(n, base); REST_8FPRS(n+8, base) |
| 98 | #define REST_32FPRS(n, base) REST_16FPRS(n, base); REST_16FPRS(n+16, base) |
| 99 | |
| 100 | #define SAVE_VR(n,b,base) li b,THREAD_VR0+(16*(n)); stvx n,b,base |
Kumar Gala | 5f7c690 | 2005-09-09 15:02:25 -0500 | [diff] [blame] | 101 | #define SAVE_2VRS(n,b,base) SAVE_VR(n,b,base); SAVE_VR(n+1,b,base) |
| 102 | #define SAVE_4VRS(n,b,base) SAVE_2VRS(n,b,base); SAVE_2VRS(n+2,b,base) |
| 103 | #define SAVE_8VRS(n,b,base) SAVE_4VRS(n,b,base); SAVE_4VRS(n+4,b,base) |
| 104 | #define SAVE_16VRS(n,b,base) SAVE_8VRS(n,b,base); SAVE_8VRS(n+8,b,base) |
| 105 | #define SAVE_32VRS(n,b,base) SAVE_16VRS(n,b,base); SAVE_16VRS(n+16,b,base) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 106 | #define REST_VR(n,b,base) li b,THREAD_VR0+(16*(n)); lvx n,b,base |
Kumar Gala | 5f7c690 | 2005-09-09 15:02:25 -0500 | [diff] [blame] | 107 | #define REST_2VRS(n,b,base) REST_VR(n,b,base); REST_VR(n+1,b,base) |
| 108 | #define REST_4VRS(n,b,base) REST_2VRS(n,b,base); REST_2VRS(n+2,b,base) |
| 109 | #define REST_8VRS(n,b,base) REST_4VRS(n,b,base); REST_4VRS(n+4,b,base) |
| 110 | #define REST_16VRS(n,b,base) REST_8VRS(n,b,base); REST_8VRS(n+8,b,base) |
| 111 | #define REST_32VRS(n,b,base) REST_16VRS(n,b,base); REST_16VRS(n+16,b,base) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 112 | |
| 113 | #define SAVE_EVR(n,s,base) evmergehi s,s,n; stw s,THREAD_EVR0+4*(n)(base) |
Kumar Gala | 5f7c690 | 2005-09-09 15:02:25 -0500 | [diff] [blame] | 114 | #define SAVE_2EVRS(n,s,base) SAVE_EVR(n,s,base); SAVE_EVR(n+1,s,base) |
| 115 | #define SAVE_4EVRS(n,s,base) SAVE_2EVRS(n,s,base); SAVE_2EVRS(n+2,s,base) |
| 116 | #define SAVE_8EVRS(n,s,base) SAVE_4EVRS(n,s,base); SAVE_4EVRS(n+4,s,base) |
| 117 | #define SAVE_16EVRS(n,s,base) SAVE_8EVRS(n,s,base); SAVE_8EVRS(n+8,s,base) |
| 118 | #define SAVE_32EVRS(n,s,base) SAVE_16EVRS(n,s,base); SAVE_16EVRS(n+16,s,base) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 119 | #define REST_EVR(n,s,base) lwz s,THREAD_EVR0+4*(n)(base); evmergelo n,s,n |
Kumar Gala | 5f7c690 | 2005-09-09 15:02:25 -0500 | [diff] [blame] | 120 | #define REST_2EVRS(n,s,base) REST_EVR(n,s,base); REST_EVR(n+1,s,base) |
| 121 | #define REST_4EVRS(n,s,base) REST_2EVRS(n,s,base); REST_2EVRS(n+2,s,base) |
| 122 | #define REST_8EVRS(n,s,base) REST_4EVRS(n,s,base); REST_4EVRS(n+4,s,base) |
| 123 | #define REST_16EVRS(n,s,base) REST_8EVRS(n,s,base); REST_8EVRS(n+8,s,base) |
| 124 | #define REST_32EVRS(n,s,base) REST_16EVRS(n,s,base); REST_16EVRS(n+16,s,base) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 125 | |
Michael Ellerman | 8c71632 | 2005-10-24 15:07:27 +1000 | [diff] [blame] | 126 | /* Macros to adjust thread priority for hardware multithreading */ |
| 127 | #define HMT_VERY_LOW or 31,31,31 # very low priority |
| 128 | #define HMT_LOW or 1,1,1 |
| 129 | #define HMT_MEDIUM_LOW or 6,6,6 # medium low priority |
| 130 | #define HMT_MEDIUM or 2,2,2 |
| 131 | #define HMT_MEDIUM_HIGH or 5,5,5 # medium high priority |
| 132 | #define HMT_HIGH or 3,3,3 |
Kumar Gala | 5f7c690 | 2005-09-09 15:02:25 -0500 | [diff] [blame] | 133 | |
| 134 | /* handle instructions that older assemblers may not know */ |
| 135 | #define RFCI .long 0x4c000066 /* rfci instruction */ |
| 136 | #define RFDI .long 0x4c00004e /* rfdi instruction */ |
| 137 | #define RFMCI .long 0x4c00004c /* rfmci instruction */ |
| 138 | |
Arnd Bergmann | 88ced03 | 2005-12-16 22:43:46 +0100 | [diff] [blame] | 139 | #ifdef __KERNEL__ |
Paul Mackerras | 40ef8cb | 2005-10-10 22:50:37 +1000 | [diff] [blame] | 140 | #ifdef CONFIG_PPC64 |
| 141 | |
| 142 | #define XGLUE(a,b) a##b |
| 143 | #define GLUE(a,b) XGLUE(a,b) |
| 144 | |
| 145 | #define _GLOBAL(name) \ |
| 146 | .section ".text"; \ |
| 147 | .align 2 ; \ |
| 148 | .globl name; \ |
| 149 | .globl GLUE(.,name); \ |
| 150 | .section ".opd","aw"; \ |
| 151 | name: \ |
| 152 | .quad GLUE(.,name); \ |
| 153 | .quad .TOC.@tocbase; \ |
| 154 | .quad 0; \ |
| 155 | .previous; \ |
| 156 | .type GLUE(.,name),@function; \ |
| 157 | GLUE(.,name): |
| 158 | |
Stephen Rothwell | fc68e86 | 2007-08-22 13:44:58 +1000 | [diff] [blame] | 159 | #define _INIT_GLOBAL(name) \ |
| 160 | .section ".text.init.refok"; \ |
| 161 | .align 2 ; \ |
| 162 | .globl name; \ |
| 163 | .globl GLUE(.,name); \ |
| 164 | .section ".opd","aw"; \ |
| 165 | name: \ |
| 166 | .quad GLUE(.,name); \ |
| 167 | .quad .TOC.@tocbase; \ |
| 168 | .quad 0; \ |
| 169 | .previous; \ |
| 170 | .type GLUE(.,name),@function; \ |
| 171 | GLUE(.,name): |
| 172 | |
Paul Mackerras | 40ef8cb | 2005-10-10 22:50:37 +1000 | [diff] [blame] | 173 | #define _KPROBE(name) \ |
| 174 | .section ".kprobes.text","a"; \ |
| 175 | .align 2 ; \ |
| 176 | .globl name; \ |
| 177 | .globl GLUE(.,name); \ |
| 178 | .section ".opd","aw"; \ |
| 179 | name: \ |
| 180 | .quad GLUE(.,name); \ |
| 181 | .quad .TOC.@tocbase; \ |
| 182 | .quad 0; \ |
| 183 | .previous; \ |
| 184 | .type GLUE(.,name),@function; \ |
| 185 | GLUE(.,name): |
| 186 | |
| 187 | #define _STATIC(name) \ |
| 188 | .section ".text"; \ |
| 189 | .align 2 ; \ |
| 190 | .section ".opd","aw"; \ |
| 191 | name: \ |
| 192 | .quad GLUE(.,name); \ |
| 193 | .quad .TOC.@tocbase; \ |
| 194 | .quad 0; \ |
| 195 | .previous; \ |
| 196 | .type GLUE(.,name),@function; \ |
| 197 | GLUE(.,name): |
| 198 | |
Stephen Rothwell | c40b91b | 2007-07-25 09:27:35 +1000 | [diff] [blame] | 199 | #define _INIT_STATIC(name) \ |
| 200 | .section ".text.init.refok"; \ |
| 201 | .align 2 ; \ |
| 202 | .section ".opd","aw"; \ |
| 203 | name: \ |
| 204 | .quad GLUE(.,name); \ |
| 205 | .quad .TOC.@tocbase; \ |
| 206 | .quad 0; \ |
| 207 | .previous; \ |
| 208 | .type GLUE(.,name),@function; \ |
| 209 | GLUE(.,name): |
| 210 | |
Paul Mackerras | 40ef8cb | 2005-10-10 22:50:37 +1000 | [diff] [blame] | 211 | #else /* 32-bit */ |
| 212 | |
Kumar Gala | 748a768 | 2007-09-13 15:42:35 -0500 | [diff] [blame] | 213 | #define _ENTRY(n) \ |
| 214 | .globl n; \ |
| 215 | n: |
| 216 | |
Paul Mackerras | 40ef8cb | 2005-10-10 22:50:37 +1000 | [diff] [blame] | 217 | #define _GLOBAL(n) \ |
| 218 | .text; \ |
| 219 | .stabs __stringify(n:F-1),N_FUN,0,0,n;\ |
| 220 | .globl n; \ |
| 221 | n: |
| 222 | |
| 223 | #define _KPROBE(n) \ |
| 224 | .section ".kprobes.text","a"; \ |
| 225 | .globl n; \ |
| 226 | n: |
| 227 | |
| 228 | #endif |
| 229 | |
Kumar Gala | 5f7c690 | 2005-09-09 15:02:25 -0500 | [diff] [blame] | 230 | /* |
David Gibson | e58c349 | 2006-01-13 14:56:25 +1100 | [diff] [blame] | 231 | * LOAD_REG_IMMEDIATE(rn, expr) |
| 232 | * Loads the value of the constant expression 'expr' into register 'rn' |
| 233 | * using immediate instructions only. Use this when it's important not |
| 234 | * to reference other data (i.e. on ppc64 when the TOC pointer is not |
| 235 | * valid). |
Kumar Gala | 5f7c690 | 2005-09-09 15:02:25 -0500 | [diff] [blame] | 236 | * |
David Gibson | e58c349 | 2006-01-13 14:56:25 +1100 | [diff] [blame] | 237 | * LOAD_REG_ADDR(rn, name) |
| 238 | * Loads the address of label 'name' into register 'rn'. Use this when |
| 239 | * you don't particularly need immediate instructions only, but you need |
| 240 | * the whole address in one register (e.g. it's a structure address and |
| 241 | * you want to access various offsets within it). On ppc32 this is |
| 242 | * identical to LOAD_REG_IMMEDIATE. |
| 243 | * |
| 244 | * LOAD_REG_ADDRBASE(rn, name) |
| 245 | * ADDROFF(name) |
| 246 | * LOAD_REG_ADDRBASE loads part of the address of label 'name' into |
| 247 | * register 'rn'. ADDROFF(name) returns the remainder of the address as |
| 248 | * a constant expression. ADDROFF(name) is a signed expression < 16 bits |
| 249 | * in size, so is suitable for use directly as an offset in load and store |
| 250 | * instructions. Use this when loading/storing a single word or less as: |
| 251 | * LOAD_REG_ADDRBASE(rX, name) |
| 252 | * ld rY,ADDROFF(name)(rX) |
Kumar Gala | 5f7c690 | 2005-09-09 15:02:25 -0500 | [diff] [blame] | 253 | */ |
| 254 | #ifdef __powerpc64__ |
David Gibson | e58c349 | 2006-01-13 14:56:25 +1100 | [diff] [blame] | 255 | #define LOAD_REG_IMMEDIATE(reg,expr) \ |
| 256 | lis (reg),(expr)@highest; \ |
| 257 | ori (reg),(reg),(expr)@higher; \ |
| 258 | rldicr (reg),(reg),32,31; \ |
| 259 | oris (reg),(reg),(expr)@h; \ |
| 260 | ori (reg),(reg),(expr)@l; |
Kumar Gala | 5f7c690 | 2005-09-09 15:02:25 -0500 | [diff] [blame] | 261 | |
David Gibson | e58c349 | 2006-01-13 14:56:25 +1100 | [diff] [blame] | 262 | #define LOAD_REG_ADDR(reg,name) \ |
| 263 | ld (reg),name@got(r2) |
Kumar Gala | 5f7c690 | 2005-09-09 15:02:25 -0500 | [diff] [blame] | 264 | |
David Gibson | e58c349 | 2006-01-13 14:56:25 +1100 | [diff] [blame] | 265 | #define LOAD_REG_ADDRBASE(reg,name) LOAD_REG_ADDR(reg,name) |
| 266 | #define ADDROFF(name) 0 |
Paul Mackerras | b85a046 | 2005-10-06 10:59:19 +1000 | [diff] [blame] | 267 | |
Paul Mackerras | f78541d | 2005-10-28 22:53:37 +1000 | [diff] [blame] | 268 | /* offsets for stack frame layout */ |
| 269 | #define LRSAVE 16 |
Paul Mackerras | b85a046 | 2005-10-06 10:59:19 +1000 | [diff] [blame] | 270 | |
| 271 | #else /* 32-bit */ |
Stephen Rothwell | 7062018 | 2005-10-12 17:44:55 +1000 | [diff] [blame] | 272 | |
David Gibson | e58c349 | 2006-01-13 14:56:25 +1100 | [diff] [blame] | 273 | #define LOAD_REG_IMMEDIATE(reg,expr) \ |
| 274 | lis (reg),(expr)@ha; \ |
| 275 | addi (reg),(reg),(expr)@l; |
Paul Mackerras | b85a046 | 2005-10-06 10:59:19 +1000 | [diff] [blame] | 276 | |
David Gibson | e58c349 | 2006-01-13 14:56:25 +1100 | [diff] [blame] | 277 | #define LOAD_REG_ADDR(reg,name) LOAD_REG_IMMEDIATE(reg, name) |
| 278 | |
| 279 | #define LOAD_REG_ADDRBASE(reg, name) lis (reg),name@ha |
| 280 | #define ADDROFF(name) name@l |
Paul Mackerras | b85a046 | 2005-10-06 10:59:19 +1000 | [diff] [blame] | 281 | |
Paul Mackerras | f78541d | 2005-10-28 22:53:37 +1000 | [diff] [blame] | 282 | /* offsets for stack frame layout */ |
| 283 | #define LRSAVE 4 |
Paul Mackerras | b85a046 | 2005-10-06 10:59:19 +1000 | [diff] [blame] | 284 | |
Kumar Gala | 5f7c690 | 2005-09-09 15:02:25 -0500 | [diff] [blame] | 285 | #endif |
| 286 | |
| 287 | /* various errata or part fixups */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 288 | #ifdef CONFIG_PPC601_SYNC_FIX |
| 289 | #define SYNC \ |
| 290 | BEGIN_FTR_SECTION \ |
| 291 | sync; \ |
| 292 | isync; \ |
| 293 | END_FTR_SECTION_IFSET(CPU_FTR_601) |
| 294 | #define SYNC_601 \ |
| 295 | BEGIN_FTR_SECTION \ |
| 296 | sync; \ |
| 297 | END_FTR_SECTION_IFSET(CPU_FTR_601) |
| 298 | #define ISYNC_601 \ |
| 299 | BEGIN_FTR_SECTION \ |
| 300 | isync; \ |
| 301 | END_FTR_SECTION_IFSET(CPU_FTR_601) |
| 302 | #else |
| 303 | #define SYNC |
| 304 | #define SYNC_601 |
| 305 | #define ISYNC_601 |
| 306 | #endif |
| 307 | |
Benjamin Herrenschmidt | 859deea | 2006-10-20 14:37:05 +1000 | [diff] [blame] | 308 | #ifdef CONFIG_PPC_CELL |
| 309 | #define MFTB(dest) \ |
| 310 | 90: mftb dest; \ |
| 311 | BEGIN_FTR_SECTION_NESTED(96); \ |
| 312 | cmpwi dest,0; \ |
| 313 | beq- 90b; \ |
| 314 | END_FTR_SECTION_NESTED(CPU_FTR_CELL_TB_BUG, CPU_FTR_CELL_TB_BUG, 96) |
| 315 | #else |
| 316 | #define MFTB(dest) mftb dest |
| 317 | #endif |
Kumar Gala | 5f7c690 | 2005-09-09 15:02:25 -0500 | [diff] [blame] | 318 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 319 | #ifndef CONFIG_SMP |
| 320 | #define TLBSYNC |
| 321 | #else /* CONFIG_SMP */ |
| 322 | /* tlbsync is not implemented on 601 */ |
| 323 | #define TLBSYNC \ |
| 324 | BEGIN_FTR_SECTION \ |
| 325 | tlbsync; \ |
| 326 | sync; \ |
| 327 | END_FTR_SECTION_IFCLR(CPU_FTR_601) |
| 328 | #endif |
| 329 | |
Kumar Gala | 5f7c690 | 2005-09-09 15:02:25 -0500 | [diff] [blame] | 330 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 331 | /* |
| 332 | * This instruction is not implemented on the PPC 603 or 601; however, on |
| 333 | * the 403GCX and 405GP tlbia IS defined and tlbie is not. |
| 334 | * All of these instructions exist in the 8xx, they have magical powers, |
| 335 | * and they must be used. |
| 336 | */ |
| 337 | |
| 338 | #if !defined(CONFIG_4xx) && !defined(CONFIG_8xx) |
| 339 | #define tlbia \ |
| 340 | li r4,1024; \ |
| 341 | mtctr r4; \ |
| 342 | lis r4,KERNELBASE@h; \ |
| 343 | 0: tlbie r4; \ |
| 344 | addi r4,r4,0x1000; \ |
| 345 | bdnz 0b |
| 346 | #endif |
| 347 | |
Kumar Gala | 5f7c690 | 2005-09-09 15:02:25 -0500 | [diff] [blame] | 348 | |
Kumar Gala | 5f7c690 | 2005-09-09 15:02:25 -0500 | [diff] [blame] | 349 | #ifdef CONFIG_IBM440EP_ERR42 |
| 350 | #define PPC440EP_ERR42 isync |
| 351 | #else |
| 352 | #define PPC440EP_ERR42 |
| 353 | #endif |
| 354 | |
| 355 | |
| 356 | #if defined(CONFIG_BOOKE) |
Paul Mackerras | 6316222 | 2005-10-27 22:44:39 +1000 | [diff] [blame] | 357 | #define toreal(rd) |
| 358 | #define fromreal(rd) |
| 359 | |
Roland McGrath | 2ca7633 | 2008-05-11 10:40:47 +1000 | [diff] [blame] | 360 | /* |
| 361 | * We use addis to ensure compatibility with the "classic" ppc versions of |
| 362 | * these macros, which use rs = 0 to get the tophys offset in rd, rather than |
| 363 | * converting the address in r0, and so this version has to do that too |
| 364 | * (i.e. set register rd to 0 when rs == 0). |
| 365 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 366 | #define tophys(rd,rs) \ |
| 367 | addis rd,rs,0 |
| 368 | |
| 369 | #define tovirt(rd,rs) \ |
| 370 | addis rd,rs,0 |
| 371 | |
Kumar Gala | 5f7c690 | 2005-09-09 15:02:25 -0500 | [diff] [blame] | 372 | #elif defined(CONFIG_PPC64) |
Paul Mackerras | 6316222 | 2005-10-27 22:44:39 +1000 | [diff] [blame] | 373 | #define toreal(rd) /* we can access c000... in real mode */ |
| 374 | #define fromreal(rd) |
| 375 | |
Kumar Gala | 5f7c690 | 2005-09-09 15:02:25 -0500 | [diff] [blame] | 376 | #define tophys(rd,rs) \ |
Paul Mackerras | 6316222 | 2005-10-27 22:44:39 +1000 | [diff] [blame] | 377 | clrldi rd,rs,2 |
Kumar Gala | 5f7c690 | 2005-09-09 15:02:25 -0500 | [diff] [blame] | 378 | |
| 379 | #define tovirt(rd,rs) \ |
Paul Mackerras | 6316222 | 2005-10-27 22:44:39 +1000 | [diff] [blame] | 380 | rotldi rd,rs,16; \ |
| 381 | ori rd,rd,((KERNELBASE>>48)&0xFFFF);\ |
| 382 | rotldi rd,rd,48 |
Kumar Gala | 5f7c690 | 2005-09-09 15:02:25 -0500 | [diff] [blame] | 383 | #else |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 384 | /* |
| 385 | * On APUS (Amiga PowerPC cpu upgrade board), we don't know the |
| 386 | * physical base address of RAM at compile time. |
| 387 | */ |
Paul Mackerras | 6316222 | 2005-10-27 22:44:39 +1000 | [diff] [blame] | 388 | #define toreal(rd) tophys(rd,rd) |
| 389 | #define fromreal(rd) tovirt(rd,rd) |
| 390 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 391 | #define tophys(rd,rs) \ |
| 392 | 0: addis rd,rs,-KERNELBASE@h; \ |
| 393 | .section ".vtop_fixup","aw"; \ |
| 394 | .align 1; \ |
| 395 | .long 0b; \ |
| 396 | .previous |
| 397 | |
| 398 | #define tovirt(rd,rs) \ |
| 399 | 0: addis rd,rs,KERNELBASE@h; \ |
| 400 | .section ".ptov_fixup","aw"; \ |
| 401 | .align 1; \ |
| 402 | .long 0b; \ |
| 403 | .previous |
Kumar Gala | 5f7c690 | 2005-09-09 15:02:25 -0500 | [diff] [blame] | 404 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 405 | |
Paul Mackerras | 40ef8cb | 2005-10-10 22:50:37 +1000 | [diff] [blame] | 406 | #ifdef CONFIG_PPC64 |
| 407 | #define RFI rfid |
| 408 | #define MTMSRD(r) mtmsrd r |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 409 | |
| 410 | #else |
| 411 | #define FIX_SRR1(ra, rb) |
| 412 | #ifndef CONFIG_40x |
| 413 | #define RFI rfi |
| 414 | #else |
| 415 | #define RFI rfi; b . /* Prevent prefetch past rfi */ |
| 416 | #endif |
| 417 | #define MTMSRD(r) mtmsr r |
| 418 | #define CLR_TOP32(r) |
Matt Porter | c9cf73a | 2005-07-31 22:34:52 -0700 | [diff] [blame] | 419 | #endif |
| 420 | |
Arnd Bergmann | 88ced03 | 2005-12-16 22:43:46 +0100 | [diff] [blame] | 421 | #endif /* __KERNEL__ */ |
| 422 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 423 | /* The boring bits... */ |
| 424 | |
| 425 | /* Condition Register Bit Fields */ |
| 426 | |
| 427 | #define cr0 0 |
| 428 | #define cr1 1 |
| 429 | #define cr2 2 |
| 430 | #define cr3 3 |
| 431 | #define cr4 4 |
| 432 | #define cr5 5 |
| 433 | #define cr6 6 |
| 434 | #define cr7 7 |
| 435 | |
| 436 | |
| 437 | /* General Purpose Registers (GPRs) */ |
| 438 | |
| 439 | #define r0 0 |
| 440 | #define r1 1 |
| 441 | #define r2 2 |
| 442 | #define r3 3 |
| 443 | #define r4 4 |
| 444 | #define r5 5 |
| 445 | #define r6 6 |
| 446 | #define r7 7 |
| 447 | #define r8 8 |
| 448 | #define r9 9 |
| 449 | #define r10 10 |
| 450 | #define r11 11 |
| 451 | #define r12 12 |
| 452 | #define r13 13 |
| 453 | #define r14 14 |
| 454 | #define r15 15 |
| 455 | #define r16 16 |
| 456 | #define r17 17 |
| 457 | #define r18 18 |
| 458 | #define r19 19 |
| 459 | #define r20 20 |
| 460 | #define r21 21 |
| 461 | #define r22 22 |
| 462 | #define r23 23 |
| 463 | #define r24 24 |
| 464 | #define r25 25 |
| 465 | #define r26 26 |
| 466 | #define r27 27 |
| 467 | #define r28 28 |
| 468 | #define r29 29 |
| 469 | #define r30 30 |
| 470 | #define r31 31 |
| 471 | |
| 472 | |
| 473 | /* Floating Point Registers (FPRs) */ |
| 474 | |
| 475 | #define fr0 0 |
| 476 | #define fr1 1 |
| 477 | #define fr2 2 |
| 478 | #define fr3 3 |
| 479 | #define fr4 4 |
| 480 | #define fr5 5 |
| 481 | #define fr6 6 |
| 482 | #define fr7 7 |
| 483 | #define fr8 8 |
| 484 | #define fr9 9 |
| 485 | #define fr10 10 |
| 486 | #define fr11 11 |
| 487 | #define fr12 12 |
| 488 | #define fr13 13 |
| 489 | #define fr14 14 |
| 490 | #define fr15 15 |
| 491 | #define fr16 16 |
| 492 | #define fr17 17 |
| 493 | #define fr18 18 |
| 494 | #define fr19 19 |
| 495 | #define fr20 20 |
| 496 | #define fr21 21 |
| 497 | #define fr22 22 |
| 498 | #define fr23 23 |
| 499 | #define fr24 24 |
| 500 | #define fr25 25 |
| 501 | #define fr26 26 |
| 502 | #define fr27 27 |
| 503 | #define fr28 28 |
| 504 | #define fr29 29 |
| 505 | #define fr30 30 |
| 506 | #define fr31 31 |
| 507 | |
Kumar Gala | 5f7c690 | 2005-09-09 15:02:25 -0500 | [diff] [blame] | 508 | /* AltiVec Registers (VPRs) */ |
| 509 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 510 | #define vr0 0 |
| 511 | #define vr1 1 |
| 512 | #define vr2 2 |
| 513 | #define vr3 3 |
| 514 | #define vr4 4 |
| 515 | #define vr5 5 |
| 516 | #define vr6 6 |
| 517 | #define vr7 7 |
| 518 | #define vr8 8 |
| 519 | #define vr9 9 |
| 520 | #define vr10 10 |
| 521 | #define vr11 11 |
| 522 | #define vr12 12 |
| 523 | #define vr13 13 |
| 524 | #define vr14 14 |
| 525 | #define vr15 15 |
| 526 | #define vr16 16 |
| 527 | #define vr17 17 |
| 528 | #define vr18 18 |
| 529 | #define vr19 19 |
| 530 | #define vr20 20 |
| 531 | #define vr21 21 |
| 532 | #define vr22 22 |
| 533 | #define vr23 23 |
| 534 | #define vr24 24 |
| 535 | #define vr25 25 |
| 536 | #define vr26 26 |
| 537 | #define vr27 27 |
| 538 | #define vr28 28 |
| 539 | #define vr29 29 |
| 540 | #define vr30 30 |
| 541 | #define vr31 31 |
| 542 | |
Kumar Gala | 5f7c690 | 2005-09-09 15:02:25 -0500 | [diff] [blame] | 543 | /* SPE Registers (EVPRs) */ |
| 544 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 545 | #define evr0 0 |
| 546 | #define evr1 1 |
| 547 | #define evr2 2 |
| 548 | #define evr3 3 |
| 549 | #define evr4 4 |
| 550 | #define evr5 5 |
| 551 | #define evr6 6 |
| 552 | #define evr7 7 |
| 553 | #define evr8 8 |
| 554 | #define evr9 9 |
| 555 | #define evr10 10 |
| 556 | #define evr11 11 |
| 557 | #define evr12 12 |
| 558 | #define evr13 13 |
| 559 | #define evr14 14 |
| 560 | #define evr15 15 |
| 561 | #define evr16 16 |
| 562 | #define evr17 17 |
| 563 | #define evr18 18 |
| 564 | #define evr19 19 |
| 565 | #define evr20 20 |
| 566 | #define evr21 21 |
| 567 | #define evr22 22 |
| 568 | #define evr23 23 |
| 569 | #define evr24 24 |
| 570 | #define evr25 25 |
| 571 | #define evr26 26 |
| 572 | #define evr27 27 |
| 573 | #define evr28 28 |
| 574 | #define evr29 29 |
| 575 | #define evr30 30 |
| 576 | #define evr31 31 |
| 577 | |
| 578 | /* some stab codes */ |
| 579 | #define N_FUN 36 |
| 580 | #define N_RSYM 64 |
| 581 | #define N_SLINE 68 |
| 582 | #define N_SO 100 |
Kumar Gala | 5f7c690 | 2005-09-09 15:02:25 -0500 | [diff] [blame] | 583 | |
Kumar Gala | 5f7c690 | 2005-09-09 15:02:25 -0500 | [diff] [blame] | 584 | #endif /* __ASSEMBLY__ */ |
| 585 | |
| 586 | #endif /* _ASM_POWERPC_PPC_ASM_H */ |