~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

Linux Cross Reference
Linux/include/asm-mips/processor.h

Version: ~ [ 2.4.0 ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 /* $Id: processor.h,v 1.25 2000/02/05 06:47:37 ralf Exp $
  2  *
  3  * This file is subject to the terms and conditions of the GNU General Public
  4  * License.  See the file "COPYING" in the main directory of this archive
  5  * for more details.
  6  *
  7  * Copyright (C) 1994 Waldorf GMBH
  8  * Copyright (C) 1995, 1996, 1997, 1998 Ralf Baechle
  9  * Copyright (C) 1996 Paul M. Antoine
 10  * Copyright (C) 1999 Silicon Graphics, Inc.
 11  */
 12 #ifndef _ASM_PROCESSOR_H
 13 #define _ASM_PROCESSOR_H
 14 
 15 #include <linux/config.h>
 16 
 17 #include <asm/isadep.h>
 18 
 19 /*
 20  * Default implementation of macro that returns current
 21  * instruction pointer ("program counter").
 22  */
 23 #define current_text_addr() ({ __label__ _l; _l: &&_l;})
 24 
 25 #if !defined (_LANGUAGE_ASSEMBLY)
 26 #include <linux/threads.h>
 27 #include <asm/cachectl.h>
 28 #include <asm/mipsregs.h>
 29 #include <asm/reg.h>
 30 #include <asm/system.h>
 31 
 32 struct mips_cpuinfo {
 33         unsigned long *pgd_quick;
 34         unsigned long *pte_quick;
 35         unsigned long pgtable_cache_sz;
 36 };
 37 
 38 /*
 39  * System setup and hardware flags..
 40  * XXX: Should go into mips_cpuinfo.
 41  */
 42 extern void (*cpu_wait)(void);  /* only available on R4[26]00 and R3081 */
 43 extern void r3081_wait(void);
 44 extern void r4k_wait(void);
 45 extern char cyclecounter_available;     /* only available from R4000 upwards. */
 46 extern char dedicated_iv_available;     /* some embedded MIPS like Nevada */
 47 extern char vce_available;              /* Supports VCED / VCEI exceptions */
 48 
 49 extern struct mips_cpuinfo boot_cpu_data;
 50 extern unsigned int vced_count, vcei_count;
 51 
 52 #ifdef CONFIG_SMP
 53 extern struct mips_cpuinfo cpu_data[];
 54 #define current_cpu_data cpu_data[smp_processor_id()]
 55 #else
 56 #define cpu_data &boot_cpu_data
 57 #define current_cpu_data boot_cpu_data
 58 #endif
 59 
 60 /*
 61  * Bus types (default is ISA, but people can check others with these..)
 62  * MCA_bus hardcoded to 0 for now.
 63  *
 64  * This needs to be extended since MIPS systems are being delivered with
 65  * numerous different types of bus systems.
 66  */
 67 extern int EISA_bus;
 68 #define MCA_bus 0
 69 #define MCA_bus__is_a_macro /* for versions in ksyms.c */
 70 
 71 /*
 72  * MIPS has no problems with write protection
 73  */
 74 #define wp_works_ok 1
 75 #define wp_works_ok__is_a_macro /* for versions in ksyms.c */
 76 
 77 /* Lazy FPU handling on uni-processor */
 78 extern struct task_struct *last_task_used_math;
 79 
 80 /*
 81  * User space process size: 2GB. This is hardcoded into a few places,
 82  * so don't change it unless you know what you are doing.  TASK_SIZE
 83  * for a 64 bit kernel expandable to 8192EB, of which the current MIPS
 84  * implementations will "only" be able to use 1TB ...
 85  */
 86 #define TASK_SIZE       (0x80000000UL)
 87 
 88 /* This decides where the kernel will search for a free chunk of vm
 89  * space during mmap's.
 90  */
 91 #define TASK_UNMAPPED_BASE      (TASK_SIZE / 3)
 92 
 93 /*
 94  * Size of io_bitmap in longwords: 32 is ports 0-0x3ff.
 95  */
 96 #define IO_BITMAP_SIZE  32
 97 
 98 #define NUM_FPU_REGS    32
 99 
100 struct mips_fpu_hard_struct {
101         unsigned int fp_regs[NUM_FPU_REGS];
102         unsigned int control;
103 } __attribute__((aligned(8)));
104 
105 /*
106  * FIXME: no fpu emulator yet (but who cares anyway?)
107  */
108 struct mips_fpu_soft_struct {
109         long    dummy;
110 };
111 
112 union mips_fpu_union {
113         struct mips_fpu_hard_struct hard;
114         struct mips_fpu_soft_struct soft;
115 };
116 
117 #define INIT_FPU { \
118         {{0,},} \
119 }
120 
121 typedef struct {
122         unsigned long seg;
123 } mm_segment_t;
124 
125 /*
126  * If you change thread_struct remember to change the #defines below too!
127  */
128 struct thread_struct {
129         /* Saved main processor registers. */
130         unsigned long reg16;
131         unsigned long reg17, reg18, reg19, reg20, reg21, reg22, reg23;
132         unsigned long reg29, reg30, reg31;
133 
134         /* Saved cp0 stuff. */
135         unsigned long cp0_status;
136 
137         /* Saved fpu/fpu emulator stuff. */
138         union mips_fpu_union fpu;
139 
140         /* Other stuff associated with the thread. */
141         unsigned long cp0_badvaddr;     /* Last user fault */
142         unsigned long cp0_baduaddr;     /* Last kernel fault accessing USEG */
143         unsigned long error_code;
144         unsigned long trap_no;
145 #define MF_FIXADE 1                     /* Fix address errors in software */
146 #define MF_LOGADE 2                     /* Log address errors to syslog */
147         unsigned long mflags;
148         mm_segment_t current_ds;
149         unsigned long irix_trampoline;  /* Wheee... */
150         unsigned long irix_oldctx;
151 };
152 
153 #endif /* !defined (_LANGUAGE_ASSEMBLY) */
154 
155 #define INIT_MMAP { &init_mm, KSEG0, KSEG1, NULL, PAGE_SHARED, \
156                     VM_READ | VM_WRITE | VM_EXEC, 1, NULL, NULL }
157 
158 #define INIT_THREAD  { \
159         /* \
160          * saved main processor registers \
161          */ \
162         0, 0, 0, 0, 0, 0, 0, 0, \
163                        0, 0, 0, \
164         /* \
165          * saved cp0 stuff \
166          */ \
167         0, \
168         /* \
169          * saved fpu/fpu emulator stuff \
170          */ \
171         INIT_FPU, \
172         /* \
173          * Other stuff associated with the process \
174          */ \
175         0, 0, 0, 0, \
176         /* \
177          * For now the default is to fix address errors \
178          */ \
179         MF_FIXADE, { 0 }, 0, 0 \
180 }
181 
182 #ifdef __KERNEL__
183 
184 #define KERNEL_STACK_SIZE 8192
185 
186 #if !defined (_LANGUAGE_ASSEMBLY)
187 
188 /* Free all resources held by a thread. */
189 #define release_thread(thread) do { } while(0)
190 
191 extern int kernel_thread(int (*fn)(void *), void * arg, unsigned long flags);
192 
193 /* Copy and release all segment info associated with a VM */
194 #define copy_segments(p, mm) do { } while(0)
195 #define release_segments(mm) do { } while(0)
196 
197 /*
198  * Return saved PC of a blocked thread.
199  */
200 extern inline unsigned long thread_saved_pc(struct thread_struct *t)
201 {
202         extern void ret_from_fork(void);
203 
204         /* New born processes are a special case */
205         if (t->reg31 == (unsigned long) ret_from_fork)
206                 return t->reg31;
207 
208         return ((unsigned long *)t->reg29)[10];
209 }
210 
211 /*
212  * Do necessary setup to start up a newly executed thread.
213  */
214 #define start_thread(regs, new_pc, new_sp) do {                         \
215         /* New thread looses kernel privileges. */                      \
216         regs->cp0_status = (regs->cp0_status & ~(ST0_CU0|ST0_KSU)) | KU_USER;\
217         regs->cp0_epc = new_pc;                                         \
218         regs->regs[29] = new_sp;                                        \
219         current->thread.current_ds = USER_DS;                           \
220 } while (0)
221 
222 unsigned long get_wchan(struct task_struct *p);
223 
224 #define __PT_REG(reg) ((long)&((struct pt_regs *)0)->reg - sizeof(struct pt_regs))
225 #define __KSTK_TOS(tsk) ((unsigned long)(tsk) + KERNEL_STACK_SIZE - 32)
226 #define KSTK_EIP(tsk) (*(unsigned long *)(__KSTK_TOS(tsk) + __PT_REG(cp0_epc)))
227 #define KSTK_ESP(tsk) (*(unsigned long *)(__KSTK_TOS(tsk) + __PT_REG(regs[29])))
228 
229 /* Allocation and freeing of basic task resources. */
230 /*
231  * NOTE! The task struct and the stack go together
232  */
233 #define THREAD_SIZE (2*PAGE_SIZE)
234 #define alloc_task_struct() \
235         ((struct task_struct *) __get_free_pages(GFP_KERNEL,1))
236 #define free_task_struct(p)     free_pages((unsigned long)(p),1)
237 #define get_task_struct(tsk)      atomic_inc(&virt_to_page(tsk)->count)
238 
239 #define init_task       (init_task_union.task)
240 #define init_stack      (init_task_union.stack)
241 
242 #endif /* !defined (_LANGUAGE_ASSEMBLY) */
243 #endif /* __KERNEL__ */
244 
245 /*
246  * Return_address is a replacement for __builtin_return_address(count)
247  * which on certain architectures cannot reasonably be implemented in GCC
248  * (MIPS, Alpha) or is unuseable with -fomit-frame-pointer (i386).
249  * Note that __builtin_return_address(x>=1) is forbidden because GCC
250  * aborts compilation on some CPUs.  It's simply not possible to unwind
251  * some CPU's stackframes.
252  *
253  * __builtin_return_address works only for non-leaf functions.  We avoid the
254  * overhead of a function call by forcing the compiler to save the return
255  * address register on the stack.
256  */
257 #define return_address() ({__asm__ __volatile__("":::"$31");__builtin_return_address(0);})
258 
259 #endif /* _ASM_PROCESSOR_H */
260 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

This page was automatically generated by the LXR engine.
Visit the LXR main site for more information.