processor.h 6.3 KB

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