processor_32.h 4.7 KB

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