processor_32.h 5.1 KB

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