VServer 1.9.2 (patch-2.6.8.1-vs1.9.2.diff)
[linux-2.6.git] / include / asm-ppc / processor.h
1 #ifdef __KERNEL__
2 #ifndef __ASM_PPC_PROCESSOR_H
3 #define __ASM_PPC_PROCESSOR_H
4
5 /*
6  * Default implementation of macro that returns current
7  * instruction pointer ("program counter").
8  */
9 #define current_text_addr() ({ __label__ _l; _l: &&_l;})
10
11 #include <linux/config.h>
12 #include <linux/stringify.h>
13
14 #include <asm/ptrace.h>
15 #include <asm/types.h>
16 #include <asm/mpc8xx.h>
17 #include <asm/reg.h>
18
19 /* 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.
21  * This is currently limited to CONFIG_PPC_MULTIPLATFORM and CHRP/PReP/PMac.
22  * -- Tom
23  */
24 #define _MACH_prep      0x00000001
25 #define _MACH_Pmac      0x00000002      /* pmac or pmac clone (non-chrp) */
26 #define _MACH_chrp      0x00000004      /* chrp machine */
27
28 /* see residual.h for these */
29 #define _PREP_Motorola  0x01    /* motorola prep */
30 #define _PREP_Firm      0x02    /* firmworks prep */
31 #define _PREP_IBM       0x00    /* ibm prep */
32 #define _PREP_Bull      0x03    /* bull prep */
33
34 /* these are arbitrary */
35 #define _CHRP_Motorola  0x04    /* motorola chrp, the cobra */
36 #define _CHRP_IBM       0x05    /* IBM chrp, the longtrail and longtrail 2 */
37
38 #define _GLOBAL(n)\
39         .stabs __stringify(n:F-1),N_FUN,0,0,n;\
40         .globl n;\
41 n:
42
43 /*
44  * this is the minimum allowable io space due to the location
45  * of the io areas on prep (first one at 0x80000000) but
46  * as soon as I get around to remapping the io areas with the BATs
47  * to match the mac we can raise this. -- Cort
48  */
49 #define TASK_SIZE       (CONFIG_TASK_SIZE)
50
51 #ifndef __ASSEMBLY__
52 #ifdef CONFIG_PPC_MULTIPLATFORM
53 extern int _machine;
54
55 /* what kind of prep workstation we are */
56 extern int _prep_type;
57
58 /*
59  * This is used to identify the board type from a given PReP board
60  * vendor. Board revision is also made available.
61  */
62 extern unsigned char ucSystemType;
63 extern unsigned char ucBoardRev;
64 extern unsigned char ucBoardRevMaj, ucBoardRevMin;
65 #else
66 #define _machine 0
67 #endif /* CONFIG_PPC_MULTIPLATFORM */
68
69 struct task_struct;
70 void start_thread(struct pt_regs *regs, unsigned long nip, unsigned long sp);
71 void release_thread(struct task_struct *);
72
73 /* Prepare to copy thread state - unlazy all lazy status */
74 extern void prepare_to_copy(struct task_struct *tsk);
75
76 /*
77  * Create a new kernel thread.
78  */
79 extern long kernel_thread(int (*fn)(void *), void *arg, unsigned long flags);
80
81 /*
82  * Bus types
83  */
84 #define MCA_bus 0
85 #define MCA_bus__is_a_macro
86
87 /* Lazy FPU handling on uni-processor */
88 extern struct task_struct *last_task_used_math;
89 extern struct task_struct *last_task_used_altivec;
90 extern struct task_struct *last_task_used_spe;
91
92 /* This decides where the kernel will search for a free chunk of vm
93  * space during mmap's.
94  */
95 #define TASK_UNMAPPED_BASE      (TASK_SIZE / 8 * 3)
96
97 typedef struct {
98         unsigned long seg;
99 } mm_segment_t;
100
101 struct thread_struct {
102         unsigned long   ksp;            /* Kernel stack pointer */
103         struct pt_regs  *regs;          /* Pointer to saved register state */
104         mm_segment_t    fs;             /* for get_fs() validation */
105         void            *pgdir;         /* root of page-table tree */
106         int             fpexc_mode;     /* floating-point exception mode */
107         signed long     last_syscall;
108 #if defined(CONFIG_4xx) || defined (CONFIG_BOOKE)
109         unsigned long   dbcr0;          /* debug control register values */
110         unsigned long   dbcr1;
111 #endif
112         double          fpr[32];        /* Complete floating point set */
113         unsigned long   fpscr_pad;      /* fpr ... fpscr must be contiguous */
114         unsigned long   fpscr;          /* Floating point status */
115 #ifdef CONFIG_ALTIVEC
116         /* Complete AltiVec register set */
117         vector128       vr[32] __attribute((aligned(16)));
118         /* AltiVec status */
119         vector128       vscr __attribute((aligned(16)));
120         unsigned long   vrsave;
121         int             used_vr;        /* set if process has used altivec */
122 #endif /* CONFIG_ALTIVEC */
123 #ifdef CONFIG_SPE
124         unsigned long   evr[32];        /* upper 32-bits of SPE regs */
125         u64             acc;            /* Accumulator */
126         unsigned long   spefscr;        /* SPE & eFP status */
127         int             used_spe;       /* set if process has used spe */
128 #endif /* CONFIG_SPE */
129 };
130
131 #define ARCH_MIN_TASKALIGN 16
132
133 #define INIT_SP         (sizeof(init_stack) + (unsigned long) &init_stack)
134
135 #define INIT_THREAD { \
136         .ksp = INIT_SP, \
137         .fs = KERNEL_DS, \
138         .pgdir = swapper_pg_dir, \
139         .fpexc_mode = MSR_FE0 | MSR_FE1, \
140 }
141
142 /*
143  * Return saved PC of a blocked thread. For now, this is the "user" PC
144  */
145 #define thread_saved_pc(tsk)    \
146         ((tsk)->thread.regs? (tsk)->thread.regs->nip: 0)
147
148 unsigned long get_wchan(struct task_struct *p);
149
150 #define KSTK_EIP(tsk)   ((tsk)->thread.regs? (tsk)->thread.regs->nip: 0)
151 #define KSTK_ESP(tsk)   ((tsk)->thread.regs? (tsk)->thread.regs->gpr[1]: 0)
152
153 /* Get/set floating-point exception mode */
154 #define GET_FPEXC_CTL(tsk, adr) get_fpexc_mode((tsk), (adr))
155 #define SET_FPEXC_CTL(tsk, val) set_fpexc_mode((tsk), (val))
156
157 extern int get_fpexc_mode(struct task_struct *tsk, unsigned long adr);
158 extern int set_fpexc_mode(struct task_struct *tsk, unsigned int val);
159
160 static inline unsigned int __unpack_fe01(unsigned int msr_bits)
161 {
162         return ((msr_bits & MSR_FE0) >> 10) | ((msr_bits & MSR_FE1) >> 8);
163 }
164
165 static inline unsigned int __pack_fe01(unsigned int fpmode)
166 {
167         return ((fpmode << 10) & MSR_FE0) | ((fpmode << 8) & MSR_FE1);
168 }
169
170 /* in process.c - for early bootup debug -- Cort */
171 int ll_printk(const char *, ...);
172 void ll_puts(const char *);
173
174 /* In misc.c */
175 void _nmask_and_or_msr(unsigned long nmask, unsigned long or_val);
176
177 #define have_of (_machine == _MACH_chrp || _machine == _MACH_Pmac)
178
179 #define cpu_relax()     barrier()
180
181 /*
182  * Prefetch macros.
183  */
184 #define ARCH_HAS_PREFETCH
185 #define ARCH_HAS_PREFETCHW
186 #define ARCH_HAS_SPINLOCK_PREFETCH
187
188 extern inline void prefetch(const void *x)
189 {
190          __asm__ __volatile__ ("dcbt 0,%0" : : "r" (x));
191 }
192
193 extern inline void prefetchw(const void *x)
194 {
195          __asm__ __volatile__ ("dcbtst 0,%0" : : "r" (x));
196 }
197
198 #define spin_lock_prefetch(x)   prefetchw(x)
199
200 extern int emulate_altivec(struct pt_regs *regs);
201
202 #endif /* !__ASSEMBLY__ */
203
204 #endif /* __ASM_PPC_PROCESSOR_H */
205 #endif /* __KERNEL__ */