processor.h 7.0 KB

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