ttable.h 20 KB

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