1b8b572e1SStephen Rothwell /* 2b8b572e1SStephen Rothwell * Copyright (C) 1995-1999 Gary Thomas, Paul Mackerras, Cort Dougan. 3b8b572e1SStephen Rothwell */ 4b8b572e1SStephen Rothwell #ifndef _ASM_POWERPC_PPC_ASM_H 5b8b572e1SStephen Rothwell #define _ASM_POWERPC_PPC_ASM_H 6b8b572e1SStephen Rothwell 7b8b572e1SStephen Rothwell #include <linux/stringify.h> 8b8b572e1SStephen Rothwell #include <asm/asm-compat.h> 9b8b572e1SStephen Rothwell #include <asm/processor.h> 1016c57b36SKumar Gala #include <asm/ppc-opcode.h> 11cf9efce0SPaul Mackerras #include <asm/firmware.h> 12b8b572e1SStephen Rothwell 13b8b572e1SStephen Rothwell #ifndef __ASSEMBLY__ 14b8b572e1SStephen Rothwell #error __FILE__ should only be used in assembler files 15b8b572e1SStephen Rothwell #else 16b8b572e1SStephen Rothwell 17b8b572e1SStephen Rothwell #define SZL (BITS_PER_LONG/8) 18b8b572e1SStephen Rothwell 19b8b572e1SStephen Rothwell /* 20b8b572e1SStephen Rothwell * Stuff for accurate CPU time accounting. 21b8b572e1SStephen Rothwell * These macros handle transitions between user and system state 22b8b572e1SStephen Rothwell * in exception entry and exit and accumulate time to the 23b8b572e1SStephen Rothwell * user_time and system_time fields in the paca. 24b8b572e1SStephen Rothwell */ 25b8b572e1SStephen Rothwell 26abf917cdSFrederic Weisbecker #ifndef CONFIG_VIRT_CPU_ACCOUNTING_NATIVE 27b8b572e1SStephen Rothwell #define ACCOUNT_CPU_USER_ENTRY(ra, rb) 28b8b572e1SStephen Rothwell #define ACCOUNT_CPU_USER_EXIT(ra, rb) 29cf9efce0SPaul Mackerras #define ACCOUNT_STOLEN_TIME 30b8b572e1SStephen Rothwell #else 31b8b572e1SStephen Rothwell #define ACCOUNT_CPU_USER_ENTRY(ra, rb) \ 32cf9efce0SPaul Mackerras MFTB(ra); /* get timebase */ \ 33cf9efce0SPaul Mackerras ld rb,PACA_STARTTIME_USER(r13); \ 34cf9efce0SPaul Mackerras std ra,PACA_STARTTIME(r13); \ 35b8b572e1SStephen Rothwell subf rb,rb,ra; /* subtract start value */ \ 36b8b572e1SStephen Rothwell ld ra,PACA_USER_TIME(r13); \ 37b8b572e1SStephen Rothwell add ra,ra,rb; /* add on to user time */ \ 38b8b572e1SStephen Rothwell std ra,PACA_USER_TIME(r13); \ 39b8b572e1SStephen Rothwell 40b8b572e1SStephen Rothwell #define ACCOUNT_CPU_USER_EXIT(ra, rb) \ 41cf9efce0SPaul Mackerras MFTB(ra); /* get timebase */ \ 42cf9efce0SPaul Mackerras ld rb,PACA_STARTTIME(r13); \ 43cf9efce0SPaul Mackerras std ra,PACA_STARTTIME_USER(r13); \ 44b8b572e1SStephen Rothwell subf rb,rb,ra; /* subtract start value */ \ 45b8b572e1SStephen Rothwell ld ra,PACA_SYSTEM_TIME(r13); \ 46cf9efce0SPaul Mackerras add ra,ra,rb; /* add on to system time */ \ 47cf9efce0SPaul Mackerras std ra,PACA_SYSTEM_TIME(r13) 48cf9efce0SPaul Mackerras 49cf9efce0SPaul Mackerras #ifdef CONFIG_PPC_SPLPAR 50cf9efce0SPaul Mackerras #define ACCOUNT_STOLEN_TIME \ 51cf9efce0SPaul Mackerras BEGIN_FW_FTR_SECTION; \ 52cf9efce0SPaul Mackerras beq 33f; \ 53cf9efce0SPaul Mackerras /* from user - see if there are any DTL entries to process */ \ 54cf9efce0SPaul Mackerras ld r10,PACALPPACAPTR(r13); /* get ptr to VPA */ \ 55cf9efce0SPaul Mackerras ld r11,PACA_DTL_RIDX(r13); /* get log read index */ \ 567ffcf8ecSAnton Blanchard addi r10,r10,LPPACA_DTLIDX; \ 577ffcf8ecSAnton Blanchard LDX_BE r10,0,r10; /* get log write index */ \ 58cf9efce0SPaul Mackerras cmpd cr1,r11,r10; \ 59cf9efce0SPaul Mackerras beq+ cr1,33f; \ 60b1576fecSAnton Blanchard bl accumulate_stolen_time; \ 61990118c8SBenjamin Herrenschmidt ld r12,_MSR(r1); \ 62990118c8SBenjamin Herrenschmidt andi. r10,r12,MSR_PR; /* Restore cr0 (coming from user) */ \ 63cf9efce0SPaul Mackerras 33: \ 64cf9efce0SPaul Mackerras END_FW_FTR_SECTION_IFSET(FW_FEATURE_SPLPAR) 65cf9efce0SPaul Mackerras 66cf9efce0SPaul Mackerras #else /* CONFIG_PPC_SPLPAR */ 67cf9efce0SPaul Mackerras #define ACCOUNT_STOLEN_TIME 68cf9efce0SPaul Mackerras 69cf9efce0SPaul Mackerras #endif /* CONFIG_PPC_SPLPAR */ 70cf9efce0SPaul Mackerras 71abf917cdSFrederic Weisbecker #endif /* CONFIG_VIRT_CPU_ACCOUNTING_NATIVE */ 72b8b572e1SStephen Rothwell 73b8b572e1SStephen Rothwell /* 74b8b572e1SStephen Rothwell * Macros for storing registers into and loading registers from 75b8b572e1SStephen Rothwell * exception frames. 76b8b572e1SStephen Rothwell */ 77b8b572e1SStephen Rothwell #ifdef __powerpc64__ 78b8b572e1SStephen Rothwell #define SAVE_GPR(n, base) std n,GPR0+8*(n)(base) 79b8b572e1SStephen Rothwell #define REST_GPR(n, base) ld n,GPR0+8*(n)(base) 80b8b572e1SStephen Rothwell #define SAVE_NVGPRS(base) SAVE_8GPRS(14, base); SAVE_10GPRS(22, base) 81b8b572e1SStephen Rothwell #define REST_NVGPRS(base) REST_8GPRS(14, base); REST_10GPRS(22, base) 82b8b572e1SStephen Rothwell #else 83b8b572e1SStephen Rothwell #define SAVE_GPR(n, base) stw n,GPR0+4*(n)(base) 84b8b572e1SStephen Rothwell #define REST_GPR(n, base) lwz n,GPR0+4*(n)(base) 85b8b572e1SStephen Rothwell #define SAVE_NVGPRS(base) SAVE_GPR(13, base); SAVE_8GPRS(14, base); \ 86b8b572e1SStephen Rothwell SAVE_10GPRS(22, base) 87b8b572e1SStephen Rothwell #define REST_NVGPRS(base) REST_GPR(13, base); REST_8GPRS(14, base); \ 88b8b572e1SStephen Rothwell REST_10GPRS(22, base) 89b8b572e1SStephen Rothwell #endif 90b8b572e1SStephen Rothwell 91b8b572e1SStephen Rothwell #define SAVE_2GPRS(n, base) SAVE_GPR(n, base); SAVE_GPR(n+1, base) 92b8b572e1SStephen Rothwell #define SAVE_4GPRS(n, base) SAVE_2GPRS(n, base); SAVE_2GPRS(n+2, base) 93b8b572e1SStephen Rothwell #define SAVE_8GPRS(n, base) SAVE_4GPRS(n, base); SAVE_4GPRS(n+4, base) 94b8b572e1SStephen Rothwell #define SAVE_10GPRS(n, base) SAVE_8GPRS(n, base); SAVE_2GPRS(n+8, base) 95b8b572e1SStephen Rothwell #define REST_2GPRS(n, base) REST_GPR(n, base); REST_GPR(n+1, base) 96b8b572e1SStephen Rothwell #define REST_4GPRS(n, base) REST_2GPRS(n, base); REST_2GPRS(n+2, base) 97b8b572e1SStephen Rothwell #define REST_8GPRS(n, base) REST_4GPRS(n, base); REST_4GPRS(n+4, base) 98b8b572e1SStephen Rothwell #define REST_10GPRS(n, base) REST_8GPRS(n, base); REST_2GPRS(n+8, base) 99b8b572e1SStephen Rothwell 100de79f7b9SPaul Mackerras #define SAVE_FPR(n, base) stfd n,8*TS_FPRWIDTH*(n)(base) 101b8b572e1SStephen Rothwell #define SAVE_2FPRS(n, base) SAVE_FPR(n, base); SAVE_FPR(n+1, base) 102b8b572e1SStephen Rothwell #define SAVE_4FPRS(n, base) SAVE_2FPRS(n, base); SAVE_2FPRS(n+2, base) 103b8b572e1SStephen Rothwell #define SAVE_8FPRS(n, base) SAVE_4FPRS(n, base); SAVE_4FPRS(n+4, base) 104b8b572e1SStephen Rothwell #define SAVE_16FPRS(n, base) SAVE_8FPRS(n, base); SAVE_8FPRS(n+8, base) 105b8b572e1SStephen Rothwell #define SAVE_32FPRS(n, base) SAVE_16FPRS(n, base); SAVE_16FPRS(n+16, base) 106de79f7b9SPaul Mackerras #define REST_FPR(n, base) lfd n,8*TS_FPRWIDTH*(n)(base) 107b8b572e1SStephen Rothwell #define REST_2FPRS(n, base) REST_FPR(n, base); REST_FPR(n+1, base) 108b8b572e1SStephen Rothwell #define REST_4FPRS(n, base) REST_2FPRS(n, base); REST_2FPRS(n+2, base) 109b8b572e1SStephen Rothwell #define REST_8FPRS(n, base) REST_4FPRS(n, base); REST_4FPRS(n+4, base) 110b8b572e1SStephen Rothwell #define REST_16FPRS(n, base) REST_8FPRS(n, base); REST_8FPRS(n+8, base) 111b8b572e1SStephen Rothwell #define REST_32FPRS(n, base) REST_16FPRS(n, base); REST_16FPRS(n+16, base) 112b8b572e1SStephen Rothwell 113de79f7b9SPaul Mackerras #define SAVE_VR(n,b,base) li b,16*(n); stvx n,base,b 114b8b572e1SStephen Rothwell #define SAVE_2VRS(n,b,base) SAVE_VR(n,b,base); SAVE_VR(n+1,b,base) 115b8b572e1SStephen Rothwell #define SAVE_4VRS(n,b,base) SAVE_2VRS(n,b,base); SAVE_2VRS(n+2,b,base) 116b8b572e1SStephen Rothwell #define SAVE_8VRS(n,b,base) SAVE_4VRS(n,b,base); SAVE_4VRS(n+4,b,base) 117b8b572e1SStephen Rothwell #define SAVE_16VRS(n,b,base) SAVE_8VRS(n,b,base); SAVE_8VRS(n+8,b,base) 118b8b572e1SStephen Rothwell #define SAVE_32VRS(n,b,base) SAVE_16VRS(n,b,base); SAVE_16VRS(n+16,b,base) 119de79f7b9SPaul Mackerras #define REST_VR(n,b,base) li b,16*(n); lvx n,base,b 120b8b572e1SStephen Rothwell #define REST_2VRS(n,b,base) REST_VR(n,b,base); REST_VR(n+1,b,base) 121b8b572e1SStephen Rothwell #define REST_4VRS(n,b,base) REST_2VRS(n,b,base); REST_2VRS(n+2,b,base) 122b8b572e1SStephen Rothwell #define REST_8VRS(n,b,base) REST_4VRS(n,b,base); REST_4VRS(n+4,b,base) 123b8b572e1SStephen Rothwell #define REST_16VRS(n,b,base) REST_8VRS(n,b,base); REST_8VRS(n+8,b,base) 124b8b572e1SStephen Rothwell #define REST_32VRS(n,b,base) REST_16VRS(n,b,base); REST_16VRS(n+16,b,base) 125b8b572e1SStephen Rothwell 126926f160fSAnton Blanchard #ifdef __BIG_ENDIAN__ 127926f160fSAnton Blanchard #define STXVD2X_ROT(n,b,base) STXVD2X(n,b,base) 128926f160fSAnton Blanchard #define LXVD2X_ROT(n,b,base) LXVD2X(n,b,base) 129926f160fSAnton Blanchard #else 130926f160fSAnton Blanchard #define STXVD2X_ROT(n,b,base) XXSWAPD(n,n); \ 131926f160fSAnton Blanchard STXVD2X(n,b,base); \ 132926f160fSAnton Blanchard XXSWAPD(n,n) 133926f160fSAnton Blanchard 134926f160fSAnton Blanchard #define LXVD2X_ROT(n,b,base) LXVD2X(n,b,base); \ 135926f160fSAnton Blanchard XXSWAPD(n,n) 136926f160fSAnton Blanchard #endif 137b8b572e1SStephen Rothwell /* Save the lower 32 VSRs in the thread VSR region */ 1383ad26e5cSBenjamin Herrenschmidt #define SAVE_VSR(n,b,base) li b,16*(n); STXVD2X_ROT(n,R##base,R##b) 139b8b572e1SStephen Rothwell #define SAVE_2VSRS(n,b,base) SAVE_VSR(n,b,base); SAVE_VSR(n+1,b,base) 140b8b572e1SStephen Rothwell #define SAVE_4VSRS(n,b,base) SAVE_2VSRS(n,b,base); SAVE_2VSRS(n+2,b,base) 141b8b572e1SStephen Rothwell #define SAVE_8VSRS(n,b,base) SAVE_4VSRS(n,b,base); SAVE_4VSRS(n+4,b,base) 142b8b572e1SStephen Rothwell #define SAVE_16VSRS(n,b,base) SAVE_8VSRS(n,b,base); SAVE_8VSRS(n+8,b,base) 143b8b572e1SStephen Rothwell #define SAVE_32VSRS(n,b,base) SAVE_16VSRS(n,b,base); SAVE_16VSRS(n+16,b,base) 1443ad26e5cSBenjamin Herrenschmidt #define REST_VSR(n,b,base) li b,16*(n); LXVD2X_ROT(n,R##base,R##b) 145b8b572e1SStephen Rothwell #define REST_2VSRS(n,b,base) REST_VSR(n,b,base); REST_VSR(n+1,b,base) 146b8b572e1SStephen Rothwell #define REST_4VSRS(n,b,base) REST_2VSRS(n,b,base); REST_2VSRS(n+2,b,base) 147b8b572e1SStephen Rothwell #define REST_8VSRS(n,b,base) REST_4VSRS(n,b,base); REST_4VSRS(n+4,b,base) 148b8b572e1SStephen Rothwell #define REST_16VSRS(n,b,base) REST_8VSRS(n,b,base); REST_8VSRS(n+8,b,base) 149b8b572e1SStephen Rothwell #define REST_32VSRS(n,b,base) REST_16VSRS(n,b,base); REST_16VSRS(n+16,b,base) 150b8b572e1SStephen Rothwell 151c51584d5SScott Wood /* 152c51584d5SScott Wood * b = base register for addressing, o = base offset from register of 1st EVR 153c51584d5SScott Wood * n = first EVR, s = scratch 154c51584d5SScott Wood */ 155c51584d5SScott Wood #define SAVE_EVR(n,s,b,o) evmergehi s,s,n; stw s,o+4*(n)(b) 156c51584d5SScott Wood #define SAVE_2EVRS(n,s,b,o) SAVE_EVR(n,s,b,o); SAVE_EVR(n+1,s,b,o) 157c51584d5SScott Wood #define SAVE_4EVRS(n,s,b,o) SAVE_2EVRS(n,s,b,o); SAVE_2EVRS(n+2,s,b,o) 158c51584d5SScott Wood #define SAVE_8EVRS(n,s,b,o) SAVE_4EVRS(n,s,b,o); SAVE_4EVRS(n+4,s,b,o) 159c51584d5SScott Wood #define SAVE_16EVRS(n,s,b,o) SAVE_8EVRS(n,s,b,o); SAVE_8EVRS(n+8,s,b,o) 160c51584d5SScott Wood #define SAVE_32EVRS(n,s,b,o) SAVE_16EVRS(n,s,b,o); SAVE_16EVRS(n+16,s,b,o) 161c51584d5SScott Wood #define REST_EVR(n,s,b,o) lwz s,o+4*(n)(b); evmergelo n,s,n 162c51584d5SScott Wood #define REST_2EVRS(n,s,b,o) REST_EVR(n,s,b,o); REST_EVR(n+1,s,b,o) 163c51584d5SScott Wood #define REST_4EVRS(n,s,b,o) REST_2EVRS(n,s,b,o); REST_2EVRS(n+2,s,b,o) 164c51584d5SScott Wood #define REST_8EVRS(n,s,b,o) REST_4EVRS(n,s,b,o); REST_4EVRS(n+4,s,b,o) 165c51584d5SScott Wood #define REST_16EVRS(n,s,b,o) REST_8EVRS(n,s,b,o); REST_8EVRS(n+8,s,b,o) 166c51584d5SScott Wood #define REST_32EVRS(n,s,b,o) REST_16EVRS(n,s,b,o); REST_16EVRS(n+16,s,b,o) 167b8b572e1SStephen Rothwell 168b8b572e1SStephen Rothwell /* Macros to adjust thread priority for hardware multithreading */ 169b8b572e1SStephen Rothwell #define HMT_VERY_LOW or 31,31,31 # very low priority 170b8b572e1SStephen Rothwell #define HMT_LOW or 1,1,1 171b8b572e1SStephen Rothwell #define HMT_MEDIUM_LOW or 6,6,6 # medium low priority 172b8b572e1SStephen Rothwell #define HMT_MEDIUM or 2,2,2 173b8b572e1SStephen Rothwell #define HMT_MEDIUM_HIGH or 5,5,5 # medium high priority 174b8b572e1SStephen Rothwell #define HMT_HIGH or 3,3,3 17550fb8ebeSBenjamin Herrenschmidt #define HMT_EXTRA_HIGH or 7,7,7 # power7 only 176b8b572e1SStephen Rothwell 177d72be892SMichael Neuling #ifdef CONFIG_PPC64 178d72be892SMichael Neuling #define ULONG_SIZE 8 179d72be892SMichael Neuling #else 180d72be892SMichael Neuling #define ULONG_SIZE 4 181d72be892SMichael Neuling #endif 1820b7673c3SMichael Neuling #define __VCPU_GPR(n) (VCPU_GPRS + (n * ULONG_SIZE)) 1830b7673c3SMichael Neuling #define VCPU_GPR(n) __VCPU_GPR(__REG_##n) 184d72be892SMichael Neuling 185b8b572e1SStephen Rothwell #ifdef __KERNEL__ 186b8b572e1SStephen Rothwell #ifdef CONFIG_PPC64 187b8b572e1SStephen Rothwell 18844ce6a5eSMichael Neuling #define STACKFRAMESIZE 256 1890b7673c3SMichael Neuling #define __STK_REG(i) (112 + ((i)-14)*8) 1900b7673c3SMichael Neuling #define STK_REG(i) __STK_REG(__REG_##i) 19144ce6a5eSMichael Neuling 1920b7673c3SMichael Neuling #define __STK_PARAM(i) (48 + ((i)-3)*8) 1930b7673c3SMichael Neuling #define STK_PARAM(i) __STK_PARAM(__REG_##i) 19444ce6a5eSMichael Neuling 195b8b572e1SStephen Rothwell #define XGLUE(a,b) a##b 196b8b572e1SStephen Rothwell #define GLUE(a,b) XGLUE(a,b) 197b8b572e1SStephen Rothwell 198b8b572e1SStephen Rothwell #define _GLOBAL(name) \ 199b8b572e1SStephen Rothwell .section ".text"; \ 200b8b572e1SStephen Rothwell .align 2 ; \ 201b8b572e1SStephen Rothwell .globl name; \ 202b8b572e1SStephen Rothwell .globl GLUE(.,name); \ 203b8b572e1SStephen Rothwell .section ".opd","aw"; \ 204b8b572e1SStephen Rothwell name: \ 205b8b572e1SStephen Rothwell .quad GLUE(.,name); \ 206b8b572e1SStephen Rothwell .quad .TOC.@tocbase; \ 207b8b572e1SStephen Rothwell .quad 0; \ 208b8b572e1SStephen Rothwell .previous; \ 209b8b572e1SStephen Rothwell .type GLUE(.,name),@function; \ 210b8b572e1SStephen Rothwell GLUE(.,name): 211b8b572e1SStephen Rothwell 212b8b572e1SStephen Rothwell #define _KPROBE(name) \ 213b8b572e1SStephen Rothwell .section ".kprobes.text","a"; \ 214b8b572e1SStephen Rothwell .align 2 ; \ 215b8b572e1SStephen Rothwell .globl name; \ 216b8b572e1SStephen Rothwell .globl GLUE(.,name); \ 217b8b572e1SStephen Rothwell .section ".opd","aw"; \ 218b8b572e1SStephen Rothwell name: \ 219b8b572e1SStephen Rothwell .quad GLUE(.,name); \ 220b8b572e1SStephen Rothwell .quad .TOC.@tocbase; \ 221b8b572e1SStephen Rothwell .quad 0; \ 222b8b572e1SStephen Rothwell .previous; \ 223b8b572e1SStephen Rothwell .type GLUE(.,name),@function; \ 224b8b572e1SStephen Rothwell GLUE(.,name): 225b8b572e1SStephen Rothwell 226c1fb0194SAnton Blanchard #define DOTSYM(a) GLUE(.,a) 227c1fb0194SAnton Blanchard 228b8b572e1SStephen Rothwell #else /* 32-bit */ 229b8b572e1SStephen Rothwell 230b8b572e1SStephen Rothwell #define _ENTRY(n) \ 231b8b572e1SStephen Rothwell .globl n; \ 232b8b572e1SStephen Rothwell n: 233b8b572e1SStephen Rothwell 234b8b572e1SStephen Rothwell #define _GLOBAL(n) \ 235b8b572e1SStephen Rothwell .text; \ 236b8b572e1SStephen Rothwell .stabs __stringify(n:F-1),N_FUN,0,0,n;\ 237b8b572e1SStephen Rothwell .globl n; \ 238b8b572e1SStephen Rothwell n: 239b8b572e1SStephen Rothwell 240b8b572e1SStephen Rothwell #define _KPROBE(n) \ 241b8b572e1SStephen Rothwell .section ".kprobes.text","a"; \ 242b8b572e1SStephen Rothwell .globl n; \ 243b8b572e1SStephen Rothwell n: 244b8b572e1SStephen Rothwell 245b8b572e1SStephen Rothwell #endif 246b8b572e1SStephen Rothwell 247b8b572e1SStephen Rothwell /* 248b8b572e1SStephen Rothwell * LOAD_REG_IMMEDIATE(rn, expr) 249b8b572e1SStephen Rothwell * Loads the value of the constant expression 'expr' into register 'rn' 250b8b572e1SStephen Rothwell * using immediate instructions only. Use this when it's important not 251b8b572e1SStephen Rothwell * to reference other data (i.e. on ppc64 when the TOC pointer is not 252e31aa453SPaul Mackerras * valid) and when 'expr' is a constant or absolute address. 253b8b572e1SStephen Rothwell * 254b8b572e1SStephen Rothwell * LOAD_REG_ADDR(rn, name) 255b8b572e1SStephen Rothwell * Loads the address of label 'name' into register 'rn'. Use this when 256b8b572e1SStephen Rothwell * you don't particularly need immediate instructions only, but you need 257b8b572e1SStephen Rothwell * the whole address in one register (e.g. it's a structure address and 258b8b572e1SStephen Rothwell * you want to access various offsets within it). On ppc32 this is 259b8b572e1SStephen Rothwell * identical to LOAD_REG_IMMEDIATE. 260b8b572e1SStephen Rothwell * 2611c49abecSKevin Hao * LOAD_REG_ADDR_PIC(rn, name) 2621c49abecSKevin Hao * Loads the address of label 'name' into register 'run'. Use this when 2631c49abecSKevin Hao * the kernel doesn't run at the linked or relocated address. Please 2641c49abecSKevin Hao * note that this macro will clobber the lr register. 2651c49abecSKevin Hao * 266b8b572e1SStephen Rothwell * LOAD_REG_ADDRBASE(rn, name) 267b8b572e1SStephen Rothwell * ADDROFF(name) 268b8b572e1SStephen Rothwell * LOAD_REG_ADDRBASE loads part of the address of label 'name' into 269b8b572e1SStephen Rothwell * register 'rn'. ADDROFF(name) returns the remainder of the address as 270b8b572e1SStephen Rothwell * a constant expression. ADDROFF(name) is a signed expression < 16 bits 271b8b572e1SStephen Rothwell * in size, so is suitable for use directly as an offset in load and store 272b8b572e1SStephen Rothwell * instructions. Use this when loading/storing a single word or less as: 273b8b572e1SStephen Rothwell * LOAD_REG_ADDRBASE(rX, name) 274b8b572e1SStephen Rothwell * ld rY,ADDROFF(name)(rX) 275b8b572e1SStephen Rothwell */ 2761c49abecSKevin Hao 2771c49abecSKevin Hao /* Be careful, this will clobber the lr register. */ 2781c49abecSKevin Hao #define LOAD_REG_ADDR_PIC(reg, name) \ 2791c49abecSKevin Hao bl 0f; \ 2801c49abecSKevin Hao 0: mflr reg; \ 2811c49abecSKevin Hao addis reg,reg,(name - 0b)@ha; \ 2821c49abecSKevin Hao addi reg,reg,(name - 0b)@l; 2831c49abecSKevin Hao 284b8b572e1SStephen Rothwell #ifdef __powerpc64__ 285b8b572e1SStephen Rothwell #define LOAD_REG_IMMEDIATE(reg,expr) \ 286564aa5cfSMichael Neuling lis reg,(expr)@highest; \ 287564aa5cfSMichael Neuling ori reg,reg,(expr)@higher; \ 288564aa5cfSMichael Neuling rldicr reg,reg,32,31; \ 289564aa5cfSMichael Neuling oris reg,reg,(expr)@h; \ 290564aa5cfSMichael Neuling ori reg,reg,(expr)@l; 291b8b572e1SStephen Rothwell 292b8b572e1SStephen Rothwell #define LOAD_REG_ADDR(reg,name) \ 293564aa5cfSMichael Neuling ld reg,name@got(r2) 294b8b572e1SStephen Rothwell 295b8b572e1SStephen Rothwell #define LOAD_REG_ADDRBASE(reg,name) LOAD_REG_ADDR(reg,name) 296b8b572e1SStephen Rothwell #define ADDROFF(name) 0 297b8b572e1SStephen Rothwell 298b8b572e1SStephen Rothwell /* offsets for stack frame layout */ 299b8b572e1SStephen Rothwell #define LRSAVE 16 300b8b572e1SStephen Rothwell 301b8b572e1SStephen Rothwell #else /* 32-bit */ 302b8b572e1SStephen Rothwell 303b8b572e1SStephen Rothwell #define LOAD_REG_IMMEDIATE(reg,expr) \ 304564aa5cfSMichael Neuling lis reg,(expr)@ha; \ 305564aa5cfSMichael Neuling addi reg,reg,(expr)@l; 306b8b572e1SStephen Rothwell 307b8b572e1SStephen Rothwell #define LOAD_REG_ADDR(reg,name) LOAD_REG_IMMEDIATE(reg, name) 308b8b572e1SStephen Rothwell 309564aa5cfSMichael Neuling #define LOAD_REG_ADDRBASE(reg, name) lis reg,name@ha 310b8b572e1SStephen Rothwell #define ADDROFF(name) name@l 311b8b572e1SStephen Rothwell 312b8b572e1SStephen Rothwell /* offsets for stack frame layout */ 313b8b572e1SStephen Rothwell #define LRSAVE 4 314b8b572e1SStephen Rothwell 315b8b572e1SStephen Rothwell #endif 316b8b572e1SStephen Rothwell 317b8b572e1SStephen Rothwell /* various errata or part fixups */ 318b8b572e1SStephen Rothwell #ifdef CONFIG_PPC601_SYNC_FIX 319b8b572e1SStephen Rothwell #define SYNC \ 320b8b572e1SStephen Rothwell BEGIN_FTR_SECTION \ 321b8b572e1SStephen Rothwell sync; \ 322b8b572e1SStephen Rothwell isync; \ 323b8b572e1SStephen Rothwell END_FTR_SECTION_IFSET(CPU_FTR_601) 324b8b572e1SStephen Rothwell #define SYNC_601 \ 325b8b572e1SStephen Rothwell BEGIN_FTR_SECTION \ 326b8b572e1SStephen Rothwell sync; \ 327b8b572e1SStephen Rothwell END_FTR_SECTION_IFSET(CPU_FTR_601) 328b8b572e1SStephen Rothwell #define ISYNC_601 \ 329b8b572e1SStephen Rothwell BEGIN_FTR_SECTION \ 330b8b572e1SStephen Rothwell isync; \ 331b8b572e1SStephen Rothwell END_FTR_SECTION_IFSET(CPU_FTR_601) 332b8b572e1SStephen Rothwell #else 333b8b572e1SStephen Rothwell #define SYNC 334b8b572e1SStephen Rothwell #define SYNC_601 335b8b572e1SStephen Rothwell #define ISYNC_601 336b8b572e1SStephen Rothwell #endif 337b8b572e1SStephen Rothwell 338d52459caSScott Wood #if defined(CONFIG_PPC_CELL) || defined(CONFIG_PPC_FSL_BOOK3E) 339b8b572e1SStephen Rothwell #define MFTB(dest) \ 340beb2dc0aSScott Wood 90: mfspr dest, SPRN_TBRL; \ 341b8b572e1SStephen Rothwell BEGIN_FTR_SECTION_NESTED(96); \ 342b8b572e1SStephen Rothwell cmpwi dest,0; \ 343b8b572e1SStephen Rothwell beq- 90b; \ 344b8b572e1SStephen Rothwell END_FTR_SECTION_NESTED(CPU_FTR_CELL_TB_BUG, CPU_FTR_CELL_TB_BUG, 96) 345ae2163beSLEROY Christophe #elif defined(CONFIG_8xx) 346ae2163beSLEROY Christophe #define MFTB(dest) mftb dest 347b8b572e1SStephen Rothwell #else 348beb2dc0aSScott Wood #define MFTB(dest) mfspr dest, SPRN_TBRL 349b8b572e1SStephen Rothwell #endif 350b8b572e1SStephen Rothwell 351b8b572e1SStephen Rothwell #ifndef CONFIG_SMP 352b8b572e1SStephen Rothwell #define TLBSYNC 353b8b572e1SStephen Rothwell #else /* CONFIG_SMP */ 354b8b572e1SStephen Rothwell /* tlbsync is not implemented on 601 */ 355b8b572e1SStephen Rothwell #define TLBSYNC \ 356b8b572e1SStephen Rothwell BEGIN_FTR_SECTION \ 357b8b572e1SStephen Rothwell tlbsync; \ 358b8b572e1SStephen Rothwell sync; \ 359b8b572e1SStephen Rothwell END_FTR_SECTION_IFCLR(CPU_FTR_601) 360b8b572e1SStephen Rothwell #endif 361b8b572e1SStephen Rothwell 362694caf02SAnton Blanchard #ifdef CONFIG_PPC64 363694caf02SAnton Blanchard #define MTOCRF(FXM, RS) \ 364694caf02SAnton Blanchard BEGIN_FTR_SECTION_NESTED(848); \ 36586e32fdcSMichael Neuling mtcrf (FXM), RS; \ 366694caf02SAnton Blanchard FTR_SECTION_ELSE_NESTED(848); \ 36786e32fdcSMichael Neuling mtocrf (FXM), RS; \ 368694caf02SAnton Blanchard ALT_FTR_SECTION_END_NESTED_IFCLR(CPU_FTR_NOEXECUTE, 848) 36913e7a8e8SHaren Myneni 37013e7a8e8SHaren Myneni /* 37113e7a8e8SHaren Myneni * PPR restore macros used in entry_64.S 37213e7a8e8SHaren Myneni * Used for P7 or later processors 37313e7a8e8SHaren Myneni */ 37413e7a8e8SHaren Myneni #define HMT_MEDIUM_LOW_HAS_PPR \ 37513e7a8e8SHaren Myneni BEGIN_FTR_SECTION_NESTED(944) \ 37613e7a8e8SHaren Myneni HMT_MEDIUM_LOW; \ 37713e7a8e8SHaren Myneni END_FTR_SECTION_NESTED(CPU_FTR_HAS_PPR,CPU_FTR_HAS_PPR,944) 37813e7a8e8SHaren Myneni 37913e7a8e8SHaren Myneni #define SET_DEFAULT_THREAD_PPR(ra, rb) \ 38013e7a8e8SHaren Myneni BEGIN_FTR_SECTION_NESTED(945) \ 38113e7a8e8SHaren Myneni lis ra,INIT_PPR@highest; /* default ppr=3 */ \ 38213e7a8e8SHaren Myneni ld rb,PACACURRENT(r13); \ 38313e7a8e8SHaren Myneni sldi ra,ra,32; /* 11- 13 bits are used for ppr */ \ 38413e7a8e8SHaren Myneni std ra,TASKTHREADPPR(rb); \ 38513e7a8e8SHaren Myneni END_FTR_SECTION_NESTED(CPU_FTR_HAS_PPR,CPU_FTR_HAS_PPR,945) 38613e7a8e8SHaren Myneni 387694caf02SAnton Blanchard #endif 388b8b572e1SStephen Rothwell 389b8b572e1SStephen Rothwell /* 390b8b572e1SStephen Rothwell * This instruction is not implemented on the PPC 603 or 601; however, on 391b8b572e1SStephen Rothwell * the 403GCX and 405GP tlbia IS defined and tlbie is not. 392b8b572e1SStephen Rothwell * All of these instructions exist in the 8xx, they have magical powers, 393b8b572e1SStephen Rothwell * and they must be used. 394b8b572e1SStephen Rothwell */ 395b8b572e1SStephen Rothwell 396b8b572e1SStephen Rothwell #if !defined(CONFIG_4xx) && !defined(CONFIG_8xx) 397b8b572e1SStephen Rothwell #define tlbia \ 398b8b572e1SStephen Rothwell li r4,1024; \ 399b8b572e1SStephen Rothwell mtctr r4; \ 400b8b572e1SStephen Rothwell lis r4,KERNELBASE@h; \ 401b8b572e1SStephen Rothwell 0: tlbie r4; \ 402b8b572e1SStephen Rothwell addi r4,r4,0x1000; \ 403b8b572e1SStephen Rothwell bdnz 0b 404b8b572e1SStephen Rothwell #endif 405b8b572e1SStephen Rothwell 406b8b572e1SStephen Rothwell 407b8b572e1SStephen Rothwell #ifdef CONFIG_IBM440EP_ERR42 408b8b572e1SStephen Rothwell #define PPC440EP_ERR42 isync 409b8b572e1SStephen Rothwell #else 410b8b572e1SStephen Rothwell #define PPC440EP_ERR42 411b8b572e1SStephen Rothwell #endif 412b8b572e1SStephen Rothwell 413a515348fSMichael Neuling /* The following stops all load and store data streams associated with stream 414a515348fSMichael Neuling * ID (ie. streams created explicitly). The embedded and server mnemonics for 415a515348fSMichael Neuling * dcbt are different so we use machine "power4" here explicitly. 416a515348fSMichael Neuling */ 417a515348fSMichael Neuling #define DCBT_STOP_ALL_STREAM_IDS(scratch) \ 418a515348fSMichael Neuling .machine push ; \ 419a515348fSMichael Neuling .machine "power4" ; \ 420a515348fSMichael Neuling lis scratch,0x60000000@h; \ 421a515348fSMichael Neuling dcbt r0,scratch,0b01010; \ 422a515348fSMichael Neuling .machine pop 423a515348fSMichael Neuling 42444c58cccSBenjamin Herrenschmidt /* 42544c58cccSBenjamin Herrenschmidt * toreal/fromreal/tophys/tovirt macros. 32-bit BookE makes them 42644c58cccSBenjamin Herrenschmidt * keep the address intact to be compatible with code shared with 42744c58cccSBenjamin Herrenschmidt * 32-bit classic. 42844c58cccSBenjamin Herrenschmidt * 42944c58cccSBenjamin Herrenschmidt * On the other hand, I find it useful to have them behave as expected 43044c58cccSBenjamin Herrenschmidt * by their name (ie always do the addition) on 64-bit BookE 43144c58cccSBenjamin Herrenschmidt */ 43244c58cccSBenjamin Herrenschmidt #if defined(CONFIG_BOOKE) && !defined(CONFIG_PPC64) 433b8b572e1SStephen Rothwell #define toreal(rd) 434b8b572e1SStephen Rothwell #define fromreal(rd) 435b8b572e1SStephen Rothwell 436b8b572e1SStephen Rothwell /* 437b8b572e1SStephen Rothwell * We use addis to ensure compatibility with the "classic" ppc versions of 438b8b572e1SStephen Rothwell * these macros, which use rs = 0 to get the tophys offset in rd, rather than 439b8b572e1SStephen Rothwell * converting the address in r0, and so this version has to do that too 440b8b572e1SStephen Rothwell * (i.e. set register rd to 0 when rs == 0). 441b8b572e1SStephen Rothwell */ 442b8b572e1SStephen Rothwell #define tophys(rd,rs) \ 443b8b572e1SStephen Rothwell addis rd,rs,0 444b8b572e1SStephen Rothwell 445b8b572e1SStephen Rothwell #define tovirt(rd,rs) \ 446b8b572e1SStephen Rothwell addis rd,rs,0 447b8b572e1SStephen Rothwell 448b8b572e1SStephen Rothwell #elif defined(CONFIG_PPC64) 449b8b572e1SStephen Rothwell #define toreal(rd) /* we can access c000... in real mode */ 450b8b572e1SStephen Rothwell #define fromreal(rd) 451b8b572e1SStephen Rothwell 452b8b572e1SStephen Rothwell #define tophys(rd,rs) \ 453b8b572e1SStephen Rothwell clrldi rd,rs,2 454b8b572e1SStephen Rothwell 455b8b572e1SStephen Rothwell #define tovirt(rd,rs) \ 456b8b572e1SStephen Rothwell rotldi rd,rs,16; \ 457b8b572e1SStephen Rothwell ori rd,rd,((KERNELBASE>>48)&0xFFFF);\ 458b8b572e1SStephen Rothwell rotldi rd,rd,48 459b8b572e1SStephen Rothwell #else 460b8b572e1SStephen Rothwell /* 461b8b572e1SStephen Rothwell * On APUS (Amiga PowerPC cpu upgrade board), we don't know the 462b8b572e1SStephen Rothwell * physical base address of RAM at compile time. 463b8b572e1SStephen Rothwell */ 464b8b572e1SStephen Rothwell #define toreal(rd) tophys(rd,rd) 465b8b572e1SStephen Rothwell #define fromreal(rd) tovirt(rd,rd) 466b8b572e1SStephen Rothwell 467b8b572e1SStephen Rothwell #define tophys(rd,rs) \ 468ccdcef72SDale Farnsworth 0: addis rd,rs,-PAGE_OFFSET@h; \ 469b8b572e1SStephen Rothwell .section ".vtop_fixup","aw"; \ 470b8b572e1SStephen Rothwell .align 1; \ 471b8b572e1SStephen Rothwell .long 0b; \ 472b8b572e1SStephen Rothwell .previous 473b8b572e1SStephen Rothwell 474b8b572e1SStephen Rothwell #define tovirt(rd,rs) \ 475ccdcef72SDale Farnsworth 0: addis rd,rs,PAGE_OFFSET@h; \ 476b8b572e1SStephen Rothwell .section ".ptov_fixup","aw"; \ 477b8b572e1SStephen Rothwell .align 1; \ 478b8b572e1SStephen Rothwell .long 0b; \ 479b8b572e1SStephen Rothwell .previous 480b8b572e1SStephen Rothwell #endif 481b8b572e1SStephen Rothwell 48244c58cccSBenjamin Herrenschmidt #ifdef CONFIG_PPC_BOOK3S_64 483b8b572e1SStephen Rothwell #define RFI rfid 484b8b572e1SStephen Rothwell #define MTMSRD(r) mtmsrd r 485b38c77d8SBenjamin Herrenschmidt #define MTMSR_EERI(reg) mtmsrd reg,1 486b8b572e1SStephen Rothwell #else 487b8b572e1SStephen Rothwell #define FIX_SRR1(ra, rb) 488b8b572e1SStephen Rothwell #ifndef CONFIG_40x 489b8b572e1SStephen Rothwell #define RFI rfi 490b8b572e1SStephen Rothwell #else 491b8b572e1SStephen Rothwell #define RFI rfi; b . /* Prevent prefetch past rfi */ 492b8b572e1SStephen Rothwell #endif 493b8b572e1SStephen Rothwell #define MTMSRD(r) mtmsr r 494b38c77d8SBenjamin Herrenschmidt #define MTMSR_EERI(reg) mtmsr reg 495b8b572e1SStephen Rothwell #define CLR_TOP32(r) 496b8b572e1SStephen Rothwell #endif 497b8b572e1SStephen Rothwell 498b8b572e1SStephen Rothwell #endif /* __KERNEL__ */ 499b8b572e1SStephen Rothwell 500b8b572e1SStephen Rothwell /* The boring bits... */ 501b8b572e1SStephen Rothwell 502b8b572e1SStephen Rothwell /* Condition Register Bit Fields */ 503b8b572e1SStephen Rothwell 504b8b572e1SStephen Rothwell #define cr0 0 505b8b572e1SStephen Rothwell #define cr1 1 506b8b572e1SStephen Rothwell #define cr2 2 507b8b572e1SStephen Rothwell #define cr3 3 508b8b572e1SStephen Rothwell #define cr4 4 509b8b572e1SStephen Rothwell #define cr5 5 510b8b572e1SStephen Rothwell #define cr6 6 511b8b572e1SStephen Rothwell #define cr7 7 512b8b572e1SStephen Rothwell 513b8b572e1SStephen Rothwell 5149a13a524SMichael Neuling /* 5159a13a524SMichael Neuling * General Purpose Registers (GPRs) 5169a13a524SMichael Neuling * 5179a13a524SMichael Neuling * The lower case r0-r31 should be used in preference to the upper 5189a13a524SMichael Neuling * case R0-R31 as they provide more error checking in the assembler. 5199a13a524SMichael Neuling * Use R0-31 only when really nessesary. 5209a13a524SMichael Neuling */ 521b8b572e1SStephen Rothwell 5229a13a524SMichael Neuling #define r0 %r0 5239a13a524SMichael Neuling #define r1 %r1 5249a13a524SMichael Neuling #define r2 %r2 5259a13a524SMichael Neuling #define r3 %r3 5269a13a524SMichael Neuling #define r4 %r4 5279a13a524SMichael Neuling #define r5 %r5 5289a13a524SMichael Neuling #define r6 %r6 5299a13a524SMichael Neuling #define r7 %r7 5309a13a524SMichael Neuling #define r8 %r8 5319a13a524SMichael Neuling #define r9 %r9 5329a13a524SMichael Neuling #define r10 %r10 5339a13a524SMichael Neuling #define r11 %r11 5349a13a524SMichael Neuling #define r12 %r12 5359a13a524SMichael Neuling #define r13 %r13 5369a13a524SMichael Neuling #define r14 %r14 5379a13a524SMichael Neuling #define r15 %r15 5389a13a524SMichael Neuling #define r16 %r16 5399a13a524SMichael Neuling #define r17 %r17 5409a13a524SMichael Neuling #define r18 %r18 5419a13a524SMichael Neuling #define r19 %r19 5429a13a524SMichael Neuling #define r20 %r20 5439a13a524SMichael Neuling #define r21 %r21 5449a13a524SMichael Neuling #define r22 %r22 5459a13a524SMichael Neuling #define r23 %r23 5469a13a524SMichael Neuling #define r24 %r24 5479a13a524SMichael Neuling #define r25 %r25 5489a13a524SMichael Neuling #define r26 %r26 5499a13a524SMichael Neuling #define r27 %r27 5509a13a524SMichael Neuling #define r28 %r28 5519a13a524SMichael Neuling #define r29 %r29 5529a13a524SMichael Neuling #define r30 %r30 5539a13a524SMichael Neuling #define r31 %r31 554b8b572e1SStephen Rothwell 555b8b572e1SStephen Rothwell 556b8b572e1SStephen Rothwell /* Floating Point Registers (FPRs) */ 557b8b572e1SStephen Rothwell 558b8b572e1SStephen Rothwell #define fr0 0 559b8b572e1SStephen Rothwell #define fr1 1 560b8b572e1SStephen Rothwell #define fr2 2 561b8b572e1SStephen Rothwell #define fr3 3 562b8b572e1SStephen Rothwell #define fr4 4 563b8b572e1SStephen Rothwell #define fr5 5 564b8b572e1SStephen Rothwell #define fr6 6 565b8b572e1SStephen Rothwell #define fr7 7 566b8b572e1SStephen Rothwell #define fr8 8 567b8b572e1SStephen Rothwell #define fr9 9 568b8b572e1SStephen Rothwell #define fr10 10 569b8b572e1SStephen Rothwell #define fr11 11 570b8b572e1SStephen Rothwell #define fr12 12 571b8b572e1SStephen Rothwell #define fr13 13 572b8b572e1SStephen Rothwell #define fr14 14 573b8b572e1SStephen Rothwell #define fr15 15 574b8b572e1SStephen Rothwell #define fr16 16 575b8b572e1SStephen Rothwell #define fr17 17 576b8b572e1SStephen Rothwell #define fr18 18 577b8b572e1SStephen Rothwell #define fr19 19 578b8b572e1SStephen Rothwell #define fr20 20 579b8b572e1SStephen Rothwell #define fr21 21 580b8b572e1SStephen Rothwell #define fr22 22 581b8b572e1SStephen Rothwell #define fr23 23 582b8b572e1SStephen Rothwell #define fr24 24 583b8b572e1SStephen Rothwell #define fr25 25 584b8b572e1SStephen Rothwell #define fr26 26 585b8b572e1SStephen Rothwell #define fr27 27 586b8b572e1SStephen Rothwell #define fr28 28 587b8b572e1SStephen Rothwell #define fr29 29 588b8b572e1SStephen Rothwell #define fr30 30 589b8b572e1SStephen Rothwell #define fr31 31 590b8b572e1SStephen Rothwell 591b8b572e1SStephen Rothwell /* AltiVec Registers (VPRs) */ 592b8b572e1SStephen Rothwell 593b8b572e1SStephen Rothwell #define vr0 0 594b8b572e1SStephen Rothwell #define vr1 1 595b8b572e1SStephen Rothwell #define vr2 2 596b8b572e1SStephen Rothwell #define vr3 3 597b8b572e1SStephen Rothwell #define vr4 4 598b8b572e1SStephen Rothwell #define vr5 5 599b8b572e1SStephen Rothwell #define vr6 6 600b8b572e1SStephen Rothwell #define vr7 7 601b8b572e1SStephen Rothwell #define vr8 8 602b8b572e1SStephen Rothwell #define vr9 9 603b8b572e1SStephen Rothwell #define vr10 10 604b8b572e1SStephen Rothwell #define vr11 11 605b8b572e1SStephen Rothwell #define vr12 12 606b8b572e1SStephen Rothwell #define vr13 13 607b8b572e1SStephen Rothwell #define vr14 14 608b8b572e1SStephen Rothwell #define vr15 15 609b8b572e1SStephen Rothwell #define vr16 16 610b8b572e1SStephen Rothwell #define vr17 17 611b8b572e1SStephen Rothwell #define vr18 18 612b8b572e1SStephen Rothwell #define vr19 19 613b8b572e1SStephen Rothwell #define vr20 20 614b8b572e1SStephen Rothwell #define vr21 21 615b8b572e1SStephen Rothwell #define vr22 22 616b8b572e1SStephen Rothwell #define vr23 23 617b8b572e1SStephen Rothwell #define vr24 24 618b8b572e1SStephen Rothwell #define vr25 25 619b8b572e1SStephen Rothwell #define vr26 26 620b8b572e1SStephen Rothwell #define vr27 27 621b8b572e1SStephen Rothwell #define vr28 28 622b8b572e1SStephen Rothwell #define vr29 29 623b8b572e1SStephen Rothwell #define vr30 30 624b8b572e1SStephen Rothwell #define vr31 31 625b8b572e1SStephen Rothwell 626b8b572e1SStephen Rothwell /* VSX Registers (VSRs) */ 627b8b572e1SStephen Rothwell 628b8b572e1SStephen Rothwell #define vsr0 0 629b8b572e1SStephen Rothwell #define vsr1 1 630b8b572e1SStephen Rothwell #define vsr2 2 631b8b572e1SStephen Rothwell #define vsr3 3 632b8b572e1SStephen Rothwell #define vsr4 4 633b8b572e1SStephen Rothwell #define vsr5 5 634b8b572e1SStephen Rothwell #define vsr6 6 635b8b572e1SStephen Rothwell #define vsr7 7 636b8b572e1SStephen Rothwell #define vsr8 8 637b8b572e1SStephen Rothwell #define vsr9 9 638b8b572e1SStephen Rothwell #define vsr10 10 639b8b572e1SStephen Rothwell #define vsr11 11 640b8b572e1SStephen Rothwell #define vsr12 12 641b8b572e1SStephen Rothwell #define vsr13 13 642b8b572e1SStephen Rothwell #define vsr14 14 643b8b572e1SStephen Rothwell #define vsr15 15 644b8b572e1SStephen Rothwell #define vsr16 16 645b8b572e1SStephen Rothwell #define vsr17 17 646b8b572e1SStephen Rothwell #define vsr18 18 647b8b572e1SStephen Rothwell #define vsr19 19 648b8b572e1SStephen Rothwell #define vsr20 20 649b8b572e1SStephen Rothwell #define vsr21 21 650b8b572e1SStephen Rothwell #define vsr22 22 651b8b572e1SStephen Rothwell #define vsr23 23 652b8b572e1SStephen Rothwell #define vsr24 24 653b8b572e1SStephen Rothwell #define vsr25 25 654b8b572e1SStephen Rothwell #define vsr26 26 655b8b572e1SStephen Rothwell #define vsr27 27 656b8b572e1SStephen Rothwell #define vsr28 28 657b8b572e1SStephen Rothwell #define vsr29 29 658b8b572e1SStephen Rothwell #define vsr30 30 659b8b572e1SStephen Rothwell #define vsr31 31 660b8b572e1SStephen Rothwell #define vsr32 32 661b8b572e1SStephen Rothwell #define vsr33 33 662b8b572e1SStephen Rothwell #define vsr34 34 663b8b572e1SStephen Rothwell #define vsr35 35 664b8b572e1SStephen Rothwell #define vsr36 36 665b8b572e1SStephen Rothwell #define vsr37 37 666b8b572e1SStephen Rothwell #define vsr38 38 667b8b572e1SStephen Rothwell #define vsr39 39 668b8b572e1SStephen Rothwell #define vsr40 40 669b8b572e1SStephen Rothwell #define vsr41 41 670b8b572e1SStephen Rothwell #define vsr42 42 671b8b572e1SStephen Rothwell #define vsr43 43 672b8b572e1SStephen Rothwell #define vsr44 44 673b8b572e1SStephen Rothwell #define vsr45 45 674b8b572e1SStephen Rothwell #define vsr46 46 675b8b572e1SStephen Rothwell #define vsr47 47 676b8b572e1SStephen Rothwell #define vsr48 48 677b8b572e1SStephen Rothwell #define vsr49 49 678b8b572e1SStephen Rothwell #define vsr50 50 679b8b572e1SStephen Rothwell #define vsr51 51 680b8b572e1SStephen Rothwell #define vsr52 52 681b8b572e1SStephen Rothwell #define vsr53 53 682b8b572e1SStephen Rothwell #define vsr54 54 683b8b572e1SStephen Rothwell #define vsr55 55 684b8b572e1SStephen Rothwell #define vsr56 56 685b8b572e1SStephen Rothwell #define vsr57 57 686b8b572e1SStephen Rothwell #define vsr58 58 687b8b572e1SStephen Rothwell #define vsr59 59 688b8b572e1SStephen Rothwell #define vsr60 60 689b8b572e1SStephen Rothwell #define vsr61 61 690b8b572e1SStephen Rothwell #define vsr62 62 691b8b572e1SStephen Rothwell #define vsr63 63 692b8b572e1SStephen Rothwell 693b8b572e1SStephen Rothwell /* SPE Registers (EVPRs) */ 694b8b572e1SStephen Rothwell 695b8b572e1SStephen Rothwell #define evr0 0 696b8b572e1SStephen Rothwell #define evr1 1 697b8b572e1SStephen Rothwell #define evr2 2 698b8b572e1SStephen Rothwell #define evr3 3 699b8b572e1SStephen Rothwell #define evr4 4 700b8b572e1SStephen Rothwell #define evr5 5 701b8b572e1SStephen Rothwell #define evr6 6 702b8b572e1SStephen Rothwell #define evr7 7 703b8b572e1SStephen Rothwell #define evr8 8 704b8b572e1SStephen Rothwell #define evr9 9 705b8b572e1SStephen Rothwell #define evr10 10 706b8b572e1SStephen Rothwell #define evr11 11 707b8b572e1SStephen Rothwell #define evr12 12 708b8b572e1SStephen Rothwell #define evr13 13 709b8b572e1SStephen Rothwell #define evr14 14 710b8b572e1SStephen Rothwell #define evr15 15 711b8b572e1SStephen Rothwell #define evr16 16 712b8b572e1SStephen Rothwell #define evr17 17 713b8b572e1SStephen Rothwell #define evr18 18 714b8b572e1SStephen Rothwell #define evr19 19 715b8b572e1SStephen Rothwell #define evr20 20 716b8b572e1SStephen Rothwell #define evr21 21 717b8b572e1SStephen Rothwell #define evr22 22 718b8b572e1SStephen Rothwell #define evr23 23 719b8b572e1SStephen Rothwell #define evr24 24 720b8b572e1SStephen Rothwell #define evr25 25 721b8b572e1SStephen Rothwell #define evr26 26 722b8b572e1SStephen Rothwell #define evr27 27 723b8b572e1SStephen Rothwell #define evr28 28 724b8b572e1SStephen Rothwell #define evr29 29 725b8b572e1SStephen Rothwell #define evr30 30 726b8b572e1SStephen Rothwell #define evr31 31 727b8b572e1SStephen Rothwell 728b8b572e1SStephen Rothwell /* some stab codes */ 729b8b572e1SStephen Rothwell #define N_FUN 36 730b8b572e1SStephen Rothwell #define N_RSYM 64 731b8b572e1SStephen Rothwell #define N_SLINE 68 732b8b572e1SStephen Rothwell #define N_SO 100 733b8b572e1SStephen Rothwell 7345c0484e2SBenjamin Herrenschmidt /* 7355c0484e2SBenjamin Herrenschmidt * Create an endian fixup trampoline 7365c0484e2SBenjamin Herrenschmidt * 7375c0484e2SBenjamin Herrenschmidt * This starts with a "tdi 0,0,0x48" instruction which is 7385c0484e2SBenjamin Herrenschmidt * essentially a "trap never", and thus akin to a nop. 7395c0484e2SBenjamin Herrenschmidt * 7405c0484e2SBenjamin Herrenschmidt * The opcode for this instruction read with the wrong endian 7415c0484e2SBenjamin Herrenschmidt * however results in a b . + 8 7425c0484e2SBenjamin Herrenschmidt * 7435c0484e2SBenjamin Herrenschmidt * So essentially we use that trick to execute the following 7445c0484e2SBenjamin Herrenschmidt * trampoline in "reverse endian" if we are running with the 7455c0484e2SBenjamin Herrenschmidt * MSR_LE bit set the "wrong" way for whatever endianness the 7465c0484e2SBenjamin Herrenschmidt * kernel is built for. 7475c0484e2SBenjamin Herrenschmidt */ 748b8b572e1SStephen Rothwell 7495c0484e2SBenjamin Herrenschmidt #ifdef CONFIG_PPC_BOOK3E 7505c0484e2SBenjamin Herrenschmidt #define FIXUP_ENDIAN 7515c0484e2SBenjamin Herrenschmidt #else 7525c0484e2SBenjamin Herrenschmidt #define FIXUP_ENDIAN \ 7535c0484e2SBenjamin Herrenschmidt tdi 0,0,0x48; /* Reverse endian of b . + 8 */ \ 7545c0484e2SBenjamin Herrenschmidt b $+36; /* Skip trampoline if endian is good */ \ 7555c0484e2SBenjamin Herrenschmidt .long 0x05009f42; /* bcl 20,31,$+4 */ \ 7565c0484e2SBenjamin Herrenschmidt .long 0xa602487d; /* mflr r10 */ \ 7575c0484e2SBenjamin Herrenschmidt .long 0x1c004a39; /* addi r10,r10,28 */ \ 7585c0484e2SBenjamin Herrenschmidt .long 0xa600607d; /* mfmsr r11 */ \ 7595c0484e2SBenjamin Herrenschmidt .long 0x01006b69; /* xori r11,r11,1 */ \ 7605c0484e2SBenjamin Herrenschmidt .long 0xa6035a7d; /* mtsrr0 r10 */ \ 7615c0484e2SBenjamin Herrenschmidt .long 0xa6037b7d; /* mtsrr1 r11 */ \ 7625c0484e2SBenjamin Herrenschmidt .long 0x2400004c /* rfid */ 7635c0484e2SBenjamin Herrenschmidt #endif /* !CONFIG_PPC_BOOK3E */ 7645c0484e2SBenjamin Herrenschmidt #endif /* __ASSEMBLY__ */ 765b8b572e1SStephen Rothwell #endif /* _ASM_POWERPC_PPC_ASM_H */ 766