powerpc: Merge asm/unistd.h
[linux-2.6/verdex.git] / include / asm-powerpc / processor.h
blob9592f533e0580a46d2e0c43b172d4ffbf147f9cb
1 #ifndef _ASM_POWERPC_PROCESSOR_H
2 #define _ASM_POWERPC_PROCESSOR_H
4 /*
5 * Copyright (C) 2001 PPC 64 Team, IBM Corp
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.
13 #include <linux/config.h>
14 #include <asm/reg.h>
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
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
31 #define _MACH_prep 0x00000001
32 #define _MACH_Pmac 0x00000002 /* pmac or pmac clone (non-chrp) */
33 #define _MACH_chrp 0x00000004 /* chrp machine */
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 */
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 */
46 #ifdef CONFIG_PPC_MULTIPLATFORM
47 extern int _machine;
49 /* what kind of prep workstation we are */
50 extern int _prep_type;
51 extern int _chrp_type;
54 * This is used to identify the board type from a given PReP board
55 * vendor. Board revision is also made available.
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 */
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
75 /* Compatibility with drivers coming from PPC32 world */
76 #define _machine (systemcfg->platform)
77 #define _MACH_Pmac PLATFORM_POWERMAC
78 #endif
81 * Default implementation of macro that returns current
82 * instruction pointer ("program counter").
84 #define current_text_addr() ({ __label__ _l; _l: &&_l;})
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")
94 #ifdef __KERNEL__
96 extern int have_of;
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 *);
102 /* Prepare to copy thread state - unlazy all lazy status */
103 extern void prepare_to_copy(struct task_struct *tsk);
105 /* Create a new kernel thread. */
106 extern long kernel_thread(int (*fn)(void *), void *arg, unsigned long flags);
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;
113 #ifdef CONFIG_PPC32
114 #define TASK_SIZE (CONFIG_TASK_SIZE)
116 /* This decides where the kernel will search for a free chunk of vm
117 * space during mmap's.
119 #define TASK_UNMAPPED_BASE (TASK_SIZE / 8 * 3)
120 #endif
122 #ifdef CONFIG_PPC64
123 /* 64-bit user address space is 44-bits (16TB user VM) */
124 #define TASK_SIZE_USER64 (0x0000100000000000UL)
127 * 32-bit user address space is 4GB - 1 page
128 * (this 1 page is needed so referencing of 0xFFFFFFFF generates EFAULT
130 #define TASK_SIZE_USER32 (0x0000000100000000UL - (1*PAGE_SIZE))
132 #define TASK_SIZE (test_thread_flag(TIF_32BIT) ? \
133 TASK_SIZE_USER32 : TASK_SIZE_USER64)
135 /* This decides where the kernel will search for a free chunk of vm
136 * space during mmap's.
138 #define TASK_UNMAPPED_BASE_USER32 (PAGE_ALIGN(TASK_SIZE_USER32 / 4))
139 #define TASK_UNMAPPED_BASE_USER64 (PAGE_ALIGN(TASK_SIZE_USER64 / 4))
141 #define TASK_UNMAPPED_BASE ((test_thread_flag(TIF_32BIT)) ? \
142 TASK_UNMAPPED_BASE_USER32 : TASK_UNMAPPED_BASE_USER64 )
143 #endif
145 typedef struct {
146 unsigned long seg;
147 } mm_segment_t;
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 #ifdef CONFIG_PPC32
166 unsigned long fpscr_pad; /* fpr ... fpscr must be contiguous */
167 #endif
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 */
176 #ifdef CONFIG_ALTIVEC
177 /* Complete AltiVec register set */
178 vector128 vr[32] __attribute((aligned(16)));
179 /* AltiVec status */
180 vector128 vscr __attribute((aligned(16)));
181 unsigned long vrsave;
182 int used_vr; /* set if process has used altivec */
183 #endif /* CONFIG_ALTIVEC */
184 #ifdef CONFIG_SPE
185 unsigned long evr[32]; /* upper 32-bits of SPE regs */
186 u64 acc; /* Accumulator */
187 unsigned long spefscr; /* SPE & eFP status */
188 int used_spe; /* set if process has used spe */
189 #endif /* CONFIG_SPE */
192 #define ARCH_MIN_TASKALIGN 16
194 #define INIT_SP (sizeof(init_stack) + (unsigned long) &init_stack)
197 #ifdef CONFIG_PPC32
198 #define INIT_THREAD { \
199 .ksp = INIT_SP, \
200 .fs = KERNEL_DS, \
201 .pgdir = swapper_pg_dir, \
202 .fpexc_mode = MSR_FE0 | MSR_FE1, \
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, \
213 #endif
216 * Return saved PC of a blocked thread. For now, this is the "user" PC
218 #define thread_saved_pc(tsk) \
219 ((tsk)->thread.regs? (tsk)->thread.regs->nip: 0)
221 unsigned long get_wchan(struct task_struct *p);
223 #define KSTK_EIP(tsk) ((tsk)->thread.regs? (tsk)->thread.regs->nip: 0)
224 #define KSTK_ESP(tsk) ((tsk)->thread.regs? (tsk)->thread.regs->gpr[1]: 0)
226 /* Get/set floating-point exception mode */
227 #define GET_FPEXC_CTL(tsk, adr) get_fpexc_mode((tsk), (adr))
228 #define SET_FPEXC_CTL(tsk, val) set_fpexc_mode((tsk), (val))
230 extern int get_fpexc_mode(struct task_struct *tsk, unsigned long adr);
231 extern int set_fpexc_mode(struct task_struct *tsk, unsigned int val);
233 static inline unsigned int __unpack_fe01(unsigned long msr_bits)
235 return ((msr_bits & MSR_FE0) >> 10) | ((msr_bits & MSR_FE1) >> 8);
238 static inline unsigned long __pack_fe01(unsigned int fpmode)
240 return ((fpmode << 10) & MSR_FE0) | ((fpmode << 8) & MSR_FE1);
243 #ifdef CONFIG_PPC64
244 #define cpu_relax() do { HMT_low(); HMT_medium(); barrier(); } while (0)
245 #else
246 #define cpu_relax() barrier()
247 #endif
250 * Prefetch macros.
252 #define ARCH_HAS_PREFETCH
253 #define ARCH_HAS_PREFETCHW
254 #define ARCH_HAS_SPINLOCK_PREFETCH
256 static inline void prefetch(const void *x)
258 if (unlikely(!x))
259 return;
261 __asm__ __volatile__ ("dcbt 0,%0" : : "r" (x));
264 static inline void prefetchw(const void *x)
266 if (unlikely(!x))
267 return;
269 __asm__ __volatile__ ("dcbtst 0,%0" : : "r" (x));
272 #define spin_lock_prefetch(x) prefetchw(x)
274 #ifdef CONFIG_PPC64
275 #define HAVE_ARCH_PICK_MMAP_LAYOUT
276 #endif
278 #endif /* __KERNEL__ */
279 #endif /* __ASSEMBLY__ */
280 #endif /* _ASM_POWERPC_PROCESSOR_H */