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