ttable.h 20 KB

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