upgrade to linux 2.6.10-1.12_FC2
[linux-2.6.git] / include / asm-mips / processor.h
1 /*
2  * This file is subject to the terms and conditions of the GNU General Public
3  * License.  See the file "COPYING" in the main directory of this archive
4  * for more details.
5  *
6  * Copyright (C) 1994 Waldorf GMBH
7  * Copyright (C) 1995, 1996, 1997, 1998, 1999, 2001, 2002, 2003 Ralf Baechle
8  * Copyright (C) 1996 Paul M. Antoine
9  * Copyright (C) 1999, 2000 Silicon Graphics, Inc.
10  */
11 #ifndef _ASM_PROCESSOR_H
12 #define _ASM_PROCESSOR_H
13
14 #include <linux/config.h>
15 #include <linux/threads.h>
16
17 #include <asm/cachectl.h>
18 #include <asm/cpu.h>
19 #include <asm/cpu-info.h>
20 #include <asm/mipsregs.h>
21 #include <asm/prefetch.h>
22 #include <asm/system.h>
23
24 /*
25  * Return current * instruction pointer ("program counter").
26  */
27 #define current_text_addr() ({ __label__ _l; _l: &&_l;})
28
29 /*
30  * System setup and hardware flags..
31  */
32 extern void (*cpu_wait)(void);
33
34 extern unsigned int vced_count, vcei_count;
35
36 /*
37  * Bus types (default is ISA, but people can check others with these..)
38  */
39 #define MCA_bus 0
40 #define MCA_bus__is_a_macro /* for versions in ksyms.c */
41
42 #ifdef CONFIG_MIPS32
43 /*
44  * User space process size: 2GB. This is hardcoded into a few places,
45  * so don't change it unless you know what you are doing.
46  */
47 #define TASK_SIZE       0x7fff8000UL
48
49 /*
50  * This decides where the kernel will search for a free chunk of vm
51  * space during mmap's.
52  */
53 #define TASK_UNMAPPED_BASE      (PAGE_ALIGN(TASK_SIZE / 3))
54 #endif
55
56 #ifdef CONFIG_MIPS64
57 /*
58  * User space process size: 1TB. This is hardcoded into a few places,
59  * so don't change it unless you know what you are doing.  TASK_SIZE
60  * is limited to 1TB by the R4000 architecture; R10000 and better can
61  * support 16TB; the architectural reserve for future expansion is
62  * 8192EB ...
63  */
64 #define TASK_SIZE32     0x7fff8000UL
65 #define TASK_SIZE       0x10000000000UL
66
67 /*
68  * This decides where the kernel will search for a free chunk of vm
69  * space during mmap's.
70  */
71 #define TASK_UNMAPPED_BASE      ((current->thread.mflags & MF_32BIT_ADDR) ? \
72         PAGE_ALIGN(TASK_SIZE32 / 3) : PAGE_ALIGN(TASK_SIZE / 3))
73 #endif
74
75 /*
76  * Size of io_bitmap in longwords.
77  */
78 #define IO_BITMAP_SIZE  2048
79
80 #define NUM_FPU_REGS    32
81
82 typedef __u64 fpureg_t;
83
84 struct mips_fpu_hard_struct {
85         fpureg_t        fpr[NUM_FPU_REGS];
86         unsigned int    fcr31;
87 };
88
89 /*
90  * It would be nice to add some more fields for emulator statistics, but there
91  * are a number of fixed offsets in offset.h and elsewhere that would have to
92  * be recalculated by hand.  So the additional information will be private to
93  * the FPU emulator for now.  See asm-mips/fpu_emulator.h.
94  */
95
96 struct mips_fpu_soft_struct {
97         fpureg_t        fpr[NUM_FPU_REGS];
98         unsigned int    fcr31;
99 };
100
101 union mips_fpu_union {
102         struct mips_fpu_hard_struct hard;
103         struct mips_fpu_soft_struct soft;
104 };
105
106 #define INIT_FPU { \
107         {{0,},} \
108 }
109
110 typedef struct {
111         unsigned long seg;
112 } mm_segment_t;
113
114 #define ARCH_MIN_TASKALIGN      8
115
116 /*
117  * If you change thread_struct remember to change the #defines below too!
118  */
119 struct thread_struct {
120         /* Saved main processor registers. */
121         unsigned long reg16;
122         unsigned long reg17, reg18, reg19, reg20, reg21, reg22, reg23;
123         unsigned long reg29, reg30, reg31;
124
125         /* Saved cp0 stuff. */
126         unsigned long cp0_status;
127
128         /* Saved fpu/fpu emulator stuff. */
129         union mips_fpu_union fpu;
130
131         /* Other stuff associated with the thread. */
132         unsigned long cp0_badvaddr;     /* Last user fault */
133         unsigned long cp0_baduaddr;     /* Last kernel fault accessing USEG */
134         unsigned long error_code;
135         unsigned long trap_no;
136 #define MF_FIXADE       1               /* Fix address errors in software */
137 #define MF_LOGADE       2               /* Log address errors to syslog */
138 #define MF_32BIT_REGS   4               /* also implies 16/32 fprs */
139 #define MF_32BIT_ADDR   8               /* 32-bit address space (o32/n32) */
140         unsigned long mflags;
141         unsigned long irix_trampoline;  /* Wheee... */
142         unsigned long irix_oldctx;
143 };
144
145 #define MF_ABI_MASK     (MF_32BIT_REGS | MF_32BIT_ADDR)
146 #define MF_O32          (MF_32BIT_REGS | MF_32BIT_ADDR)
147 #define MF_N32          MF_32BIT_ADDR
148 #define MF_N64          0
149
150 #define INIT_THREAD  { \
151         /* \
152          * saved main processor registers \
153          */ \
154         0, 0, 0, 0, 0, 0, 0, 0, \
155                        0, 0, 0, \
156         /* \
157          * saved cp0 stuff \
158          */ \
159         0, \
160         /* \
161          * saved fpu/fpu emulator stuff \
162          */ \
163         INIT_FPU, \
164         /* \
165          * Other stuff associated with the process \
166          */ \
167         0, 0, 0, 0, \
168         /* \
169          * For now the default is to fix address errors \
170          */ \
171         MF_FIXADE, 0, 0 \
172 }
173
174 struct task_struct;
175
176 /* Free all resources held by a thread. */
177 #define release_thread(thread) do { } while(0)
178
179 /* Prepare to copy thread state - unlazy all lazy status */
180 #define prepare_to_copy(tsk)    do { } while (0)
181
182 extern long kernel_thread(int (*fn)(void *), void * arg, unsigned long flags);
183
184 extern unsigned long thread_saved_pc(struct task_struct *tsk);
185
186 /*
187  * Do necessary setup to start up a newly executed thread.
188  */
189 extern void start_thread(struct pt_regs * regs, unsigned long pc, unsigned long sp);
190
191 unsigned long get_wchan(struct task_struct *p);
192
193 #define __PT_REG(reg) ((long)&((struct pt_regs *)0)->reg - sizeof(struct pt_regs))
194 #define __KSTK_TOS(tsk) ((unsigned long)(tsk->thread_info) + THREAD_SIZE - 32)
195 #define KSTK_EIP(tsk) (*(unsigned long *)(__KSTK_TOS(tsk) + __PT_REG(cp0_epc)))
196 #define KSTK_ESP(tsk) (*(unsigned long *)(__KSTK_TOS(tsk) + __PT_REG(regs[29])))
197 #define KSTK_STATUS(tsk) (*(unsigned long *)(__KSTK_TOS(tsk) + __PT_REG(cp0_status)))
198
199 #define cpu_relax()     barrier()
200
201 /*
202  * Return_address is a replacement for __builtin_return_address(count)
203  * which on certain architectures cannot reasonably be implemented in GCC
204  * (MIPS, Alpha) or is unuseable with -fomit-frame-pointer (i386).
205  * Note that __builtin_return_address(x>=1) is forbidden because GCC
206  * aborts compilation on some CPUs.  It's simply not possible to unwind
207  * some CPU's stackframes.
208  *
209  * __builtin_return_address works only for non-leaf functions.  We avoid the
210  * overhead of a function call by forcing the compiler to save the return
211  * address register on the stack.
212  */
213 #define return_address() ({__asm__ __volatile__("":::"$31");__builtin_return_address(0);})
214
215 #ifdef CONFIG_CPU_HAS_PREFETCH
216
217 #define ARCH_HAS_PREFETCH
218
219 extern inline void prefetch(const void *addr)
220 {
221         __asm__ __volatile__(
222         "       .set    mips4           \n"
223         "       pref    %0, (%1)        \n"
224         "       .set    mips0           \n"
225         :
226         : "i" (Pref_Load), "r" (addr));
227 }
228
229 #endif
230
231 #endif /* _ASM_PROCESSOR_H */