processor_64.h 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232
  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/ptrace.h>
  19. #include <cpu/registers.h>
  20. /*
  21. * Default implementation of macro that returns current
  22. * instruction pointer ("program counter").
  23. */
  24. #define current_text_addr() ({ \
  25. void *pc; \
  26. unsigned long long __dummy = 0; \
  27. __asm__("gettr tr0, %1\n\t" \
  28. "pta 4, tr0\n\t" \
  29. "gettr tr0, %0\n\t" \
  30. "ptabs %1, tr0\n\t" \
  31. :"=r" (pc), "=r" (__dummy) \
  32. : "1" (__dummy)); \
  33. pc; })
  34. #endif
  35. /*
  36. * User space process size: 2GB - 4k.
  37. */
  38. #define TASK_SIZE 0x7ffff000UL
  39. #define STACK_TOP TASK_SIZE
  40. #define STACK_TOP_MAX STACK_TOP
  41. /* This decides where the kernel will search for a free chunk of vm
  42. * space during mmap's.
  43. */
  44. #define TASK_UNMAPPED_BASE (TASK_SIZE / 3)
  45. /*
  46. * Bit of SR register
  47. *
  48. * FD-bit:
  49. * When it's set, it means the processor doesn't have right to use FPU,
  50. * and it results exception when the floating operation is executed.
  51. *
  52. * IMASK-bit:
  53. * Interrupt level mask
  54. *
  55. * STEP-bit:
  56. * Single step bit
  57. *
  58. */
  59. #if defined(CONFIG_SH64_SR_WATCH)
  60. #define SR_MMU 0x84000000
  61. #else
  62. #define SR_MMU 0x80000000
  63. #endif
  64. #define SR_IMASK 0x000000f0
  65. #define SR_FD 0x00008000
  66. #define SR_SSTEP 0x08000000
  67. #ifndef __ASSEMBLY__
  68. /*
  69. * FPU structure and data : require 8-byte alignment as we need to access it
  70. with fld.p, fst.p
  71. */
  72. struct sh_fpu_hard_struct {
  73. unsigned long fp_regs[64];
  74. unsigned int fpscr;
  75. /* long status; * software status information */
  76. };
  77. #if 0
  78. /* Dummy fpu emulator */
  79. struct sh_fpu_soft_struct {
  80. unsigned long long fp_regs[32];
  81. unsigned int fpscr;
  82. unsigned char lookahead;
  83. unsigned long entry_pc;
  84. };
  85. #endif
  86. union sh_fpu_union {
  87. struct sh_fpu_hard_struct hard;
  88. /* 'hard' itself only produces 32 bit alignment, yet we need
  89. to access it using 64 bit load/store as well. */
  90. unsigned long long alignment_dummy;
  91. };
  92. struct thread_struct {
  93. unsigned long sp;
  94. unsigned long pc;
  95. /* This stores the address of the pt_regs built during a context
  96. switch, or of the register save area built for a kernel mode
  97. exception. It is used for backtracing the stack of a sleeping task
  98. or one that traps in kernel mode. */
  99. struct pt_regs *kregs;
  100. /* This stores the address of the pt_regs constructed on entry from
  101. user mode. It is a fixed value over the lifetime of a process, or
  102. NULL for a kernel thread. */
  103. struct pt_regs *uregs;
  104. unsigned long trap_no, error_code;
  105. unsigned long address;
  106. /* Hardware debugging registers may come here */
  107. /* floating point info */
  108. union sh_fpu_union fpu;
  109. };
  110. #define INIT_MMAP \
  111. { &init_mm, 0, 0, NULL, PAGE_SHARED, VM_READ | VM_WRITE | VM_EXEC, 1, NULL, NULL }
  112. #define INIT_THREAD { \
  113. .sp = sizeof(init_stack) + \
  114. (long) &init_stack, \
  115. .pc = 0, \
  116. .kregs = &fake_swapper_regs, \
  117. .uregs = NULL, \
  118. .trap_no = 0, \
  119. .error_code = 0, \
  120. .address = 0, \
  121. .fpu = { { { 0, } }, } \
  122. }
  123. /*
  124. * Do necessary setup to start up a newly executed thread.
  125. */
  126. #define SR_USER (SR_MMU | SR_FD)
  127. #define start_thread(_regs, new_pc, new_sp) \
  128. set_fs(USER_DS); \
  129. _regs->sr = SR_USER; /* User mode. */ \
  130. _regs->pc = new_pc - 4; /* Compensate syscall exit */ \
  131. _regs->pc |= 1; /* Set SHmedia ! */ \
  132. _regs->regs[18] = 0; \
  133. _regs->regs[15] = new_sp
  134. /* Forward declaration, a strange C thing */
  135. struct task_struct;
  136. struct mm_struct;
  137. /* Free all resources held by a thread. */
  138. extern void release_thread(struct task_struct *);
  139. /*
  140. * create a kernel thread without removing it from tasklists
  141. */
  142. extern int kernel_thread(int (*fn)(void *), void * arg, unsigned long flags);
  143. /* Copy and release all segment info associated with a VM */
  144. #define copy_segments(p, mm) do { } while (0)
  145. #define release_segments(mm) do { } while (0)
  146. #define forget_segments() do { } while (0)
  147. #define prepare_to_copy(tsk) do { } while (0)
  148. /*
  149. * FPU lazy state save handling.
  150. */
  151. static inline void disable_fpu(void)
  152. {
  153. unsigned long long __dummy;
  154. /* Set FD flag in SR */
  155. __asm__ __volatile__("getcon " __SR ", %0\n\t"
  156. "or %0, %1, %0\n\t"
  157. "putcon %0, " __SR "\n\t"
  158. : "=&r" (__dummy)
  159. : "r" (SR_FD));
  160. }
  161. static inline void enable_fpu(void)
  162. {
  163. unsigned long long __dummy;
  164. /* Clear out FD flag in SR */
  165. __asm__ __volatile__("getcon " __SR ", %0\n\t"
  166. "and %0, %1, %0\n\t"
  167. "putcon %0, " __SR "\n\t"
  168. : "=&r" (__dummy)
  169. : "r" (~SR_FD));
  170. }
  171. /* Round to nearest, no exceptions on inexact, overflow, underflow,
  172. zero-divide, invalid. Configure option for whether to flush denorms to
  173. zero, or except if a denorm is encountered. */
  174. #if defined(CONFIG_SH64_FPU_DENORM_FLUSH)
  175. #define FPSCR_INIT 0x00040000
  176. #else
  177. #define FPSCR_INIT 0x00000000
  178. #endif
  179. #ifdef CONFIG_SH_FPU
  180. /* Initialise the FP state of a task */
  181. void fpinit(struct sh_fpu_hard_struct *fpregs);
  182. #else
  183. #define fpinit(fpregs) do { } while (0)
  184. #endif
  185. extern struct task_struct *last_task_used_math;
  186. /*
  187. * Return saved PC of a blocked thread.
  188. */
  189. #define thread_saved_pc(tsk) (tsk->thread.pc)
  190. extern unsigned long get_wchan(struct task_struct *p);
  191. #define KSTK_EIP(tsk) ((tsk)->thread.pc)
  192. #define KSTK_ESP(tsk) ((tsk)->thread.sp)
  193. #define user_stack_pointer(_regs) ((_regs)->regs[15])
  194. #endif /* __ASSEMBLY__ */
  195. #endif /* __ASM_SH_PROCESSOR_64_H */