aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorPaul Mackerras <paulus@samba.org>2005-10-10 00:19:43 -0400
committerPaul Mackerras <paulus@samba.org>2005-10-10 00:19:43 -0400
commit9f04b9e327c495f8ddbf89c08da6cbe626e1b1b3 (patch)
tree381e9786b837085bd555c705542047f54cd2beab /include
parentb60fc8bbd2d0ea2a9b1fc7271d521fcf47f27bfd (diff)
powerpc: Merged processor.h.
This adds register definitions from the ppc64 processor.h to reg.h, and makes a single merged processor.h. I moved __is_processor from the ppc64 system.h to the merged reg.h along with the PVR register constants. Signed-off-by: Paul Mackerras <paulus@samba.org>
Diffstat (limited to 'include')
-rw-r--r--include/asm-powerpc/processor.h (renamed from include/asm-ppc/processor.h)185
-rw-r--r--include/asm-powerpc/reg.h281
-rw-r--r--include/asm-ppc64/processor.h567
-rw-r--r--include/asm-ppc64/system.h7
4 files changed, 353 insertions, 687 deletions
diff --git a/include/asm-ppc/processor.h b/include/asm-powerpc/processor.h
index b05b5d9cae20..9592f533e058 100644
--- a/include/asm-ppc/processor.h
+++ b/include/asm-powerpc/processor.h
@@ -1,21 +1,28 @@
1#ifdef __KERNEL__ 1#ifndef _ASM_POWERPC_PROCESSOR_H
2#ifndef __ASM_PPC_PROCESSOR_H 2#define _ASM_POWERPC_PROCESSOR_H
3#define __ASM_PPC_PROCESSOR_H
4 3
5/* 4/*
6 * Default implementation of macro that returns current 5 * Copyright (C) 2001 PPC 64 Team, IBM Corp
7 * instruction pointer ("program counter"). 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.
8 */ 11 */
9#define current_text_addr() ({ __label__ _l; _l: &&_l;})
10 12
11#include <linux/config.h> 13#include <linux/config.h>
12#include <linux/stringify.h> 14#include <asm/reg.h>
13 15
16#ifndef __ASSEMBLY__
17#include <linux/compiler.h>
14#include <asm/ptrace.h> 18#include <asm/ptrace.h>
15#include <asm/types.h> 19#include <asm/types.h>
16#include <asm/mpc8xx.h> 20#ifdef CONFIG_PPC64
17#include <asm/reg.h> 21#include <asm/systemcfg.h>
22#endif
18 23
24#ifdef CONFIG_PPC32
25/* 32-bit platform types */
19/* We only need to define a new _MACH_xxx for machines which are part of 26/* We only need to define a new _MACH_xxx for machines which are part of
20 * a configuration which supports more than one type of different machine. 27 * a configuration which supports more than one type of different machine.
21 * This is currently limited to CONFIG_PPC_MULTIPLATFORM and CHRP/PReP/PMac. 28 * This is currently limited to CONFIG_PPC_MULTIPLATFORM and CHRP/PReP/PMac.
@@ -36,20 +43,6 @@
36#define _CHRP_IBM 0x05 /* IBM chrp, the longtrail and longtrail 2 */ 43#define _CHRP_IBM 0x05 /* IBM chrp, the longtrail and longtrail 2 */
37#define _CHRP_Pegasos 0x06 /* Genesi/bplan's Pegasos and Pegasos2 */ 44#define _CHRP_Pegasos 0x06 /* Genesi/bplan's Pegasos and Pegasos2 */
38 45
39#define _GLOBAL(n)\
40 .stabs __stringify(n:F-1),N_FUN,0,0,n;\
41 .globl n;\
42n:
43
44/*
45 * this is the minimum allowable io space due to the location
46 * of the io areas on prep (first one at 0x80000000) but
47 * as soon as I get around to remapping the io areas with the BATs
48 * to match the mac we can raise this. -- Cort
49 */
50#define TASK_SIZE (CONFIG_TASK_SIZE)
51
52#ifndef __ASSEMBLY__
53#ifdef CONFIG_PPC_MULTIPLATFORM 46#ifdef CONFIG_PPC_MULTIPLATFORM
54extern int _machine; 47extern int _machine;
55 48
@@ -67,17 +60,49 @@ extern unsigned char ucBoardRevMaj, ucBoardRevMin;
67#else 60#else
68#define _machine 0 61#define _machine 0
69#endif /* CONFIG_PPC_MULTIPLATFORM */ 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_BPA 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
96extern int have_of;
70 97
71struct task_struct; 98struct task_struct;
72void start_thread(struct pt_regs *regs, unsigned long nip, unsigned long sp); 99void start_thread(struct pt_regs *regs, unsigned long fdptr, unsigned long sp);
73void release_thread(struct task_struct *); 100void release_thread(struct task_struct *);
74 101
75/* Prepare to copy thread state - unlazy all lazy status */ 102/* Prepare to copy thread state - unlazy all lazy status */
76extern void prepare_to_copy(struct task_struct *tsk); 103extern void prepare_to_copy(struct task_struct *tsk);
77 104
78/* 105/* Create a new kernel thread. */
79 * Create a new kernel thread.
80 */
81extern long kernel_thread(int (*fn)(void *), void *arg, unsigned long flags); 106extern long kernel_thread(int (*fn)(void *), void *arg, unsigned long flags);
82 107
83/* Lazy FPU handling on uni-processor */ 108/* Lazy FPU handling on uni-processor */
@@ -85,10 +110,37 @@ extern struct task_struct *last_task_used_math;
85extern struct task_struct *last_task_used_altivec; 110extern struct task_struct *last_task_used_altivec;
86extern struct task_struct *last_task_used_spe; 111extern struct task_struct *last_task_used_spe;
87 112
113#ifdef CONFIG_PPC32
114#define TASK_SIZE (CONFIG_TASK_SIZE)
115
88/* This decides where the kernel will search for a free chunk of vm 116/* This decides where the kernel will search for a free chunk of vm
89 * space during mmap's. 117 * space during mmap's.
90 */ 118 */
91#define TASK_UNMAPPED_BASE (TASK_SIZE / 8 * 3) 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
92 144
93typedef struct { 145typedef struct {
94 unsigned long seg; 146 unsigned long seg;
@@ -96,18 +148,31 @@ typedef struct {
96 148
97struct thread_struct { 149struct thread_struct {
98 unsigned long ksp; /* Kernel stack pointer */ 150 unsigned long ksp; /* Kernel stack pointer */
151#ifdef CONFIG_PPC64
152 unsigned long ksp_vsid;
153#endif
99 struct pt_regs *regs; /* Pointer to saved register state */ 154 struct pt_regs *regs; /* Pointer to saved register state */
100 mm_segment_t fs; /* for get_fs() validation */ 155 mm_segment_t fs; /* for get_fs() validation */
156#ifdef CONFIG_PPC32
101 void *pgdir; /* root of page-table tree */ 157 void *pgdir; /* root of page-table tree */
102 int fpexc_mode; /* floating-point exception mode */
103 signed long last_syscall; 158 signed long last_syscall;
159#endif
104#if defined(CONFIG_4xx) || defined (CONFIG_BOOKE) 160#if defined(CONFIG_4xx) || defined (CONFIG_BOOKE)
105 unsigned long dbcr0; /* debug control register values */ 161 unsigned long dbcr0; /* debug control register values */
106 unsigned long dbcr1; 162 unsigned long dbcr1;
107#endif 163#endif
108 double fpr[32]; /* Complete floating point set */ 164 double fpr[32]; /* Complete floating point set */
165#ifdef CONFIG_PPC32
109 unsigned long fpscr_pad; /* fpr ... fpscr must be contiguous */ 166 unsigned long fpscr_pad; /* fpr ... fpscr must be contiguous */
167#endif
110 unsigned long fpscr; /* Floating point status */ 168 unsigned long fpscr; /* Floating point status */
169 int fpexc_mode; /* floating-point exception mode */
170#ifdef CONFIG_PPC64
171 unsigned long start_tb; /* Start purr when proc switched in */
172 unsigned long accum_tb; /* Total accumilated purr for process */
173 unsigned long vdso_base; /* base of the vDSO library */
174#endif
175 unsigned long dabr; /* Data address breakpoint register */
111#ifdef CONFIG_ALTIVEC 176#ifdef CONFIG_ALTIVEC
112 /* Complete AltiVec register set */ 177 /* Complete AltiVec register set */
113 vector128 vr[32] __attribute((aligned(16))); 178 vector128 vr[32] __attribute((aligned(16)));
@@ -128,51 +193,58 @@ struct thread_struct {
128 193
129#define INIT_SP (sizeof(init_stack) + (unsigned long) &init_stack) 194#define INIT_SP (sizeof(init_stack) + (unsigned long) &init_stack)
130 195
196
197#ifdef CONFIG_PPC32
131#define INIT_THREAD { \ 198#define INIT_THREAD { \
132 .ksp = INIT_SP, \ 199 .ksp = INIT_SP, \
133 .fs = KERNEL_DS, \ 200 .fs = KERNEL_DS, \
134 .pgdir = swapper_pg_dir, \ 201 .pgdir = swapper_pg_dir, \
135 .fpexc_mode = MSR_FE0 | MSR_FE1, \ 202 .fpexc_mode = MSR_FE0 | MSR_FE1, \
136} 203}
204#else
205#define INIT_THREAD { \
206 .ksp = INIT_SP, \
207 .regs = (struct pt_regs *)INIT_SP - 1, /* XXX bogus, I think */ \
208 .fs = KERNEL_DS, \
209 .fpr = {0}, \
210 .fpscr = 0, \
211 .fpexc_mode = MSR_FE0|MSR_FE1, \
212}
213#endif
137 214
138/* 215/*
139 * Return saved PC of a blocked thread. For now, this is the "user" PC 216 * Return saved PC of a blocked thread. For now, this is the "user" PC
140 */ 217 */
141#define thread_saved_pc(tsk) \ 218#define thread_saved_pc(tsk) \
142 ((tsk)->thread.regs? (tsk)->thread.regs->nip: 0) 219 ((tsk)->thread.regs? (tsk)->thread.regs->nip: 0)
143 220
144unsigned long get_wchan(struct task_struct *p); 221unsigned long get_wchan(struct task_struct *p);
145 222
146#define KSTK_EIP(tsk) ((tsk)->thread.regs? (tsk)->thread.regs->nip: 0) 223#define KSTK_EIP(tsk) ((tsk)->thread.regs? (tsk)->thread.regs->nip: 0)
147#define KSTK_ESP(tsk) ((tsk)->thread.regs? (tsk)->thread.regs->gpr[1]: 0) 224#define KSTK_ESP(tsk) ((tsk)->thread.regs? (tsk)->thread.regs->gpr[1]: 0)
148 225
149/* Get/set floating-point exception mode */ 226/* Get/set floating-point exception mode */
150#define GET_FPEXC_CTL(tsk, adr) get_fpexc_mode((tsk), (adr)) 227#define GET_FPEXC_CTL(tsk, adr) get_fpexc_mode((tsk), (adr))
151#define SET_FPEXC_CTL(tsk, val) set_fpexc_mode((tsk), (val)) 228#define SET_FPEXC_CTL(tsk, val) set_fpexc_mode((tsk), (val))
152 229
153extern int get_fpexc_mode(struct task_struct *tsk, unsigned long adr); 230extern int get_fpexc_mode(struct task_struct *tsk, unsigned long adr);
154extern int set_fpexc_mode(struct task_struct *tsk, unsigned int val); 231extern int set_fpexc_mode(struct task_struct *tsk, unsigned int val);
155 232
156static inline unsigned int __unpack_fe01(unsigned int msr_bits) 233static inline unsigned int __unpack_fe01(unsigned long msr_bits)
157{ 234{
158 return ((msr_bits & MSR_FE0) >> 10) | ((msr_bits & MSR_FE1) >> 8); 235 return ((msr_bits & MSR_FE0) >> 10) | ((msr_bits & MSR_FE1) >> 8);
159} 236}
160 237
161static inline unsigned int __pack_fe01(unsigned int fpmode) 238static inline unsigned long __pack_fe01(unsigned int fpmode)
162{ 239{
163 return ((fpmode << 10) & MSR_FE0) | ((fpmode << 8) & MSR_FE1); 240 return ((fpmode << 10) & MSR_FE0) | ((fpmode << 8) & MSR_FE1);
164} 241}
165 242
166/* in process.c - for early bootup debug -- Cort */ 243#ifdef CONFIG_PPC64
167int ll_printk(const char *, ...); 244#define cpu_relax() do { HMT_low(); HMT_medium(); barrier(); } while (0)
168void ll_puts(const char *); 245#else
169
170/* In misc.c */
171void _nmask_and_or_msr(unsigned long nmask, unsigned long or_val);
172
173#define have_of (_machine == _MACH_chrp || _machine == _MACH_Pmac)
174
175#define cpu_relax() barrier() 246#define cpu_relax() barrier()
247#endif
176 248
177/* 249/*
178 * Prefetch macros. 250 * Prefetch macros.
@@ -181,21 +253,28 @@ void _nmask_and_or_msr(unsigned long nmask, unsigned long or_val);
181#define ARCH_HAS_PREFETCHW 253#define ARCH_HAS_PREFETCHW
182#define ARCH_HAS_SPINLOCK_PREFETCH 254#define ARCH_HAS_SPINLOCK_PREFETCH
183 255
184extern inline void prefetch(const void *x) 256static inline void prefetch(const void *x)
185{ 257{
186 __asm__ __volatile__ ("dcbt 0,%0" : : "r" (x)); 258 if (unlikely(!x))
259 return;
260
261 __asm__ __volatile__ ("dcbt 0,%0" : : "r" (x));
187} 262}
188 263
189extern inline void prefetchw(const void *x) 264static inline void prefetchw(const void *x)
190{ 265{
191 __asm__ __volatile__ ("dcbtst 0,%0" : : "r" (x)); 266 if (unlikely(!x))
267 return;
268
269 __asm__ __volatile__ ("dcbtst 0,%0" : : "r" (x));
192} 270}
193 271
194#define spin_lock_prefetch(x) prefetchw(x) 272#define spin_lock_prefetch(x) prefetchw(x)
195 273
196extern int emulate_altivec(struct pt_regs *regs); 274#ifdef CONFIG_PPC64
197 275#define HAVE_ARCH_PICK_MMAP_LAYOUT
198#endif /* !__ASSEMBLY__ */ 276#endif
199 277
200#endif /* __ASM_PPC_PROCESSOR_H */
201#endif /* __KERNEL__ */ 278#endif /* __KERNEL__ */
279#endif /* __ASSEMBLY__ */
280#endif /* _ASM_POWERPC_PROCESSOR_H */
diff --git a/include/asm-powerpc/reg.h b/include/asm-powerpc/reg.h
index 1402a2dedffb..ff619630dff9 100644
--- a/include/asm-powerpc/reg.h
+++ b/include/asm-powerpc/reg.h
@@ -6,53 +6,95 @@
6 * Implementations of the PowerPC Architecture (a.k.a. Green Book) here. 6 * Implementations of the PowerPC Architecture (a.k.a. Green Book) here.
7 */ 7 */
8 8
9#ifndef _ASM_POWERPC_REGS_H 9#ifndef _ASM_POWERPC_REG_H
10#define _ASM_POWERPC_REGS_H 10#define _ASM_POWERPC_REG_H
11#ifdef __KERNEL__ 11#ifdef __KERNEL__
12 12
13#include <linux/stringify.h> 13#include <linux/stringify.h>
14#include <asm/cputable.h>
14 15
15/* Pickup Book E specific registers. */ 16/* Pickup Book E specific registers. */
16#if defined(CONFIG_BOOKE) || defined(CONFIG_40x) 17#if defined(CONFIG_BOOKE) || defined(CONFIG_40x)
17#include <asm/reg_booke.h> 18#include <asm/reg_booke.h>
18#endif 19#endif
19 20
20/* Machine State Register (MSR) Fields */ 21#define MSR_SF_LG 63 /* Enable 64 bit mode */
21#define MSR_SF (1<<63) 22#define MSR_ISF_LG 61 /* Interrupt 64b mode valid on 630 */
22#define MSR_ISF (1<<61) 23#define MSR_HV_LG 60 /* Hypervisor state */
23#define MSR_VEC (1<<25) /* Enable AltiVec */ 24#define MSR_VEC_LG 25 /* Enable AltiVec */
24#define MSR_POW (1<<18) /* Enable Power Management */ 25#define MSR_POW_LG 18 /* Enable Power Management */
25#define MSR_WE (1<<18) /* Wait State Enable */ 26#define MSR_WE_LG 18 /* Wait State Enable */
26#define MSR_TGPR (1<<17) /* TLB Update registers in use */ 27#define MSR_TGPR_LG 17 /* TLB Update registers in use */
27#define MSR_CE (1<<17) /* Critical Interrupt Enable */ 28#define MSR_CE_LG 17 /* Critical Interrupt Enable */
28#define MSR_ILE (1<<16) /* Interrupt Little Endian */ 29#define MSR_ILE_LG 16 /* Interrupt Little Endian */
29#define MSR_EE (1<<15) /* External Interrupt Enable */ 30#define MSR_EE_LG 15 /* External Interrupt Enable */
30#define MSR_PR (1<<14) /* Problem State / Privilege Level */ 31#define MSR_PR_LG 14 /* Problem State / Privilege Level */
31#define MSR_FP (1<<13) /* Floating Point enable */ 32#define MSR_FP_LG 13 /* Floating Point enable */
32#define MSR_ME (1<<12) /* Machine Check Enable */ 33#define MSR_ME_LG 12 /* Machine Check Enable */
33#define MSR_FE0 (1<<11) /* Floating Exception mode 0 */ 34#define MSR_FE0_LG 11 /* Floating Exception mode 0 */
34#define MSR_SE (1<<10) /* Single Step */ 35#define MSR_SE_LG 10 /* Single Step */
35#define MSR_BE (1<<9) /* Branch Trace */ 36#define MSR_BE_LG 9 /* Branch Trace */
36#define MSR_DE (1<<9) /* Debug Exception Enable */ 37#define MSR_DE_LG 9 /* Debug Exception Enable */
37#define MSR_FE1 (1<<8) /* Floating Exception mode 1 */ 38#define MSR_FE1_LG 8 /* Floating Exception mode 1 */
38#define MSR_IP (1<<6) /* Exception prefix 0x000/0xFFF */ 39#define MSR_IP_LG 6 /* Exception prefix 0x000/0xFFF */
39#define MSR_IR (1<<5) /* Instruction Relocate */ 40#define MSR_IR_LG 5 /* Instruction Relocate */
40#define MSR_DR (1<<4) /* Data Relocate */ 41#define MSR_DR_LG 4 /* Data Relocate */
41#define MSR_PE (1<<3) /* Protection Enable */ 42#define MSR_PE_LG 3 /* Protection Enable */
42#define MSR_PX (1<<2) /* Protection Exclusive Mode */ 43#define MSR_PX_LG 2 /* Protection Exclusive Mode */
43#define MSR_RI (1<<1) /* Recoverable Exception */ 44#define MSR_PMM_LG 2 /* Performance monitor */
44#define MSR_LE (1<<0) /* Little Endian */ 45#define MSR_RI_LG 1 /* Recoverable Exception */
46#define MSR_LE_LG 0 /* Little Endian */
45 47
48#ifdef __ASSEMBLY__
49#define __MASK(X) (1<<(X))
50#else
51#define __MASK(X) (1UL<<(X))
52#endif
53
54#define MSR_SF __MASK(MSR_SF_LG) /* Enable 64 bit mode */
55#define MSR_ISF __MASK(MSR_ISF_LG) /* Interrupt 64b mode valid on 630 */
56#define MSR_HV __MASK(MSR_HV_LG) /* Hypervisor state */
57#define MSR_VEC __MASK(MSR_VEC_LG) /* Enable AltiVec */
58#define MSR_POW __MASK(MSR_POW_LG) /* Enable Power Management */
59#define MSR_WE __MASK(MSR_WE_LG) /* Wait State Enable */
60#define MSR_TGPR __MASK(MSR_TGPR_LG) /* TLB Update registers in use */
61#define MSR_CE __MASK(MSR_CE_LG) /* Critical Interrupt Enable */
62#define MSR_ILE __MASK(MSR_ILE_LG) /* Interrupt Little Endian */
63#define MSR_EE __MASK(MSR_EE_LG) /* External Interrupt Enable */
64#define MSR_PR __MASK(MSR_PR_LG) /* Problem State / Privilege Level */
65#define MSR_FP __MASK(MSR_FP_LG) /* Floating Point enable */
66#define MSR_ME __MASK(MSR_ME_LG) /* Machine Check Enable */
67#define MSR_FE0 __MASK(MSR_FE0_LG) /* Floating Exception mode 0 */
68#define MSR_SE __MASK(MSR_SE_LG) /* Single Step */
69#define MSR_BE __MASK(MSR_BE_LG) /* Branch Trace */
70#define MSR_DE __MASK(MSR_DE_LG) /* Debug Exception Enable */
71#define MSR_FE1 __MASK(MSR_FE1_LG) /* Floating Exception mode 1 */
72#define MSR_IP __MASK(MSR_IP_LG) /* Exception prefix 0x000/0xFFF */
73#define MSR_IR __MASK(MSR_IR_LG) /* Instruction Relocate */
74#define MSR_DR __MASK(MSR_DR_LG) /* Data Relocate */
75#define MSR_PE __MASK(MSR_PE_LG) /* Protection Enable */
76#define MSR_PX __MASK(MSR_PX_LG) /* Protection Exclusive Mode */
77#define MSR_PMM __MASK(MSR_PMM_LG) /* Performance monitor */
78#define MSR_RI __MASK(MSR_RI_LG) /* Recoverable Exception */
79#define MSR_LE __MASK(MSR_LE_LG) /* Little Endian */
80
81#ifdef CONFIG_PPC64
82#define MSR_ MSR_ME | MSR_RI | MSR_IR | MSR_DR | MSR_ISF
83#define MSR_KERNEL MSR_ | MSR_SF | MSR_HV
84
85#define MSR_USER32 MSR_ | MSR_PR | MSR_EE
86#define MSR_USER64 MSR_USER32 | MSR_SF
87
88#else /* 32-bit */
46/* Default MSR for kernel mode. */ 89/* Default MSR for kernel mode. */
47#ifdef CONFIG_APUS_FAST_EXCEPT 90#ifdef CONFIG_APUS_FAST_EXCEPT
48#define MSR_KERNEL (MSR_ME|MSR_IP|MSR_RI|MSR_IR|MSR_DR) 91#define MSR_KERNEL (MSR_ME|MSR_IP|MSR_RI|MSR_IR|MSR_DR)
49#endif 92#else
50
51#ifndef MSR_KERNEL
52#define MSR_KERNEL (MSR_ME|MSR_RI|MSR_IR|MSR_DR) 93#define MSR_KERNEL (MSR_ME|MSR_RI|MSR_IR|MSR_DR)
53#endif 94#endif
54 95
55#define MSR_USER (MSR_KERNEL|MSR_PR|MSR_EE) 96#define MSR_USER (MSR_KERNEL|MSR_PR|MSR_EE)
97#endif
56 98
57/* Floating Point Status and Control Register (FPSCR) Fields */ 99/* Floating Point Status and Control Register (FPSCR) Fields */
58#define FPSCR_FX 0x80000000 /* FPU exception summary */ 100#define FPSCR_FX 0x80000000 /* FPU exception summary */
@@ -85,6 +127,9 @@
85 127
86/* Special Purpose Registers (SPRNs)*/ 128/* Special Purpose Registers (SPRNs)*/
87#define SPRN_CTR 0x009 /* Count Register */ 129#define SPRN_CTR 0x009 /* Count Register */
130#define SPRN_CTRLF 0x088
131#define SPRN_CTRLT 0x098
132#define CTRL_RUNLATCH 0x1
88#define SPRN_DABR 0x3F5 /* Data Address Breakpoint Register */ 133#define SPRN_DABR 0x3F5 /* Data Address Breakpoint Register */
89#define DABR_TRANSLATION (1UL << 2) 134#define DABR_TRANSLATION (1UL << 2)
90#define SPRN_DAR 0x013 /* Data Address Register */ 135#define SPRN_DAR 0x013 /* Data Address Register */
@@ -193,6 +238,16 @@
193#define SPRN_IABR 0x3F2 /* Instruction Address Breakpoint Register */ 238#define SPRN_IABR 0x3F2 /* Instruction Address Breakpoint Register */
194#define SPRN_HID4 0x3F4 /* 970 HID4 */ 239#define SPRN_HID4 0x3F4 /* 970 HID4 */
195#define SPRN_HID5 0x3F6 /* 970 HID5 */ 240#define SPRN_HID5 0x3F6 /* 970 HID5 */
241#define SPRN_HID6 0x3F9 /* BE HID 6 */
242#define HID6_LB (0x0F<<12) /* Concurrent Large Page Modes */
243#define HID6_DLP (1<<20) /* Disable all large page modes (4K only) */
244#define SPRN_TSCR 0x399 /* Thread switch control on BE */
245#define SPRN_TTR 0x39A /* Thread switch timeout on BE */
246#define TSCR_DEC_ENABLE 0x200000 /* Decrementer Interrupt */
247#define TSCR_EE_ENABLE 0x100000 /* External Interrupt */
248#define TSCR_EE_BOOST 0x080000 /* External Interrupt Boost */
249#define SPRN_TSC 0x3FD /* Thread switch control on others */
250#define SPRN_TST 0x3FC /* Thread switch timeout on others */
196#if !defined(SPRN_IAC1) && !defined(SPRN_IAC2) 251#if !defined(SPRN_IAC1) && !defined(SPRN_IAC2)
197#define SPRN_IAC1 0x3F4 /* Instruction Address Compare 1 */ 252#define SPRN_IAC1 0x3F4 /* Instruction Address Compare 1 */
198#define SPRN_IAC2 0x3F5 /* Instruction Address Compare 2 */ 253#define SPRN_IAC2 0x3F5 /* Instruction Address Compare 2 */
@@ -276,22 +331,18 @@
276#define L3CR_L3DO 0x00000040 /* L3 data only mode */ 331#define L3CR_L3DO 0x00000040 /* L3 data only mode */
277#define L3CR_PMEN 0x00000004 /* L3 private memory enable */ 332#define L3CR_PMEN 0x00000004 /* L3 private memory enable */
278#define L3CR_PMSIZ 0x00000001 /* L3 private memory size */ 333#define L3CR_PMSIZ 0x00000001 /* L3 private memory size */
334
279#define SPRN_MSSCR0 0x3f6 /* Memory Subsystem Control Register 0 */ 335#define SPRN_MSSCR0 0x3f6 /* Memory Subsystem Control Register 0 */
280#define SPRN_MSSSR0 0x3f7 /* Memory Subsystem Status Register 1 */ 336#define SPRN_MSSSR0 0x3f7 /* Memory Subsystem Status Register 1 */
281#define SPRN_LDSTCR 0x3f8 /* Load/Store control register */ 337#define SPRN_LDSTCR 0x3f8 /* Load/Store control register */
282#define SPRN_LDSTDB 0x3f4 /* */ 338#define SPRN_LDSTDB 0x3f4 /* */
283#define SPRN_LR 0x008 /* Link Register */ 339#define SPRN_LR 0x008 /* Link Register */
284#define SPRN_MMCR0 0x3B8 /* Monitor Mode Control Register 0 */
285#define SPRN_MMCR1 0x3BC /* Monitor Mode Control Register 1 */
286#ifndef SPRN_PIR 340#ifndef SPRN_PIR
287#define SPRN_PIR 0x3FF /* Processor Identification Register */ 341#define SPRN_PIR 0x3FF /* Processor Identification Register */
288#endif 342#endif
289#define SPRN_PMC1 0x3B9 /* Performance Counter Register 1 */
290#define SPRN_PMC2 0x3BA /* Performance Counter Register 2 */
291#define SPRN_PMC3 0x3BD /* Performance Counter Register 3 */
292#define SPRN_PMC4 0x3BE /* Performance Counter Register 4 */
293#define SPRN_PTEHI 0x3D5 /* 981 7450 PTE HI word (S/W TLB load) */ 343#define SPRN_PTEHI 0x3D5 /* 981 7450 PTE HI word (S/W TLB load) */
294#define SPRN_PTELO 0x3D6 /* 982 7450 PTE LO word (S/W TLB load) */ 344#define SPRN_PTELO 0x3D6 /* 982 7450 PTE LO word (S/W TLB load) */
345#define SPRN_PURR 0x135 /* Processor Utilization of Resources Reg */
295#define SPRN_PVR 0x11F /* Processor Version Register */ 346#define SPRN_PVR 0x11F /* Processor Version Register */
296#define SPRN_RPA 0x3D6 /* Required Physical Address Register */ 347#define SPRN_RPA 0x3D6 /* Required Physical Address Register */
297#define SPRN_SDA 0x3BF /* Sampled Data Address Register */ 348#define SPRN_SDA 0x3BF /* Sampled Data Address Register */
@@ -333,6 +384,52 @@
333#define SPRN_VRSAVE 0x100 /* Vector Register Save Register */ 384#define SPRN_VRSAVE 0x100 /* Vector Register Save Register */
334#define SPRN_XER 0x001 /* Fixed Point Exception Register */ 385#define SPRN_XER 0x001 /* Fixed Point Exception Register */
335 386
387/* Performance monitor SPRs */
388#ifdef CONFIG_PPC64
389#define SPRN_MMCR0 795
390#define MMCR0_FC 0x80000000UL /* freeze counters */
391#define MMCR0_FCS 0x40000000UL /* freeze in supervisor state */
392#define MMCR0_KERNEL_DISABLE MMCR0_FCS
393#define MMCR0_FCP 0x20000000UL /* freeze in problem state */
394#define MMCR0_PROBLEM_DISABLE MMCR0_FCP
395#define MMCR0_FCM1 0x10000000UL /* freeze counters while MSR mark = 1 */
396#define MMCR0_FCM0 0x08000000UL /* freeze counters while MSR mark = 0 */
397#define MMCR0_PMXE 0x04000000UL /* performance monitor exception enable */
398#define MMCR0_FCECE 0x02000000UL /* freeze ctrs on enabled cond or event */
399#define MMCR0_TBEE 0x00400000UL /* time base exception enable */
400#define MMCR0_PMC1CE 0x00008000UL /* PMC1 count enable*/
401#define MMCR0_PMCjCE 0x00004000UL /* PMCj count enable*/
402#define MMCR0_TRIGGER 0x00002000UL /* TRIGGER enable */
403#define MMCR0_PMAO 0x00000080UL /* performance monitor alert has occurred, set to 0 after handling exception */
404#define MMCR0_SHRFC 0x00000040UL /* SHRre freeze conditions between threads */
405#define MMCR0_FCTI 0x00000008UL /* freeze counters in tags inactive mode */
406#define MMCR0_FCTA 0x00000004UL /* freeze counters in tags active mode */
407#define MMCR0_FCWAIT 0x00000002UL /* freeze counter in WAIT state */
408#define MMCR0_FCHV 0x00000001UL /* freeze conditions in hypervisor mode */
409#define SPRN_MMCR1 798
410#define SPRN_MMCRA 0x312
411#define MMCRA_SIHV 0x10000000UL /* state of MSR HV when SIAR set */
412#define MMCRA_SIPR 0x08000000UL /* state of MSR PR when SIAR set */
413#define MMCRA_SAMPLE_ENABLE 0x00000001UL /* enable sampling */
414#define SPRN_PMC1 787
415#define SPRN_PMC2 788
416#define SPRN_PMC3 789
417#define SPRN_PMC4 790
418#define SPRN_PMC5 791
419#define SPRN_PMC6 792
420#define SPRN_PMC7 793
421#define SPRN_PMC8 794
422#define SPRN_SIAR 780
423#define SPRN_SDAR 781
424
425#else /* 32-bit */
426#define SPRN_MMCR0 0x3B8 /* Monitor Mode Control Register 0 */
427#define SPRN_MMCR1 0x3BC /* Monitor Mode Control Register 1 */
428#define SPRN_PMC1 0x3B9 /* Performance Counter Register 1 */
429#define SPRN_PMC2 0x3BA /* Performance Counter Register 2 */
430#define SPRN_PMC3 0x3BD /* Performance Counter Register 3 */
431#define SPRN_PMC4 0x3BE /* Performance Counter Register 4 */
432
336/* Bit definitions for MMCR0 and PMC1 / PMC2. */ 433/* Bit definitions for MMCR0 and PMC1 / PMC2. */
337#define MMCR0_PMC1_CYCLES (1 << 7) 434#define MMCR0_PMC1_CYCLES (1 << 7)
338#define MMCR0_PMC1_ICACHEMISS (5 << 7) 435#define MMCR0_PMC1_ICACHEMISS (5 << 7)
@@ -342,14 +439,15 @@
342#define MMCR0_PMC2_ITLB 0x7 439#define MMCR0_PMC2_ITLB 0x7
343#define MMCR0_PMC2_LOADMISSTIME 0x5 440#define MMCR0_PMC2_LOADMISSTIME 0x5
344#define MMCR0_PMXE (1 << 26) 441#define MMCR0_PMXE (1 << 26)
345 442#endif
346/* Processor Version Register */
347 443
348/* Processor Version Register (PVR) field extraction */ 444/* Processor Version Register (PVR) field extraction */
349 445
350#define PVR_VER(pvr) (((pvr) >> 16) & 0xFFFF) /* Version field */ 446#define PVR_VER(pvr) (((pvr) >> 16) & 0xFFFF) /* Version field */
351#define PVR_REV(pvr) (((pvr) >> 0) & 0xFFFF) /* Revison field */ 447#define PVR_REV(pvr) (((pvr) >> 0) & 0xFFFF) /* Revison field */
352 448
449#define __is_processor(pv) (PVR_VER(mfspr(SPRN_PVR)) == (pv))
450
353/* 451/*
354 * IBM has further subdivided the standard PowerPC 16-bit version and 452 * IBM has further subdivided the standard PowerPC 16-bit version and
355 * revision subfields of the PVR for the PowerPC 403s into the following: 453 * revision subfields of the PVR for the PowerPC 403s into the following:
@@ -405,42 +503,105 @@
405#define PVR_8245 0x80811014 503#define PVR_8245 0x80811014
406#define PVR_8260 PVR_8240 504#define PVR_8260 PVR_8240
407 505
408#if 0 506/* 64-bit processors */
409/* Segment Registers */ 507/* XXX the prefix should be PVR_, we'll do a global sweep to fix it one day */
410#define SR0 0 508#define PV_NORTHSTAR 0x0033
411#define SR1 1 509#define PV_PULSAR 0x0034
412#define SR2 2 510#define PV_POWER4 0x0035
413#define SR3 3 511#define PV_ICESTAR 0x0036
414#define SR4 4 512#define PV_SSTAR 0x0037
415#define SR5 5 513#define PV_POWER4p 0x0038
416#define SR6 6 514#define PV_970 0x0039
417#define SR7 7 515#define PV_POWER5 0x003A
418#define SR8 8 516#define PV_POWER5p 0x003B
419#define SR9 9 517#define PV_970FX 0x003C
420#define SR10 10 518#define PV_630 0x0040
421#define SR11 11 519#define PV_630p 0x0041
422#define SR12 12 520#define PV_970MP 0x0044
423#define SR13 13 521#define PV_BE 0x0070
424#define SR14 14 522
425#define SR15 15 523/*
426#endif 524 * Number of entries in the SLB. If this ever changes we should handle
525 * it with a use a cpu feature fixup.
526 */
527#define SLB_NUM_ENTRIES 64
427 528
428/* Macros for setting and retrieving special purpose registers */ 529/* Macros for setting and retrieving special purpose registers */
429#ifndef __ASSEMBLY__ 530#ifndef __ASSEMBLY__
430#define mfmsr() ({unsigned int rval; \ 531#define mfmsr() ({unsigned long rval; \
431 asm volatile("mfmsr %0" : "=r" (rval)); rval;}) 532 asm volatile("mfmsr %0" : "=r" (rval)); rval;})
533#ifdef CONFIG_PPC64
534#define __mtmsrd(v, l) asm volatile("mtmsrd %0," __stringify(l) \
535 : : "r" (v))
536#define mtmsrd(v) __mtmsrd((v), 0)
537#else
432#define mtmsr(v) asm volatile("mtmsr %0" : : "r" (v)) 538#define mtmsr(v) asm volatile("mtmsr %0" : : "r" (v))
539#endif
433 540
434#define mfspr(rn) ({unsigned int rval; \ 541#define mfspr(rn) ({unsigned long rval; \
435 asm volatile("mfspr %0," __stringify(rn) \ 542 asm volatile("mfspr %0," __stringify(rn) \
436 : "=r" (rval)); rval;}) 543 : "=r" (rval)); rval;})
437#define mtspr(rn, v) asm volatile("mtspr " __stringify(rn) ",%0" : : "r" (v)) 544#define mtspr(rn, v) asm volatile("mtspr " __stringify(rn) ",%0" : : "r" (v))
438 545
546#define mftb() ({unsigned long rval; \
547 asm volatile("mftb %0" : "=r" (rval)); rval;})
548#define mftbl() ({unsigned long rval; \
549 asm volatile("mftbl %0" : "=r" (rval)); rval;})
550
551#define mttbl(v) asm volatile("mttbl %0":: "r"(v))
552#define mttbu(v) asm volatile("mttbu %0":: "r"(v))
553
554#ifdef CONFIG_PPC32
439#define mfsrin(v) ({unsigned int rval; \ 555#define mfsrin(v) ({unsigned int rval; \
440 asm volatile("mfsrin %0,%1" : "=r" (rval) : "r" (v)); \ 556 asm volatile("mfsrin %0,%1" : "=r" (rval) : "r" (v)); \
441 rval;}) 557 rval;})
558#endif
442 559
443#define proc_trap() asm volatile("trap") 560#define proc_trap() asm volatile("trap")
561
562#ifdef CONFIG_PPC64
563static inline void ppc64_runlatch_on(void)
564{
565 unsigned long ctrl;
566
567 if (cpu_has_feature(CPU_FTR_CTRL)) {
568 ctrl = mfspr(SPRN_CTRLF);
569 ctrl |= CTRL_RUNLATCH;
570 mtspr(SPRN_CTRLT, ctrl);
571 }
572}
573
574static inline void ppc64_runlatch_off(void)
575{
576 unsigned long ctrl;
577
578 if (cpu_has_feature(CPU_FTR_CTRL)) {
579 ctrl = mfspr(SPRN_CTRLF);
580 ctrl &= ~CTRL_RUNLATCH;
581 mtspr(SPRN_CTRLT, ctrl);
582 }
583}
584
585static inline void set_tb(unsigned int upper, unsigned int lower)
586{
587 mttbl(0);
588 mttbu(upper);
589 mttbl(lower);
590}
591#endif
592
593#define __get_SP() ({unsigned long sp; \
594 asm volatile("mr %0,1": "=r" (sp)); sp;})
595
596#else /* __ASSEMBLY__ */
597
598#define RUNLATCH_ON(REG) \
599BEGIN_FTR_SECTION \
600 mfspr (REG),SPRN_CTRLF; \
601 ori (REG),(REG),CTRL_RUNLATCH; \
602 mtspr SPRN_CTRLT,(REG); \
603END_FTR_SECTION_IFSET(CPU_FTR_CTRL)
604
444#endif /* __ASSEMBLY__ */ 605#endif /* __ASSEMBLY__ */
445#endif /* __KERNEL__ */ 606#endif /* __KERNEL__ */
446#endif /* _ASM_POWERPC_REGS_H */ 607#endif /* _ASM_POWERPC_REG_H */
diff --git a/include/asm-ppc64/processor.h b/include/asm-ppc64/processor.h
deleted file mode 100644
index 6447fbee7d69..000000000000
--- a/include/asm-ppc64/processor.h
+++ /dev/null
@@ -1,567 +0,0 @@
1#ifndef __ASM_PPC64_PROCESSOR_H
2#define __ASM_PPC64_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/stringify.h>
14#ifndef __ASSEMBLY__
15#include <linux/config.h>
16#include <asm/atomic.h>
17#include <asm/ppcdebug.h>
18#include <asm/a.out.h>
19#endif
20#include <asm/ptrace.h>
21#include <asm/types.h>
22#include <asm/systemcfg.h>
23#include <asm/cputable.h>
24
25/* Machine State Register (MSR) Fields */
26#define MSR_SF_LG 63 /* Enable 64 bit mode */
27#define MSR_ISF_LG 61 /* Interrupt 64b mode valid on 630 */
28#define MSR_HV_LG 60 /* Hypervisor state */
29#define MSR_VEC_LG 25 /* Enable AltiVec */
30#define MSR_POW_LG 18 /* Enable Power Management */
31#define MSR_WE_LG 18 /* Wait State Enable */
32#define MSR_TGPR_LG 17 /* TLB Update registers in use */
33#define MSR_CE_LG 17 /* Critical Interrupt Enable */
34#define MSR_ILE_LG 16 /* Interrupt Little Endian */
35#define MSR_EE_LG 15 /* External Interrupt Enable */
36#define MSR_PR_LG 14 /* Problem State / Privilege Level */
37#define MSR_FP_LG 13 /* Floating Point enable */
38#define MSR_ME_LG 12 /* Machine Check Enable */
39#define MSR_FE0_LG 11 /* Floating Exception mode 0 */
40#define MSR_SE_LG 10 /* Single Step */
41#define MSR_BE_LG 9 /* Branch Trace */
42#define MSR_DE_LG 9 /* Debug Exception Enable */
43#define MSR_FE1_LG 8 /* Floating Exception mode 1 */
44#define MSR_IP_LG 6 /* Exception prefix 0x000/0xFFF */
45#define MSR_IR_LG 5 /* Instruction Relocate */
46#define MSR_DR_LG 4 /* Data Relocate */
47#define MSR_PE_LG 3 /* Protection Enable */
48#define MSR_PX_LG 2 /* Protection Exclusive Mode */
49#define MSR_PMM_LG 2 /* Performance monitor */
50#define MSR_RI_LG 1 /* Recoverable Exception */
51#define MSR_LE_LG 0 /* Little Endian */
52
53#ifdef __ASSEMBLY__
54#define __MASK(X) (1<<(X))
55#else
56#define __MASK(X) (1UL<<(X))
57#endif
58
59#define MSR_SF __MASK(MSR_SF_LG) /* Enable 64 bit mode */
60#define MSR_ISF __MASK(MSR_ISF_LG) /* Interrupt 64b mode valid on 630 */
61#define MSR_HV __MASK(MSR_HV_LG) /* Hypervisor state */
62#define MSR_VEC __MASK(MSR_VEC_LG) /* Enable AltiVec */
63#define MSR_POW __MASK(MSR_POW_LG) /* Enable Power Management */
64#define MSR_WE __MASK(MSR_WE_LG) /* Wait State Enable */
65#define MSR_TGPR __MASK(MSR_TGPR_LG) /* TLB Update registers in use */
66#define MSR_CE __MASK(MSR_CE_LG) /* Critical Interrupt Enable */
67#define MSR_ILE __MASK(MSR_ILE_LG) /* Interrupt Little Endian */
68#define MSR_EE __MASK(MSR_EE_LG) /* External Interrupt Enable */
69#define MSR_PR __MASK(MSR_PR_LG) /* Problem State / Privilege Level */
70#define MSR_FP __MASK(MSR_FP_LG) /* Floating Point enable */
71#define MSR_ME __MASK(MSR_ME_LG) /* Machine Check Enable */
72#define MSR_FE0 __MASK(MSR_FE0_LG) /* Floating Exception mode 0 */
73#define MSR_SE __MASK(MSR_SE_LG) /* Single Step */
74#define MSR_BE __MASK(MSR_BE_LG) /* Branch Trace */
75#define MSR_DE __MASK(MSR_DE_LG) /* Debug Exception Enable */
76#define MSR_FE1 __MASK(MSR_FE1_LG) /* Floating Exception mode 1 */
77#define MSR_IP __MASK(MSR_IP_LG) /* Exception prefix 0x000/0xFFF */
78#define MSR_IR __MASK(MSR_IR_LG) /* Instruction Relocate */
79#define MSR_DR __MASK(MSR_DR_LG) /* Data Relocate */
80#define MSR_PE __MASK(MSR_PE_LG) /* Protection Enable */
81#define MSR_PX __MASK(MSR_PX_LG) /* Protection Exclusive Mode */
82#define MSR_PMM __MASK(MSR_PMM_LG) /* Performance monitor */
83#define MSR_RI __MASK(MSR_RI_LG) /* Recoverable Exception */
84#define MSR_LE __MASK(MSR_LE_LG) /* Little Endian */
85
86#define MSR_ MSR_ME | MSR_RI | MSR_IR | MSR_DR | MSR_ISF
87#define MSR_KERNEL MSR_ | MSR_SF | MSR_HV
88
89#define MSR_USER32 MSR_ | MSR_PR | MSR_EE
90#define MSR_USER64 MSR_USER32 | MSR_SF
91
92/* Floating Point Status and Control Register (FPSCR) Fields */
93
94#define FPSCR_FX 0x80000000 /* FPU exception summary */
95#define FPSCR_FEX 0x40000000 /* FPU enabled exception summary */
96#define FPSCR_VX 0x20000000 /* Invalid operation summary */
97#define FPSCR_OX 0x10000000 /* Overflow exception summary */
98#define FPSCR_UX 0x08000000 /* Underflow exception summary */
99#define FPSCR_ZX 0x04000000 /* Zero-divide exception summary */
100#define FPSCR_XX 0x02000000 /* Inexact exception summary */
101#define FPSCR_VXSNAN 0x01000000 /* Invalid op for SNaN */
102#define FPSCR_VXISI 0x00800000 /* Invalid op for Inv - Inv */
103#define FPSCR_VXIDI 0x00400000 /* Invalid op for Inv / Inv */
104#define FPSCR_VXZDZ 0x00200000 /* Invalid op for Zero / Zero */
105#define FPSCR_VXIMZ 0x00100000 /* Invalid op for Inv * Zero */
106#define FPSCR_VXVC 0x00080000 /* Invalid op for Compare */
107#define FPSCR_FR 0x00040000 /* Fraction rounded */
108#define FPSCR_FI 0x00020000 /* Fraction inexact */
109#define FPSCR_FPRF 0x0001f000 /* FPU Result Flags */
110#define FPSCR_FPCC 0x0000f000 /* FPU Condition Codes */
111#define FPSCR_VXSOFT 0x00000400 /* Invalid op for software request */
112#define FPSCR_VXSQRT 0x00000200 /* Invalid op for square root */
113#define FPSCR_VXCVI 0x00000100 /* Invalid op for integer convert */
114#define FPSCR_VE 0x00000080 /* Invalid op exception enable */
115#define FPSCR_OE 0x00000040 /* IEEE overflow exception enable */
116#define FPSCR_UE 0x00000020 /* IEEE underflow exception enable */
117#define FPSCR_ZE 0x00000010 /* IEEE zero divide exception enable */
118#define FPSCR_XE 0x00000008 /* FP inexact exception enable */
119#define FPSCR_NI 0x00000004 /* FPU non IEEE-Mode */
120#define FPSCR_RN 0x00000003 /* FPU rounding control */
121
122/* Special Purpose Registers (SPRNs)*/
123
124#define SPRN_CTR 0x009 /* Count Register */
125#define SPRN_DABR 0x3F5 /* Data Address Breakpoint Register */
126#define DABR_TRANSLATION (1UL << 2)
127#define SPRN_DAR 0x013 /* Data Address Register */
128#define SPRN_DEC 0x016 /* Decrement Register */
129#define SPRN_DSISR 0x012 /* Data Storage Interrupt Status Register */
130#define DSISR_NOHPTE 0x40000000 /* no translation found */
131#define DSISR_PROTFAULT 0x08000000 /* protection fault */
132#define DSISR_ISSTORE 0x02000000 /* access was a store */
133#define DSISR_DABRMATCH 0x00400000 /* hit data breakpoint */
134#define DSISR_NOSEGMENT 0x00200000 /* STAB/SLB miss */
135#define SPRN_HID0 0x3F0 /* Hardware Implementation Register 0 */
136#define SPRN_MSRDORM 0x3F1 /* Hardware Implementation Register 1 */
137#define SPRN_HID1 0x3F1 /* Hardware Implementation Register 1 */
138#define SPRN_IABR 0x3F2 /* Instruction Address Breakpoint Register */
139#define SPRN_NIADORM 0x3F3 /* Hardware Implementation Register 2 */
140#define SPRN_HID4 0x3F4 /* 970 HID4 */
141#define SPRN_HID5 0x3F6 /* 970 HID5 */
142#define SPRN_HID6 0x3F9 /* BE HID 6 */
143#define HID6_LB (0x0F<<12) /* Concurrent Large Page Modes */
144#define HID6_DLP (1<<20) /* Disable all large page modes (4K only) */
145#define SPRN_TSCR 0x399 /* Thread switch control on BE */
146#define SPRN_TTR 0x39A /* Thread switch timeout on BE */
147#define TSCR_DEC_ENABLE 0x200000 /* Decrementer Interrupt */
148#define TSCR_EE_ENABLE 0x100000 /* External Interrupt */
149#define TSCR_EE_BOOST 0x080000 /* External Interrupt Boost */
150#define SPRN_TSC 0x3FD /* Thread switch control on others */
151#define SPRN_TST 0x3FC /* Thread switch timeout on others */
152#define SPRN_L2CR 0x3F9 /* Level 2 Cache Control Regsiter */
153#define SPRN_LR 0x008 /* Link Register */
154#define SPRN_PIR 0x3FF /* Processor Identification Register */
155#define SPRN_PIT 0x3DB /* Programmable Interval Timer */
156#define SPRN_PURR 0x135 /* Processor Utilization of Resources Register */
157#define SPRN_PVR 0x11F /* Processor Version Register */
158#define SPRN_RPA 0x3D6 /* Required Physical Address Register */
159#define SPRN_SDA 0x3BF /* Sampled Data Address Register */
160#define SPRN_SDR1 0x019 /* MMU Hash Base Register */
161#define SPRN_SIA 0x3BB /* Sampled Instruction Address Register */
162#define SPRN_SPRG0 0x110 /* Special Purpose Register General 0 */
163#define SPRN_SPRG1 0x111 /* Special Purpose Register General 1 */
164#define SPRN_SPRG2 0x112 /* Special Purpose Register General 2 */
165#define SPRN_SPRG3 0x113 /* Special Purpose Register General 3 */
166#define SPRN_SRR0 0x01A /* Save/Restore Register 0 */
167#define SPRN_SRR1 0x01B /* Save/Restore Register 1 */
168#define SPRN_TBRL 0x10C /* Time Base Read Lower Register (user, R/O) */
169#define SPRN_TBRU 0x10D /* Time Base Read Upper Register (user, R/O) */
170#define SPRN_TBWL 0x11C /* Time Base Lower Register (super, W/O) */
171#define SPRN_TBWU 0x11D /* Time Base Write Upper Register (super, W/O) */
172#define SPRN_HIOR 0x137 /* 970 Hypervisor interrupt offset */
173#define SPRN_USIA 0x3AB /* User Sampled Instruction Address Register */
174#define SPRN_XER 0x001 /* Fixed Point Exception Register */
175#define SPRN_VRSAVE 0x100 /* Vector save */
176#define SPRN_CTRLF 0x088
177#define SPRN_CTRLT 0x098
178#define CTRL_RUNLATCH 0x1
179
180/* Performance monitor SPRs */
181#define SPRN_SIAR 780
182#define SPRN_SDAR 781
183#define SPRN_MMCRA 786
184#define MMCRA_SIHV 0x10000000UL /* state of MSR HV when SIAR set */
185#define MMCRA_SIPR 0x08000000UL /* state of MSR PR when SIAR set */
186#define MMCRA_SAMPLE_ENABLE 0x00000001UL /* enable sampling */
187#define SPRN_PMC1 787
188#define SPRN_PMC2 788
189#define SPRN_PMC3 789
190#define SPRN_PMC4 790
191#define SPRN_PMC5 791
192#define SPRN_PMC6 792
193#define SPRN_PMC7 793
194#define SPRN_PMC8 794
195#define SPRN_MMCR0 795
196#define MMCR0_FC 0x80000000UL /* freeze counters. set to 1 on a perfmon exception */
197#define MMCR0_FCS 0x40000000UL /* freeze in supervisor state */
198#define MMCR0_KERNEL_DISABLE MMCR0_FCS
199#define MMCR0_FCP 0x20000000UL /* freeze in problem state */
200#define MMCR0_PROBLEM_DISABLE MMCR0_FCP
201#define MMCR0_FCM1 0x10000000UL /* freeze counters while MSR mark = 1 */
202#define MMCR0_FCM0 0x08000000UL /* freeze counters while MSR mark = 0 */
203#define MMCR0_PMXE 0x04000000UL /* performance monitor exception enable */
204#define MMCR0_FCECE 0x02000000UL /* freeze counters on enabled condition or event */
205/* time base exception enable */
206#define MMCR0_TBEE 0x00400000UL /* time base exception enable */
207#define MMCR0_PMC1CE 0x00008000UL /* PMC1 count enable*/
208#define MMCR0_PMCjCE 0x00004000UL /* PMCj count enable*/
209#define MMCR0_TRIGGER 0x00002000UL /* TRIGGER enable */
210#define MMCR0_PMAO 0x00000080UL /* performance monitor alert has occurred, set to 0 after handling exception */
211#define MMCR0_SHRFC 0x00000040UL /* SHRre freeze conditions between threads */
212#define MMCR0_FCTI 0x00000008UL /* freeze counters in tags inactive mode */
213#define MMCR0_FCTA 0x00000004UL /* freeze counters in tags active mode */
214#define MMCR0_FCWAIT 0x00000002UL /* freeze counter in WAIT state */
215#define MMCR0_FCHV 0x00000001UL /* freeze conditions in hypervisor mode */
216#define SPRN_MMCR1 798
217
218/* Short-hand versions for a number of the above SPRNs */
219
220#define CTR SPRN_CTR /* Counter Register */
221#define DAR SPRN_DAR /* Data Address Register */
222#define DABR SPRN_DABR /* Data Address Breakpoint Register */
223#define DEC SPRN_DEC /* Decrement Register */
224#define DSISR SPRN_DSISR /* Data Storage Interrupt Status Register */
225#define HID0 SPRN_HID0 /* Hardware Implementation Register 0 */
226#define MSRDORM SPRN_MSRDORM /* MSR Dormant Register */
227#define NIADORM SPRN_NIADORM /* NIA Dormant Register */
228#define TSC SPRN_TSC /* Thread switch control */
229#define TST SPRN_TST /* Thread switch timeout */
230#define IABR SPRN_IABR /* Instruction Address Breakpoint Register */
231#define L2CR SPRN_L2CR /* PPC 750 L2 control register */
232#define __LR SPRN_LR
233#define PVR SPRN_PVR /* Processor Version */
234#define PIR SPRN_PIR /* Processor ID */
235#define PURR SPRN_PURR /* Processor Utilization of Resource Register */
236#define SDR1 SPRN_SDR1 /* MMU hash base register */
237#define SPR0 SPRN_SPRG0 /* Supervisor Private Registers */
238#define SPR1 SPRN_SPRG1
239#define SPR2 SPRN_SPRG2
240#define SPR3 SPRN_SPRG3
241#define SPRG0 SPRN_SPRG0
242#define SPRG1 SPRN_SPRG1
243#define SPRG2 SPRN_SPRG2
244#define SPRG3 SPRN_SPRG3
245#define SRR0 SPRN_SRR0 /* Save and Restore Register 0 */
246#define SRR1 SPRN_SRR1 /* Save and Restore Register 1 */
247#define TBRL SPRN_TBRL /* Time Base Read Lower Register */
248#define TBRU SPRN_TBRU /* Time Base Read Upper Register */
249#define TBWL SPRN_TBWL /* Time Base Write Lower Register */
250#define TBWU SPRN_TBWU /* Time Base Write Upper Register */
251#define XER SPRN_XER
252
253/* Processor Version Register (PVR) field extraction */
254
255#define PVR_VER(pvr) (((pvr) >> 16) & 0xFFFF) /* Version field */
256#define PVR_REV(pvr) (((pvr) >> 0) & 0xFFFF) /* Revison field */
257
258/* Processor Version Numbers */
259#define PV_NORTHSTAR 0x0033
260#define PV_PULSAR 0x0034
261#define PV_POWER4 0x0035
262#define PV_ICESTAR 0x0036
263#define PV_SSTAR 0x0037
264#define PV_POWER4p 0x0038
265#define PV_970 0x0039
266#define PV_POWER5 0x003A
267#define PV_POWER5p 0x003B
268#define PV_970FX 0x003C
269#define PV_630 0x0040
270#define PV_630p 0x0041
271#define PV_970MP 0x0044
272#define PV_BE 0x0070
273
274/* Platforms supported by PPC64 */
275#define PLATFORM_PSERIES 0x0100
276#define PLATFORM_PSERIES_LPAR 0x0101
277#define PLATFORM_ISERIES_LPAR 0x0201
278#define PLATFORM_LPAR 0x0001
279#define PLATFORM_POWERMAC 0x0400
280#define PLATFORM_MAPLE 0x0500
281#define PLATFORM_BPA 0x1000
282
283/* Compatibility with drivers coming from PPC32 world */
284#define _machine (systemcfg->platform)
285#define _MACH_Pmac PLATFORM_POWERMAC
286
287/*
288 * List of interrupt controllers.
289 */
290#define IC_INVALID 0
291#define IC_OPEN_PIC 1
292#define IC_PPC_XIC 2
293#define IC_BPA_IIC 3
294#define IC_ISERIES 4
295
296#define XGLUE(a,b) a##b
297#define GLUE(a,b) XGLUE(a,b)
298
299#ifdef __ASSEMBLY__
300
301#define _GLOBAL(name) \
302 .section ".text"; \
303 .align 2 ; \
304 .globl name; \
305 .globl GLUE(.,name); \
306 .section ".opd","aw"; \
307name: \
308 .quad GLUE(.,name); \
309 .quad .TOC.@tocbase; \
310 .quad 0; \
311 .previous; \
312 .type GLUE(.,name),@function; \
313GLUE(.,name):
314
315#define _KPROBE(name) \
316 .section ".kprobes.text","a"; \
317 .align 2 ; \
318 .globl name; \
319 .globl GLUE(.,name); \
320 .section ".opd","aw"; \
321name: \
322 .quad GLUE(.,name); \
323 .quad .TOC.@tocbase; \
324 .quad 0; \
325 .previous; \
326 .type GLUE(.,name),@function; \
327GLUE(.,name):
328
329#define _STATIC(name) \
330 .section ".text"; \
331 .align 2 ; \
332 .section ".opd","aw"; \
333name: \
334 .quad GLUE(.,name); \
335 .quad .TOC.@tocbase; \
336 .quad 0; \
337 .previous; \
338 .type GLUE(.,name),@function; \
339GLUE(.,name):
340
341#else /* __ASSEMBLY__ */
342
343/*
344 * Default implementation of macro that returns current
345 * instruction pointer ("program counter").
346 */
347#define current_text_addr() ({ __label__ _l; _l: &&_l;})
348
349/* Macros for setting and retrieving special purpose registers */
350
351#define mfmsr() ({unsigned long rval; \
352 asm volatile("mfmsr %0" : "=r" (rval)); rval;})
353
354#define __mtmsrd(v, l) asm volatile("mtmsrd %0," __stringify(l) \
355 : : "r" (v))
356#define mtmsrd(v) __mtmsrd((v), 0)
357
358#define mfspr(rn) ({unsigned long rval; \
359 asm volatile("mfspr %0," __stringify(rn) \
360 : "=r" (rval)); rval;})
361#define mtspr(rn, v) asm volatile("mtspr " __stringify(rn) ",%0" : : "r" (v))
362
363#define mftb() ({unsigned long rval; \
364 asm volatile("mftb %0" : "=r" (rval)); rval;})
365
366#define mttbl(v) asm volatile("mttbl %0":: "r"(v))
367#define mttbu(v) asm volatile("mttbu %0":: "r"(v))
368
369#define mfasr() ({unsigned long rval; \
370 asm volatile("mfasr %0" : "=r" (rval)); rval;})
371
372/* Macros for adjusting thread priority (hardware multi-threading) */
373#define HMT_very_low() asm volatile("or 31,31,31 # very low priority")
374#define HMT_low() asm volatile("or 1,1,1 # low priority")
375#define HMT_medium_low() asm volatile("or 6,6,6 # medium low priority")
376#define HMT_medium() asm volatile("or 2,2,2 # medium priority")
377#define HMT_medium_high() asm volatile("or 5,5,5 # medium high priority")
378#define HMT_high() asm volatile("or 3,3,3 # high priority")
379
380static inline void set_tb(unsigned int upper, unsigned int lower)
381{
382 mttbl(0);
383 mttbu(upper);
384 mttbl(lower);
385}
386
387#define __get_SP() ({unsigned long sp; \
388 asm volatile("mr %0,1": "=r" (sp)); sp;})
389
390#ifdef __KERNEL__
391
392extern int have_of;
393extern u64 ppc64_interrupt_controller;
394
395struct task_struct;
396void start_thread(struct pt_regs *regs, unsigned long fdptr, unsigned long sp);
397void release_thread(struct task_struct *);
398
399/* Prepare to copy thread state - unlazy all lazy status */
400extern void prepare_to_copy(struct task_struct *tsk);
401
402/* Create a new kernel thread. */
403extern long kernel_thread(int (*fn)(void *), void *arg, unsigned long flags);
404
405/* Lazy FPU handling on uni-processor */
406extern struct task_struct *last_task_used_math;
407extern struct task_struct *last_task_used_altivec;
408
409/* 64-bit user address space is 44-bits (16TB user VM) */
410#define TASK_SIZE_USER64 (0x0000100000000000UL)
411
412/*
413 * 32-bit user address space is 4GB - 1 page
414 * (this 1 page is needed so referencing of 0xFFFFFFFF generates EFAULT
415 */
416#define TASK_SIZE_USER32 (0x0000000100000000UL - (1*PAGE_SIZE))
417
418#define TASK_SIZE (test_thread_flag(TIF_32BIT) ? \
419 TASK_SIZE_USER32 : TASK_SIZE_USER64)
420
421/* This decides where the kernel will search for a free chunk of vm
422 * space during mmap's.
423 */
424#define TASK_UNMAPPED_BASE_USER32 (PAGE_ALIGN(TASK_SIZE_USER32 / 4))
425#define TASK_UNMAPPED_BASE_USER64 (PAGE_ALIGN(TASK_SIZE_USER64 / 4))
426
427#define TASK_UNMAPPED_BASE ((test_thread_flag(TIF_32BIT)||(ppcdebugset(PPCDBG_BINFMT_32ADDR))) ? \
428 TASK_UNMAPPED_BASE_USER32 : TASK_UNMAPPED_BASE_USER64 )
429
430typedef struct {
431 unsigned long seg;
432} mm_segment_t;
433
434struct thread_struct {
435 unsigned long ksp; /* Kernel stack pointer */
436 unsigned long ksp_vsid;
437 struct pt_regs *regs; /* Pointer to saved register state */
438 mm_segment_t fs; /* for get_fs() validation */
439 double fpr[32]; /* Complete floating point set */
440 unsigned long fpscr; /* Floating point status (plus pad) */
441 unsigned long fpexc_mode; /* Floating-point exception mode */
442 unsigned long start_tb; /* Start purr when proc switched in */
443 unsigned long accum_tb; /* Total accumilated purr for process */
444 unsigned long vdso_base; /* base of the vDSO library */
445 unsigned long dabr; /* Data address breakpoint register */
446#ifdef CONFIG_ALTIVEC
447 /* Complete AltiVec register set */
448 vector128 vr[32] __attribute((aligned(16)));
449 /* AltiVec status */
450 vector128 vscr __attribute((aligned(16)));
451 unsigned long vrsave;
452 int used_vr; /* set if process has used altivec */
453#endif /* CONFIG_ALTIVEC */
454};
455
456#define ARCH_MIN_TASKALIGN 16
457
458#define INIT_SP (sizeof(init_stack) + (unsigned long) &init_stack)
459
460#define INIT_THREAD { \
461 .ksp = INIT_SP, \
462 .regs = (struct pt_regs *)INIT_SP - 1, \
463 .fs = KERNEL_DS, \
464 .fpr = {0}, \
465 .fpscr = 0, \
466 .fpexc_mode = MSR_FE0|MSR_FE1, \
467}
468
469/*
470 * Return saved PC of a blocked thread. For now, this is the "user" PC
471 */
472#define thread_saved_pc(tsk) \
473 ((tsk)->thread.regs? (tsk)->thread.regs->nip: 0)
474
475unsigned long get_wchan(struct task_struct *p);
476
477#define KSTK_EIP(tsk) ((tsk)->thread.regs? (tsk)->thread.regs->nip: 0)
478#define KSTK_ESP(tsk) ((tsk)->thread.regs? (tsk)->thread.regs->gpr[1]: 0)
479
480/* Get/set floating-point exception mode */
481#define GET_FPEXC_CTL(tsk, adr) get_fpexc_mode((tsk), (adr))
482#define SET_FPEXC_CTL(tsk, val) set_fpexc_mode((tsk), (val))
483
484extern int get_fpexc_mode(struct task_struct *tsk, unsigned long adr);
485extern int set_fpexc_mode(struct task_struct *tsk, unsigned int val);
486
487static inline unsigned int __unpack_fe01(unsigned long msr_bits)
488{
489 return ((msr_bits & MSR_FE0) >> 10) | ((msr_bits & MSR_FE1) >> 8);
490}
491
492static inline unsigned long __pack_fe01(unsigned int fpmode)
493{
494 return ((fpmode << 10) & MSR_FE0) | ((fpmode << 8) & MSR_FE1);
495}
496
497#define cpu_relax() do { HMT_low(); HMT_medium(); barrier(); } while (0)
498
499/*
500 * Prefetch macros.
501 */
502#define ARCH_HAS_PREFETCH
503#define ARCH_HAS_PREFETCHW
504#define ARCH_HAS_SPINLOCK_PREFETCH
505
506static inline void prefetch(const void *x)
507{
508 if (unlikely(!x))
509 return;
510
511 __asm__ __volatile__ ("dcbt 0,%0" : : "r" (x));
512}
513
514static inline void prefetchw(const void *x)
515{
516 if (unlikely(!x))
517 return;
518
519 __asm__ __volatile__ ("dcbtst 0,%0" : : "r" (x));
520}
521
522#define spin_lock_prefetch(x) prefetchw(x)
523
524#define HAVE_ARCH_PICK_MMAP_LAYOUT
525
526static inline void ppc64_runlatch_on(void)
527{
528 unsigned long ctrl;
529
530 if (cpu_has_feature(CPU_FTR_CTRL)) {
531 ctrl = mfspr(SPRN_CTRLF);
532 ctrl |= CTRL_RUNLATCH;
533 mtspr(SPRN_CTRLT, ctrl);
534 }
535}
536
537static inline void ppc64_runlatch_off(void)
538{
539 unsigned long ctrl;
540
541 if (cpu_has_feature(CPU_FTR_CTRL)) {
542 ctrl = mfspr(SPRN_CTRLF);
543 ctrl &= ~CTRL_RUNLATCH;
544 mtspr(SPRN_CTRLT, ctrl);
545 }
546}
547
548#endif /* __KERNEL__ */
549
550#endif /* __ASSEMBLY__ */
551
552#ifdef __KERNEL__
553#define RUNLATCH_ON(REG) \
554BEGIN_FTR_SECTION \
555 mfspr (REG),SPRN_CTRLF; \
556 ori (REG),(REG),CTRL_RUNLATCH; \
557 mtspr SPRN_CTRLT,(REG); \
558END_FTR_SECTION_IFSET(CPU_FTR_CTRL)
559#endif
560
561/*
562 * Number of entries in the SLB. If this ever changes we should handle
563 * it with a use a cpu feature fixup.
564 */
565#define SLB_NUM_ENTRIES 64
566
567#endif /* __ASM_PPC64_PROCESSOR_H */
diff --git a/include/asm-ppc64/system.h b/include/asm-ppc64/system.h
index 1fbdc9f0590c..c04d62c592a6 100644
--- a/include/asm-ppc64/system.h
+++ b/include/asm-ppc64/system.h
@@ -144,13 +144,6 @@ struct thread_struct;
144extern struct task_struct * _switch(struct thread_struct *prev, 144extern struct task_struct * _switch(struct thread_struct *prev,
145 struct thread_struct *next); 145 struct thread_struct *next);
146 146
147static inline int __is_processor(unsigned long pv)
148{
149 unsigned long pvr;
150 asm("mfspr %0, 0x11F" : "=r" (pvr));
151 return(PVR_VER(pvr) == pv);
152}
153
154/* 147/*
155 * Atomic exchange 148 * Atomic exchange
156 * 149 *