ttable.h 19 KB

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