ftp://ftp.kernel.org/pub/linux/kernel/v2.6/linux-2.6.6.tar.bz2
[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 #ifndef __ASSEMBLY__
44 #ifdef CONFIG_PPC_MULTIPLATFORM
45 extern int _machine;
46
47 /* what kind of prep workstation we are */
48 extern int _prep_type;
49
50 /*
51  * This is used to identify the board type from a given PReP board
52  * vendor. Board revision is also made available.
53  */
54 extern unsigned char ucSystemType;
55 extern unsigned char ucBoardRev;
56 extern unsigned char ucBoardRevMaj, ucBoardRevMin;
57 #else
58 #define _machine 0
59 #endif /* CONFIG_PPC_MULTIPLATFORM */
60
61 struct task_struct;
62 void start_thread(struct pt_regs *regs, unsigned long nip, unsigned long sp);
63 void release_thread(struct task_struct *);
64
65 /* Prepare to copy thread state - unlazy all lazy status */
66 extern void prepare_to_copy(struct task_struct *tsk);
67
68 /*
69  * Create a new kernel thread.
70  */
71 extern long kernel_thread(int (*fn)(void *), void *arg, unsigned long flags);
72
73 /*
74  * Bus types
75  */
76 #define MCA_bus 0
77 #define MCA_bus__is_a_macro
78
79 /* Lazy FPU handling on uni-processor */
80 extern struct task_struct *last_task_used_math;
81 extern struct task_struct *last_task_used_altivec;
82
83 /*
84  * this is the minimum allowable io space due to the location
85  * of the io areas on prep (first one at 0x80000000) but
86  * as soon as I get around to remapping the io areas with the BATs
87  * to match the mac we can raise this. -- Cort
88  */
89 #define TASK_SIZE       (CONFIG_TASK_SIZE)
90
91 /* This decides where the kernel will search for a free chunk of vm
92  * space during mmap's.
93  */
94 #define TASK_UNMAPPED_BASE      (TASK_SIZE / 8 * 3)
95
96 typedef struct {
97         unsigned long seg;
98 } mm_segment_t;
99
100 struct thread_struct {
101         unsigned long   ksp;            /* Kernel stack pointer */
102         struct pt_regs  *regs;          /* Pointer to saved register state */
103         mm_segment_t    fs;             /* for get_fs() validation */
104         void            *pgdir;         /* root of page-table tree */
105         int             fpexc_mode;     /* floating-point exception mode */
106         signed long     last_syscall;
107 #ifdef CONFIG_4xx
108         unsigned long   dbcr0;          /* debug control register values */
109         unsigned long   dbcr1;
110 #endif
111         double          fpr[32];        /* Complete floating point set */
112         unsigned long   fpscr_pad;      /* fpr ... fpscr must be contiguous */
113         unsigned long   fpscr;          /* Floating point status */
114 #ifdef CONFIG_ALTIVEC
115         /* Complete AltiVec register set */
116         vector128       vr[32] __attribute((aligned(16)));
117         /* AltiVec status */
118         vector128       vscr __attribute((aligned(16)));
119         unsigned long   vrsave;
120         int             used_vr;        /* set if process has used altivec */
121 #endif /* CONFIG_ALTIVEC */
122 };
123
124 #define ARCH_MIN_TASKALIGN 16
125
126 #define INIT_SP         (sizeof(init_stack) + (unsigned long) &init_stack)
127
128 #define INIT_THREAD { \
129         .ksp = INIT_SP, \
130         .fs = KERNEL_DS, \
131         .pgdir = swapper_pg_dir, \
132         .fpexc_mode = MSR_FE0 | MSR_FE1, \
133 }
134
135 /*
136  * Return saved PC of a blocked thread. For now, this is the "user" PC
137  */
138 #define thread_saved_pc(tsk)    \
139         ((tsk)->thread.regs? (tsk)->thread.regs->nip: 0)
140
141 unsigned long get_wchan(struct task_struct *p);
142
143 #define KSTK_EIP(tsk)   ((tsk)->thread.regs? (tsk)->thread.regs->nip: 0)
144 #define KSTK_ESP(tsk)   ((tsk)->thread.regs? (tsk)->thread.regs->gpr[1]: 0)
145
146 /* Get/set floating-point exception mode */
147 #define GET_FPEXC_CTL(tsk, adr) get_fpexc_mode((tsk), (adr))
148 #define SET_FPEXC_CTL(tsk, val) set_fpexc_mode((tsk), (val))
149
150 extern int get_fpexc_mode(struct task_struct *tsk, unsigned long adr);
151 extern int set_fpexc_mode(struct task_struct *tsk, unsigned int val);
152
153 static inline unsigned int __unpack_fe01(unsigned int msr_bits)
154 {
155         return ((msr_bits & MSR_FE0) >> 10) | ((msr_bits & MSR_FE1) >> 8);
156 }
157
158 static inline unsigned int __pack_fe01(unsigned int fpmode)
159 {
160         return ((fpmode << 10) & MSR_FE0) | ((fpmode << 8) & MSR_FE1);
161 }
162
163 /* in process.c - for early bootup debug -- Cort */
164 int ll_printk(const char *, ...);
165 void ll_puts(const char *);
166
167 /* In misc.c */
168 void _nmask_and_or_msr(unsigned long nmask, unsigned long or_val);
169
170 #define have_of (_machine == _MACH_chrp || _machine == _MACH_Pmac)
171
172 #define cpu_relax()     barrier()
173
174 /*
175  * Prefetch macros.
176  */
177 #define ARCH_HAS_PREFETCH
178 #define ARCH_HAS_PREFETCHW
179 #define ARCH_HAS_SPINLOCK_PREFETCH
180
181 extern inline void prefetch(const void *x)
182 {
183          __asm__ __volatile__ ("dcbt 0,%0" : : "r" (x));
184 }
185
186 extern inline void prefetchw(const void *x)
187 {
188          __asm__ __volatile__ ("dcbtst 0,%0" : : "r" (x));
189 }
190
191 #define spin_lock_prefetch(x)   prefetchw(x)
192
193 #endif /* !__ASSEMBLY__ */
194
195 #endif /* __ASM_PPC_PROCESSOR_H */
196 #endif /* __KERNEL__ */