ttable.h 20 KB

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