processor_64.h 5.5 KB

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