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