processor_64.h 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291
  1. #ifndef __ASM_SH_PROCESSOR_64_H
  2. #define __ASM_SH_PROCESSOR_64_H
  3. /*
  4. * include/asm-sh/processor_64.h
  5. *
  6. * Copyright (C) 2000, 2001 Paolo Alberelli
  7. * Copyright (C) 2003 Paul Mundt
  8. * Copyright (C) 2004 Richard Curnow
  9. *
  10. * This file is subject to the terms and conditions of the GNU General Public
  11. * License. See the file "COPYING" in the main directory of this archive
  12. * for more details.
  13. */
  14. #ifndef __ASSEMBLY__
  15. #include <linux/compiler.h>
  16. #include <asm/page.h>
  17. #include <asm/types.h>
  18. #include <asm/cache.h>
  19. #include <asm/ptrace.h>
  20. #include <asm/cpu/registers.h>
  21. /*
  22. * Default implementation of macro that returns current
  23. * instruction pointer ("program counter").
  24. */
  25. #define current_text_addr() ({ \
  26. void *pc; \
  27. unsigned long long __dummy = 0; \
  28. __asm__("gettr tr0, %1\n\t" \
  29. "pta 4, tr0\n\t" \
  30. "gettr tr0, %0\n\t" \
  31. "ptabs %1, tr0\n\t" \
  32. :"=r" (pc), "=r" (__dummy) \
  33. : "1" (__dummy)); \
  34. pc; })
  35. /*
  36. * TLB information structure
  37. *
  38. * Defined for both I and D tlb, per-processor.
  39. */
  40. struct tlb_info {
  41. unsigned long long next;
  42. unsigned long long first;
  43. unsigned long long last;
  44. unsigned int entries;
  45. unsigned int step;
  46. unsigned long flags;
  47. };
  48. struct sh_cpuinfo {
  49. enum cpu_type type;
  50. unsigned long loops_per_jiffy;
  51. unsigned long asid_cache;
  52. unsigned int cpu_clock, master_clock, bus_clock, module_clock;
  53. /* Cache info */
  54. struct cache_info icache;
  55. struct cache_info dcache;
  56. struct cache_info scache;
  57. /* TLB info */
  58. struct tlb_info itlb;
  59. struct tlb_info dtlb;
  60. unsigned long flags;
  61. };
  62. extern struct sh_cpuinfo cpu_data[];
  63. #define boot_cpu_data cpu_data[0]
  64. #define current_cpu_data cpu_data[smp_processor_id()]
  65. #define raw_current_cpu_data cpu_data[raw_smp_processor_id()]
  66. #endif
  67. /*
  68. * User space process size: 2GB - 4k.
  69. */
  70. #define TASK_SIZE 0x7ffff000UL
  71. /* This decides where the kernel will search for a free chunk of vm
  72. * space during mmap's.
  73. */
  74. #define TASK_UNMAPPED_BASE (TASK_SIZE / 3)
  75. /*
  76. * Bit of SR register
  77. *
  78. * FD-bit:
  79. * When it's set, it means the processor doesn't have right to use FPU,
  80. * and it results exception when the floating operation is executed.
  81. *
  82. * IMASK-bit:
  83. * Interrupt level mask
  84. *
  85. * STEP-bit:
  86. * Single step bit
  87. *
  88. */
  89. #define SR_FD 0x00008000
  90. #if defined(CONFIG_SH64_SR_WATCH)
  91. #define SR_MMU 0x84000000
  92. #else
  93. #define SR_MMU 0x80000000
  94. #endif
  95. #define SR_IMASK 0x000000f0
  96. #define SR_SSTEP 0x08000000
  97. #ifndef __ASSEMBLY__
  98. /*
  99. * FPU structure and data : require 8-byte alignment as we need to access it
  100. with fld.p, fst.p
  101. */
  102. struct sh_fpu_hard_struct {
  103. unsigned long fp_regs[64];
  104. unsigned int fpscr;
  105. /* long status; * software status information */
  106. };
  107. #if 0
  108. /* Dummy fpu emulator */
  109. struct sh_fpu_soft_struct {
  110. unsigned long long fp_regs[32];
  111. unsigned int fpscr;
  112. unsigned char lookahead;
  113. unsigned long entry_pc;
  114. };
  115. #endif
  116. union sh_fpu_union {
  117. struct sh_fpu_hard_struct hard;
  118. /* 'hard' itself only produces 32 bit alignment, yet we need
  119. to access it using 64 bit load/store as well. */
  120. unsigned long long alignment_dummy;
  121. };
  122. struct thread_struct {
  123. unsigned long sp;
  124. unsigned long pc;
  125. /* This stores the address of the pt_regs built during a context
  126. switch, or of the register save area built for a kernel mode
  127. exception. It is used for backtracing the stack of a sleeping task
  128. or one that traps in kernel mode. */
  129. struct pt_regs *kregs;
  130. /* This stores the address of the pt_regs constructed on entry from
  131. user mode. It is a fixed value over the lifetime of a process, or
  132. NULL for a kernel thread. */
  133. struct pt_regs *uregs;
  134. unsigned long trap_no, error_code;
  135. unsigned long address;
  136. /* Hardware debugging registers may come here */
  137. /* floating point info */
  138. union sh_fpu_union fpu;
  139. };
  140. typedef struct {
  141. unsigned long seg;
  142. } mm_segment_t;
  143. #define INIT_MMAP \
  144. { &init_mm, 0, 0, NULL, PAGE_SHARED, VM_READ | VM_WRITE | VM_EXEC, 1, NULL, NULL }
  145. extern struct pt_regs fake_swapper_regs;
  146. #define INIT_THREAD { \
  147. .sp = sizeof(init_stack) + \
  148. (long) &init_stack, \
  149. .pc = 0, \
  150. .kregs = &fake_swapper_regs, \
  151. .uregs = NULL, \
  152. .trap_no = 0, \
  153. .error_code = 0, \
  154. .address = 0, \
  155. .fpu = { { { 0, } }, } \
  156. }
  157. /*
  158. * Do necessary setup to start up a newly executed thread.
  159. */
  160. #define SR_USER (SR_MMU | SR_FD)
  161. #define start_thread(regs, new_pc, new_sp) \
  162. set_fs(USER_DS); \
  163. regs->sr = SR_USER; /* User mode. */ \
  164. regs->pc = new_pc - 4; /* Compensate syscall exit */ \
  165. regs->pc |= 1; /* Set SHmedia ! */ \
  166. regs->regs[18] = 0; \
  167. regs->regs[15] = new_sp
  168. /* Forward declaration, a strange C thing */
  169. struct task_struct;
  170. struct mm_struct;
  171. /* Free all resources held by a thread. */
  172. extern void release_thread(struct task_struct *);
  173. /*
  174. * create a kernel thread without removing it from tasklists
  175. */
  176. extern int kernel_thread(int (*fn)(void *), void * arg, unsigned long flags);
  177. /* Copy and release all segment info associated with a VM */
  178. #define copy_segments(p, mm) do { } while (0)
  179. #define release_segments(mm) do { } while (0)
  180. #define forget_segments() do { } while (0)
  181. #define prepare_to_copy(tsk) do { } while (0)
  182. /*
  183. * FPU lazy state save handling.
  184. */
  185. static inline void disable_fpu(void)
  186. {
  187. unsigned long long __dummy;
  188. /* Set FD flag in SR */
  189. __asm__ __volatile__("getcon " __SR ", %0\n\t"
  190. "or %0, %1, %0\n\t"
  191. "putcon %0, " __SR "\n\t"
  192. : "=&r" (__dummy)
  193. : "r" (SR_FD));
  194. }
  195. static inline void enable_fpu(void)
  196. {
  197. unsigned long long __dummy;
  198. /* Clear out FD flag in SR */
  199. __asm__ __volatile__("getcon " __SR ", %0\n\t"
  200. "and %0, %1, %0\n\t"
  201. "putcon %0, " __SR "\n\t"
  202. : "=&r" (__dummy)
  203. : "r" (~SR_FD));
  204. }
  205. static inline void release_fpu(struct pt_regs *regs)
  206. {
  207. regs->sr |= SR_FD;
  208. }
  209. static inline void grab_fpu(struct pt_regs *regs)
  210. {
  211. regs->sr &= ~SR_FD;
  212. }
  213. /* Round to nearest, no exceptions on inexact, overflow, underflow,
  214. zero-divide, invalid. Configure option for whether to flush denorms to
  215. zero, or except if a denorm is encountered. */
  216. #if defined(CONFIG_SH64_FPU_DENORM_FLUSH)
  217. #define FPSCR_INIT 0x00040000
  218. #else
  219. #define FPSCR_INIT 0x00000000
  220. #endif
  221. #ifdef CONFIG_SH_FPU
  222. /* Save the current FP regs */
  223. void fpsave(struct sh_fpu_hard_struct *fpregs);
  224. /* Initialise the FP state of a task */
  225. void fpinit(struct sh_fpu_hard_struct *fpregs);
  226. #else
  227. #define fpsave(fpregs) do { } while (0)
  228. #define fpinit(fpregs) do { } while (0)
  229. #endif
  230. extern struct task_struct *last_task_used_math;
  231. /*
  232. * Return saved PC of a blocked thread.
  233. */
  234. #define thread_saved_pc(tsk) (tsk->thread.pc)
  235. extern unsigned long get_wchan(struct task_struct *p);
  236. #define KSTK_EIP(tsk) ((tsk)->thread.pc)
  237. #define KSTK_ESP(tsk) ((tsk)->thread.sp)
  238. #define cpu_relax() barrier()
  239. #endif /* __ASSEMBLY__ */
  240. #endif /* __ASM_SH_PROCESSOR_64_H */