processor.h 6.3 KB

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