processor_32.h 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241
  1. /*
  2. * include/asm-sh/processor.h
  3. *
  4. * Copyright (C) 1999, 2000 Niibe Yutaka
  5. * Copyright (C) 2002, 2003 Paul Mundt
  6. */
  7. #ifndef __ASM_SH_PROCESSOR_32_H
  8. #define __ASM_SH_PROCESSOR_32_H
  9. #ifdef __KERNEL__
  10. #include <linux/compiler.h>
  11. #include <asm/page.h>
  12. #include <asm/types.h>
  13. #include <asm/cache.h>
  14. #include <asm/ptrace.h>
  15. /*
  16. * Default implementation of macro that returns current
  17. * instruction pointer ("program counter").
  18. */
  19. #define current_text_addr() ({ void *pc; __asm__("mova 1f, %0\n1:":"=z" (pc)); pc; })
  20. /* Core Processor Version Register */
  21. #define CCN_PVR 0xff000030
  22. #define CCN_CVR 0xff000040
  23. #define CCN_PRR 0xff000044
  24. struct sh_cpuinfo {
  25. unsigned int type;
  26. unsigned long loops_per_jiffy;
  27. unsigned long asid_cache;
  28. struct cache_info icache; /* Primary I-cache */
  29. struct cache_info dcache; /* Primary D-cache */
  30. struct cache_info scache; /* Secondary cache */
  31. unsigned long flags;
  32. } __attribute__ ((aligned(L1_CACHE_BYTES)));
  33. extern struct sh_cpuinfo cpu_data[];
  34. #define boot_cpu_data cpu_data[0]
  35. #define current_cpu_data cpu_data[smp_processor_id()]
  36. #define raw_current_cpu_data cpu_data[raw_smp_processor_id()]
  37. /*
  38. * User space process size: 2GB.
  39. *
  40. * Since SH7709 and SH7750 have "area 7", we can't use 0x7c000000--0x7fffffff
  41. */
  42. #define TASK_SIZE 0x7c000000UL
  43. /* This decides where the kernel will search for a free chunk of vm
  44. * space during mmap's.
  45. */
  46. #define TASK_UNMAPPED_BASE (TASK_SIZE / 3)
  47. /*
  48. * Bit of SR register
  49. *
  50. * FD-bit:
  51. * When it's set, it means the processor doesn't have right to use FPU,
  52. * and it results exception when the floating operation is executed.
  53. *
  54. * IMASK-bit:
  55. * Interrupt level mask
  56. */
  57. #define SR_FD 0x00008000
  58. #define SR_DSP 0x00001000
  59. #define SR_IMASK 0x000000f0
  60. /*
  61. * FPU structure and data
  62. */
  63. struct sh_fpu_hard_struct {
  64. unsigned long fp_regs[16];
  65. unsigned long xfp_regs[16];
  66. unsigned long fpscr;
  67. unsigned long fpul;
  68. long status; /* software status information */
  69. };
  70. /* Dummy fpu emulator */
  71. struct sh_fpu_soft_struct {
  72. unsigned long fp_regs[16];
  73. unsigned long xfp_regs[16];
  74. unsigned long fpscr;
  75. unsigned long fpul;
  76. unsigned char lookahead;
  77. unsigned long entry_pc;
  78. };
  79. union sh_fpu_union {
  80. struct sh_fpu_hard_struct hard;
  81. struct sh_fpu_soft_struct soft;
  82. };
  83. struct thread_struct {
  84. /* Saved registers when thread is descheduled */
  85. unsigned long sp;
  86. unsigned long pc;
  87. /* Hardware debugging registers */
  88. unsigned long ubc_pc;
  89. /* floating point info */
  90. union sh_fpu_union fpu;
  91. };
  92. typedef struct {
  93. unsigned long seg;
  94. } mm_segment_t;
  95. /* Count of active tasks with UBC settings */
  96. extern int ubc_usercnt;
  97. #define INIT_THREAD { \
  98. .sp = sizeof(init_stack) + (long) &init_stack, \
  99. }
  100. /*
  101. * Do necessary setup to start up a newly executed thread.
  102. */
  103. #define start_thread(regs, new_pc, new_sp) \
  104. set_fs(USER_DS); \
  105. regs->pr = 0; \
  106. regs->sr = SR_FD; /* User mode. */ \
  107. regs->pc = new_pc; \
  108. regs->regs[15] = new_sp
  109. /* Forward declaration, a strange C thing */
  110. struct task_struct;
  111. struct mm_struct;
  112. /* Free all resources held by a thread. */
  113. extern void release_thread(struct task_struct *);
  114. /* Prepare to copy thread state - unlazy all lazy status */
  115. #define prepare_to_copy(tsk) do { } while (0)
  116. /*
  117. * create a kernel thread without removing it from tasklists
  118. */
  119. extern int kernel_thread(int (*fn)(void *), void * arg, unsigned long flags);
  120. /* Copy and release all segment info associated with a VM */
  121. #define copy_segments(p, mm) do { } while(0)
  122. #define release_segments(mm) do { } while(0)
  123. /*
  124. * FPU lazy state save handling.
  125. */
  126. static __inline__ void disable_fpu(void)
  127. {
  128. unsigned long __dummy;
  129. /* Set FD flag in SR */
  130. __asm__ __volatile__("stc sr, %0\n\t"
  131. "or %1, %0\n\t"
  132. "ldc %0, sr"
  133. : "=&r" (__dummy)
  134. : "r" (SR_FD));
  135. }
  136. static __inline__ void enable_fpu(void)
  137. {
  138. unsigned long __dummy;
  139. /* Clear out FD flag in SR */
  140. __asm__ __volatile__("stc sr, %0\n\t"
  141. "and %1, %0\n\t"
  142. "ldc %0, sr"
  143. : "=&r" (__dummy)
  144. : "r" (~SR_FD));
  145. }
  146. static __inline__ void release_fpu(struct pt_regs *regs)
  147. {
  148. regs->sr |= SR_FD;
  149. }
  150. static __inline__ void grab_fpu(struct pt_regs *regs)
  151. {
  152. regs->sr &= ~SR_FD;
  153. }
  154. extern void save_fpu(struct task_struct *__tsk, struct pt_regs *regs);
  155. #define unlazy_fpu(tsk, regs) do { \
  156. if (test_tsk_thread_flag(tsk, TIF_USEDFPU)) { \
  157. save_fpu(tsk, regs); \
  158. } \
  159. } while (0)
  160. #define clear_fpu(tsk, regs) do { \
  161. if (test_tsk_thread_flag(tsk, TIF_USEDFPU)) { \
  162. clear_tsk_thread_flag(tsk, TIF_USEDFPU); \
  163. release_fpu(regs); \
  164. } \
  165. } while (0)
  166. /* Double presision, NANS as NANS, rounding to nearest, no exceptions */
  167. #define FPSCR_INIT 0x00080000
  168. #define FPSCR_CAUSE_MASK 0x0001f000 /* Cause bits */
  169. #define FPSCR_FLAG_MASK 0x0000007c /* Flag bits */
  170. /*
  171. * Return saved PC of a blocked thread.
  172. */
  173. #define thread_saved_pc(tsk) (tsk->thread.pc)
  174. void show_trace(struct task_struct *tsk, unsigned long *sp,
  175. struct pt_regs *regs);
  176. extern unsigned long get_wchan(struct task_struct *p);
  177. #define KSTK_EIP(tsk) (task_pt_regs(tsk)->pc)
  178. #define KSTK_ESP(tsk) (task_pt_regs(tsk)->regs[15])
  179. #define cpu_sleep() __asm__ __volatile__ ("sleep" : : : "memory")
  180. #define cpu_relax() barrier()
  181. #if defined(CONFIG_CPU_SH2A) || defined(CONFIG_CPU_SH3) || \
  182. defined(CONFIG_CPU_SH4)
  183. #define PREFETCH_STRIDE L1_CACHE_BYTES
  184. #define ARCH_HAS_PREFETCH
  185. #define ARCH_HAS_PREFETCHW
  186. static inline void prefetch(void *x)
  187. {
  188. __asm__ __volatile__ ("pref @%0\n\t" : : "r" (x) : "memory");
  189. }
  190. #define prefetchw(x) prefetch(x)
  191. #endif
  192. #endif /* __KERNEL__ */
  193. #endif /* __ASM_SH_PROCESSOR_32_H */