processor.h 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254
  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/cpumask.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 \
  57. (test_thread_flag(TIF_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. /*
  63. * It would be nice to add some more fields for emulator statistics, but there
  64. * are a number of fixed offsets in offset.h and elsewhere that would have to
  65. * be recalculated by hand. So the additional information will be private to
  66. * the FPU emulator for now. See asm-mips/fpu_emulator.h.
  67. */
  68. struct mips_fpu_struct {
  69. fpureg_t fpr[NUM_FPU_REGS];
  70. unsigned int fcr31;
  71. };
  72. #define NUM_DSP_REGS 6
  73. typedef __u32 dspreg_t;
  74. struct mips_dsp_state {
  75. dspreg_t dspr[NUM_DSP_REGS];
  76. unsigned int dspcontrol;
  77. };
  78. #define INIT_CPUMASK { \
  79. {0,} \
  80. }
  81. typedef struct {
  82. unsigned long seg;
  83. } mm_segment_t;
  84. #define ARCH_MIN_TASKALIGN 8
  85. struct mips_abi;
  86. /*
  87. * If you change thread_struct remember to change the #defines below too!
  88. */
  89. struct thread_struct {
  90. /* Saved main processor registers. */
  91. unsigned long reg16;
  92. unsigned long reg17, reg18, reg19, reg20, reg21, reg22, reg23;
  93. unsigned long reg29, reg30, reg31;
  94. /* Saved cp0 stuff. */
  95. unsigned long cp0_status;
  96. /* Saved fpu/fpu emulator stuff. */
  97. struct mips_fpu_struct fpu;
  98. #ifdef CONFIG_MIPS_MT_FPAFF
  99. /* Emulated instruction count */
  100. unsigned long emulated_fp;
  101. /* Saved per-thread scheduler affinity mask */
  102. cpumask_t user_cpus_allowed;
  103. #endif /* CONFIG_MIPS_MT_FPAFF */
  104. /* Saved state of the DSP ASE, if available. */
  105. struct mips_dsp_state dsp;
  106. /* Other stuff associated with the thread. */
  107. unsigned long cp0_badvaddr; /* Last user fault */
  108. unsigned long cp0_baduaddr; /* Last kernel fault accessing USEG */
  109. unsigned long error_code;
  110. unsigned long trap_no;
  111. unsigned long irix_trampoline; /* Wheee... */
  112. unsigned long irix_oldctx;
  113. struct mips_abi *abi;
  114. };
  115. #ifdef CONFIG_MIPS_MT_FPAFF
  116. #define FPAFF_INIT \
  117. .emulated_fp = 0, \
  118. .user_cpus_allowed = INIT_CPUMASK,
  119. #else
  120. #define FPAFF_INIT
  121. #endif /* CONFIG_MIPS_MT_FPAFF */
  122. #define INIT_THREAD { \
  123. /* \
  124. * Saved main processor registers \
  125. */ \
  126. .reg16 = 0, \
  127. .reg17 = 0, \
  128. .reg18 = 0, \
  129. .reg19 = 0, \
  130. .reg20 = 0, \
  131. .reg21 = 0, \
  132. .reg22 = 0, \
  133. .reg23 = 0, \
  134. .reg29 = 0, \
  135. .reg30 = 0, \
  136. .reg31 = 0, \
  137. /* \
  138. * Saved cp0 stuff \
  139. */ \
  140. .cp0_status = 0, \
  141. /* \
  142. * Saved FPU/FPU emulator stuff \
  143. */ \
  144. .fpu = { \
  145. .fpr = {0,}, \
  146. .fcr31 = 0, \
  147. }, \
  148. /* \
  149. * FPU affinity state (null if not FPAFF) \
  150. */ \
  151. FPAFF_INIT \
  152. /* \
  153. * Saved DSP stuff \
  154. */ \
  155. .dsp = { \
  156. .dspr = {0, }, \
  157. .dspcontrol = 0, \
  158. }, \
  159. /* \
  160. * Other stuff associated with the process \
  161. */ \
  162. .cp0_badvaddr = 0, \
  163. .cp0_baduaddr = 0, \
  164. .error_code = 0, \
  165. .trap_no = 0, \
  166. .irix_trampoline = 0, \
  167. .irix_oldctx = 0, \
  168. }
  169. struct task_struct;
  170. /* Free all resources held by a thread. */
  171. #define release_thread(thread) do { } while(0)
  172. /* Prepare to copy thread state - unlazy all lazy status */
  173. #define prepare_to_copy(tsk) do { } while (0)
  174. extern long kernel_thread(int (*fn)(void *), void * arg, unsigned long flags);
  175. extern unsigned long thread_saved_pc(struct task_struct *tsk);
  176. /*
  177. * Do necessary setup to start up a newly executed thread.
  178. */
  179. extern void start_thread(struct pt_regs * regs, unsigned long pc, unsigned long sp);
  180. unsigned long get_wchan(struct task_struct *p);
  181. #define __KSTK_TOS(tsk) ((unsigned long)task_stack_page(tsk) + THREAD_SIZE - 32)
  182. #define task_pt_regs(tsk) ((struct pt_regs *)__KSTK_TOS(tsk) - 1)
  183. #define KSTK_EIP(tsk) (task_pt_regs(tsk)->cp0_epc)
  184. #define KSTK_ESP(tsk) (task_pt_regs(tsk)->regs[29])
  185. #define KSTK_STATUS(tsk) (task_pt_regs(tsk)->cp0_status)
  186. #define cpu_relax() barrier()
  187. /*
  188. * Return_address is a replacement for __builtin_return_address(count)
  189. * which on certain architectures cannot reasonably be implemented in GCC
  190. * (MIPS, Alpha) or is unuseable with -fomit-frame-pointer (i386).
  191. * Note that __builtin_return_address(x>=1) is forbidden because GCC
  192. * aborts compilation on some CPUs. It's simply not possible to unwind
  193. * some CPU's stackframes.
  194. *
  195. * __builtin_return_address works only for non-leaf functions. We avoid the
  196. * overhead of a function call by forcing the compiler to save the return
  197. * address register on the stack.
  198. */
  199. #define return_address() ({__asm__ __volatile__("":::"$31");__builtin_return_address(0);})
  200. #ifdef CONFIG_CPU_HAS_PREFETCH
  201. #define ARCH_HAS_PREFETCH
  202. static inline void prefetch(const void *addr)
  203. {
  204. __asm__ __volatile__(
  205. " .set mips4 \n"
  206. " pref %0, (%1) \n"
  207. " .set mips0 \n"
  208. :
  209. : "i" (Pref_Load), "r" (addr));
  210. }
  211. #endif
  212. #endif /* _ASM_PROCESSOR_H */