diff options
Diffstat (limited to 'include/asm-powerpc/processor.h')
| -rw-r--r-- | include/asm-powerpc/processor.h | 281 |
1 files changed, 281 insertions, 0 deletions
diff --git a/include/asm-powerpc/processor.h b/include/asm-powerpc/processor.h new file mode 100644 index 000000000000..1dc4bf7b52b3 --- /dev/null +++ b/include/asm-powerpc/processor.h | |||
| @@ -0,0 +1,281 @@ | |||
| 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 | |||
| 13 | #include <linux/config.h> | ||
| 14 | #include <asm/reg.h> | ||
| 15 | |||
| 16 | #ifndef __ASSEMBLY__ | ||
| 17 | #include <linux/compiler.h> | ||
| 18 | #include <asm/ptrace.h> | ||
| 19 | #include <asm/types.h> | ||
| 20 | #ifdef CONFIG_PPC64 | ||
| 21 | #include <asm/systemcfg.h> | ||
| 22 | #endif | ||
| 23 | |||
| 24 | #ifdef CONFIG_PPC32 | ||
| 25 | /* 32-bit platform types */ | ||
| 26 | /* We only need to define a new _MACH_xxx for machines which are part of | ||
| 27 | * a configuration which supports more than one type of different machine. | ||
| 28 | * This is currently limited to CONFIG_PPC_MULTIPLATFORM and CHRP/PReP/PMac. | ||
| 29 | * -- Tom | ||
| 30 | */ | ||
| 31 | #define _MACH_prep 0x00000001 | ||
| 32 | #define _MACH_Pmac 0x00000002 /* pmac or pmac clone (non-chrp) */ | ||
| 33 | #define _MACH_chrp 0x00000004 /* chrp machine */ | ||
| 34 | |||
| 35 | /* see residual.h for these */ | ||
| 36 | #define _PREP_Motorola 0x01 /* motorola prep */ | ||
| 37 | #define _PREP_Firm 0x02 /* firmworks prep */ | ||
| 38 | #define _PREP_IBM 0x00 /* ibm prep */ | ||
| 39 | #define _PREP_Bull 0x03 /* bull prep */ | ||
| 40 | |||
| 41 | /* these are arbitrary */ | ||
| 42 | #define _CHRP_Motorola 0x04 /* motorola chrp, the cobra */ | ||
| 43 | #define _CHRP_IBM 0x05 /* IBM chrp, the longtrail and longtrail 2 */ | ||
| 44 | #define _CHRP_Pegasos 0x06 /* Genesi/bplan's Pegasos and Pegasos2 */ | ||
| 45 | |||
| 46 | #ifdef CONFIG_PPC_MULTIPLATFORM | ||
| 47 | extern int _machine; | ||
| 48 | |||
| 49 | /* what kind of prep workstation we are */ | ||
| 50 | extern int _prep_type; | ||
| 51 | extern int _chrp_type; | ||
| 52 | |||
| 53 | /* | ||
| 54 | * This is used to identify the board type from a given PReP board | ||
| 55 | * vendor. Board revision is also made available. | ||
| 56 | */ | ||
| 57 | extern unsigned char ucSystemType; | ||
| 58 | extern unsigned char ucBoardRev; | ||
| 59 | extern unsigned char ucBoardRevMaj, ucBoardRevMin; | ||
| 60 | #else | ||
| 61 | #define _machine 0 | ||
| 62 | #endif /* CONFIG_PPC_MULTIPLATFORM */ | ||
| 63 | #endif /* CONFIG_PPC32 */ | ||
| 64 | |||
| 65 | #ifdef CONFIG_PPC64 | ||
| 66 | /* Platforms supported by PPC64 */ | ||
| 67 | #define PLATFORM_PSERIES 0x0100 | ||
| 68 | #define PLATFORM_PSERIES_LPAR 0x0101 | ||
| 69 | #define PLATFORM_ISERIES_LPAR 0x0201 | ||
| 70 | #define PLATFORM_LPAR 0x0001 | ||
| 71 | #define PLATFORM_POWERMAC 0x0400 | ||
| 72 | #define PLATFORM_MAPLE 0x0500 | ||
| 73 | #define PLATFORM_CELL 0x1000 | ||
| 74 | |||
| 75 | /* Compatibility with drivers coming from PPC32 world */ | ||
| 76 | #define _machine (systemcfg->platform) | ||
| 77 | #define _MACH_Pmac PLATFORM_POWERMAC | ||
| 78 | #endif | ||
| 79 | |||
| 80 | /* | ||
| 81 | * Default implementation of macro that returns current | ||
| 82 | * instruction pointer ("program counter"). | ||
| 83 | */ | ||
| 84 | #define current_text_addr() ({ __label__ _l; _l: &&_l;}) | ||
| 85 | |||
| 86 | /* Macros for adjusting thread priority (hardware multi-threading) */ | ||
| 87 | #define HMT_very_low() asm volatile("or 31,31,31 # very low priority") | ||
| 88 | #define HMT_low() asm volatile("or 1,1,1 # low priority") | ||
| 89 | #define HMT_medium_low() asm volatile("or 6,6,6 # medium low priority") | ||
| 90 | #define HMT_medium() asm volatile("or 2,2,2 # medium priority") | ||
| 91 | #define HMT_medium_high() asm volatile("or 5,5,5 # medium high priority") | ||
| 92 | #define HMT_high() asm volatile("or 3,3,3 # high priority") | ||
| 93 | |||
| 94 | #ifdef __KERNEL__ | ||
| 95 | |||
| 96 | extern int have_of; | ||
| 97 | |||
| 98 | struct task_struct; | ||
| 99 | void start_thread(struct pt_regs *regs, unsigned long fdptr, unsigned long sp); | ||
| 100 | void release_thread(struct task_struct *); | ||
| 101 | |||
| 102 | /* Prepare to copy thread state - unlazy all lazy status */ | ||
| 103 | extern void prepare_to_copy(struct task_struct *tsk); | ||
| 104 | |||
| 105 | /* Create a new kernel thread. */ | ||
| 106 | extern long kernel_thread(int (*fn)(void *), void *arg, unsigned long flags); | ||
| 107 | |||
| 108 | /* Lazy FPU handling on uni-processor */ | ||
| 109 | extern struct task_struct *last_task_used_math; | ||
| 110 | extern struct task_struct *last_task_used_altivec; | ||
| 111 | extern struct task_struct *last_task_used_spe; | ||
| 112 | |||
| 113 | #ifdef CONFIG_PPC32 | ||
| 114 | #define TASK_SIZE (CONFIG_TASK_SIZE) | ||
| 115 | |||
| 116 | /* This decides where the kernel will search for a free chunk of vm | ||
| 117 | * space during mmap's. | ||
| 118 | */ | ||
| 119 | #define TASK_UNMAPPED_BASE (TASK_SIZE / 8 * 3) | ||
| 120 | #endif | ||
| 121 | |||
| 122 | #ifdef CONFIG_PPC64 | ||
| 123 | /* 64-bit user address space is 44-bits (16TB user VM) */ | ||
| 124 | #define TASK_SIZE_USER64 (0x0000100000000000UL) | ||
| 125 | |||
| 126 | /* | ||
| 127 | * 32-bit user address space is 4GB - 1 page | ||
| 128 | * (this 1 page is needed so referencing of 0xFFFFFFFF generates EFAULT | ||
| 129 | */ | ||
| 130 | #define TASK_SIZE_USER32 (0x0000000100000000UL - (1*PAGE_SIZE)) | ||
| 131 | |||
| 132 | #define TASK_SIZE (test_thread_flag(TIF_32BIT) ? \ | ||
| 133 | TASK_SIZE_USER32 : TASK_SIZE_USER64) | ||
| 134 | |||
| 135 | /* This decides where the kernel will search for a free chunk of vm | ||
| 136 | * space during mmap's. | ||
| 137 | */ | ||
| 138 | #define TASK_UNMAPPED_BASE_USER32 (PAGE_ALIGN(TASK_SIZE_USER32 / 4)) | ||
| 139 | #define TASK_UNMAPPED_BASE_USER64 (PAGE_ALIGN(TASK_SIZE_USER64 / 4)) | ||
| 140 | |||
| 141 | #define TASK_UNMAPPED_BASE ((test_thread_flag(TIF_32BIT)) ? \ | ||
| 142 | TASK_UNMAPPED_BASE_USER32 : TASK_UNMAPPED_BASE_USER64 ) | ||
| 143 | #endif | ||
| 144 | |||
| 145 | typedef struct { | ||
| 146 | unsigned long seg; | ||
| 147 | } mm_segment_t; | ||
| 148 | |||
| 149 | struct thread_struct { | ||
| 150 | unsigned long ksp; /* Kernel stack pointer */ | ||
| 151 | #ifdef CONFIG_PPC64 | ||
| 152 | unsigned long ksp_vsid; | ||
| 153 | #endif | ||
| 154 | struct pt_regs *regs; /* Pointer to saved register state */ | ||
| 155 | mm_segment_t fs; /* for get_fs() validation */ | ||
| 156 | #ifdef CONFIG_PPC32 | ||
| 157 | void *pgdir; /* root of page-table tree */ | ||
| 158 | signed long last_syscall; | ||
| 159 | #endif | ||
| 160 | #if defined(CONFIG_4xx) || defined (CONFIG_BOOKE) | ||
| 161 | unsigned long dbcr0; /* debug control register values */ | ||
| 162 | unsigned long dbcr1; | ||
| 163 | #endif | ||
| 164 | double fpr[32]; /* Complete floating point set */ | ||
| 165 | struct { /* fpr ... fpscr must be contiguous */ | ||
| 166 | |||
| 167 | unsigned int pad; | ||
| 168 | unsigned int val; /* Floating point status */ | ||
| 169 | } fpscr; | ||
| 170 | int fpexc_mode; /* floating-point exception mode */ | ||
| 171 | #ifdef CONFIG_PPC64 | ||
| 172 | unsigned long start_tb; /* Start purr when proc switched in */ | ||
| 173 | unsigned long accum_tb; /* Total accumilated purr for process */ | ||
| 174 | unsigned long vdso_base; /* base of the vDSO library */ | ||
| 175 | #endif | ||
| 176 | unsigned long dabr; /* Data address breakpoint register */ | ||
| 177 | #ifdef CONFIG_ALTIVEC | ||
| 178 | /* Complete AltiVec register set */ | ||
| 179 | vector128 vr[32] __attribute((aligned(16))); | ||
| 180 | /* AltiVec status */ | ||
| 181 | vector128 vscr __attribute((aligned(16))); | ||
| 182 | unsigned long vrsave; | ||
| 183 | int used_vr; /* set if process has used altivec */ | ||
| 184 | #endif /* CONFIG_ALTIVEC */ | ||
| 185 | #ifdef CONFIG_SPE | ||
| 186 | unsigned long evr[32]; /* upper 32-bits of SPE regs */ | ||
| 187 | u64 acc; /* Accumulator */ | ||
| 188 | unsigned long spefscr; /* SPE & eFP status */ | ||
| 189 | int used_spe; /* set if process has used spe */ | ||
| 190 | #endif /* CONFIG_SPE */ | ||
| 191 | }; | ||
| 192 | |||
| 193 | #define ARCH_MIN_TASKALIGN 16 | ||
| 194 | |||
| 195 | #define INIT_SP (sizeof(init_stack) + (unsigned long) &init_stack) | ||
| 196 | |||
| 197 | |||
| 198 | #ifdef CONFIG_PPC32 | ||
| 199 | #define INIT_THREAD { \ | ||
| 200 | .ksp = INIT_SP, \ | ||
| 201 | .fs = KERNEL_DS, \ | ||
| 202 | .pgdir = swapper_pg_dir, \ | ||
| 203 | .fpexc_mode = MSR_FE0 | MSR_FE1, \ | ||
| 204 | } | ||
| 205 | #else | ||
| 206 | #define INIT_THREAD { \ | ||
| 207 | .ksp = INIT_SP, \ | ||
| 208 | .regs = (struct pt_regs *)INIT_SP - 1, /* XXX bogus, I think */ \ | ||
| 209 | .fs = KERNEL_DS, \ | ||
| 210 | .fpr = {0}, \ | ||
| 211 | .fpscr = { .val = 0, }, \ | ||
| 212 | .fpexc_mode = MSR_FE0|MSR_FE1, \ | ||
| 213 | } | ||
| 214 | #endif | ||
| 215 | |||
| 216 | /* | ||
| 217 | * Return saved PC of a blocked thread. For now, this is the "user" PC | ||
| 218 | */ | ||
| 219 | #define thread_saved_pc(tsk) \ | ||
| 220 | ((tsk)->thread.regs? (tsk)->thread.regs->nip: 0) | ||
| 221 | |||
| 222 | unsigned long get_wchan(struct task_struct *p); | ||
| 223 | |||
| 224 | #define KSTK_EIP(tsk) ((tsk)->thread.regs? (tsk)->thread.regs->nip: 0) | ||
| 225 | #define KSTK_ESP(tsk) ((tsk)->thread.regs? (tsk)->thread.regs->gpr[1]: 0) | ||
| 226 | |||
| 227 | /* Get/set floating-point exception mode */ | ||
| 228 | #define GET_FPEXC_CTL(tsk, adr) get_fpexc_mode((tsk), (adr)) | ||
| 229 | #define SET_FPEXC_CTL(tsk, val) set_fpexc_mode((tsk), (val)) | ||
| 230 | |||
| 231 | extern int get_fpexc_mode(struct task_struct *tsk, unsigned long adr); | ||
| 232 | extern int set_fpexc_mode(struct task_struct *tsk, unsigned int val); | ||
| 233 | |||
| 234 | static inline unsigned int __unpack_fe01(unsigned long msr_bits) | ||
| 235 | { | ||
| 236 | return ((msr_bits & MSR_FE0) >> 10) | ((msr_bits & MSR_FE1) >> 8); | ||
| 237 | } | ||
| 238 | |||
| 239 | static inline unsigned long __pack_fe01(unsigned int fpmode) | ||
| 240 | { | ||
| 241 | return ((fpmode << 10) & MSR_FE0) | ((fpmode << 8) & MSR_FE1); | ||
| 242 | } | ||
| 243 | |||
| 244 | #ifdef CONFIG_PPC64 | ||
| 245 | #define cpu_relax() do { HMT_low(); HMT_medium(); barrier(); } while (0) | ||
| 246 | #else | ||
| 247 | #define cpu_relax() barrier() | ||
| 248 | #endif | ||
| 249 | |||
| 250 | /* | ||
| 251 | * Prefetch macros. | ||
| 252 | */ | ||
| 253 | #define ARCH_HAS_PREFETCH | ||
| 254 | #define ARCH_HAS_PREFETCHW | ||
| 255 | #define ARCH_HAS_SPINLOCK_PREFETCH | ||
| 256 | |||
| 257 | static inline void prefetch(const void *x) | ||
| 258 | { | ||
| 259 | if (unlikely(!x)) | ||
| 260 | return; | ||
| 261 | |||
| 262 | __asm__ __volatile__ ("dcbt 0,%0" : : "r" (x)); | ||
| 263 | } | ||
| 264 | |||
| 265 | static inline void prefetchw(const void *x) | ||
| 266 | { | ||
| 267 | if (unlikely(!x)) | ||
| 268 | return; | ||
| 269 | |||
| 270 | __asm__ __volatile__ ("dcbtst 0,%0" : : "r" (x)); | ||
| 271 | } | ||
| 272 | |||
| 273 | #define spin_lock_prefetch(x) prefetchw(x) | ||
| 274 | |||
| 275 | #ifdef CONFIG_PPC64 | ||
| 276 | #define HAVE_ARCH_PICK_MMAP_LAYOUT | ||
| 277 | #endif | ||
| 278 | |||
| 279 | #endif /* __KERNEL__ */ | ||
| 280 | #endif /* __ASSEMBLY__ */ | ||
| 281 | #endif /* _ASM_POWERPC_PROCESSOR_H */ | ||
