ttable.h 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670
  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 <asm/utrap.h>
  5. #ifdef __ASSEMBLY__
  6. #include <asm/thread_info.h>
  7. #endif
  8. #define BOOT_KERNEL b sparc64_boot; nop; nop; nop; nop; nop; nop; nop;
  9. /* We need a "cleaned" instruction... */
  10. #define CLEAN_WINDOW \
  11. rdpr %cleanwin, %l0; add %l0, 1, %l0; \
  12. wrpr %l0, 0x0, %cleanwin; \
  13. clr %o0; clr %o1; clr %o2; clr %o3; \
  14. clr %o4; clr %o5; clr %o6; clr %o7; \
  15. clr %l0; clr %l1; clr %l2; clr %l3; \
  16. clr %l4; clr %l5; clr %l6; clr %l7; \
  17. retry; \
  18. nop;nop;nop;nop;nop;nop;nop;nop;nop;nop;nop;nop;
  19. #define TRAP(routine) \
  20. sethi %hi(109f), %g7; \
  21. ba,pt %xcc, etrap; \
  22. 109: or %g7, %lo(109b), %g7; \
  23. call routine; \
  24. add %sp, PTREGS_OFF, %o0; \
  25. ba,pt %xcc, rtrap; \
  26. clr %l6; \
  27. nop;
  28. #define TRAP_7INSNS(routine) \
  29. sethi %hi(109f), %g7; \
  30. ba,pt %xcc, etrap; \
  31. 109: or %g7, %lo(109b), %g7; \
  32. call routine; \
  33. add %sp, PTREGS_OFF, %o0; \
  34. ba,pt %xcc, rtrap; \
  35. clr %l6;
  36. #define TRAP_SAVEFPU(routine) \
  37. sethi %hi(109f), %g7; \
  38. ba,pt %xcc, do_fptrap; \
  39. 109: or %g7, %lo(109b), %g7; \
  40. call routine; \
  41. add %sp, PTREGS_OFF, %o0; \
  42. ba,pt %xcc, rtrap; \
  43. clr %l6; \
  44. nop;
  45. #define TRAP_NOSAVE(routine) \
  46. ba,pt %xcc, routine; \
  47. nop; \
  48. nop; nop; nop; nop; nop; nop;
  49. #define TRAP_NOSAVE_7INSNS(routine) \
  50. ba,pt %xcc, routine; \
  51. nop; \
  52. nop; nop; nop; nop; nop;
  53. #define TRAPTL1(routine) \
  54. sethi %hi(109f), %g7; \
  55. ba,pt %xcc, etraptl1; \
  56. 109: or %g7, %lo(109b), %g7; \
  57. call routine; \
  58. add %sp, PTREGS_OFF, %o0; \
  59. ba,pt %xcc, rtrap; \
  60. clr %l6; \
  61. nop;
  62. #define TRAP_ARG(routine, arg) \
  63. sethi %hi(109f), %g7; \
  64. ba,pt %xcc, etrap; \
  65. 109: or %g7, %lo(109b), %g7; \
  66. add %sp, PTREGS_OFF, %o0; \
  67. call routine; \
  68. mov arg, %o1; \
  69. ba,pt %xcc, rtrap; \
  70. clr %l6;
  71. #define TRAPTL1_ARG(routine, arg) \
  72. sethi %hi(109f), %g7; \
  73. ba,pt %xcc, etraptl1; \
  74. 109: or %g7, %lo(109b), %g7; \
  75. add %sp, PTREGS_OFF, %o0; \
  76. call routine; \
  77. mov arg, %o1; \
  78. ba,pt %xcc, rtrap; \
  79. clr %l6;
  80. #define SYSCALL_TRAP(routine, systbl) \
  81. sethi %hi(109f), %g7; \
  82. ba,pt %xcc, etrap; \
  83. 109: or %g7, %lo(109b), %g7; \
  84. sethi %hi(systbl), %l7; \
  85. ba,pt %xcc, routine; \
  86. or %l7, %lo(systbl), %l7; \
  87. nop; nop;
  88. #define INDIRECT_SOLARIS_SYSCALL(num) \
  89. sethi %hi(109f), %g7; \
  90. ba,pt %xcc, etrap; \
  91. 109: or %g7, %lo(109b), %g7; \
  92. ba,pt %xcc, tl0_solaris + 0xc; \
  93. mov num, %g1; \
  94. nop;nop;nop;
  95. #define TRAP_UTRAP(handler,lvl) \
  96. mov handler, %g3; \
  97. ba,pt %xcc, utrap_trap; \
  98. mov lvl, %g4; \
  99. nop; \
  100. nop; \
  101. nop; \
  102. nop; \
  103. nop;
  104. #ifdef CONFIG_SUNOS_EMUL
  105. #define SUNOS_SYSCALL_TRAP SYSCALL_TRAP(linux_sparc_syscall32, sunos_sys_table)
  106. #else
  107. #define SUNOS_SYSCALL_TRAP TRAP(sunos_syscall)
  108. #endif
  109. #ifdef CONFIG_COMPAT
  110. #define LINUX_32BIT_SYSCALL_TRAP SYSCALL_TRAP(linux_sparc_syscall32, sys_call_table32)
  111. #else
  112. #define LINUX_32BIT_SYSCALL_TRAP BTRAP(0x110)
  113. #endif
  114. #define LINUX_64BIT_SYSCALL_TRAP SYSCALL_TRAP(linux_sparc_syscall, sys_call_table64)
  115. #define GETCC_TRAP TRAP(getcc)
  116. #define SETCC_TRAP TRAP(setcc)
  117. #ifdef CONFIG_SOLARIS_EMUL
  118. #define SOLARIS_SYSCALL_TRAP TRAP(solaris_sparc_syscall)
  119. #else
  120. #define SOLARIS_SYSCALL_TRAP TRAP(solaris_syscall)
  121. #endif
  122. #define BREAKPOINT_TRAP TRAP(breakpoint_trap)
  123. #ifdef CONFIG_TRACE_IRQFLAGS
  124. #define TRAP_IRQ(routine, level) \
  125. rdpr %pil, %g2; \
  126. wrpr %g0, 15, %pil; \
  127. sethi %hi(1f-4), %g7; \
  128. ba,pt %xcc, etrap_irq; \
  129. or %g7, %lo(1f-4), %g7; \
  130. nop; \
  131. nop; \
  132. nop; \
  133. .subsection 2; \
  134. 1: call trace_hardirqs_off; \
  135. nop; \
  136. mov level, %o0; \
  137. call routine; \
  138. add %sp, PTREGS_OFF, %o1; \
  139. ba,a,pt %xcc, rtrap_irq; \
  140. .previous;
  141. #else
  142. #define TRAP_IRQ(routine, level) \
  143. rdpr %pil, %g2; \
  144. wrpr %g0, 15, %pil; \
  145. ba,pt %xcc, etrap_irq; \
  146. rd %pc, %g7; \
  147. mov level, %o0; \
  148. call routine; \
  149. add %sp, PTREGS_OFF, %o1; \
  150. ba,a,pt %xcc, rtrap_irq;
  151. #endif
  152. #define TRAP_IVEC TRAP_NOSAVE(do_ivec)
  153. #define BTRAP(lvl) TRAP_ARG(bad_trap, lvl)
  154. #define BTRAPTL1(lvl) TRAPTL1_ARG(bad_trap_tl1, lvl)
  155. #define FLUSH_WINDOW_TRAP \
  156. ba,pt %xcc, etrap; \
  157. rd %pc, %g7; \
  158. flushw; \
  159. ldx [%sp + PTREGS_OFF + PT_V9_TNPC], %l1; \
  160. add %l1, 4, %l2; \
  161. stx %l1, [%sp + PTREGS_OFF + PT_V9_TPC]; \
  162. ba,pt %xcc, rtrap_clr_l6; \
  163. stx %l2, [%sp + PTREGS_OFF + PT_V9_TNPC];
  164. #ifdef CONFIG_KPROBES
  165. #define KPROBES_TRAP(lvl) TRAP_IRQ(kprobe_trap, lvl)
  166. #else
  167. #define KPROBES_TRAP(lvl) TRAP_ARG(bad_trap, lvl)
  168. #endif
  169. #define SUN4V_ITSB_MISS \
  170. ldxa [%g0] ASI_SCRATCHPAD, %g2; \
  171. ldx [%g2 + HV_FAULT_I_ADDR_OFFSET], %g4; \
  172. ldx [%g2 + HV_FAULT_I_CTX_OFFSET], %g5; \
  173. srlx %g4, 22, %g6; \
  174. ba,pt %xcc, sun4v_itsb_miss; \
  175. nop; \
  176. nop; \
  177. nop;
  178. #define SUN4V_DTSB_MISS \
  179. ldxa [%g0] ASI_SCRATCHPAD, %g2; \
  180. ldx [%g2 + HV_FAULT_D_ADDR_OFFSET], %g4; \
  181. ldx [%g2 + HV_FAULT_D_CTX_OFFSET], %g5; \
  182. srlx %g4, 22, %g6; \
  183. ba,pt %xcc, sun4v_dtsb_miss; \
  184. nop; \
  185. nop; \
  186. nop;
  187. /* Before touching these macros, you owe it to yourself to go and
  188. * see how arch/sparc64/kernel/winfixup.S works... -DaveM
  189. *
  190. * For the user cases we used to use the %asi register, but
  191. * it turns out that the "wr xxx, %asi" costs ~5 cycles, so
  192. * now we use immediate ASI loads and stores instead. Kudos
  193. * to Greg Onufer for pointing out this performance anomaly.
  194. *
  195. * Further note that we cannot use the g2, g4, g5, and g7 alternate
  196. * globals in the spill routines, check out the save instruction in
  197. * arch/sparc64/kernel/etrap.S to see what I mean about g2, and
  198. * g4/g5 are the globals which are preserved by etrap processing
  199. * for the caller of it. The g7 register is the return pc for
  200. * etrap. Finally, g6 is the current thread register so we cannot
  201. * us it in the spill handlers either. Most of these rules do not
  202. * apply to fill processing, only g6 is not usable.
  203. */
  204. /* Normal kernel spill */
  205. #define SPILL_0_NORMAL \
  206. stx %l0, [%sp + STACK_BIAS + 0x00]; \
  207. stx %l1, [%sp + STACK_BIAS + 0x08]; \
  208. stx %l2, [%sp + STACK_BIAS + 0x10]; \
  209. stx %l3, [%sp + STACK_BIAS + 0x18]; \
  210. stx %l4, [%sp + STACK_BIAS + 0x20]; \
  211. stx %l5, [%sp + STACK_BIAS + 0x28]; \
  212. stx %l6, [%sp + STACK_BIAS + 0x30]; \
  213. stx %l7, [%sp + STACK_BIAS + 0x38]; \
  214. stx %i0, [%sp + STACK_BIAS + 0x40]; \
  215. stx %i1, [%sp + STACK_BIAS + 0x48]; \
  216. stx %i2, [%sp + STACK_BIAS + 0x50]; \
  217. stx %i3, [%sp + STACK_BIAS + 0x58]; \
  218. stx %i4, [%sp + STACK_BIAS + 0x60]; \
  219. stx %i5, [%sp + STACK_BIAS + 0x68]; \
  220. stx %i6, [%sp + STACK_BIAS + 0x70]; \
  221. stx %i7, [%sp + STACK_BIAS + 0x78]; \
  222. saved; retry; nop; nop; nop; nop; nop; nop; \
  223. nop; nop; nop; nop; nop; nop; nop; nop;
  224. #define SPILL_0_NORMAL_ETRAP \
  225. etrap_kernel_spill: \
  226. stx %l0, [%sp + STACK_BIAS + 0x00]; \
  227. stx %l1, [%sp + STACK_BIAS + 0x08]; \
  228. stx %l2, [%sp + STACK_BIAS + 0x10]; \
  229. stx %l3, [%sp + STACK_BIAS + 0x18]; \
  230. stx %l4, [%sp + STACK_BIAS + 0x20]; \
  231. stx %l5, [%sp + STACK_BIAS + 0x28]; \
  232. stx %l6, [%sp + STACK_BIAS + 0x30]; \
  233. stx %l7, [%sp + STACK_BIAS + 0x38]; \
  234. stx %i0, [%sp + STACK_BIAS + 0x40]; \
  235. stx %i1, [%sp + STACK_BIAS + 0x48]; \
  236. stx %i2, [%sp + STACK_BIAS + 0x50]; \
  237. stx %i3, [%sp + STACK_BIAS + 0x58]; \
  238. stx %i4, [%sp + STACK_BIAS + 0x60]; \
  239. stx %i5, [%sp + STACK_BIAS + 0x68]; \
  240. stx %i6, [%sp + STACK_BIAS + 0x70]; \
  241. stx %i7, [%sp + STACK_BIAS + 0x78]; \
  242. saved; \
  243. sub %g1, 2, %g1; \
  244. ba,pt %xcc, etrap_save; \
  245. wrpr %g1, %cwp; \
  246. nop; nop; nop; nop; nop; nop; nop; nop; \
  247. nop; nop; nop; nop;
  248. /* Normal 64bit spill */
  249. #define SPILL_1_GENERIC(ASI) \
  250. add %sp, STACK_BIAS + 0x00, %g1; \
  251. stxa %l0, [%g1 + %g0] ASI; \
  252. mov 0x08, %g3; \
  253. stxa %l1, [%g1 + %g3] ASI; \
  254. add %g1, 0x10, %g1; \
  255. stxa %l2, [%g1 + %g0] ASI; \
  256. stxa %l3, [%g1 + %g3] ASI; \
  257. add %g1, 0x10, %g1; \
  258. stxa %l4, [%g1 + %g0] ASI; \
  259. stxa %l5, [%g1 + %g3] ASI; \
  260. add %g1, 0x10, %g1; \
  261. stxa %l6, [%g1 + %g0] ASI; \
  262. stxa %l7, [%g1 + %g3] ASI; \
  263. add %g1, 0x10, %g1; \
  264. stxa %i0, [%g1 + %g0] ASI; \
  265. stxa %i1, [%g1 + %g3] ASI; \
  266. add %g1, 0x10, %g1; \
  267. stxa %i2, [%g1 + %g0] ASI; \
  268. stxa %i3, [%g1 + %g3] ASI; \
  269. add %g1, 0x10, %g1; \
  270. stxa %i4, [%g1 + %g0] ASI; \
  271. stxa %i5, [%g1 + %g3] ASI; \
  272. add %g1, 0x10, %g1; \
  273. stxa %i6, [%g1 + %g0] ASI; \
  274. stxa %i7, [%g1 + %g3] ASI; \
  275. saved; \
  276. retry; nop; nop; \
  277. b,a,pt %xcc, spill_fixup_dax; \
  278. b,a,pt %xcc, spill_fixup_mna; \
  279. b,a,pt %xcc, spill_fixup;
  280. #define SPILL_1_GENERIC_ETRAP \
  281. etrap_user_spill_64bit: \
  282. stxa %l0, [%sp + STACK_BIAS + 0x00] %asi; \
  283. stxa %l1, [%sp + STACK_BIAS + 0x08] %asi; \
  284. stxa %l2, [%sp + STACK_BIAS + 0x10] %asi; \
  285. stxa %l3, [%sp + STACK_BIAS + 0x18] %asi; \
  286. stxa %l4, [%sp + STACK_BIAS + 0x20] %asi; \
  287. stxa %l5, [%sp + STACK_BIAS + 0x28] %asi; \
  288. stxa %l6, [%sp + STACK_BIAS + 0x30] %asi; \
  289. stxa %l7, [%sp + STACK_BIAS + 0x38] %asi; \
  290. stxa %i0, [%sp + STACK_BIAS + 0x40] %asi; \
  291. stxa %i1, [%sp + STACK_BIAS + 0x48] %asi; \
  292. stxa %i2, [%sp + STACK_BIAS + 0x50] %asi; \
  293. stxa %i3, [%sp + STACK_BIAS + 0x58] %asi; \
  294. stxa %i4, [%sp + STACK_BIAS + 0x60] %asi; \
  295. stxa %i5, [%sp + STACK_BIAS + 0x68] %asi; \
  296. stxa %i6, [%sp + STACK_BIAS + 0x70] %asi; \
  297. stxa %i7, [%sp + STACK_BIAS + 0x78] %asi; \
  298. saved; \
  299. sub %g1, 2, %g1; \
  300. ba,pt %xcc, etrap_save; \
  301. wrpr %g1, %cwp; \
  302. nop; nop; nop; nop; nop; \
  303. nop; nop; nop; nop; \
  304. ba,a,pt %xcc, etrap_spill_fixup_64bit; \
  305. ba,a,pt %xcc, etrap_spill_fixup_64bit; \
  306. ba,a,pt %xcc, etrap_spill_fixup_64bit;
  307. #define SPILL_1_GENERIC_ETRAP_FIXUP \
  308. etrap_spill_fixup_64bit: \
  309. ldub [%g6 + TI_WSAVED], %g1; \
  310. sll %g1, 3, %g3; \
  311. add %g6, %g3, %g3; \
  312. stx %sp, [%g3 + TI_RWIN_SPTRS]; \
  313. sll %g1, 7, %g3; \
  314. add %g6, %g3, %g3; \
  315. stx %l0, [%g3 + TI_REG_WINDOW + 0x00]; \
  316. stx %l1, [%g3 + TI_REG_WINDOW + 0x08]; \
  317. stx %l2, [%g3 + TI_REG_WINDOW + 0x10]; \
  318. stx %l3, [%g3 + TI_REG_WINDOW + 0x18]; \
  319. stx %l4, [%g3 + TI_REG_WINDOW + 0x20]; \
  320. stx %l5, [%g3 + TI_REG_WINDOW + 0x28]; \
  321. stx %l6, [%g3 + TI_REG_WINDOW + 0x30]; \
  322. stx %l7, [%g3 + TI_REG_WINDOW + 0x38]; \
  323. stx %i0, [%g3 + TI_REG_WINDOW + 0x40]; \
  324. stx %i1, [%g3 + TI_REG_WINDOW + 0x48]; \
  325. stx %i2, [%g3 + TI_REG_WINDOW + 0x50]; \
  326. stx %i3, [%g3 + TI_REG_WINDOW + 0x58]; \
  327. stx %i4, [%g3 + TI_REG_WINDOW + 0x60]; \
  328. stx %i5, [%g3 + TI_REG_WINDOW + 0x68]; \
  329. stx %i6, [%g3 + TI_REG_WINDOW + 0x70]; \
  330. stx %i7, [%g3 + TI_REG_WINDOW + 0x78]; \
  331. add %g1, 1, %g1; \
  332. stb %g1, [%g6 + TI_WSAVED]; \
  333. saved; \
  334. rdpr %cwp, %g1; \
  335. sub %g1, 2, %g1; \
  336. ba,pt %xcc, etrap_save; \
  337. wrpr %g1, %cwp; \
  338. nop; nop; nop
  339. /* Normal 32bit spill */
  340. #define SPILL_2_GENERIC(ASI) \
  341. srl %sp, 0, %sp; \
  342. stwa %l0, [%sp + %g0] ASI; \
  343. mov 0x04, %g3; \
  344. stwa %l1, [%sp + %g3] ASI; \
  345. add %sp, 0x08, %g1; \
  346. stwa %l2, [%g1 + %g0] ASI; \
  347. stwa %l3, [%g1 + %g3] ASI; \
  348. add %g1, 0x08, %g1; \
  349. stwa %l4, [%g1 + %g0] ASI; \
  350. stwa %l5, [%g1 + %g3] ASI; \
  351. add %g1, 0x08, %g1; \
  352. stwa %l6, [%g1 + %g0] ASI; \
  353. stwa %l7, [%g1 + %g3] ASI; \
  354. add %g1, 0x08, %g1; \
  355. stwa %i0, [%g1 + %g0] ASI; \
  356. stwa %i1, [%g1 + %g3] ASI; \
  357. add %g1, 0x08, %g1; \
  358. stwa %i2, [%g1 + %g0] ASI; \
  359. stwa %i3, [%g1 + %g3] ASI; \
  360. add %g1, 0x08, %g1; \
  361. stwa %i4, [%g1 + %g0] ASI; \
  362. stwa %i5, [%g1 + %g3] ASI; \
  363. add %g1, 0x08, %g1; \
  364. stwa %i6, [%g1 + %g0] ASI; \
  365. stwa %i7, [%g1 + %g3] ASI; \
  366. saved; \
  367. retry; nop; nop; \
  368. b,a,pt %xcc, spill_fixup_dax; \
  369. b,a,pt %xcc, spill_fixup_mna; \
  370. b,a,pt %xcc, spill_fixup;
  371. #define SPILL_2_GENERIC_ETRAP \
  372. etrap_user_spill_32bit: \
  373. srl %sp, 0, %sp; \
  374. stwa %l0, [%sp + 0x00] %asi; \
  375. stwa %l1, [%sp + 0x04] %asi; \
  376. stwa %l2, [%sp + 0x08] %asi; \
  377. stwa %l3, [%sp + 0x0c] %asi; \
  378. stwa %l4, [%sp + 0x10] %asi; \
  379. stwa %l5, [%sp + 0x14] %asi; \
  380. stwa %l6, [%sp + 0x18] %asi; \
  381. stwa %l7, [%sp + 0x1c] %asi; \
  382. stwa %i0, [%sp + 0x20] %asi; \
  383. stwa %i1, [%sp + 0x24] %asi; \
  384. stwa %i2, [%sp + 0x28] %asi; \
  385. stwa %i3, [%sp + 0x2c] %asi; \
  386. stwa %i4, [%sp + 0x30] %asi; \
  387. stwa %i5, [%sp + 0x34] %asi; \
  388. stwa %i6, [%sp + 0x38] %asi; \
  389. stwa %i7, [%sp + 0x3c] %asi; \
  390. saved; \
  391. sub %g1, 2, %g1; \
  392. ba,pt %xcc, etrap_save; \
  393. wrpr %g1, %cwp; \
  394. nop; nop; nop; nop; \
  395. nop; nop; nop; nop; \
  396. ba,a,pt %xcc, etrap_spill_fixup_32bit; \
  397. ba,a,pt %xcc, etrap_spill_fixup_32bit; \
  398. ba,a,pt %xcc, etrap_spill_fixup_32bit;
  399. #define SPILL_2_GENERIC_ETRAP_FIXUP \
  400. etrap_spill_fixup_32bit: \
  401. ldub [%g6 + TI_WSAVED], %g1; \
  402. sll %g1, 3, %g3; \
  403. add %g6, %g3, %g3; \
  404. stx %sp, [%g3 + TI_RWIN_SPTRS]; \
  405. sll %g1, 7, %g3; \
  406. add %g6, %g3, %g3; \
  407. stw %l0, [%g3 + TI_REG_WINDOW + 0x00]; \
  408. stw %l1, [%g3 + TI_REG_WINDOW + 0x04]; \
  409. stw %l2, [%g3 + TI_REG_WINDOW + 0x08]; \
  410. stw %l3, [%g3 + TI_REG_WINDOW + 0x0c]; \
  411. stw %l4, [%g3 + TI_REG_WINDOW + 0x10]; \
  412. stw %l5, [%g3 + TI_REG_WINDOW + 0x14]; \
  413. stw %l6, [%g3 + TI_REG_WINDOW + 0x18]; \
  414. stw %l7, [%g3 + TI_REG_WINDOW + 0x1c]; \
  415. stw %i0, [%g3 + TI_REG_WINDOW + 0x20]; \
  416. stw %i1, [%g3 + TI_REG_WINDOW + 0x24]; \
  417. stw %i2, [%g3 + TI_REG_WINDOW + 0x28]; \
  418. stw %i3, [%g3 + TI_REG_WINDOW + 0x2c]; \
  419. stw %i4, [%g3 + TI_REG_WINDOW + 0x30]; \
  420. stw %i5, [%g3 + TI_REG_WINDOW + 0x34]; \
  421. stw %i6, [%g3 + TI_REG_WINDOW + 0x38]; \
  422. stw %i7, [%g3 + TI_REG_WINDOW + 0x3c]; \
  423. add %g1, 1, %g1; \
  424. stb %g1, [%g6 + TI_WSAVED]; \
  425. saved; \
  426. rdpr %cwp, %g1; \
  427. sub %g1, 2, %g1; \
  428. ba,pt %xcc, etrap_save; \
  429. wrpr %g1, %cwp; \
  430. nop; nop; nop
  431. #define SPILL_1_NORMAL SPILL_1_GENERIC(ASI_AIUP)
  432. #define SPILL_2_NORMAL SPILL_2_GENERIC(ASI_AIUP)
  433. #define SPILL_3_NORMAL SPILL_0_NORMAL
  434. #define SPILL_4_NORMAL SPILL_0_NORMAL
  435. #define SPILL_5_NORMAL SPILL_0_NORMAL
  436. #define SPILL_6_NORMAL SPILL_0_NORMAL
  437. #define SPILL_7_NORMAL SPILL_0_NORMAL
  438. #define SPILL_0_OTHER SPILL_0_NORMAL
  439. #define SPILL_1_OTHER SPILL_1_GENERIC(ASI_AIUS)
  440. #define SPILL_2_OTHER SPILL_2_GENERIC(ASI_AIUS)
  441. #define SPILL_3_OTHER SPILL_3_NORMAL
  442. #define SPILL_4_OTHER SPILL_4_NORMAL
  443. #define SPILL_5_OTHER SPILL_5_NORMAL
  444. #define SPILL_6_OTHER SPILL_6_NORMAL
  445. #define SPILL_7_OTHER SPILL_7_NORMAL
  446. /* Normal kernel fill */
  447. #define FILL_0_NORMAL \
  448. ldx [%sp + STACK_BIAS + 0x00], %l0; \
  449. ldx [%sp + STACK_BIAS + 0x08], %l1; \
  450. ldx [%sp + STACK_BIAS + 0x10], %l2; \
  451. ldx [%sp + STACK_BIAS + 0x18], %l3; \
  452. ldx [%sp + STACK_BIAS + 0x20], %l4; \
  453. ldx [%sp + STACK_BIAS + 0x28], %l5; \
  454. ldx [%sp + STACK_BIAS + 0x30], %l6; \
  455. ldx [%sp + STACK_BIAS + 0x38], %l7; \
  456. ldx [%sp + STACK_BIAS + 0x40], %i0; \
  457. ldx [%sp + STACK_BIAS + 0x48], %i1; \
  458. ldx [%sp + STACK_BIAS + 0x50], %i2; \
  459. ldx [%sp + STACK_BIAS + 0x58], %i3; \
  460. ldx [%sp + STACK_BIAS + 0x60], %i4; \
  461. ldx [%sp + STACK_BIAS + 0x68], %i5; \
  462. ldx [%sp + STACK_BIAS + 0x70], %i6; \
  463. ldx [%sp + STACK_BIAS + 0x78], %i7; \
  464. restored; retry; nop; nop; nop; nop; nop; nop; \
  465. nop; nop; nop; nop; nop; nop; nop; nop;
  466. #define FILL_0_NORMAL_RTRAP \
  467. kern_rtt_fill: \
  468. rdpr %cwp, %g1; \
  469. sub %g1, 1, %g1; \
  470. wrpr %g1, %cwp; \
  471. ldx [%sp + STACK_BIAS + 0x00], %l0; \
  472. ldx [%sp + STACK_BIAS + 0x08], %l1; \
  473. ldx [%sp + STACK_BIAS + 0x10], %l2; \
  474. ldx [%sp + STACK_BIAS + 0x18], %l3; \
  475. ldx [%sp + STACK_BIAS + 0x20], %l4; \
  476. ldx [%sp + STACK_BIAS + 0x28], %l5; \
  477. ldx [%sp + STACK_BIAS + 0x30], %l6; \
  478. ldx [%sp + STACK_BIAS + 0x38], %l7; \
  479. ldx [%sp + STACK_BIAS + 0x40], %i0; \
  480. ldx [%sp + STACK_BIAS + 0x48], %i1; \
  481. ldx [%sp + STACK_BIAS + 0x50], %i2; \
  482. ldx [%sp + STACK_BIAS + 0x58], %i3; \
  483. ldx [%sp + STACK_BIAS + 0x60], %i4; \
  484. ldx [%sp + STACK_BIAS + 0x68], %i5; \
  485. ldx [%sp + STACK_BIAS + 0x70], %i6; \
  486. ldx [%sp + STACK_BIAS + 0x78], %i7; \
  487. restored; \
  488. add %g1, 1, %g1; \
  489. ba,pt %xcc, kern_rtt_restore; \
  490. wrpr %g1, %cwp; \
  491. nop; nop; nop; nop; nop; \
  492. nop; nop; nop; nop;
  493. /* Normal 64bit fill */
  494. #define FILL_1_GENERIC(ASI) \
  495. add %sp, STACK_BIAS + 0x00, %g1; \
  496. ldxa [%g1 + %g0] ASI, %l0; \
  497. mov 0x08, %g2; \
  498. mov 0x10, %g3; \
  499. ldxa [%g1 + %g2] ASI, %l1; \
  500. mov 0x18, %g5; \
  501. ldxa [%g1 + %g3] ASI, %l2; \
  502. ldxa [%g1 + %g5] ASI, %l3; \
  503. add %g1, 0x20, %g1; \
  504. ldxa [%g1 + %g0] ASI, %l4; \
  505. ldxa [%g1 + %g2] ASI, %l5; \
  506. ldxa [%g1 + %g3] ASI, %l6; \
  507. ldxa [%g1 + %g5] ASI, %l7; \
  508. add %g1, 0x20, %g1; \
  509. ldxa [%g1 + %g0] ASI, %i0; \
  510. ldxa [%g1 + %g2] ASI, %i1; \
  511. ldxa [%g1 + %g3] ASI, %i2; \
  512. ldxa [%g1 + %g5] ASI, %i3; \
  513. add %g1, 0x20, %g1; \
  514. ldxa [%g1 + %g0] ASI, %i4; \
  515. ldxa [%g1 + %g2] ASI, %i5; \
  516. ldxa [%g1 + %g3] ASI, %i6; \
  517. ldxa [%g1 + %g5] ASI, %i7; \
  518. restored; \
  519. retry; nop; nop; nop; nop; \
  520. b,a,pt %xcc, fill_fixup_dax; \
  521. b,a,pt %xcc, fill_fixup_mna; \
  522. b,a,pt %xcc, fill_fixup;
  523. #define FILL_1_GENERIC_RTRAP \
  524. user_rtt_fill_64bit: \
  525. ldxa [%sp + STACK_BIAS + 0x00] %asi, %l0; \
  526. ldxa [%sp + STACK_BIAS + 0x08] %asi, %l1; \
  527. ldxa [%sp + STACK_BIAS + 0x10] %asi, %l2; \
  528. ldxa [%sp + STACK_BIAS + 0x18] %asi, %l3; \
  529. ldxa [%sp + STACK_BIAS + 0x20] %asi, %l4; \
  530. ldxa [%sp + STACK_BIAS + 0x28] %asi, %l5; \
  531. ldxa [%sp + STACK_BIAS + 0x30] %asi, %l6; \
  532. ldxa [%sp + STACK_BIAS + 0x38] %asi, %l7; \
  533. ldxa [%sp + STACK_BIAS + 0x40] %asi, %i0; \
  534. ldxa [%sp + STACK_BIAS + 0x48] %asi, %i1; \
  535. ldxa [%sp + STACK_BIAS + 0x50] %asi, %i2; \
  536. ldxa [%sp + STACK_BIAS + 0x58] %asi, %i3; \
  537. ldxa [%sp + STACK_BIAS + 0x60] %asi, %i4; \
  538. ldxa [%sp + STACK_BIAS + 0x68] %asi, %i5; \
  539. ldxa [%sp + STACK_BIAS + 0x70] %asi, %i6; \
  540. ldxa [%sp + STACK_BIAS + 0x78] %asi, %i7; \
  541. ba,pt %xcc, user_rtt_pre_restore; \
  542. restored; \
  543. nop; nop; nop; nop; nop; nop; \
  544. nop; nop; nop; nop; nop; \
  545. ba,a,pt %xcc, user_rtt_fill_fixup; \
  546. ba,a,pt %xcc, user_rtt_fill_fixup; \
  547. ba,a,pt %xcc, user_rtt_fill_fixup;
  548. /* Normal 32bit fill */
  549. #define FILL_2_GENERIC(ASI) \
  550. srl %sp, 0, %sp; \
  551. lduwa [%sp + %g0] ASI, %l0; \
  552. mov 0x04, %g2; \
  553. mov 0x08, %g3; \
  554. lduwa [%sp + %g2] ASI, %l1; \
  555. mov 0x0c, %g5; \
  556. lduwa [%sp + %g3] ASI, %l2; \
  557. lduwa [%sp + %g5] ASI, %l3; \
  558. add %sp, 0x10, %g1; \
  559. lduwa [%g1 + %g0] ASI, %l4; \
  560. lduwa [%g1 + %g2] ASI, %l5; \
  561. lduwa [%g1 + %g3] ASI, %l6; \
  562. lduwa [%g1 + %g5] ASI, %l7; \
  563. add %g1, 0x10, %g1; \
  564. lduwa [%g1 + %g0] ASI, %i0; \
  565. lduwa [%g1 + %g2] ASI, %i1; \
  566. lduwa [%g1 + %g3] ASI, %i2; \
  567. lduwa [%g1 + %g5] ASI, %i3; \
  568. add %g1, 0x10, %g1; \
  569. lduwa [%g1 + %g0] ASI, %i4; \
  570. lduwa [%g1 + %g2] ASI, %i5; \
  571. lduwa [%g1 + %g3] ASI, %i6; \
  572. lduwa [%g1 + %g5] ASI, %i7; \
  573. restored; \
  574. retry; nop; nop; nop; nop; \
  575. b,a,pt %xcc, fill_fixup_dax; \
  576. b,a,pt %xcc, fill_fixup_mna; \
  577. b,a,pt %xcc, fill_fixup;
  578. #define FILL_2_GENERIC_RTRAP \
  579. user_rtt_fill_32bit: \
  580. srl %sp, 0, %sp; \
  581. lduwa [%sp + 0x00] %asi, %l0; \
  582. lduwa [%sp + 0x04] %asi, %l1; \
  583. lduwa [%sp + 0x08] %asi, %l2; \
  584. lduwa [%sp + 0x0c] %asi, %l3; \
  585. lduwa [%sp + 0x10] %asi, %l4; \
  586. lduwa [%sp + 0x14] %asi, %l5; \
  587. lduwa [%sp + 0x18] %asi, %l6; \
  588. lduwa [%sp + 0x1c] %asi, %l7; \
  589. lduwa [%sp + 0x20] %asi, %i0; \
  590. lduwa [%sp + 0x24] %asi, %i1; \
  591. lduwa [%sp + 0x28] %asi, %i2; \
  592. lduwa [%sp + 0x2c] %asi, %i3; \
  593. lduwa [%sp + 0x30] %asi, %i4; \
  594. lduwa [%sp + 0x34] %asi, %i5; \
  595. lduwa [%sp + 0x38] %asi, %i6; \
  596. lduwa [%sp + 0x3c] %asi, %i7; \
  597. ba,pt %xcc, user_rtt_pre_restore; \
  598. restored; \
  599. nop; nop; nop; nop; nop; \
  600. nop; nop; nop; nop; nop; \
  601. ba,a,pt %xcc, user_rtt_fill_fixup; \
  602. ba,a,pt %xcc, user_rtt_fill_fixup; \
  603. ba,a,pt %xcc, user_rtt_fill_fixup;
  604. #define FILL_1_NORMAL FILL_1_GENERIC(ASI_AIUP)
  605. #define FILL_2_NORMAL FILL_2_GENERIC(ASI_AIUP)
  606. #define FILL_3_NORMAL FILL_0_NORMAL
  607. #define FILL_4_NORMAL FILL_0_NORMAL
  608. #define FILL_5_NORMAL FILL_0_NORMAL
  609. #define FILL_6_NORMAL FILL_0_NORMAL
  610. #define FILL_7_NORMAL FILL_0_NORMAL
  611. #define FILL_0_OTHER FILL_0_NORMAL
  612. #define FILL_1_OTHER FILL_1_GENERIC(ASI_AIUS)
  613. #define FILL_2_OTHER FILL_2_GENERIC(ASI_AIUS)
  614. #define FILL_3_OTHER FILL_3_NORMAL
  615. #define FILL_4_OTHER FILL_4_NORMAL
  616. #define FILL_5_OTHER FILL_5_NORMAL
  617. #define FILL_6_OTHER FILL_6_NORMAL
  618. #define FILL_7_OTHER FILL_7_NORMAL
  619. #endif /* !(_SPARC64_TTABLE_H) */