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