ttable.h 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407
  1. /* $Id: ttable.h,v 1.18 2002/02/09 19:49:32 davem Exp $ */
  2. #ifndef _SPARC64_TTABLE_H
  3. #define _SPARC64_TTABLE_H
  4. #include <linux/config.h>
  5. #include <asm/utrap.h>
  6. #ifdef __ASSEMBLY__
  7. #include <asm/thread_info.h>
  8. #endif
  9. #define BOOT_KERNEL b sparc64_boot; nop; nop; nop; nop; nop; nop; nop;
  10. /* We need a "cleaned" instruction... */
  11. #define CLEAN_WINDOW \
  12. rdpr %cleanwin, %l0; add %l0, 1, %l0; \
  13. wrpr %l0, 0x0, %cleanwin; \
  14. clr %o0; clr %o1; clr %o2; clr %o3; \
  15. clr %o4; clr %o5; clr %o6; clr %o7; \
  16. clr %l0; clr %l1; clr %l2; clr %l3; \
  17. clr %l4; clr %l5; clr %l6; clr %l7; \
  18. retry; \
  19. nop;nop;nop;nop;nop;nop;nop;nop;nop;nop;nop;nop;
  20. #define TRAP(routine) \
  21. sethi %hi(109f), %g7; \
  22. ba,pt %xcc, etrap; \
  23. 109: or %g7, %lo(109b), %g7; \
  24. call routine; \
  25. add %sp, PTREGS_OFF, %o0; \
  26. ba,pt %xcc, rtrap; \
  27. clr %l6; \
  28. nop;
  29. #define TRAP_7INSNS(routine) \
  30. sethi %hi(109f), %g7; \
  31. ba,pt %xcc, etrap; \
  32. 109: or %g7, %lo(109b), %g7; \
  33. call routine; \
  34. add %sp, PTREGS_OFF, %o0; \
  35. ba,pt %xcc, rtrap; \
  36. clr %l6;
  37. #define TRAP_SAVEFPU(routine) \
  38. sethi %hi(109f), %g7; \
  39. ba,pt %xcc, do_fptrap; \
  40. 109: or %g7, %lo(109b), %g7; \
  41. call routine; \
  42. add %sp, PTREGS_OFF, %o0; \
  43. ba,pt %xcc, rtrap; \
  44. clr %l6; \
  45. nop;
  46. #define TRAP_NOSAVE(routine) \
  47. ba,pt %xcc, routine; \
  48. nop; \
  49. nop; nop; nop; nop; nop; nop;
  50. #define TRAP_NOSAVE_7INSNS(routine) \
  51. ba,pt %xcc, routine; \
  52. nop; \
  53. nop; nop; nop; nop; nop;
  54. #define TRAPTL1(routine) \
  55. sethi %hi(109f), %g7; \
  56. ba,pt %xcc, etraptl1; \
  57. 109: or %g7, %lo(109b), %g7; \
  58. call routine; \
  59. add %sp, PTREGS_OFF, %o0; \
  60. ba,pt %xcc, rtrap; \
  61. clr %l6; \
  62. nop;
  63. #define TRAP_ARG(routine, arg) \
  64. sethi %hi(109f), %g7; \
  65. ba,pt %xcc, etrap; \
  66. 109: or %g7, %lo(109b), %g7; \
  67. add %sp, PTREGS_OFF, %o0; \
  68. call routine; \
  69. mov arg, %o1; \
  70. ba,pt %xcc, rtrap; \
  71. clr %l6;
  72. #define TRAPTL1_ARG(routine, arg) \
  73. sethi %hi(109f), %g7; \
  74. ba,pt %xcc, etraptl1; \
  75. 109: or %g7, %lo(109b), %g7; \
  76. add %sp, PTREGS_OFF, %o0; \
  77. call routine; \
  78. mov arg, %o1; \
  79. ba,pt %xcc, rtrap; \
  80. clr %l6;
  81. #define SYSCALL_TRAP(routine, systbl) \
  82. sethi %hi(109f), %g7; \
  83. ba,pt %xcc, scetrap; \
  84. 109: or %g7, %lo(109b), %g7; \
  85. sethi %hi(systbl), %l7; \
  86. ba,pt %xcc, routine; \
  87. or %l7, %lo(systbl), %l7; \
  88. nop; nop;
  89. #define INDIRECT_SOLARIS_SYSCALL(num) \
  90. sethi %hi(109f), %g7; \
  91. ba,pt %xcc, etrap; \
  92. 109: or %g7, %lo(109b), %g7; \
  93. ba,pt %xcc, tl0_solaris + 0xc; \
  94. mov num, %g1; \
  95. nop;nop;nop;
  96. #define TRAP_UTRAP(handler,lvl) \
  97. ldx [%g6 + TI_UTRAPS], %g1; \
  98. sethi %hi(109f), %g7; \
  99. brz,pn %g1, utrap; \
  100. or %g7, %lo(109f), %g7; \
  101. ba,pt %xcc, utrap; \
  102. 109: ldx [%g1 + handler*8], %g1; \
  103. ba,pt %xcc, utrap_ill; \
  104. mov lvl, %o1;
  105. #ifdef CONFIG_SUNOS_EMUL
  106. #define SUNOS_SYSCALL_TRAP SYSCALL_TRAP(linux_sparc_syscall32, sunos_sys_table)
  107. #else
  108. #define SUNOS_SYSCALL_TRAP TRAP(sunos_syscall)
  109. #endif
  110. #ifdef CONFIG_COMPAT
  111. #define LINUX_32BIT_SYSCALL_TRAP SYSCALL_TRAP(linux_sparc_syscall32, sys_call_table32)
  112. #else
  113. #define LINUX_32BIT_SYSCALL_TRAP BTRAP(0x110)
  114. #endif
  115. #define LINUX_64BIT_SYSCALL_TRAP SYSCALL_TRAP(linux_sparc_syscall, sys_call_table64)
  116. #define GETCC_TRAP TRAP(getcc)
  117. #define SETCC_TRAP TRAP(setcc)
  118. #ifdef CONFIG_SOLARIS_EMUL
  119. #define SOLARIS_SYSCALL_TRAP TRAP(solaris_sparc_syscall)
  120. #else
  121. #define SOLARIS_SYSCALL_TRAP TRAP(solaris_syscall)
  122. #endif
  123. /* FIXME: Write these actually */
  124. #define NETBSD_SYSCALL_TRAP TRAP(netbsd_syscall)
  125. #define BREAKPOINT_TRAP TRAP(breakpoint_trap)
  126. #define TRAP_IRQ(routine, level) \
  127. rdpr %pil, %g2; \
  128. wrpr %g0, 15, %pil; \
  129. b,pt %xcc, etrap_irq; \
  130. rd %pc, %g7; \
  131. mov level, %o0; \
  132. call routine; \
  133. add %sp, PTREGS_OFF, %o1; \
  134. ba,a,pt %xcc, rtrap_irq;
  135. #define TICK_SMP_IRQ \
  136. rdpr %pil, %g2; \
  137. wrpr %g0, 15, %pil; \
  138. sethi %hi(109f), %g7; \
  139. b,pt %xcc, etrap_irq; \
  140. 109: or %g7, %lo(109b), %g7; \
  141. call smp_percpu_timer_interrupt; \
  142. add %sp, PTREGS_OFF, %o0; \
  143. ba,a,pt %xcc, rtrap_irq;
  144. #define TRAP_IVEC TRAP_NOSAVE(do_ivec)
  145. #define BTRAP(lvl) TRAP_ARG(bad_trap, lvl)
  146. #define BTRAPTL1(lvl) TRAPTL1_ARG(bad_trap_tl1, lvl)
  147. #define FLUSH_WINDOW_TRAP \
  148. ba,pt %xcc, etrap; \
  149. rd %pc, %g7; \
  150. flushw; \
  151. ldx [%sp + PTREGS_OFF + PT_V9_TNPC], %l1; \
  152. add %l1, 4, %l2; \
  153. stx %l1, [%sp + PTREGS_OFF + PT_V9_TPC]; \
  154. ba,pt %xcc, rtrap_clr_l6; \
  155. stx %l2, [%sp + PTREGS_OFF + PT_V9_TNPC];
  156. #ifdef CONFIG_KPROBES
  157. #define KPROBES_TRAP(lvl) TRAP_IRQ(kprobe_trap, lvl)
  158. #else
  159. #define KPROBES_TRAP(lvl) TRAP_ARG(bad_trap, lvl)
  160. #endif
  161. /* Before touching these macros, you owe it to yourself to go and
  162. * see how arch/sparc64/kernel/winfixup.S works... -DaveM
  163. *
  164. * For the user cases we used to use the %asi register, but
  165. * it turns out that the "wr xxx, %asi" costs ~5 cycles, so
  166. * now we use immediate ASI loads and stores instead. Kudos
  167. * to Greg Onufer for pointing out this performance anomaly.
  168. *
  169. * Further note that we cannot use the g2, g4, g5, and g7 alternate
  170. * globals in the spill routines, check out the save instruction in
  171. * arch/sparc64/kernel/etrap.S to see what I mean about g2, and
  172. * g4/g5 are the globals which are preserved by etrap processing
  173. * for the caller of it. The g7 register is the return pc for
  174. * etrap. Finally, g6 is the current thread register so we cannot
  175. * us it in the spill handlers either. Most of these rules do not
  176. * apply to fill processing, only g6 is not usable.
  177. */
  178. /* Normal kernel spill */
  179. #define SPILL_0_NORMAL \
  180. stx %l0, [%sp + STACK_BIAS + 0x00]; \
  181. stx %l1, [%sp + STACK_BIAS + 0x08]; \
  182. stx %l2, [%sp + STACK_BIAS + 0x10]; \
  183. stx %l3, [%sp + STACK_BIAS + 0x18]; \
  184. stx %l4, [%sp + STACK_BIAS + 0x20]; \
  185. stx %l5, [%sp + STACK_BIAS + 0x28]; \
  186. stx %l6, [%sp + STACK_BIAS + 0x30]; \
  187. stx %l7, [%sp + STACK_BIAS + 0x38]; \
  188. stx %i0, [%sp + STACK_BIAS + 0x40]; \
  189. stx %i1, [%sp + STACK_BIAS + 0x48]; \
  190. stx %i2, [%sp + STACK_BIAS + 0x50]; \
  191. stx %i3, [%sp + STACK_BIAS + 0x58]; \
  192. stx %i4, [%sp + STACK_BIAS + 0x60]; \
  193. stx %i5, [%sp + STACK_BIAS + 0x68]; \
  194. stx %i6, [%sp + STACK_BIAS + 0x70]; \
  195. stx %i7, [%sp + STACK_BIAS + 0x78]; \
  196. saved; retry; nop; nop; nop; nop; nop; nop; \
  197. nop; nop; nop; nop; nop; nop; nop; nop;
  198. /* Normal 64bit spill */
  199. #define SPILL_1_GENERIC(ASI) \
  200. add %sp, STACK_BIAS + 0x00, %g1; \
  201. stxa %l0, [%g1 + %g0] ASI; \
  202. mov 0x08, %g3; \
  203. stxa %l1, [%g1 + %g3] ASI; \
  204. add %g1, 0x10, %g1; \
  205. stxa %l2, [%g1 + %g0] ASI; \
  206. stxa %l3, [%g1 + %g3] ASI; \
  207. add %g1, 0x10, %g1; \
  208. stxa %l4, [%g1 + %g0] ASI; \
  209. stxa %l5, [%g1 + %g3] ASI; \
  210. add %g1, 0x10, %g1; \
  211. stxa %l6, [%g1 + %g0] ASI; \
  212. stxa %l7, [%g1 + %g3] ASI; \
  213. add %g1, 0x10, %g1; \
  214. stxa %i0, [%g1 + %g0] ASI; \
  215. stxa %i1, [%g1 + %g3] ASI; \
  216. add %g1, 0x10, %g1; \
  217. stxa %i2, [%g1 + %g0] ASI; \
  218. stxa %i3, [%g1 + %g3] ASI; \
  219. add %g1, 0x10, %g1; \
  220. stxa %i4, [%g1 + %g0] ASI; \
  221. stxa %i5, [%g1 + %g3] ASI; \
  222. add %g1, 0x10, %g1; \
  223. stxa %i6, [%g1 + %g0] ASI; \
  224. stxa %i7, [%g1 + %g3] ASI; \
  225. saved; \
  226. retry; nop; nop; \
  227. b,a,pt %xcc, spill_fixup_dax; \
  228. b,a,pt %xcc, spill_fixup_mna; \
  229. b,a,pt %xcc, spill_fixup;
  230. /* Normal 32bit spill */
  231. #define SPILL_2_GENERIC(ASI) \
  232. srl %sp, 0, %sp; \
  233. stwa %l0, [%sp + %g0] ASI; \
  234. mov 0x04, %g3; \
  235. stwa %l1, [%sp + %g3] ASI; \
  236. add %sp, 0x08, %g1; \
  237. stwa %l2, [%g1 + %g0] ASI; \
  238. stwa %l3, [%g1 + %g3] ASI; \
  239. add %g1, 0x08, %g1; \
  240. stwa %l4, [%g1 + %g0] ASI; \
  241. stwa %l5, [%g1 + %g3] ASI; \
  242. add %g1, 0x08, %g1; \
  243. stwa %l6, [%g1 + %g0] ASI; \
  244. stwa %l7, [%g1 + %g3] ASI; \
  245. add %g1, 0x08, %g1; \
  246. stwa %i0, [%g1 + %g0] ASI; \
  247. stwa %i1, [%g1 + %g3] ASI; \
  248. add %g1, 0x08, %g1; \
  249. stwa %i2, [%g1 + %g0] ASI; \
  250. stwa %i3, [%g1 + %g3] ASI; \
  251. add %g1, 0x08, %g1; \
  252. stwa %i4, [%g1 + %g0] ASI; \
  253. stwa %i5, [%g1 + %g3] ASI; \
  254. add %g1, 0x08, %g1; \
  255. stwa %i6, [%g1 + %g0] ASI; \
  256. stwa %i7, [%g1 + %g3] ASI; \
  257. saved; \
  258. retry; nop; nop; \
  259. b,a,pt %xcc, spill_fixup_dax; \
  260. b,a,pt %xcc, spill_fixup_mna; \
  261. b,a,pt %xcc, spill_fixup;
  262. #define SPILL_1_NORMAL SPILL_1_GENERIC(ASI_AIUP)
  263. #define SPILL_2_NORMAL SPILL_2_GENERIC(ASI_AIUP)
  264. #define SPILL_3_NORMAL SPILL_0_NORMAL
  265. #define SPILL_4_NORMAL SPILL_0_NORMAL
  266. #define SPILL_5_NORMAL SPILL_0_NORMAL
  267. #define SPILL_6_NORMAL SPILL_0_NORMAL
  268. #define SPILL_7_NORMAL SPILL_0_NORMAL
  269. #define SPILL_0_OTHER SPILL_0_NORMAL
  270. #define SPILL_1_OTHER SPILL_1_GENERIC(ASI_AIUS)
  271. #define SPILL_2_OTHER SPILL_2_GENERIC(ASI_AIUS)
  272. #define SPILL_3_OTHER SPILL_3_NORMAL
  273. #define SPILL_4_OTHER SPILL_4_NORMAL
  274. #define SPILL_5_OTHER SPILL_5_NORMAL
  275. #define SPILL_6_OTHER SPILL_6_NORMAL
  276. #define SPILL_7_OTHER SPILL_7_NORMAL
  277. /* Normal kernel fill */
  278. #define FILL_0_NORMAL \
  279. ldx [%sp + STACK_BIAS + 0x00], %l0; \
  280. ldx [%sp + STACK_BIAS + 0x08], %l1; \
  281. ldx [%sp + STACK_BIAS + 0x10], %l2; \
  282. ldx [%sp + STACK_BIAS + 0x18], %l3; \
  283. ldx [%sp + STACK_BIAS + 0x20], %l4; \
  284. ldx [%sp + STACK_BIAS + 0x28], %l5; \
  285. ldx [%sp + STACK_BIAS + 0x30], %l6; \
  286. ldx [%sp + STACK_BIAS + 0x38], %l7; \
  287. ldx [%sp + STACK_BIAS + 0x40], %i0; \
  288. ldx [%sp + STACK_BIAS + 0x48], %i1; \
  289. ldx [%sp + STACK_BIAS + 0x50], %i2; \
  290. ldx [%sp + STACK_BIAS + 0x58], %i3; \
  291. ldx [%sp + STACK_BIAS + 0x60], %i4; \
  292. ldx [%sp + STACK_BIAS + 0x68], %i5; \
  293. ldx [%sp + STACK_BIAS + 0x70], %i6; \
  294. ldx [%sp + STACK_BIAS + 0x78], %i7; \
  295. restored; retry; nop; nop; nop; nop; nop; nop; \
  296. nop; nop; nop; nop; nop; nop; nop; nop;
  297. /* Normal 64bit fill */
  298. #define FILL_1_GENERIC(ASI) \
  299. add %sp, STACK_BIAS + 0x00, %g1; \
  300. ldxa [%g1 + %g0] ASI, %l0; \
  301. mov 0x08, %g2; \
  302. mov 0x10, %g3; \
  303. ldxa [%g1 + %g2] ASI, %l1; \
  304. mov 0x18, %g5; \
  305. ldxa [%g1 + %g3] ASI, %l2; \
  306. ldxa [%g1 + %g5] ASI, %l3; \
  307. add %g1, 0x20, %g1; \
  308. ldxa [%g1 + %g0] ASI, %l4; \
  309. ldxa [%g1 + %g2] ASI, %l5; \
  310. ldxa [%g1 + %g3] ASI, %l6; \
  311. ldxa [%g1 + %g5] ASI, %l7; \
  312. add %g1, 0x20, %g1; \
  313. ldxa [%g1 + %g0] ASI, %i0; \
  314. ldxa [%g1 + %g2] ASI, %i1; \
  315. ldxa [%g1 + %g3] ASI, %i2; \
  316. ldxa [%g1 + %g5] ASI, %i3; \
  317. add %g1, 0x20, %g1; \
  318. ldxa [%g1 + %g0] ASI, %i4; \
  319. ldxa [%g1 + %g2] ASI, %i5; \
  320. ldxa [%g1 + %g3] ASI, %i6; \
  321. ldxa [%g1 + %g5] ASI, %i7; \
  322. restored; \
  323. retry; nop; nop; nop; nop; \
  324. b,a,pt %xcc, fill_fixup_dax; \
  325. b,a,pt %xcc, fill_fixup_mna; \
  326. b,a,pt %xcc, fill_fixup;
  327. /* Normal 32bit fill */
  328. #define FILL_2_GENERIC(ASI) \
  329. srl %sp, 0, %sp; \
  330. lduwa [%sp + %g0] ASI, %l0; \
  331. mov 0x04, %g2; \
  332. mov 0x08, %g3; \
  333. lduwa [%sp + %g2] ASI, %l1; \
  334. mov 0x0c, %g5; \
  335. lduwa [%sp + %g3] ASI, %l2; \
  336. lduwa [%sp + %g5] ASI, %l3; \
  337. add %sp, 0x10, %g1; \
  338. lduwa [%g1 + %g0] ASI, %l4; \
  339. lduwa [%g1 + %g2] ASI, %l5; \
  340. lduwa [%g1 + %g3] ASI, %l6; \
  341. lduwa [%g1 + %g5] ASI, %l7; \
  342. add %g1, 0x10, %g1; \
  343. lduwa [%g1 + %g0] ASI, %i0; \
  344. lduwa [%g1 + %g2] ASI, %i1; \
  345. lduwa [%g1 + %g3] ASI, %i2; \
  346. lduwa [%g1 + %g5] ASI, %i3; \
  347. add %g1, 0x10, %g1; \
  348. lduwa [%g1 + %g0] ASI, %i4; \
  349. lduwa [%g1 + %g2] ASI, %i5; \
  350. lduwa [%g1 + %g3] ASI, %i6; \
  351. lduwa [%g1 + %g5] ASI, %i7; \
  352. restored; \
  353. retry; nop; nop; nop; nop; \
  354. b,a,pt %xcc, fill_fixup_dax; \
  355. b,a,pt %xcc, fill_fixup_mna; \
  356. b,a,pt %xcc, fill_fixup;
  357. #define FILL_1_NORMAL FILL_1_GENERIC(ASI_AIUP)
  358. #define FILL_2_NORMAL FILL_2_GENERIC(ASI_AIUP)
  359. #define FILL_3_NORMAL FILL_0_NORMAL
  360. #define FILL_4_NORMAL FILL_0_NORMAL
  361. #define FILL_5_NORMAL FILL_0_NORMAL
  362. #define FILL_6_NORMAL FILL_0_NORMAL
  363. #define FILL_7_NORMAL FILL_0_NORMAL
  364. #define FILL_0_OTHER FILL_0_NORMAL
  365. #define FILL_1_OTHER FILL_1_GENERIC(ASI_AIUS)
  366. #define FILL_2_OTHER FILL_2_GENERIC(ASI_AIUS)
  367. #define FILL_3_OTHER FILL_3_NORMAL
  368. #define FILL_4_OTHER FILL_4_NORMAL
  369. #define FILL_5_OTHER FILL_5_NORMAL
  370. #define FILL_6_OTHER FILL_6_NORMAL
  371. #define FILL_7_OTHER FILL_7_NORMAL
  372. #endif /* !(_SPARC64_TTABLE_H) */