ttable.h 20 KB

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