Paul Mackerras | 9f04b9e | 2005-10-10 14:19:43 +1000 | [diff] [blame] | 1 | #ifndef _ASM_POWERPC_PROCESSOR_H |
| 2 | #define _ASM_POWERPC_PROCESSOR_H |
| 3 | |
| 4 | /* |
| 5 | * Copyright (C) 2001 PPC 64 Team, IBM Corp |
| 6 | * |
| 7 | * This program is free software; you can redistribute it and/or |
| 8 | * modify it under the terms of the GNU General Public License |
| 9 | * as published by the Free Software Foundation; either version |
| 10 | * 2 of the License, or (at your option) any later version. |
| 11 | */ |
| 12 | |
Paul Mackerras | 9f04b9e | 2005-10-10 14:19:43 +1000 | [diff] [blame] | 13 | #include <asm/reg.h> |
| 14 | |
Michael Neuling | c6e6771 | 2008-06-25 14:07:18 +1000 | [diff] [blame] | 15 | #ifdef CONFIG_VSX |
| 16 | #define TS_FPRWIDTH 2 |
| 17 | #else |
Michael Neuling | 9c75a31 | 2008-06-26 17:07:48 +1000 | [diff] [blame] | 18 | #define TS_FPRWIDTH 1 |
Michael Neuling | c6e6771 | 2008-06-25 14:07:18 +1000 | [diff] [blame] | 19 | #endif |
Michael Neuling | 9c75a31 | 2008-06-26 17:07:48 +1000 | [diff] [blame] | 20 | |
Haren Myneni | 9277924 | 2012-12-06 21:49:56 +0000 | [diff] [blame^] | 21 | #ifdef CONFIG_PPC64 |
| 22 | /* Default SMT priority is set to 3. Use 11- 13bits to save priority. */ |
| 23 | #define PPR_PRIORITY 3 |
| 24 | #ifdef __ASSEMBLY__ |
| 25 | #define INIT_PPR (PPR_PRIORITY << 50) |
| 26 | #else |
| 27 | #define INIT_PPR ((u64)PPR_PRIORITY << 50) |
| 28 | #endif /* __ASSEMBLY__ */ |
| 29 | #endif /* CONFIG_PPC64 */ |
| 30 | |
Paul Mackerras | 9f04b9e | 2005-10-10 14:19:43 +1000 | [diff] [blame] | 31 | #ifndef __ASSEMBLY__ |
| 32 | #include <linux/compiler.h> |
Ashish Kalra | 1325a68 | 2011-04-22 16:48:27 -0500 | [diff] [blame] | 33 | #include <linux/cache.h> |
Paul Mackerras | 9f04b9e | 2005-10-10 14:19:43 +1000 | [diff] [blame] | 34 | #include <asm/ptrace.h> |
| 35 | #include <asm/types.h> |
Paul Mackerras | 9f04b9e | 2005-10-10 14:19:43 +1000 | [diff] [blame] | 36 | |
Paul Mackerras | 799d604 | 2005-11-10 13:37:51 +1100 | [diff] [blame] | 37 | /* We do _not_ want to define new machine types at all, those must die |
| 38 | * in favor of using the device-tree |
| 39 | * -- BenH. |
Paul Mackerras | 9f04b9e | 2005-10-10 14:19:43 +1000 | [diff] [blame] | 40 | */ |
Paul Mackerras | 9f04b9e | 2005-10-10 14:19:43 +1000 | [diff] [blame] | 41 | |
Paul Mackerras | 799d604 | 2005-11-10 13:37:51 +1100 | [diff] [blame] | 42 | /* PREP sub-platform types see residual.h for these */ |
Paul Mackerras | 9f04b9e | 2005-10-10 14:19:43 +1000 | [diff] [blame] | 43 | #define _PREP_Motorola 0x01 /* motorola prep */ |
| 44 | #define _PREP_Firm 0x02 /* firmworks prep */ |
| 45 | #define _PREP_IBM 0x00 /* ibm prep */ |
| 46 | #define _PREP_Bull 0x03 /* bull prep */ |
| 47 | |
Paul Mackerras | 799d604 | 2005-11-10 13:37:51 +1100 | [diff] [blame] | 48 | /* CHRP sub-platform types. These are arbitrary */ |
Paul Mackerras | 9f04b9e | 2005-10-10 14:19:43 +1000 | [diff] [blame] | 49 | #define _CHRP_Motorola 0x04 /* motorola chrp, the cobra */ |
| 50 | #define _CHRP_IBM 0x05 /* IBM chrp, the longtrail and longtrail 2 */ |
| 51 | #define _CHRP_Pegasos 0x06 /* Genesi/bplan's Pegasos and Pegasos2 */ |
Benjamin Herrenschmidt | 26c5032 | 2006-07-04 14:16:28 +1000 | [diff] [blame] | 52 | #define _CHRP_briq 0x07 /* TotalImpact's briQ */ |
Paul Mackerras | 9f04b9e | 2005-10-10 14:19:43 +1000 | [diff] [blame] | 53 | |
Benjamin Herrenschmidt | e822250 | 2006-03-28 23:15:54 +1100 | [diff] [blame] | 54 | #if defined(__KERNEL__) && defined(CONFIG_PPC32) |
| 55 | |
| 56 | extern int _chrp_type; |
Paul Mackerras | 799d604 | 2005-11-10 13:37:51 +1100 | [diff] [blame] | 57 | |
Paul Mackerras | 0a26b13 | 2006-03-28 10:22:10 +1100 | [diff] [blame] | 58 | #ifdef CONFIG_PPC_PREP |
Paul Mackerras | 799d604 | 2005-11-10 13:37:51 +1100 | [diff] [blame] | 59 | |
Paul Mackerras | 9f04b9e | 2005-10-10 14:19:43 +1000 | [diff] [blame] | 60 | /* what kind of prep workstation we are */ |
| 61 | extern int _prep_type; |
Paul Mackerras | 9f04b9e | 2005-10-10 14:19:43 +1000 | [diff] [blame] | 62 | |
Paul Mackerras | 0a26b13 | 2006-03-28 10:22:10 +1100 | [diff] [blame] | 63 | #endif /* CONFIG_PPC_PREP */ |
| 64 | |
Benjamin Herrenschmidt | e822250 | 2006-03-28 23:15:54 +1100 | [diff] [blame] | 65 | #endif /* defined(__KERNEL__) && defined(CONFIG_PPC32) */ |
| 66 | |
Paul Mackerras | 9f04b9e | 2005-10-10 14:19:43 +1000 | [diff] [blame] | 67 | /* |
| 68 | * Default implementation of macro that returns current |
| 69 | * instruction pointer ("program counter"). |
| 70 | */ |
| 71 | #define current_text_addr() ({ __label__ _l; _l: &&_l;}) |
| 72 | |
| 73 | /* Macros for adjusting thread priority (hardware multi-threading) */ |
| 74 | #define HMT_very_low() asm volatile("or 31,31,31 # very low priority") |
| 75 | #define HMT_low() asm volatile("or 1,1,1 # low priority") |
| 76 | #define HMT_medium_low() asm volatile("or 6,6,6 # medium low priority") |
| 77 | #define HMT_medium() asm volatile("or 2,2,2 # medium priority") |
| 78 | #define HMT_medium_high() asm volatile("or 5,5,5 # medium high priority") |
| 79 | #define HMT_high() asm volatile("or 3,3,3 # high priority") |
| 80 | |
| 81 | #ifdef __KERNEL__ |
| 82 | |
Paul Mackerras | 9f04b9e | 2005-10-10 14:19:43 +1000 | [diff] [blame] | 83 | struct task_struct; |
| 84 | void start_thread(struct pt_regs *regs, unsigned long fdptr, unsigned long sp); |
| 85 | void release_thread(struct task_struct *); |
| 86 | |
Paul Mackerras | 9f04b9e | 2005-10-10 14:19:43 +1000 | [diff] [blame] | 87 | /* Lazy FPU handling on uni-processor */ |
| 88 | extern struct task_struct *last_task_used_math; |
| 89 | extern struct task_struct *last_task_used_altivec; |
Michael Neuling | c6e6771 | 2008-06-25 14:07:18 +1000 | [diff] [blame] | 90 | extern struct task_struct *last_task_used_vsx; |
Paul Mackerras | 9f04b9e | 2005-10-10 14:19:43 +1000 | [diff] [blame] | 91 | extern struct task_struct *last_task_used_spe; |
| 92 | |
| 93 | #ifdef CONFIG_PPC32 |
Rune Torgersen | 7c4f10b | 2008-05-24 01:59:15 +1000 | [diff] [blame] | 94 | |
| 95 | #if CONFIG_TASK_SIZE > CONFIG_KERNEL_START |
| 96 | #error User TASK_SIZE overlaps with KERNEL_START address |
| 97 | #endif |
Paul Mackerras | 9f04b9e | 2005-10-10 14:19:43 +1000 | [diff] [blame] | 98 | #define TASK_SIZE (CONFIG_TASK_SIZE) |
| 99 | |
| 100 | /* This decides where the kernel will search for a free chunk of vm |
| 101 | * space during mmap's. |
| 102 | */ |
| 103 | #define TASK_UNMAPPED_BASE (TASK_SIZE / 8 * 3) |
| 104 | #endif |
| 105 | |
| 106 | #ifdef CONFIG_PPC64 |
Aneesh Kumar K.V | 048ee09 | 2012-09-10 02:52:55 +0000 | [diff] [blame] | 107 | /* 64-bit user address space is 46-bits (64TB user VM) */ |
| 108 | #define TASK_SIZE_USER64 (0x0000400000000000UL) |
Paul Mackerras | 9f04b9e | 2005-10-10 14:19:43 +1000 | [diff] [blame] | 109 | |
| 110 | /* |
| 111 | * 32-bit user address space is 4GB - 1 page |
| 112 | * (this 1 page is needed so referencing of 0xFFFFFFFF generates EFAULT |
| 113 | */ |
| 114 | #define TASK_SIZE_USER32 (0x0000000100000000UL - (1*PAGE_SIZE)) |
| 115 | |
Dave Hansen | 8245525 | 2008-02-04 22:28:59 -0800 | [diff] [blame] | 116 | #define TASK_SIZE_OF(tsk) (test_tsk_thread_flag(tsk, TIF_32BIT) ? \ |
Paul Mackerras | 9f04b9e | 2005-10-10 14:19:43 +1000 | [diff] [blame] | 117 | TASK_SIZE_USER32 : TASK_SIZE_USER64) |
Dave Hansen | 8245525 | 2008-02-04 22:28:59 -0800 | [diff] [blame] | 118 | #define TASK_SIZE TASK_SIZE_OF(current) |
Paul Mackerras | 9f04b9e | 2005-10-10 14:19:43 +1000 | [diff] [blame] | 119 | |
| 120 | /* This decides where the kernel will search for a free chunk of vm |
| 121 | * space during mmap's. |
| 122 | */ |
| 123 | #define TASK_UNMAPPED_BASE_USER32 (PAGE_ALIGN(TASK_SIZE_USER32 / 4)) |
| 124 | #define TASK_UNMAPPED_BASE_USER64 (PAGE_ALIGN(TASK_SIZE_USER64 / 4)) |
| 125 | |
Denis Kirjanov | cab175f | 2010-08-27 03:49:11 +0000 | [diff] [blame] | 126 | #define TASK_UNMAPPED_BASE ((is_32bit_task()) ? \ |
Paul Mackerras | 9f04b9e | 2005-10-10 14:19:43 +1000 | [diff] [blame] | 127 | TASK_UNMAPPED_BASE_USER32 : TASK_UNMAPPED_BASE_USER64 ) |
| 128 | #endif |
| 129 | |
David Howells | 922a70d | 2008-02-08 04:19:26 -0800 | [diff] [blame] | 130 | #ifdef __powerpc64__ |
| 131 | |
| 132 | #define STACK_TOP_USER64 TASK_SIZE_USER64 |
| 133 | #define STACK_TOP_USER32 TASK_SIZE_USER32 |
| 134 | |
Denis Kirjanov | cab175f | 2010-08-27 03:49:11 +0000 | [diff] [blame] | 135 | #define STACK_TOP (is_32bit_task() ? \ |
David Howells | 922a70d | 2008-02-08 04:19:26 -0800 | [diff] [blame] | 136 | STACK_TOP_USER32 : STACK_TOP_USER64) |
| 137 | |
| 138 | #define STACK_TOP_MAX STACK_TOP_USER64 |
| 139 | |
| 140 | #else /* __powerpc64__ */ |
| 141 | |
| 142 | #define STACK_TOP TASK_SIZE |
| 143 | #define STACK_TOP_MAX STACK_TOP |
| 144 | |
| 145 | #endif /* __powerpc64__ */ |
David Howells | 922a70d | 2008-02-08 04:19:26 -0800 | [diff] [blame] | 146 | |
Paul Mackerras | 9f04b9e | 2005-10-10 14:19:43 +1000 | [diff] [blame] | 147 | typedef struct { |
| 148 | unsigned long seg; |
| 149 | } mm_segment_t; |
| 150 | |
Michael Neuling | c6e6771 | 2008-06-25 14:07:18 +1000 | [diff] [blame] | 151 | #define TS_FPROFFSET 0 |
| 152 | #define TS_VSRLOWOFFSET 1 |
| 153 | #define TS_FPR(i) fpr[i][TS_FPROFFSET] |
Michael Neuling | 9c75a31 | 2008-06-26 17:07:48 +1000 | [diff] [blame] | 154 | |
Paul Mackerras | 9f04b9e | 2005-10-10 14:19:43 +1000 | [diff] [blame] | 155 | struct thread_struct { |
| 156 | unsigned long ksp; /* Kernel stack pointer */ |
Kumar Gala | 8521882 | 2008-04-28 16:21:22 +1000 | [diff] [blame] | 157 | unsigned long ksp_limit; /* if ksp <= ksp_limit stack overflow */ |
| 158 | |
Paul Mackerras | 9f04b9e | 2005-10-10 14:19:43 +1000 | [diff] [blame] | 159 | #ifdef CONFIG_PPC64 |
| 160 | unsigned long ksp_vsid; |
| 161 | #endif |
| 162 | struct pt_regs *regs; /* Pointer to saved register state */ |
| 163 | mm_segment_t fs; /* for get_fs() validation */ |
Ashish Kalra | 1325a68 | 2011-04-22 16:48:27 -0500 | [diff] [blame] | 164 | #ifdef CONFIG_BOOKE |
| 165 | /* BookE base exception scratch space; align on cacheline */ |
| 166 | unsigned long normsave[8] ____cacheline_aligned; |
| 167 | #endif |
Paul Mackerras | 9f04b9e | 2005-10-10 14:19:43 +1000 | [diff] [blame] | 168 | #ifdef CONFIG_PPC32 |
| 169 | void *pgdir; /* root of page-table tree */ |
Paul Mackerras | 9f04b9e | 2005-10-10 14:19:43 +1000 | [diff] [blame] | 170 | #endif |
Dave Kleikamp | 99396ac | 2010-02-08 11:53:26 +0000 | [diff] [blame] | 171 | #ifdef CONFIG_PPC_ADV_DEBUG_REGS |
| 172 | /* |
| 173 | * The following help to manage the use of Debug Control Registers |
| 174 | * om the BookE platforms. |
| 175 | */ |
| 176 | unsigned long dbcr0; |
Paul Mackerras | 9f04b9e | 2005-10-10 14:19:43 +1000 | [diff] [blame] | 177 | unsigned long dbcr1; |
Dave Kleikamp | 99396ac | 2010-02-08 11:53:26 +0000 | [diff] [blame] | 178 | #ifdef CONFIG_BOOKE |
| 179 | unsigned long dbcr2; |
| 180 | #endif |
| 181 | /* |
| 182 | * The stored value of the DBSR register will be the value at the |
| 183 | * last debug interrupt. This register can only be read from the |
| 184 | * user (will never be written to) and has value while helping to |
| 185 | * describe the reason for the last debug trap. Torez |
| 186 | */ |
| 187 | unsigned long dbsr; |
| 188 | /* |
| 189 | * The following will contain addresses used by debug applications |
| 190 | * to help trace and trap on particular address locations. |
| 191 | * The bits in the Debug Control Registers above help define which |
| 192 | * of the following registers will contain valid data and/or addresses. |
| 193 | */ |
| 194 | unsigned long iac1; |
| 195 | unsigned long iac2; |
| 196 | #if CONFIG_PPC_ADV_DEBUG_IACS > 2 |
| 197 | unsigned long iac3; |
| 198 | unsigned long iac4; |
| 199 | #endif |
| 200 | unsigned long dac1; |
| 201 | unsigned long dac2; |
| 202 | #if CONFIG_PPC_ADV_DEBUG_DVCS > 0 |
| 203 | unsigned long dvc1; |
| 204 | unsigned long dvc2; |
| 205 | #endif |
Paul Mackerras | 9f04b9e | 2005-10-10 14:19:43 +1000 | [diff] [blame] | 206 | #endif |
Michael Neuling | c6e6771 | 2008-06-25 14:07:18 +1000 | [diff] [blame] | 207 | /* FP and VSX 0-31 register set */ |
| 208 | double fpr[32][TS_FPRWIDTH]; |
| 209 | struct { |
David Gibson | 25c8a78 | 2005-10-27 16:27:25 +1000 | [diff] [blame] | 210 | |
| 211 | unsigned int pad; |
| 212 | unsigned int val; /* Floating point status */ |
| 213 | } fpscr; |
Paul Mackerras | 9f04b9e | 2005-10-10 14:19:43 +1000 | [diff] [blame] | 214 | int fpexc_mode; /* floating-point exception mode */ |
Paul Mackerras | e9370ae | 2006-06-07 16:15:39 +1000 | [diff] [blame] | 215 | unsigned int align_ctl; /* alignment handling control */ |
Paul Mackerras | 9f04b9e | 2005-10-10 14:19:43 +1000 | [diff] [blame] | 216 | #ifdef CONFIG_PPC64 |
| 217 | unsigned long start_tb; /* Start purr when proc switched in */ |
| 218 | unsigned long accum_tb; /* Total accumilated purr for process */ |
K.Prasad | 5aae8a5 | 2010-06-15 11:35:19 +0530 | [diff] [blame] | 219 | #ifdef CONFIG_HAVE_HW_BREAKPOINT |
| 220 | struct perf_event *ptrace_bps[HBP_NUM]; |
| 221 | /* |
| 222 | * Helps identify source of single-step exception and subsequent |
| 223 | * hw-breakpoint enablement |
| 224 | */ |
| 225 | struct perf_event *last_hit_ubp; |
| 226 | #endif /* CONFIG_HAVE_HW_BREAKPOINT */ |
Paul Mackerras | 9f04b9e | 2005-10-10 14:19:43 +1000 | [diff] [blame] | 227 | #endif |
| 228 | unsigned long dabr; /* Data address breakpoint register */ |
Michael Neuling | 4474ef0 | 2012-09-06 21:24:56 +0000 | [diff] [blame] | 229 | unsigned long dabrx; /* ... extension */ |
Ananth N Mavinakayanahalli | 41ab526 | 2012-08-23 21:27:09 +0000 | [diff] [blame] | 230 | unsigned long trap_nr; /* last trap # on this thread */ |
Paul Mackerras | 9f04b9e | 2005-10-10 14:19:43 +1000 | [diff] [blame] | 231 | #ifdef CONFIG_ALTIVEC |
| 232 | /* Complete AltiVec register set */ |
Mike Frysinger | fc624ea | 2007-07-15 13:36:09 +1000 | [diff] [blame] | 233 | vector128 vr[32] __attribute__((aligned(16))); |
Paul Mackerras | 9f04b9e | 2005-10-10 14:19:43 +1000 | [diff] [blame] | 234 | /* AltiVec status */ |
Mike Frysinger | fc624ea | 2007-07-15 13:36:09 +1000 | [diff] [blame] | 235 | vector128 vscr __attribute__((aligned(16))); |
Paul Mackerras | 9f04b9e | 2005-10-10 14:19:43 +1000 | [diff] [blame] | 236 | unsigned long vrsave; |
| 237 | int used_vr; /* set if process has used altivec */ |
| 238 | #endif /* CONFIG_ALTIVEC */ |
Michael Neuling | c6e6771 | 2008-06-25 14:07:18 +1000 | [diff] [blame] | 239 | #ifdef CONFIG_VSX |
| 240 | /* VSR status */ |
| 241 | int used_vsr; /* set if process has used altivec */ |
| 242 | #endif /* CONFIG_VSX */ |
Paul Mackerras | 9f04b9e | 2005-10-10 14:19:43 +1000 | [diff] [blame] | 243 | #ifdef CONFIG_SPE |
| 244 | unsigned long evr[32]; /* upper 32-bits of SPE regs */ |
| 245 | u64 acc; /* Accumulator */ |
| 246 | unsigned long spefscr; /* SPE & eFP status */ |
| 247 | int used_spe; /* set if process has used spe */ |
| 248 | #endif /* CONFIG_SPE */ |
Alexander Graf | 97e4925 | 2010-04-16 00:11:51 +0200 | [diff] [blame] | 249 | #ifdef CONFIG_KVM_BOOK3S_32_HANDLER |
| 250 | void* kvm_shadow_vcpu; /* KVM internal data */ |
| 251 | #endif /* CONFIG_KVM_BOOK3S_32_HANDLER */ |
Scott Wood | d30f6e4 | 2011-12-20 15:34:43 +0000 | [diff] [blame] | 252 | #if defined(CONFIG_KVM) && defined(CONFIG_BOOKE) |
| 253 | struct kvm_vcpu *kvm_vcpu; |
| 254 | #endif |
Alexey Kardashevskiy | efcac65 | 2011-03-02 15:18:48 +0000 | [diff] [blame] | 255 | #ifdef CONFIG_PPC64 |
| 256 | unsigned long dscr; |
| 257 | int dscr_inherit; |
Haren Myneni | 9277924 | 2012-12-06 21:49:56 +0000 | [diff] [blame^] | 258 | unsigned long ppr; /* used to save/restore SMT priority */ |
Alexey Kardashevskiy | efcac65 | 2011-03-02 15:18:48 +0000 | [diff] [blame] | 259 | #endif |
Paul Mackerras | 9f04b9e | 2005-10-10 14:19:43 +1000 | [diff] [blame] | 260 | }; |
| 261 | |
| 262 | #define ARCH_MIN_TASKALIGN 16 |
| 263 | |
| 264 | #define INIT_SP (sizeof(init_stack) + (unsigned long) &init_stack) |
Kumar Gala | 8521882 | 2008-04-28 16:21:22 +1000 | [diff] [blame] | 265 | #define INIT_SP_LIMIT \ |
| 266 | (_ALIGN_UP(sizeof(init_thread_info), 16) + (unsigned long) &init_stack) |
Paul Mackerras | 9f04b9e | 2005-10-10 14:19:43 +1000 | [diff] [blame] | 267 | |
Liu Yu | 6a800f3 | 2008-10-28 11:50:21 +0800 | [diff] [blame] | 268 | #ifdef CONFIG_SPE |
| 269 | #define SPEFSCR_INIT .spefscr = SPEFSCR_FINVE | SPEFSCR_FDBZE | SPEFSCR_FUNFE | SPEFSCR_FOVFE, |
| 270 | #else |
| 271 | #define SPEFSCR_INIT |
| 272 | #endif |
Paul Mackerras | 9f04b9e | 2005-10-10 14:19:43 +1000 | [diff] [blame] | 273 | |
| 274 | #ifdef CONFIG_PPC32 |
| 275 | #define INIT_THREAD { \ |
| 276 | .ksp = INIT_SP, \ |
Kumar Gala | 8521882 | 2008-04-28 16:21:22 +1000 | [diff] [blame] | 277 | .ksp_limit = INIT_SP_LIMIT, \ |
Paul Mackerras | 9f04b9e | 2005-10-10 14:19:43 +1000 | [diff] [blame] | 278 | .fs = KERNEL_DS, \ |
| 279 | .pgdir = swapper_pg_dir, \ |
| 280 | .fpexc_mode = MSR_FE0 | MSR_FE1, \ |
Liu Yu | 6a800f3 | 2008-10-28 11:50:21 +0800 | [diff] [blame] | 281 | SPEFSCR_INIT \ |
Paul Mackerras | 9f04b9e | 2005-10-10 14:19:43 +1000 | [diff] [blame] | 282 | } |
| 283 | #else |
| 284 | #define INIT_THREAD { \ |
| 285 | .ksp = INIT_SP, \ |
Kumar Gala | 8521882 | 2008-04-28 16:21:22 +1000 | [diff] [blame] | 286 | .ksp_limit = INIT_SP_LIMIT, \ |
Paul Mackerras | 9f04b9e | 2005-10-10 14:19:43 +1000 | [diff] [blame] | 287 | .regs = (struct pt_regs *)INIT_SP - 1, /* XXX bogus, I think */ \ |
| 288 | .fs = KERNEL_DS, \ |
Michael Neuling | e17a256 | 2008-07-01 17:00:39 +1000 | [diff] [blame] | 289 | .fpr = {{0}}, \ |
David Gibson | 25c8a78 | 2005-10-27 16:27:25 +1000 | [diff] [blame] | 290 | .fpscr = { .val = 0, }, \ |
Arnd Bergmann | ddf5f75 | 2006-06-20 02:30:33 +0200 | [diff] [blame] | 291 | .fpexc_mode = 0, \ |
Haren Myneni | 9277924 | 2012-12-06 21:49:56 +0000 | [diff] [blame^] | 292 | .ppr = INIT_PPR, \ |
Paul Mackerras | 9f04b9e | 2005-10-10 14:19:43 +1000 | [diff] [blame] | 293 | } |
| 294 | #endif |
| 295 | |
| 296 | /* |
| 297 | * Return saved PC of a blocked thread. For now, this is the "user" PC |
| 298 | */ |
| 299 | #define thread_saved_pc(tsk) \ |
| 300 | ((tsk)->thread.regs? (tsk)->thread.regs->nip: 0) |
| 301 | |
Srinivasa Ds | e5093ff | 2008-07-08 00:22:27 +1000 | [diff] [blame] | 302 | #define task_pt_regs(tsk) ((struct pt_regs *)(tsk)->thread.regs) |
| 303 | |
Paul Mackerras | 9f04b9e | 2005-10-10 14:19:43 +1000 | [diff] [blame] | 304 | unsigned long get_wchan(struct task_struct *p); |
| 305 | |
| 306 | #define KSTK_EIP(tsk) ((tsk)->thread.regs? (tsk)->thread.regs->nip: 0) |
| 307 | #define KSTK_ESP(tsk) ((tsk)->thread.regs? (tsk)->thread.regs->gpr[1]: 0) |
| 308 | |
| 309 | /* Get/set floating-point exception mode */ |
| 310 | #define GET_FPEXC_CTL(tsk, adr) get_fpexc_mode((tsk), (adr)) |
| 311 | #define SET_FPEXC_CTL(tsk, val) set_fpexc_mode((tsk), (val)) |
| 312 | |
| 313 | extern int get_fpexc_mode(struct task_struct *tsk, unsigned long adr); |
| 314 | extern int set_fpexc_mode(struct task_struct *tsk, unsigned int val); |
| 315 | |
Paul Mackerras | fab5db9 | 2006-06-07 16:14:40 +1000 | [diff] [blame] | 316 | #define GET_ENDIAN(tsk, adr) get_endian((tsk), (adr)) |
| 317 | #define SET_ENDIAN(tsk, val) set_endian((tsk), (val)) |
| 318 | |
| 319 | extern int get_endian(struct task_struct *tsk, unsigned long adr); |
| 320 | extern int set_endian(struct task_struct *tsk, unsigned int val); |
| 321 | |
Paul Mackerras | e9370ae | 2006-06-07 16:15:39 +1000 | [diff] [blame] | 322 | #define GET_UNALIGN_CTL(tsk, adr) get_unalign_ctl((tsk), (adr)) |
| 323 | #define SET_UNALIGN_CTL(tsk, val) set_unalign_ctl((tsk), (val)) |
| 324 | |
| 325 | extern int get_unalign_ctl(struct task_struct *tsk, unsigned long adr); |
| 326 | extern int set_unalign_ctl(struct task_struct *tsk, unsigned int val); |
| 327 | |
Paul Mackerras | 9f04b9e | 2005-10-10 14:19:43 +1000 | [diff] [blame] | 328 | static inline unsigned int __unpack_fe01(unsigned long msr_bits) |
| 329 | { |
| 330 | return ((msr_bits & MSR_FE0) >> 10) | ((msr_bits & MSR_FE1) >> 8); |
| 331 | } |
| 332 | |
| 333 | static inline unsigned long __pack_fe01(unsigned int fpmode) |
| 334 | { |
| 335 | return ((fpmode << 10) & MSR_FE0) | ((fpmode << 8) & MSR_FE1); |
| 336 | } |
| 337 | |
| 338 | #ifdef CONFIG_PPC64 |
| 339 | #define cpu_relax() do { HMT_low(); HMT_medium(); barrier(); } while (0) |
| 340 | #else |
| 341 | #define cpu_relax() barrier() |
| 342 | #endif |
| 343 | |
Anton Blanchard | 2f25194 | 2006-03-27 11:46:18 +1100 | [diff] [blame] | 344 | /* Check that a certain kernel stack pointer is valid in task_struct p */ |
| 345 | int validate_sp(unsigned long sp, struct task_struct *p, |
| 346 | unsigned long nbytes); |
| 347 | |
Paul Mackerras | 9f04b9e | 2005-10-10 14:19:43 +1000 | [diff] [blame] | 348 | /* |
| 349 | * Prefetch macros. |
| 350 | */ |
| 351 | #define ARCH_HAS_PREFETCH |
| 352 | #define ARCH_HAS_PREFETCHW |
| 353 | #define ARCH_HAS_SPINLOCK_PREFETCH |
| 354 | |
| 355 | static inline void prefetch(const void *x) |
| 356 | { |
| 357 | if (unlikely(!x)) |
| 358 | return; |
| 359 | |
| 360 | __asm__ __volatile__ ("dcbt 0,%0" : : "r" (x)); |
| 361 | } |
| 362 | |
| 363 | static inline void prefetchw(const void *x) |
| 364 | { |
| 365 | if (unlikely(!x)) |
| 366 | return; |
| 367 | |
| 368 | __asm__ __volatile__ ("dcbtst 0,%0" : : "r" (x)); |
| 369 | } |
| 370 | |
| 371 | #define spin_lock_prefetch(x) prefetchw(x) |
| 372 | |
| 373 | #ifdef CONFIG_PPC64 |
| 374 | #define HAVE_ARCH_PICK_MMAP_LAYOUT |
| 375 | #endif |
| 376 | |
Josh Boyer | efbda86 | 2009-03-25 06:23:59 +0000 | [diff] [blame] | 377 | #ifdef CONFIG_PPC64 |
| 378 | static inline unsigned long get_clean_sp(struct pt_regs *regs, int is_32) |
| 379 | { |
| 380 | unsigned long sp; |
| 381 | |
| 382 | if (is_32) |
| 383 | sp = regs->gpr[1] & 0x0ffffffffUL; |
| 384 | else |
| 385 | sp = regs->gpr[1]; |
| 386 | |
| 387 | return sp; |
| 388 | } |
| 389 | #else |
| 390 | static inline unsigned long get_clean_sp(struct pt_regs *regs, int is_32) |
| 391 | { |
| 392 | return regs->gpr[1]; |
| 393 | } |
| 394 | #endif |
| 395 | |
Deepthi Dharwar | e8bb3e0 | 2011-11-30 02:47:03 +0000 | [diff] [blame] | 396 | extern unsigned long cpuidle_disable; |
Deepthi Dharwar | 771dae8 | 2011-11-30 02:46:31 +0000 | [diff] [blame] | 397 | enum idle_boot_override {IDLE_NO_OVERRIDE = 0, IDLE_POWERSAVE_OFF}; |
| 398 | |
David Howells | ae3a197 | 2012-03-28 18:30:02 +0100 | [diff] [blame] | 399 | extern int powersave_nap; /* set if nap mode can be used in idle loop */ |
Paul Mackerras | 375f561 | 2012-07-26 18:51:09 +0000 | [diff] [blame] | 400 | extern void power7_nap(void); |
David Howells | ae3a197 | 2012-03-28 18:30:02 +0100 | [diff] [blame] | 401 | |
| 402 | #ifdef CONFIG_PSERIES_IDLE |
Deepthi Dharwar | 8ea959a | 2012-10-03 18:42:18 +0000 | [diff] [blame] | 403 | extern void update_smt_snooze_delay(int cpu, int residency); |
David Howells | ae3a197 | 2012-03-28 18:30:02 +0100 | [diff] [blame] | 404 | #else |
Deepthi Dharwar | 8ea959a | 2012-10-03 18:42:18 +0000 | [diff] [blame] | 405 | static inline void update_smt_snooze_delay(int cpu, int residency) {} |
David Howells | ae3a197 | 2012-03-28 18:30:02 +0100 | [diff] [blame] | 406 | #endif |
| 407 | |
| 408 | extern void flush_instruction_cache(void); |
| 409 | extern void hard_reset_now(void); |
| 410 | extern void poweroff_now(void); |
| 411 | extern int fix_alignment(struct pt_regs *); |
| 412 | extern void cvt_fd(float *from, double *to); |
| 413 | extern void cvt_df(double *from, float *to); |
| 414 | extern void _nmask_and_or_msr(unsigned long nmask, unsigned long or_val); |
| 415 | |
| 416 | #ifdef CONFIG_PPC64 |
| 417 | /* |
| 418 | * We handle most unaligned accesses in hardware. On the other hand |
| 419 | * unaligned DMA can be very expensive on some ppc64 IO chips (it does |
| 420 | * powers of 2 writes until it reaches sufficient alignment). |
| 421 | * |
| 422 | * Based on this we disable the IP header alignment in network drivers. |
| 423 | */ |
| 424 | #define NET_IP_ALIGN 0 |
| 425 | #endif |
| 426 | |
Paul Mackerras | 9f04b9e | 2005-10-10 14:19:43 +1000 | [diff] [blame] | 427 | #endif /* __KERNEL__ */ |
| 428 | #endif /* __ASSEMBLY__ */ |
| 429 | #endif /* _ASM_POWERPC_PROCESSOR_H */ |