processor_32.h 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220
  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 <linux/linkage.h>
  12. #include <asm/page.h>
  13. #include <asm/types.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\n.align 2\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. asmlinkage void __init sh_cpu_init(void);
  25. /*
  26. * User space process size: 2GB.
  27. *
  28. * Since SH7709 and SH7750 have "area 7", we can't use 0x7c000000--0x7fffffff
  29. */
  30. #define TASK_SIZE 0x7c000000UL
  31. #define STACK_TOP TASK_SIZE
  32. #define STACK_TOP_MAX STACK_TOP
  33. /* This decides where the kernel will search for a free chunk of vm
  34. * space during mmap's.
  35. */
  36. #define TASK_UNMAPPED_BASE (TASK_SIZE / 3)
  37. /*
  38. * Bit of SR register
  39. *
  40. * FD-bit:
  41. * When it's set, it means the processor doesn't have right to use FPU,
  42. * and it results exception when the floating operation is executed.
  43. *
  44. * IMASK-bit:
  45. * Interrupt level mask
  46. */
  47. #define SR_DSP 0x00001000
  48. #define SR_IMASK 0x000000f0
  49. #define SR_FD 0x00008000
  50. /*
  51. * DSP structure and data
  52. */
  53. struct sh_dsp_struct {
  54. unsigned long dsp_regs[14];
  55. long status;
  56. };
  57. /*
  58. * FPU structure and data
  59. */
  60. struct sh_fpu_hard_struct {
  61. unsigned long fp_regs[16];
  62. unsigned long xfp_regs[16];
  63. unsigned long fpscr;
  64. unsigned long fpul;
  65. long status; /* software status information */
  66. };
  67. /* Dummy fpu emulator */
  68. struct sh_fpu_soft_struct {
  69. unsigned long fp_regs[16];
  70. unsigned long xfp_regs[16];
  71. unsigned long fpscr;
  72. unsigned long fpul;
  73. unsigned char lookahead;
  74. unsigned long entry_pc;
  75. };
  76. union sh_fpu_union {
  77. struct sh_fpu_hard_struct hard;
  78. struct sh_fpu_soft_struct soft;
  79. };
  80. struct thread_struct {
  81. /* Saved registers when thread is descheduled */
  82. unsigned long sp;
  83. unsigned long pc;
  84. /* Hardware debugging registers */
  85. unsigned long ubc_pc;
  86. /* floating point info */
  87. union sh_fpu_union fpu;
  88. #ifdef CONFIG_SH_DSP
  89. /* Dsp status information */
  90. struct sh_dsp_struct dsp_status;
  91. #endif
  92. };
  93. /* Count of active tasks with UBC settings */
  94. extern int ubc_usercnt;
  95. #define INIT_THREAD { \
  96. .sp = sizeof(init_stack) + (long) &init_stack, \
  97. }
  98. /*
  99. * Do necessary setup to start up a newly executed thread.
  100. */
  101. #define start_thread(_regs, new_pc, new_sp) \
  102. set_fs(USER_DS); \
  103. _regs->pr = 0; \
  104. _regs->sr = SR_FD; /* User mode. */ \
  105. _regs->pc = new_pc; \
  106. _regs->regs[15] = new_sp
  107. /* Forward declaration, a strange C thing */
  108. struct task_struct;
  109. struct mm_struct;
  110. /* Free all resources held by a thread. */
  111. extern void release_thread(struct task_struct *);
  112. /* Prepare to copy thread state - unlazy all lazy status */
  113. #define prepare_to_copy(tsk) do { } while (0)
  114. /*
  115. * create a kernel thread without removing it from tasklists
  116. */
  117. extern int kernel_thread(int (*fn)(void *), void * arg, unsigned long flags);
  118. /* Copy and release all segment info associated with a VM */
  119. #define copy_segments(p, mm) do { } while(0)
  120. #define release_segments(mm) do { } while(0)
  121. /*
  122. * FPU lazy state save handling.
  123. */
  124. static __inline__ void disable_fpu(void)
  125. {
  126. unsigned long __dummy;
  127. /* Set FD flag in SR */
  128. __asm__ __volatile__("stc sr, %0\n\t"
  129. "or %1, %0\n\t"
  130. "ldc %0, sr"
  131. : "=&r" (__dummy)
  132. : "r" (SR_FD));
  133. }
  134. static __inline__ void enable_fpu(void)
  135. {
  136. unsigned long __dummy;
  137. /* Clear out FD flag in SR */
  138. __asm__ __volatile__("stc sr, %0\n\t"
  139. "and %1, %0\n\t"
  140. "ldc %0, sr"
  141. : "=&r" (__dummy)
  142. : "r" (~SR_FD));
  143. }
  144. /* Double presision, NANS as NANS, rounding to nearest, no exceptions */
  145. #define FPSCR_INIT 0x00080000
  146. #define FPSCR_CAUSE_MASK 0x0001f000 /* Cause bits */
  147. #define FPSCR_FLAG_MASK 0x0000007c /* Flag bits */
  148. /*
  149. * Return saved PC of a blocked thread.
  150. */
  151. #define thread_saved_pc(tsk) (tsk->thread.pc)
  152. void show_trace(struct task_struct *tsk, unsigned long *sp,
  153. struct pt_regs *regs);
  154. #ifdef CONFIG_DUMP_CODE
  155. void show_code(struct pt_regs *regs);
  156. #else
  157. static inline void show_code(struct pt_regs *regs)
  158. {
  159. }
  160. #endif
  161. extern unsigned long get_wchan(struct task_struct *p);
  162. #define KSTK_EIP(tsk) (task_pt_regs(tsk)->pc)
  163. #define KSTK_ESP(tsk) (task_pt_regs(tsk)->regs[15])
  164. #define user_stack_pointer(_regs) ((_regs)->regs[15])
  165. #if defined(CONFIG_CPU_SH2A) || defined(CONFIG_CPU_SH4)
  166. #define PREFETCH_STRIDE L1_CACHE_BYTES
  167. #define ARCH_HAS_PREFETCH
  168. #define ARCH_HAS_PREFETCHW
  169. static inline void prefetch(void *x)
  170. {
  171. __asm__ __volatile__ ("pref @%0\n\t" : : "r" (x) : "memory");
  172. }
  173. #define prefetchw(x) prefetch(x)
  174. #endif
  175. #endif /* __KERNEL__ */
  176. #endif /* __ASM_SH_PROCESSOR_32_H */