processor_64.h 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237
  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. /* Dummy fpu emulator */
  78. struct sh_fpu_soft_struct {
  79. unsigned long fp_regs[64];
  80. unsigned int fpscr;
  81. unsigned char lookahead;
  82. unsigned long entry_pc;
  83. };
  84. union thread_xstate {
  85. struct sh_fpu_hard_struct hardfpu;
  86. struct sh_fpu_soft_struct softfpu;
  87. /*
  88. * The structure definitions only produce 32 bit alignment, yet we need
  89. * to access them using 64 bit load/store as well.
  90. */
  91. unsigned long long alignment_dummy;
  92. };
  93. struct thread_struct {
  94. unsigned long sp;
  95. unsigned long pc;
  96. /* Various thread flags, see SH_THREAD_xxx */
  97. unsigned long flags;
  98. /* This stores the address of the pt_regs built during a context
  99. switch, or of the register save area built for a kernel mode
  100. exception. It is used for backtracing the stack of a sleeping task
  101. or one that traps in kernel mode. */
  102. struct pt_regs *kregs;
  103. /* This stores the address of the pt_regs constructed on entry from
  104. user mode. It is a fixed value over the lifetime of a process, or
  105. NULL for a kernel thread. */
  106. struct pt_regs *uregs;
  107. unsigned long trap_no, error_code;
  108. unsigned long address;
  109. /* Hardware debugging registers may come here */
  110. /* floating point info */
  111. union thread_xstate *xstate;
  112. };
  113. #define INIT_MMAP \
  114. { &init_mm, 0, 0, NULL, PAGE_SHARED, VM_READ | VM_WRITE | VM_EXEC, 1, NULL, NULL }
  115. #define INIT_THREAD { \
  116. .sp = sizeof(init_stack) + \
  117. (long) &init_stack, \
  118. .pc = 0, \
  119. .kregs = &fake_swapper_regs, \
  120. .uregs = NULL, \
  121. .trap_no = 0, \
  122. .error_code = 0, \
  123. .address = 0, \
  124. .flags = 0, \
  125. }
  126. /*
  127. * Do necessary setup to start up a newly executed thread.
  128. */
  129. #define SR_USER (SR_MMU | SR_FD)
  130. #define start_thread(_regs, new_pc, new_sp) \
  131. set_fs(USER_DS); \
  132. _regs->sr = SR_USER; /* User mode. */ \
  133. _regs->pc = new_pc - 4; /* Compensate syscall exit */ \
  134. _regs->pc |= 1; /* Set SHmedia ! */ \
  135. _regs->regs[18] = 0; \
  136. _regs->regs[15] = new_sp
  137. /* Forward declaration, a strange C thing */
  138. struct task_struct;
  139. struct mm_struct;
  140. /* Free all resources held by a thread. */
  141. extern void release_thread(struct task_struct *);
  142. /*
  143. * create a kernel thread without removing it from tasklists
  144. */
  145. extern int kernel_thread(int (*fn)(void *), void * arg, unsigned long flags);
  146. /* Copy and release all segment info associated with a VM */
  147. #define copy_segments(p, mm) do { } while (0)
  148. #define release_segments(mm) do { } while (0)
  149. #define forget_segments() do { } while (0)
  150. #define prepare_to_copy(tsk) do { } while (0)
  151. /*
  152. * FPU lazy state save handling.
  153. */
  154. static inline void disable_fpu(void)
  155. {
  156. unsigned long long __dummy;
  157. /* Set FD flag in SR */
  158. __asm__ __volatile__("getcon " __SR ", %0\n\t"
  159. "or %0, %1, %0\n\t"
  160. "putcon %0, " __SR "\n\t"
  161. : "=&r" (__dummy)
  162. : "r" (SR_FD));
  163. }
  164. static inline void enable_fpu(void)
  165. {
  166. unsigned long long __dummy;
  167. /* Clear out FD flag in SR */
  168. __asm__ __volatile__("getcon " __SR ", %0\n\t"
  169. "and %0, %1, %0\n\t"
  170. "putcon %0, " __SR "\n\t"
  171. : "=&r" (__dummy)
  172. : "r" (~SR_FD));
  173. }
  174. /* Round to nearest, no exceptions on inexact, overflow, underflow,
  175. zero-divide, invalid. Configure option for whether to flush denorms to
  176. zero, or except if a denorm is encountered. */
  177. #if defined(CONFIG_SH64_FPU_DENORM_FLUSH)
  178. #define FPSCR_INIT 0x00040000
  179. #else
  180. #define FPSCR_INIT 0x00000000
  181. #endif
  182. #ifdef CONFIG_SH_FPU
  183. /* Initialise the FP state of a task */
  184. void fpinit(struct sh_fpu_hard_struct *fpregs);
  185. #else
  186. #define fpinit(fpregs) do { } while (0)
  187. #endif
  188. extern struct task_struct *last_task_used_math;
  189. /*
  190. * Return saved PC of a blocked thread.
  191. */
  192. #define thread_saved_pc(tsk) (tsk->thread.pc)
  193. extern unsigned long get_wchan(struct task_struct *p);
  194. #define KSTK_EIP(tsk) ((tsk)->thread.pc)
  195. #define KSTK_ESP(tsk) ((tsk)->thread.sp)
  196. #define user_stack_pointer(_regs) ((_regs)->regs[15])
  197. #endif /* __ASSEMBLY__ */
  198. #endif /* __ASM_SH_PROCESSOR_64_H */