]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blob - include/asm-powerpc/processor.h
[PATCH] powerpc: merge code values for identifying platforms
[linux-2.6-omap-h63xx.git] / include / asm-powerpc / processor.h
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
21 /* We do _not_ want to define new machine types at all, those must die
22  * in favor of using the device-tree
23  * -- BenH.
24  */
25
26 /* Platforms codes (to be obsoleted) */
27 #define PLATFORM_PSERIES        0x0100
28 #define PLATFORM_PSERIES_LPAR   0x0101
29 #define PLATFORM_ISERIES_LPAR   0x0201
30 #define PLATFORM_LPAR           0x0001
31 #define PLATFORM_POWERMAC       0x0400
32 #define PLATFORM_MAPLE          0x0500
33 #define PLATFORM_PREP           0x0600
34 #define PLATFORM_CHRP           0x0700
35 #define PLATFORM_CELL           0x1000
36
37 /* Compat platform codes for 32 bits */
38 #define _MACH_prep      PLATFORM_PREP
39 #define _MACH_Pmac      PLATFORM_POWERMAC
40 #define _MACH_chrp      PLATFORM_CHRP
41
42 /* PREP sub-platform types see residual.h for these */
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
48 /* CHRP sub-platform types. These are arbitrary */
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 */
52
53 #define platform_is_pseries()   (_machine == PLATFORM_PSERIES || \
54                                  _machine == PLATFORM_PSERIES_LPAR)
55 #define platform_is_lpar()      (!!(_machine & PLATFORM_LPAR))
56
57 #if defined(CONFIG_PPC_MULTIPLATFORM)
58 extern int _machine;
59
60 #ifdef CONFIG_PPC32
61
62 /* what kind of prep workstation we are */
63 extern int _prep_type;
64 extern int _chrp_type;
65
66 /*
67  * This is used to identify the board type from a given PReP board
68  * vendor. Board revision is also made available. This will be moved
69  * elsewhere soon
70  */
71 extern unsigned char ucSystemType;
72 extern unsigned char ucBoardRev;
73 extern unsigned char ucBoardRevMaj, ucBoardRevMin;
74
75 #endif /* CONFIG_PPC32 */
76
77 #elif defined(CONFIG_PPC_ISERIES)
78 /*
79  * iSeries is soon to become MULTIPLATFORM hopefully ...
80  */
81 #define _machine CONFIG_PPC_ISERIES_LPAR
82 #else
83 #define _machine 0
84 #endif /* CONFIG_PPC_MULTIPLATFORM */
85
86
87
88
89 /*
90  * Default implementation of macro that returns current
91  * instruction pointer ("program counter").
92  */
93 #define current_text_addr() ({ __label__ _l; _l: &&_l;})
94
95 /* Macros for adjusting thread priority (hardware multi-threading) */
96 #define HMT_very_low()   asm volatile("or 31,31,31   # very low priority")
97 #define HMT_low()        asm volatile("or 1,1,1      # low priority")
98 #define HMT_medium_low() asm volatile("or 6,6,6      # medium low priority")
99 #define HMT_medium()     asm volatile("or 2,2,2      # medium priority")
100 #define HMT_medium_high() asm volatile("or 5,5,5      # medium high priority")
101 #define HMT_high()       asm volatile("or 3,3,3      # high priority")
102
103 #ifdef __KERNEL__
104
105 extern int have_of;
106
107 struct task_struct;
108 void start_thread(struct pt_regs *regs, unsigned long fdptr, unsigned long sp);
109 void release_thread(struct task_struct *);
110
111 /* Prepare to copy thread state - unlazy all lazy status */
112 extern void prepare_to_copy(struct task_struct *tsk);
113
114 /* Create a new kernel thread. */
115 extern long kernel_thread(int (*fn)(void *), void *arg, unsigned long flags);
116
117 /* Lazy FPU handling on uni-processor */
118 extern struct task_struct *last_task_used_math;
119 extern struct task_struct *last_task_used_altivec;
120 extern struct task_struct *last_task_used_spe;
121
122 #ifdef CONFIG_PPC32
123 #define TASK_SIZE       (CONFIG_TASK_SIZE)
124
125 /* This decides where the kernel will search for a free chunk of vm
126  * space during mmap's.
127  */
128 #define TASK_UNMAPPED_BASE      (TASK_SIZE / 8 * 3)
129 #endif
130
131 #ifdef CONFIG_PPC64
132 /* 64-bit user address space is 44-bits (16TB user VM) */
133 #define TASK_SIZE_USER64 (0x0000100000000000UL)
134
135 /* 
136  * 32-bit user address space is 4GB - 1 page 
137  * (this 1 page is needed so referencing of 0xFFFFFFFF generates EFAULT
138  */
139 #define TASK_SIZE_USER32 (0x0000000100000000UL - (1*PAGE_SIZE))
140
141 #define TASK_SIZE (test_thread_flag(TIF_32BIT) ? \
142                 TASK_SIZE_USER32 : TASK_SIZE_USER64)
143
144 /* This decides where the kernel will search for a free chunk of vm
145  * space during mmap's.
146  */
147 #define TASK_UNMAPPED_BASE_USER32 (PAGE_ALIGN(TASK_SIZE_USER32 / 4))
148 #define TASK_UNMAPPED_BASE_USER64 (PAGE_ALIGN(TASK_SIZE_USER64 / 4))
149
150 #define TASK_UNMAPPED_BASE ((test_thread_flag(TIF_32BIT)) ? \
151                 TASK_UNMAPPED_BASE_USER32 : TASK_UNMAPPED_BASE_USER64 )
152 #endif
153
154 typedef struct {
155         unsigned long seg;
156 } mm_segment_t;
157
158 struct thread_struct {
159         unsigned long   ksp;            /* Kernel stack pointer */
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 */
165 #ifdef CONFIG_PPC32
166         void            *pgdir;         /* root of page-table tree */
167         signed long     last_syscall;
168 #endif
169 #if defined(CONFIG_4xx) || defined (CONFIG_BOOKE)
170         unsigned long   dbcr0;          /* debug control register values */
171         unsigned long   dbcr1;
172 #endif
173         double          fpr[32];        /* Complete floating point set */
174         struct {                        /* fpr ... fpscr must be contiguous */
175
176                 unsigned int pad;
177                 unsigned int val;       /* Floating point status */
178         } fpscr;
179         int             fpexc_mode;     /* floating-point exception mode */
180 #ifdef CONFIG_PPC64
181         unsigned long   start_tb;       /* Start purr when proc switched in */
182         unsigned long   accum_tb;       /* Total accumilated purr for process */
183         unsigned long   vdso_base;      /* base of the vDSO library */
184 #endif
185         unsigned long   dabr;           /* Data address breakpoint register */
186 #ifdef CONFIG_ALTIVEC
187         /* Complete AltiVec register set */
188         vector128       vr[32] __attribute((aligned(16)));
189         /* AltiVec status */
190         vector128       vscr __attribute((aligned(16)));
191         unsigned long   vrsave;
192         int             used_vr;        /* set if process has used altivec */
193 #endif /* CONFIG_ALTIVEC */
194 #ifdef CONFIG_SPE
195         unsigned long   evr[32];        /* upper 32-bits of SPE regs */
196         u64             acc;            /* Accumulator */
197         unsigned long   spefscr;        /* SPE & eFP status */
198         int             used_spe;       /* set if process has used spe */
199 #endif /* CONFIG_SPE */
200 };
201
202 #define ARCH_MIN_TASKALIGN 16
203
204 #define INIT_SP         (sizeof(init_stack) + (unsigned long) &init_stack)
205
206
207 #ifdef CONFIG_PPC32
208 #define INIT_THREAD { \
209         .ksp = INIT_SP, \
210         .fs = KERNEL_DS, \
211         .pgdir = swapper_pg_dir, \
212         .fpexc_mode = MSR_FE0 | MSR_FE1, \
213 }
214 #else
215 #define INIT_THREAD  { \
216         .ksp = INIT_SP, \
217         .regs = (struct pt_regs *)INIT_SP - 1, /* XXX bogus, I think */ \
218         .fs = KERNEL_DS, \
219         .fpr = {0}, \
220         .fpscr = { .val = 0, }, \
221         .fpexc_mode = MSR_FE0|MSR_FE1, \
222 }
223 #endif
224
225 /*
226  * Return saved PC of a blocked thread. For now, this is the "user" PC
227  */
228 #define thread_saved_pc(tsk)    \
229         ((tsk)->thread.regs? (tsk)->thread.regs->nip: 0)
230
231 unsigned long get_wchan(struct task_struct *p);
232
233 #define KSTK_EIP(tsk)  ((tsk)->thread.regs? (tsk)->thread.regs->nip: 0)
234 #define KSTK_ESP(tsk)  ((tsk)->thread.regs? (tsk)->thread.regs->gpr[1]: 0)
235
236 /* Get/set floating-point exception mode */
237 #define GET_FPEXC_CTL(tsk, adr) get_fpexc_mode((tsk), (adr))
238 #define SET_FPEXC_CTL(tsk, val) set_fpexc_mode((tsk), (val))
239
240 extern int get_fpexc_mode(struct task_struct *tsk, unsigned long adr);
241 extern int set_fpexc_mode(struct task_struct *tsk, unsigned int val);
242
243 static inline unsigned int __unpack_fe01(unsigned long msr_bits)
244 {
245         return ((msr_bits & MSR_FE0) >> 10) | ((msr_bits & MSR_FE1) >> 8);
246 }
247
248 static inline unsigned long __pack_fe01(unsigned int fpmode)
249 {
250         return ((fpmode << 10) & MSR_FE0) | ((fpmode << 8) & MSR_FE1);
251 }
252
253 #ifdef CONFIG_PPC64
254 #define cpu_relax()     do { HMT_low(); HMT_medium(); barrier(); } while (0)
255 #else
256 #define cpu_relax()     barrier()
257 #endif
258
259 /*
260  * Prefetch macros.
261  */
262 #define ARCH_HAS_PREFETCH
263 #define ARCH_HAS_PREFETCHW
264 #define ARCH_HAS_SPINLOCK_PREFETCH
265
266 static inline void prefetch(const void *x)
267 {
268         if (unlikely(!x))
269                 return;
270
271         __asm__ __volatile__ ("dcbt 0,%0" : : "r" (x));
272 }
273
274 static inline void prefetchw(const void *x)
275 {
276         if (unlikely(!x))
277                 return;
278
279         __asm__ __volatile__ ("dcbtst 0,%0" : : "r" (x));
280 }
281
282 #define spin_lock_prefetch(x)   prefetchw(x)
283
284 #ifdef CONFIG_PPC64
285 #define HAVE_ARCH_PICK_MMAP_LAYOUT
286 #endif
287
288 #endif /* __KERNEL__ */
289 #endif /* __ASSEMBLY__ */
290 #endif /* _ASM_POWERPC_PROCESSOR_H */