processor_64.h 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275
  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 <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. #define STACK_TOP TASK_SIZE
  72. #define STACK_TOP_MAX STACK_TOP
  73. /* This decides where the kernel will search for a free chunk of vm
  74. * space during mmap's.
  75. */
  76. #define TASK_UNMAPPED_BASE (TASK_SIZE / 3)
  77. /*
  78. * Bit of SR register
  79. *
  80. * FD-bit:
  81. * When it's set, it means the processor doesn't have right to use FPU,
  82. * and it results exception when the floating operation is executed.
  83. *
  84. * IMASK-bit:
  85. * Interrupt level mask
  86. *
  87. * STEP-bit:
  88. * Single step bit
  89. *
  90. */
  91. #if defined(CONFIG_SH64_SR_WATCH)
  92. #define SR_MMU 0x84000000
  93. #else
  94. #define SR_MMU 0x80000000
  95. #endif
  96. #define SR_IMASK 0x000000f0
  97. #define SR_FD 0x00008000
  98. #define SR_SSTEP 0x08000000
  99. #ifndef __ASSEMBLY__
  100. /*
  101. * FPU structure and data : require 8-byte alignment as we need to access it
  102. with fld.p, fst.p
  103. */
  104. struct sh_fpu_hard_struct {
  105. unsigned long fp_regs[64];
  106. unsigned int fpscr;
  107. /* long status; * software status information */
  108. };
  109. #if 0
  110. /* Dummy fpu emulator */
  111. struct sh_fpu_soft_struct {
  112. unsigned long long fp_regs[32];
  113. unsigned int fpscr;
  114. unsigned char lookahead;
  115. unsigned long entry_pc;
  116. };
  117. #endif
  118. union sh_fpu_union {
  119. struct sh_fpu_hard_struct hard;
  120. /* 'hard' itself only produces 32 bit alignment, yet we need
  121. to access it using 64 bit load/store as well. */
  122. unsigned long long alignment_dummy;
  123. };
  124. struct thread_struct {
  125. unsigned long sp;
  126. unsigned long pc;
  127. /* This stores the address of the pt_regs built during a context
  128. switch, or of the register save area built for a kernel mode
  129. exception. It is used for backtracing the stack of a sleeping task
  130. or one that traps in kernel mode. */
  131. struct pt_regs *kregs;
  132. /* This stores the address of the pt_regs constructed on entry from
  133. user mode. It is a fixed value over the lifetime of a process, or
  134. NULL for a kernel thread. */
  135. struct pt_regs *uregs;
  136. unsigned long trap_no, error_code;
  137. unsigned long address;
  138. /* Hardware debugging registers may come here */
  139. /* floating point info */
  140. union sh_fpu_union fpu;
  141. };
  142. #define INIT_MMAP \
  143. { &init_mm, 0, 0, NULL, PAGE_SHARED, VM_READ | VM_WRITE | VM_EXEC, 1, NULL, NULL }
  144. extern struct pt_regs fake_swapper_regs;
  145. #define INIT_THREAD { \
  146. .sp = sizeof(init_stack) + \
  147. (long) &init_stack, \
  148. .pc = 0, \
  149. .kregs = &fake_swapper_regs, \
  150. .uregs = NULL, \
  151. .trap_no = 0, \
  152. .error_code = 0, \
  153. .address = 0, \
  154. .fpu = { { { 0, } }, } \
  155. }
  156. /*
  157. * Do necessary setup to start up a newly executed thread.
  158. */
  159. #define SR_USER (SR_MMU | SR_FD)
  160. #define start_thread(regs, new_pc, new_sp) \
  161. set_fs(USER_DS); \
  162. regs->sr = SR_USER; /* User mode. */ \
  163. regs->pc = new_pc - 4; /* Compensate syscall exit */ \
  164. regs->pc |= 1; /* Set SHmedia ! */ \
  165. regs->regs[18] = 0; \
  166. regs->regs[15] = new_sp
  167. /* Forward declaration, a strange C thing */
  168. struct task_struct;
  169. struct mm_struct;
  170. /* Free all resources held by a thread. */
  171. extern void release_thread(struct task_struct *);
  172. /*
  173. * create a kernel thread without removing it from tasklists
  174. */
  175. extern int kernel_thread(int (*fn)(void *), void * arg, unsigned long flags);
  176. /* Copy and release all segment info associated with a VM */
  177. #define copy_segments(p, mm) do { } while (0)
  178. #define release_segments(mm) do { } while (0)
  179. #define forget_segments() do { } while (0)
  180. #define prepare_to_copy(tsk) do { } while (0)
  181. /*
  182. * FPU lazy state save handling.
  183. */
  184. static inline void disable_fpu(void)
  185. {
  186. unsigned long long __dummy;
  187. /* Set FD flag in SR */
  188. __asm__ __volatile__("getcon " __SR ", %0\n\t"
  189. "or %0, %1, %0\n\t"
  190. "putcon %0, " __SR "\n\t"
  191. : "=&r" (__dummy)
  192. : "r" (SR_FD));
  193. }
  194. static inline void enable_fpu(void)
  195. {
  196. unsigned long long __dummy;
  197. /* Clear out FD flag in SR */
  198. __asm__ __volatile__("getcon " __SR ", %0\n\t"
  199. "and %0, %1, %0\n\t"
  200. "putcon %0, " __SR "\n\t"
  201. : "=&r" (__dummy)
  202. : "r" (~SR_FD));
  203. }
  204. /* Round to nearest, no exceptions on inexact, overflow, underflow,
  205. zero-divide, invalid. Configure option for whether to flush denorms to
  206. zero, or except if a denorm is encountered. */
  207. #if defined(CONFIG_SH64_FPU_DENORM_FLUSH)
  208. #define FPSCR_INIT 0x00040000
  209. #else
  210. #define FPSCR_INIT 0x00000000
  211. #endif
  212. #ifdef CONFIG_SH_FPU
  213. /* Initialise the FP state of a task */
  214. void fpinit(struct sh_fpu_hard_struct *fpregs);
  215. #else
  216. #define fpinit(fpregs) do { } while (0)
  217. #endif
  218. extern struct task_struct *last_task_used_math;
  219. /*
  220. * Return saved PC of a blocked thread.
  221. */
  222. #define thread_saved_pc(tsk) (tsk->thread.pc)
  223. extern unsigned long get_wchan(struct task_struct *p);
  224. #define KSTK_EIP(tsk) ((tsk)->thread.pc)
  225. #define KSTK_ESP(tsk) ((tsk)->thread.sp)
  226. #define cpu_relax() barrier()
  227. #endif /* __ASSEMBLY__ */
  228. #endif /* __ASM_SH_PROCESSOR_64_H */