entry.S 41 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692
  1. /* $Id: entry.S,v 1.144 2002/02/09 19:49:30 davem Exp $
  2. * arch/sparc64/kernel/entry.S: Sparc64 trap low-level entry points.
  3. *
  4. * Copyright (C) 1995,1997 David S. Miller (davem@caip.rutgers.edu)
  5. * Copyright (C) 1996 Eddie C. Dost (ecd@skynet.be)
  6. * Copyright (C) 1996 Miguel de Icaza (miguel@nuclecu.unam.mx)
  7. * Copyright (C) 1996,98,99 Jakub Jelinek (jj@sunsite.mff.cuni.cz)
  8. */
  9. #include <linux/config.h>
  10. #include <linux/errno.h>
  11. #include <asm/head.h>
  12. #include <asm/asi.h>
  13. #include <asm/smp.h>
  14. #include <asm/ptrace.h>
  15. #include <asm/page.h>
  16. #include <asm/signal.h>
  17. #include <asm/pgtable.h>
  18. #include <asm/processor.h>
  19. #include <asm/visasm.h>
  20. #include <asm/estate.h>
  21. #include <asm/auxio.h>
  22. #include <asm/sfafsr.h>
  23. #define curptr g6
  24. #define NR_SYSCALLS 299 /* Each OS is different... */
  25. .text
  26. .align 32
  27. /* This is trivial with the new code... */
  28. .globl do_fpdis
  29. do_fpdis:
  30. sethi %hi(TSTATE_PEF), %g4
  31. rdpr %tstate, %g5
  32. andcc %g5, %g4, %g0
  33. be,pt %xcc, 1f
  34. nop
  35. rd %fprs, %g5
  36. andcc %g5, FPRS_FEF, %g0
  37. be,pt %xcc, 1f
  38. nop
  39. /* Legal state when DCR_IFPOE is set in Cheetah %dcr. */
  40. sethi %hi(109f), %g7
  41. ba,pt %xcc, etrap
  42. 109: or %g7, %lo(109b), %g7
  43. add %g0, %g0, %g0
  44. ba,a,pt %xcc, rtrap_clr_l6
  45. 1: ldub [%g6 + TI_FPSAVED], %g5
  46. wr %g0, FPRS_FEF, %fprs
  47. andcc %g5, FPRS_FEF, %g0
  48. be,a,pt %icc, 1f
  49. clr %g7
  50. ldx [%g6 + TI_GSR], %g7
  51. 1: andcc %g5, FPRS_DL, %g0
  52. bne,pn %icc, 2f
  53. fzero %f0
  54. andcc %g5, FPRS_DU, %g0
  55. bne,pn %icc, 1f
  56. fzero %f2
  57. faddd %f0, %f2, %f4
  58. fmuld %f0, %f2, %f6
  59. faddd %f0, %f2, %f8
  60. fmuld %f0, %f2, %f10
  61. faddd %f0, %f2, %f12
  62. fmuld %f0, %f2, %f14
  63. faddd %f0, %f2, %f16
  64. fmuld %f0, %f2, %f18
  65. faddd %f0, %f2, %f20
  66. fmuld %f0, %f2, %f22
  67. faddd %f0, %f2, %f24
  68. fmuld %f0, %f2, %f26
  69. faddd %f0, %f2, %f28
  70. fmuld %f0, %f2, %f30
  71. faddd %f0, %f2, %f32
  72. fmuld %f0, %f2, %f34
  73. faddd %f0, %f2, %f36
  74. fmuld %f0, %f2, %f38
  75. faddd %f0, %f2, %f40
  76. fmuld %f0, %f2, %f42
  77. faddd %f0, %f2, %f44
  78. fmuld %f0, %f2, %f46
  79. faddd %f0, %f2, %f48
  80. fmuld %f0, %f2, %f50
  81. faddd %f0, %f2, %f52
  82. fmuld %f0, %f2, %f54
  83. faddd %f0, %f2, %f56
  84. fmuld %f0, %f2, %f58
  85. b,pt %xcc, fpdis_exit2
  86. faddd %f0, %f2, %f60
  87. 1: mov SECONDARY_CONTEXT, %g3
  88. add %g6, TI_FPREGS + 0x80, %g1
  89. faddd %f0, %f2, %f4
  90. fmuld %f0, %f2, %f6
  91. ldxa [%g3] ASI_DMMU, %g5
  92. sethi %hi(sparc64_kern_sec_context), %g2
  93. ldx [%g2 + %lo(sparc64_kern_sec_context)], %g2
  94. stxa %g2, [%g3] ASI_DMMU
  95. membar #Sync
  96. add %g6, TI_FPREGS + 0xc0, %g2
  97. faddd %f0, %f2, %f8
  98. fmuld %f0, %f2, %f10
  99. membar #Sync
  100. ldda [%g1] ASI_BLK_S, %f32
  101. ldda [%g2] ASI_BLK_S, %f48
  102. membar #Sync
  103. faddd %f0, %f2, %f12
  104. fmuld %f0, %f2, %f14
  105. faddd %f0, %f2, %f16
  106. fmuld %f0, %f2, %f18
  107. faddd %f0, %f2, %f20
  108. fmuld %f0, %f2, %f22
  109. faddd %f0, %f2, %f24
  110. fmuld %f0, %f2, %f26
  111. faddd %f0, %f2, %f28
  112. fmuld %f0, %f2, %f30
  113. b,pt %xcc, fpdis_exit
  114. nop
  115. 2: andcc %g5, FPRS_DU, %g0
  116. bne,pt %icc, 3f
  117. fzero %f32
  118. mov SECONDARY_CONTEXT, %g3
  119. fzero %f34
  120. ldxa [%g3] ASI_DMMU, %g5
  121. add %g6, TI_FPREGS, %g1
  122. sethi %hi(sparc64_kern_sec_context), %g2
  123. ldx [%g2 + %lo(sparc64_kern_sec_context)], %g2
  124. stxa %g2, [%g3] ASI_DMMU
  125. membar #Sync
  126. add %g6, TI_FPREGS + 0x40, %g2
  127. faddd %f32, %f34, %f36
  128. fmuld %f32, %f34, %f38
  129. membar #Sync
  130. ldda [%g1] ASI_BLK_S, %f0
  131. ldda [%g2] ASI_BLK_S, %f16
  132. membar #Sync
  133. faddd %f32, %f34, %f40
  134. fmuld %f32, %f34, %f42
  135. faddd %f32, %f34, %f44
  136. fmuld %f32, %f34, %f46
  137. faddd %f32, %f34, %f48
  138. fmuld %f32, %f34, %f50
  139. faddd %f32, %f34, %f52
  140. fmuld %f32, %f34, %f54
  141. faddd %f32, %f34, %f56
  142. fmuld %f32, %f34, %f58
  143. faddd %f32, %f34, %f60
  144. fmuld %f32, %f34, %f62
  145. ba,pt %xcc, fpdis_exit
  146. nop
  147. 3: mov SECONDARY_CONTEXT, %g3
  148. add %g6, TI_FPREGS, %g1
  149. ldxa [%g3] ASI_DMMU, %g5
  150. sethi %hi(sparc64_kern_sec_context), %g2
  151. ldx [%g2 + %lo(sparc64_kern_sec_context)], %g2
  152. stxa %g2, [%g3] ASI_DMMU
  153. membar #Sync
  154. mov 0x40, %g2
  155. membar #Sync
  156. ldda [%g1] ASI_BLK_S, %f0
  157. ldda [%g1 + %g2] ASI_BLK_S, %f16
  158. add %g1, 0x80, %g1
  159. ldda [%g1] ASI_BLK_S, %f32
  160. ldda [%g1 + %g2] ASI_BLK_S, %f48
  161. membar #Sync
  162. fpdis_exit:
  163. stxa %g5, [%g3] ASI_DMMU
  164. membar #Sync
  165. fpdis_exit2:
  166. wr %g7, 0, %gsr
  167. ldx [%g6 + TI_XFSR], %fsr
  168. rdpr %tstate, %g3
  169. or %g3, %g4, %g3 ! anal...
  170. wrpr %g3, %tstate
  171. wr %g0, FPRS_FEF, %fprs ! clean DU/DL bits
  172. retry
  173. .align 32
  174. fp_other_bounce:
  175. call do_fpother
  176. add %sp, PTREGS_OFF, %o0
  177. ba,pt %xcc, rtrap
  178. clr %l6
  179. .globl do_fpother_check_fitos
  180. .align 32
  181. do_fpother_check_fitos:
  182. sethi %hi(fp_other_bounce - 4), %g7
  183. or %g7, %lo(fp_other_bounce - 4), %g7
  184. /* NOTE: Need to preserve %g7 until we fully commit
  185. * to the fitos fixup.
  186. */
  187. stx %fsr, [%g6 + TI_XFSR]
  188. rdpr %tstate, %g3
  189. andcc %g3, TSTATE_PRIV, %g0
  190. bne,pn %xcc, do_fptrap_after_fsr
  191. nop
  192. ldx [%g6 + TI_XFSR], %g3
  193. srlx %g3, 14, %g1
  194. and %g1, 7, %g1
  195. cmp %g1, 2 ! Unfinished FP-OP
  196. bne,pn %xcc, do_fptrap_after_fsr
  197. sethi %hi(1 << 23), %g1 ! Inexact
  198. andcc %g3, %g1, %g0
  199. bne,pn %xcc, do_fptrap_after_fsr
  200. rdpr %tpc, %g1
  201. lduwa [%g1] ASI_AIUP, %g3 ! This cannot ever fail
  202. #define FITOS_MASK 0xc1f83fe0
  203. #define FITOS_COMPARE 0x81a01880
  204. sethi %hi(FITOS_MASK), %g1
  205. or %g1, %lo(FITOS_MASK), %g1
  206. and %g3, %g1, %g1
  207. sethi %hi(FITOS_COMPARE), %g2
  208. or %g2, %lo(FITOS_COMPARE), %g2
  209. cmp %g1, %g2
  210. bne,pn %xcc, do_fptrap_after_fsr
  211. nop
  212. std %f62, [%g6 + TI_FPREGS + (62 * 4)]
  213. sethi %hi(fitos_table_1), %g1
  214. and %g3, 0x1f, %g2
  215. or %g1, %lo(fitos_table_1), %g1
  216. sllx %g2, 2, %g2
  217. jmpl %g1 + %g2, %g0
  218. ba,pt %xcc, fitos_emul_continue
  219. fitos_table_1:
  220. fitod %f0, %f62
  221. fitod %f1, %f62
  222. fitod %f2, %f62
  223. fitod %f3, %f62
  224. fitod %f4, %f62
  225. fitod %f5, %f62
  226. fitod %f6, %f62
  227. fitod %f7, %f62
  228. fitod %f8, %f62
  229. fitod %f9, %f62
  230. fitod %f10, %f62
  231. fitod %f11, %f62
  232. fitod %f12, %f62
  233. fitod %f13, %f62
  234. fitod %f14, %f62
  235. fitod %f15, %f62
  236. fitod %f16, %f62
  237. fitod %f17, %f62
  238. fitod %f18, %f62
  239. fitod %f19, %f62
  240. fitod %f20, %f62
  241. fitod %f21, %f62
  242. fitod %f22, %f62
  243. fitod %f23, %f62
  244. fitod %f24, %f62
  245. fitod %f25, %f62
  246. fitod %f26, %f62
  247. fitod %f27, %f62
  248. fitod %f28, %f62
  249. fitod %f29, %f62
  250. fitod %f30, %f62
  251. fitod %f31, %f62
  252. fitos_emul_continue:
  253. sethi %hi(fitos_table_2), %g1
  254. srl %g3, 25, %g2
  255. or %g1, %lo(fitos_table_2), %g1
  256. and %g2, 0x1f, %g2
  257. sllx %g2, 2, %g2
  258. jmpl %g1 + %g2, %g0
  259. ba,pt %xcc, fitos_emul_fini
  260. fitos_table_2:
  261. fdtos %f62, %f0
  262. fdtos %f62, %f1
  263. fdtos %f62, %f2
  264. fdtos %f62, %f3
  265. fdtos %f62, %f4
  266. fdtos %f62, %f5
  267. fdtos %f62, %f6
  268. fdtos %f62, %f7
  269. fdtos %f62, %f8
  270. fdtos %f62, %f9
  271. fdtos %f62, %f10
  272. fdtos %f62, %f11
  273. fdtos %f62, %f12
  274. fdtos %f62, %f13
  275. fdtos %f62, %f14
  276. fdtos %f62, %f15
  277. fdtos %f62, %f16
  278. fdtos %f62, %f17
  279. fdtos %f62, %f18
  280. fdtos %f62, %f19
  281. fdtos %f62, %f20
  282. fdtos %f62, %f21
  283. fdtos %f62, %f22
  284. fdtos %f62, %f23
  285. fdtos %f62, %f24
  286. fdtos %f62, %f25
  287. fdtos %f62, %f26
  288. fdtos %f62, %f27
  289. fdtos %f62, %f28
  290. fdtos %f62, %f29
  291. fdtos %f62, %f30
  292. fdtos %f62, %f31
  293. fitos_emul_fini:
  294. ldd [%g6 + TI_FPREGS + (62 * 4)], %f62
  295. done
  296. .globl do_fptrap
  297. .align 32
  298. do_fptrap:
  299. stx %fsr, [%g6 + TI_XFSR]
  300. do_fptrap_after_fsr:
  301. ldub [%g6 + TI_FPSAVED], %g3
  302. rd %fprs, %g1
  303. or %g3, %g1, %g3
  304. stb %g3, [%g6 + TI_FPSAVED]
  305. rd %gsr, %g3
  306. stx %g3, [%g6 + TI_GSR]
  307. mov SECONDARY_CONTEXT, %g3
  308. ldxa [%g3] ASI_DMMU, %g5
  309. sethi %hi(sparc64_kern_sec_context), %g2
  310. ldx [%g2 + %lo(sparc64_kern_sec_context)], %g2
  311. stxa %g2, [%g3] ASI_DMMU
  312. membar #Sync
  313. add %g6, TI_FPREGS, %g2
  314. andcc %g1, FPRS_DL, %g0
  315. be,pn %icc, 4f
  316. mov 0x40, %g3
  317. stda %f0, [%g2] ASI_BLK_S
  318. stda %f16, [%g2 + %g3] ASI_BLK_S
  319. andcc %g1, FPRS_DU, %g0
  320. be,pn %icc, 5f
  321. 4: add %g2, 128, %g2
  322. stda %f32, [%g2] ASI_BLK_S
  323. stda %f48, [%g2 + %g3] ASI_BLK_S
  324. 5: mov SECONDARY_CONTEXT, %g1
  325. membar #Sync
  326. stxa %g5, [%g1] ASI_DMMU
  327. membar #Sync
  328. ba,pt %xcc, etrap
  329. wr %g0, 0, %fprs
  330. /* The registers for cross calls will be:
  331. *
  332. * DATA 0: [low 32-bits] Address of function to call, jmp to this
  333. * [high 32-bits] MMU Context Argument 0, place in %g5
  334. * DATA 1: Address Argument 1, place in %g1
  335. * DATA 2: Address Argument 2, place in %g7
  336. *
  337. * With this method we can do most of the cross-call tlb/cache
  338. * flushing very quickly.
  339. *
  340. * Current CPU's IRQ worklist table is locked into %g6, don't touch.
  341. */
  342. .text
  343. .align 32
  344. .globl do_ivec
  345. do_ivec:
  346. mov 0x40, %g3
  347. ldxa [%g3 + %g0] ASI_INTR_R, %g3
  348. sethi %hi(KERNBASE), %g4
  349. cmp %g3, %g4
  350. bgeu,pn %xcc, do_ivec_xcall
  351. srlx %g3, 32, %g5
  352. stxa %g0, [%g0] ASI_INTR_RECEIVE
  353. membar #Sync
  354. sethi %hi(ivector_table), %g2
  355. sllx %g3, 5, %g3
  356. or %g2, %lo(ivector_table), %g2
  357. add %g2, %g3, %g3
  358. ldub [%g3 + 0x04], %g4 /* pil */
  359. mov 1, %g2
  360. sllx %g2, %g4, %g2
  361. sllx %g4, 2, %g4
  362. lduw [%g6 + %g4], %g5 /* g5 = irq_work(cpu, pil) */
  363. stw %g5, [%g3 + 0x00] /* bucket->irq_chain = g5 */
  364. stw %g3, [%g6 + %g4] /* irq_work(cpu, pil) = bucket */
  365. wr %g2, 0x0, %set_softint
  366. retry
  367. do_ivec_xcall:
  368. mov 0x50, %g1
  369. ldxa [%g1 + %g0] ASI_INTR_R, %g1
  370. srl %g3, 0, %g3
  371. mov 0x60, %g7
  372. ldxa [%g7 + %g0] ASI_INTR_R, %g7
  373. stxa %g0, [%g0] ASI_INTR_RECEIVE
  374. membar #Sync
  375. ba,pt %xcc, 1f
  376. nop
  377. .align 32
  378. 1: jmpl %g3, %g0
  379. nop
  380. .globl save_alternate_globals
  381. save_alternate_globals: /* %o0 = save_area */
  382. rdpr %pstate, %o5
  383. andn %o5, PSTATE_IE, %o1
  384. wrpr %o1, PSTATE_AG, %pstate
  385. stx %g0, [%o0 + 0x00]
  386. stx %g1, [%o0 + 0x08]
  387. stx %g2, [%o0 + 0x10]
  388. stx %g3, [%o0 + 0x18]
  389. stx %g4, [%o0 + 0x20]
  390. stx %g5, [%o0 + 0x28]
  391. stx %g6, [%o0 + 0x30]
  392. stx %g7, [%o0 + 0x38]
  393. wrpr %o1, PSTATE_IG, %pstate
  394. stx %g0, [%o0 + 0x40]
  395. stx %g1, [%o0 + 0x48]
  396. stx %g2, [%o0 + 0x50]
  397. stx %g3, [%o0 + 0x58]
  398. stx %g4, [%o0 + 0x60]
  399. stx %g5, [%o0 + 0x68]
  400. stx %g6, [%o0 + 0x70]
  401. stx %g7, [%o0 + 0x78]
  402. wrpr %o1, PSTATE_MG, %pstate
  403. stx %g0, [%o0 + 0x80]
  404. stx %g1, [%o0 + 0x88]
  405. stx %g2, [%o0 + 0x90]
  406. stx %g3, [%o0 + 0x98]
  407. stx %g4, [%o0 + 0xa0]
  408. stx %g5, [%o0 + 0xa8]
  409. stx %g6, [%o0 + 0xb0]
  410. stx %g7, [%o0 + 0xb8]
  411. wrpr %o5, 0x0, %pstate
  412. retl
  413. nop
  414. .globl restore_alternate_globals
  415. restore_alternate_globals: /* %o0 = save_area */
  416. rdpr %pstate, %o5
  417. andn %o5, PSTATE_IE, %o1
  418. wrpr %o1, PSTATE_AG, %pstate
  419. ldx [%o0 + 0x00], %g0
  420. ldx [%o0 + 0x08], %g1
  421. ldx [%o0 + 0x10], %g2
  422. ldx [%o0 + 0x18], %g3
  423. ldx [%o0 + 0x20], %g4
  424. ldx [%o0 + 0x28], %g5
  425. ldx [%o0 + 0x30], %g6
  426. ldx [%o0 + 0x38], %g7
  427. wrpr %o1, PSTATE_IG, %pstate
  428. ldx [%o0 + 0x40], %g0
  429. ldx [%o0 + 0x48], %g1
  430. ldx [%o0 + 0x50], %g2
  431. ldx [%o0 + 0x58], %g3
  432. ldx [%o0 + 0x60], %g4
  433. ldx [%o0 + 0x68], %g5
  434. ldx [%o0 + 0x70], %g6
  435. ldx [%o0 + 0x78], %g7
  436. wrpr %o1, PSTATE_MG, %pstate
  437. ldx [%o0 + 0x80], %g0
  438. ldx [%o0 + 0x88], %g1
  439. ldx [%o0 + 0x90], %g2
  440. ldx [%o0 + 0x98], %g3
  441. ldx [%o0 + 0xa0], %g4
  442. ldx [%o0 + 0xa8], %g5
  443. ldx [%o0 + 0xb0], %g6
  444. ldx [%o0 + 0xb8], %g7
  445. wrpr %o5, 0x0, %pstate
  446. retl
  447. nop
  448. .globl getcc, setcc
  449. getcc:
  450. ldx [%o0 + PT_V9_TSTATE], %o1
  451. srlx %o1, 32, %o1
  452. and %o1, 0xf, %o1
  453. retl
  454. stx %o1, [%o0 + PT_V9_G1]
  455. setcc:
  456. ldx [%o0 + PT_V9_TSTATE], %o1
  457. ldx [%o0 + PT_V9_G1], %o2
  458. or %g0, %ulo(TSTATE_ICC), %o3
  459. sllx %o3, 32, %o3
  460. andn %o1, %o3, %o1
  461. sllx %o2, 32, %o2
  462. and %o2, %o3, %o2
  463. or %o1, %o2, %o1
  464. retl
  465. stx %o1, [%o0 + PT_V9_TSTATE]
  466. .globl utrap, utrap_ill
  467. utrap: brz,pn %g1, etrap
  468. nop
  469. save %sp, -128, %sp
  470. rdpr %tstate, %l6
  471. rdpr %cwp, %l7
  472. andn %l6, TSTATE_CWP, %l6
  473. wrpr %l6, %l7, %tstate
  474. rdpr %tpc, %l6
  475. rdpr %tnpc, %l7
  476. wrpr %g1, 0, %tnpc
  477. done
  478. utrap_ill:
  479. call bad_trap
  480. add %sp, PTREGS_OFF, %o0
  481. ba,pt %xcc, rtrap
  482. clr %l6
  483. /* XXX Here is stuff we still need to write... -DaveM XXX */
  484. .globl netbsd_syscall
  485. netbsd_syscall:
  486. retl
  487. nop
  488. /* We need to carefully read the error status, ACK
  489. * the errors, prevent recursive traps, and pass the
  490. * information on to C code for logging.
  491. *
  492. * We pass the AFAR in as-is, and we encode the status
  493. * information as described in asm-sparc64/sfafsr.h
  494. */
  495. .globl __spitfire_access_error
  496. __spitfire_access_error:
  497. /* Disable ESTATE error reporting so that we do not
  498. * take recursive traps and RED state the processor.
  499. */
  500. stxa %g0, [%g0] ASI_ESTATE_ERROR_EN
  501. membar #Sync
  502. mov UDBE_UE, %g1
  503. ldxa [%g0] ASI_AFSR, %g4 ! Get AFSR
  504. /* __spitfire_cee_trap branches here with AFSR in %g4 and
  505. * UDBE_CE in %g1. It only clears ESTATE_ERR_CE in the
  506. * ESTATE Error Enable register.
  507. */
  508. __spitfire_cee_trap_continue:
  509. ldxa [%g0] ASI_AFAR, %g5 ! Get AFAR
  510. rdpr %tt, %g3
  511. and %g3, 0x1ff, %g3 ! Paranoia
  512. sllx %g3, SFSTAT_TRAP_TYPE_SHIFT, %g3
  513. or %g4, %g3, %g4
  514. rdpr %tl, %g3
  515. cmp %g3, 1
  516. mov 1, %g3
  517. bleu %xcc, 1f
  518. sllx %g3, SFSTAT_TL_GT_ONE_SHIFT, %g3
  519. or %g4, %g3, %g4
  520. /* Read in the UDB error register state, clearing the
  521. * sticky error bits as-needed. We only clear them if
  522. * the UE bit is set. Likewise, __spitfire_cee_trap
  523. * below will only do so if the CE bit is set.
  524. *
  525. * NOTE: UltraSparc-I/II have high and low UDB error
  526. * registers, corresponding to the two UDB units
  527. * present on those chips. UltraSparc-IIi only
  528. * has a single UDB, called "SDB" in the manual.
  529. * For IIi the upper UDB register always reads
  530. * as zero so for our purposes things will just
  531. * work with the checks below.
  532. */
  533. 1: ldxa [%g0] ASI_UDBH_ERROR_R, %g3
  534. and %g3, 0x3ff, %g7 ! Paranoia
  535. sllx %g7, SFSTAT_UDBH_SHIFT, %g7
  536. or %g4, %g7, %g4
  537. andcc %g3, %g1, %g3 ! UDBE_UE or UDBE_CE
  538. be,pn %xcc, 1f
  539. nop
  540. stxa %g3, [%g0] ASI_UDB_ERROR_W
  541. membar #Sync
  542. 1: mov 0x18, %g3
  543. ldxa [%g3] ASI_UDBL_ERROR_R, %g3
  544. and %g3, 0x3ff, %g7 ! Paranoia
  545. sllx %g7, SFSTAT_UDBL_SHIFT, %g7
  546. or %g4, %g7, %g4
  547. andcc %g3, %g1, %g3 ! UDBE_UE or UDBE_CE
  548. be,pn %xcc, 1f
  549. nop
  550. mov 0x18, %g7
  551. stxa %g3, [%g7] ASI_UDB_ERROR_W
  552. membar #Sync
  553. 1: /* Ok, now that we've latched the error state,
  554. * clear the sticky bits in the AFSR.
  555. */
  556. stxa %g4, [%g0] ASI_AFSR
  557. membar #Sync
  558. rdpr %tl, %g2
  559. cmp %g2, 1
  560. rdpr %pil, %g2
  561. bleu,pt %xcc, 1f
  562. wrpr %g0, 15, %pil
  563. ba,pt %xcc, etraptl1
  564. rd %pc, %g7
  565. ba,pt %xcc, 2f
  566. nop
  567. 1: ba,pt %xcc, etrap_irq
  568. rd %pc, %g7
  569. 2: mov %l4, %o1
  570. mov %l5, %o2
  571. call spitfire_access_error
  572. add %sp, PTREGS_OFF, %o0
  573. ba,pt %xcc, rtrap
  574. clr %l6
  575. /* This is the trap handler entry point for ECC correctable
  576. * errors. They are corrected, but we listen for the trap
  577. * so that the event can be logged.
  578. *
  579. * Disrupting errors are either:
  580. * 1) single-bit ECC errors during UDB reads to system
  581. * memory
  582. * 2) data parity errors during write-back events
  583. *
  584. * As far as I can make out from the manual, the CEE trap
  585. * is only for correctable errors during memory read
  586. * accesses by the front-end of the processor.
  587. *
  588. * The code below is only for trap level 1 CEE events,
  589. * as it is the only situation where we can safely record
  590. * and log. For trap level >1 we just clear the CE bit
  591. * in the AFSR and return.
  592. *
  593. * This is just like __spiftire_access_error above, but it
  594. * specifically handles correctable errors. If an
  595. * uncorrectable error is indicated in the AFSR we
  596. * will branch directly above to __spitfire_access_error
  597. * to handle it instead. Uncorrectable therefore takes
  598. * priority over correctable, and the error logging
  599. * C code will notice this case by inspecting the
  600. * trap type.
  601. */
  602. .globl __spitfire_cee_trap
  603. __spitfire_cee_trap:
  604. ldxa [%g0] ASI_AFSR, %g4 ! Get AFSR
  605. mov 1, %g3
  606. sllx %g3, SFAFSR_UE_SHIFT, %g3
  607. andcc %g4, %g3, %g0 ! Check for UE
  608. bne,pn %xcc, __spitfire_access_error
  609. nop
  610. /* Ok, in this case we only have a correctable error.
  611. * Indicate we only wish to capture that state in register
  612. * %g1, and we only disable CE error reporting unlike UE
  613. * handling which disables all errors.
  614. */
  615. ldxa [%g0] ASI_ESTATE_ERROR_EN, %g3
  616. andn %g3, ESTATE_ERR_CE, %g3
  617. stxa %g3, [%g0] ASI_ESTATE_ERROR_EN
  618. membar #Sync
  619. /* Preserve AFSR in %g4, indicate UDB state to capture in %g1 */
  620. ba,pt %xcc, __spitfire_cee_trap_continue
  621. mov UDBE_CE, %g1
  622. .globl __spitfire_data_access_exception
  623. .globl __spitfire_data_access_exception_tl1
  624. __spitfire_data_access_exception_tl1:
  625. rdpr %pstate, %g4
  626. wrpr %g4, PSTATE_MG|PSTATE_AG, %pstate
  627. mov TLB_SFSR, %g3
  628. mov DMMU_SFAR, %g5
  629. ldxa [%g3] ASI_DMMU, %g4 ! Get SFSR
  630. ldxa [%g5] ASI_DMMU, %g5 ! Get SFAR
  631. stxa %g0, [%g3] ASI_DMMU ! Clear SFSR.FaultValid bit
  632. membar #Sync
  633. rdpr %tt, %g3
  634. cmp %g3, 0x80 ! first win spill/fill trap
  635. blu,pn %xcc, 1f
  636. cmp %g3, 0xff ! last win spill/fill trap
  637. bgu,pn %xcc, 1f
  638. nop
  639. ba,pt %xcc, winfix_dax
  640. rdpr %tpc, %g3
  641. 1: sethi %hi(109f), %g7
  642. ba,pt %xcc, etraptl1
  643. 109: or %g7, %lo(109b), %g7
  644. mov %l4, %o1
  645. mov %l5, %o2
  646. call spitfire_data_access_exception_tl1
  647. add %sp, PTREGS_OFF, %o0
  648. ba,pt %xcc, rtrap
  649. clr %l6
  650. __spitfire_data_access_exception:
  651. rdpr %pstate, %g4
  652. wrpr %g4, PSTATE_MG|PSTATE_AG, %pstate
  653. mov TLB_SFSR, %g3
  654. mov DMMU_SFAR, %g5
  655. ldxa [%g3] ASI_DMMU, %g4 ! Get SFSR
  656. ldxa [%g5] ASI_DMMU, %g5 ! Get SFAR
  657. stxa %g0, [%g3] ASI_DMMU ! Clear SFSR.FaultValid bit
  658. membar #Sync
  659. sethi %hi(109f), %g7
  660. ba,pt %xcc, etrap
  661. 109: or %g7, %lo(109b), %g7
  662. mov %l4, %o1
  663. mov %l5, %o2
  664. call spitfire_data_access_exception
  665. add %sp, PTREGS_OFF, %o0
  666. ba,pt %xcc, rtrap
  667. clr %l6
  668. .globl __spitfire_insn_access_exception
  669. .globl __spitfire_insn_access_exception_tl1
  670. __spitfire_insn_access_exception_tl1:
  671. rdpr %pstate, %g4
  672. wrpr %g4, PSTATE_MG|PSTATE_AG, %pstate
  673. mov TLB_SFSR, %g3
  674. ldxa [%g3] ASI_IMMU, %g4 ! Get SFSR
  675. rdpr %tpc, %g5 ! IMMU has no SFAR, use TPC
  676. stxa %g0, [%g3] ASI_IMMU ! Clear FaultValid bit
  677. membar #Sync
  678. sethi %hi(109f), %g7
  679. ba,pt %xcc, etraptl1
  680. 109: or %g7, %lo(109b), %g7
  681. mov %l4, %o1
  682. mov %l5, %o2
  683. call spitfire_insn_access_exception_tl1
  684. add %sp, PTREGS_OFF, %o0
  685. ba,pt %xcc, rtrap
  686. clr %l6
  687. __spitfire_insn_access_exception:
  688. rdpr %pstate, %g4
  689. wrpr %g4, PSTATE_MG|PSTATE_AG, %pstate
  690. mov TLB_SFSR, %g3
  691. ldxa [%g3] ASI_IMMU, %g4 ! Get SFSR
  692. rdpr %tpc, %g5 ! IMMU has no SFAR, use TPC
  693. stxa %g0, [%g3] ASI_IMMU ! Clear FaultValid bit
  694. membar #Sync
  695. sethi %hi(109f), %g7
  696. ba,pt %xcc, etrap
  697. 109: or %g7, %lo(109b), %g7
  698. mov %l4, %o1
  699. mov %l5, %o2
  700. call spitfire_insn_access_exception
  701. add %sp, PTREGS_OFF, %o0
  702. ba,pt %xcc, rtrap
  703. clr %l6
  704. /* These get patched into the trap table at boot time
  705. * once we know we have a cheetah processor.
  706. */
  707. .globl cheetah_fecc_trap_vector, cheetah_fecc_trap_vector_tl1
  708. cheetah_fecc_trap_vector:
  709. membar #Sync
  710. ldxa [%g0] ASI_DCU_CONTROL_REG, %g1
  711. andn %g1, DCU_DC | DCU_IC, %g1
  712. stxa %g1, [%g0] ASI_DCU_CONTROL_REG
  713. membar #Sync
  714. sethi %hi(cheetah_fast_ecc), %g2
  715. jmpl %g2 + %lo(cheetah_fast_ecc), %g0
  716. mov 0, %g1
  717. cheetah_fecc_trap_vector_tl1:
  718. membar #Sync
  719. ldxa [%g0] ASI_DCU_CONTROL_REG, %g1
  720. andn %g1, DCU_DC | DCU_IC, %g1
  721. stxa %g1, [%g0] ASI_DCU_CONTROL_REG
  722. membar #Sync
  723. sethi %hi(cheetah_fast_ecc), %g2
  724. jmpl %g2 + %lo(cheetah_fast_ecc), %g0
  725. mov 1, %g1
  726. .globl cheetah_cee_trap_vector, cheetah_cee_trap_vector_tl1
  727. cheetah_cee_trap_vector:
  728. membar #Sync
  729. ldxa [%g0] ASI_DCU_CONTROL_REG, %g1
  730. andn %g1, DCU_IC, %g1
  731. stxa %g1, [%g0] ASI_DCU_CONTROL_REG
  732. membar #Sync
  733. sethi %hi(cheetah_cee), %g2
  734. jmpl %g2 + %lo(cheetah_cee), %g0
  735. mov 0, %g1
  736. cheetah_cee_trap_vector_tl1:
  737. membar #Sync
  738. ldxa [%g0] ASI_DCU_CONTROL_REG, %g1
  739. andn %g1, DCU_IC, %g1
  740. stxa %g1, [%g0] ASI_DCU_CONTROL_REG
  741. membar #Sync
  742. sethi %hi(cheetah_cee), %g2
  743. jmpl %g2 + %lo(cheetah_cee), %g0
  744. mov 1, %g1
  745. .globl cheetah_deferred_trap_vector, cheetah_deferred_trap_vector_tl1
  746. cheetah_deferred_trap_vector:
  747. membar #Sync
  748. ldxa [%g0] ASI_DCU_CONTROL_REG, %g1;
  749. andn %g1, DCU_DC | DCU_IC, %g1;
  750. stxa %g1, [%g0] ASI_DCU_CONTROL_REG;
  751. membar #Sync;
  752. sethi %hi(cheetah_deferred_trap), %g2
  753. jmpl %g2 + %lo(cheetah_deferred_trap), %g0
  754. mov 0, %g1
  755. cheetah_deferred_trap_vector_tl1:
  756. membar #Sync;
  757. ldxa [%g0] ASI_DCU_CONTROL_REG, %g1;
  758. andn %g1, DCU_DC | DCU_IC, %g1;
  759. stxa %g1, [%g0] ASI_DCU_CONTROL_REG;
  760. membar #Sync;
  761. sethi %hi(cheetah_deferred_trap), %g2
  762. jmpl %g2 + %lo(cheetah_deferred_trap), %g0
  763. mov 1, %g1
  764. /* Cheetah+ specific traps. These are for the new I/D cache parity
  765. * error traps. The first argument to cheetah_plus_parity_handler
  766. * is encoded as follows:
  767. *
  768. * Bit0: 0=dcache,1=icache
  769. * Bit1: 0=recoverable,1=unrecoverable
  770. */
  771. .globl cheetah_plus_dcpe_trap_vector, cheetah_plus_dcpe_trap_vector_tl1
  772. cheetah_plus_dcpe_trap_vector:
  773. membar #Sync
  774. sethi %hi(do_cheetah_plus_data_parity), %g7
  775. jmpl %g7 + %lo(do_cheetah_plus_data_parity), %g0
  776. nop
  777. nop
  778. nop
  779. nop
  780. nop
  781. do_cheetah_plus_data_parity:
  782. rdpr %pil, %g2
  783. wrpr %g0, 15, %pil
  784. ba,pt %xcc, etrap_irq
  785. rd %pc, %g7
  786. mov 0x0, %o0
  787. call cheetah_plus_parity_error
  788. add %sp, PTREGS_OFF, %o1
  789. ba,a,pt %xcc, rtrap_irq
  790. cheetah_plus_dcpe_trap_vector_tl1:
  791. membar #Sync
  792. wrpr PSTATE_IG | PSTATE_PEF | PSTATE_PRIV, %pstate
  793. sethi %hi(do_dcpe_tl1), %g3
  794. jmpl %g3 + %lo(do_dcpe_tl1), %g0
  795. nop
  796. nop
  797. nop
  798. nop
  799. .globl cheetah_plus_icpe_trap_vector, cheetah_plus_icpe_trap_vector_tl1
  800. cheetah_plus_icpe_trap_vector:
  801. membar #Sync
  802. sethi %hi(do_cheetah_plus_insn_parity), %g7
  803. jmpl %g7 + %lo(do_cheetah_plus_insn_parity), %g0
  804. nop
  805. nop
  806. nop
  807. nop
  808. nop
  809. do_cheetah_plus_insn_parity:
  810. rdpr %pil, %g2
  811. wrpr %g0, 15, %pil
  812. ba,pt %xcc, etrap_irq
  813. rd %pc, %g7
  814. mov 0x1, %o0
  815. call cheetah_plus_parity_error
  816. add %sp, PTREGS_OFF, %o1
  817. ba,a,pt %xcc, rtrap_irq
  818. cheetah_plus_icpe_trap_vector_tl1:
  819. membar #Sync
  820. wrpr PSTATE_IG | PSTATE_PEF | PSTATE_PRIV, %pstate
  821. sethi %hi(do_icpe_tl1), %g3
  822. jmpl %g3 + %lo(do_icpe_tl1), %g0
  823. nop
  824. nop
  825. nop
  826. nop
  827. /* If we take one of these traps when tl >= 1, then we
  828. * jump to interrupt globals. If some trap level above us
  829. * was also using interrupt globals, we cannot recover.
  830. * We may use all interrupt global registers except %g6.
  831. */
  832. .globl do_dcpe_tl1, do_icpe_tl1
  833. do_dcpe_tl1:
  834. rdpr %tl, %g1 ! Save original trap level
  835. mov 1, %g2 ! Setup TSTATE checking loop
  836. sethi %hi(TSTATE_IG), %g3 ! TSTATE mask bit
  837. 1: wrpr %g2, %tl ! Set trap level to check
  838. rdpr %tstate, %g4 ! Read TSTATE for this level
  839. andcc %g4, %g3, %g0 ! Interrupt globals in use?
  840. bne,a,pn %xcc, do_dcpe_tl1_fatal ! Yep, irrecoverable
  841. wrpr %g1, %tl ! Restore original trap level
  842. add %g2, 1, %g2 ! Next trap level
  843. cmp %g2, %g1 ! Hit them all yet?
  844. ble,pt %icc, 1b ! Not yet
  845. nop
  846. wrpr %g1, %tl ! Restore original trap level
  847. do_dcpe_tl1_nonfatal: /* Ok we may use interrupt globals safely. */
  848. sethi %hi(dcache_parity_tl1_occurred), %g2
  849. lduw [%g2 + %lo(dcache_parity_tl1_occurred)], %g1
  850. add %g1, 1, %g1
  851. stw %g1, [%g2 + %lo(dcache_parity_tl1_occurred)]
  852. /* Reset D-cache parity */
  853. sethi %hi(1 << 16), %g1 ! D-cache size
  854. mov (1 << 5), %g2 ! D-cache line size
  855. sub %g1, %g2, %g1 ! Move down 1 cacheline
  856. 1: srl %g1, 14, %g3 ! Compute UTAG
  857. membar #Sync
  858. stxa %g3, [%g1] ASI_DCACHE_UTAG
  859. membar #Sync
  860. sub %g2, 8, %g3 ! 64-bit data word within line
  861. 2: membar #Sync
  862. stxa %g0, [%g1 + %g3] ASI_DCACHE_DATA
  863. membar #Sync
  864. subcc %g3, 8, %g3 ! Next 64-bit data word
  865. bge,pt %icc, 2b
  866. nop
  867. subcc %g1, %g2, %g1 ! Next cacheline
  868. bge,pt %icc, 1b
  869. nop
  870. ba,pt %xcc, dcpe_icpe_tl1_common
  871. nop
  872. do_dcpe_tl1_fatal:
  873. sethi %hi(1f), %g7
  874. ba,pt %xcc, etraptl1
  875. 1: or %g7, %lo(1b), %g7
  876. mov 0x2, %o0
  877. call cheetah_plus_parity_error
  878. add %sp, PTREGS_OFF, %o1
  879. ba,pt %xcc, rtrap
  880. clr %l6
  881. do_icpe_tl1:
  882. rdpr %tl, %g1 ! Save original trap level
  883. mov 1, %g2 ! Setup TSTATE checking loop
  884. sethi %hi(TSTATE_IG), %g3 ! TSTATE mask bit
  885. 1: wrpr %g2, %tl ! Set trap level to check
  886. rdpr %tstate, %g4 ! Read TSTATE for this level
  887. andcc %g4, %g3, %g0 ! Interrupt globals in use?
  888. bne,a,pn %xcc, do_icpe_tl1_fatal ! Yep, irrecoverable
  889. wrpr %g1, %tl ! Restore original trap level
  890. add %g2, 1, %g2 ! Next trap level
  891. cmp %g2, %g1 ! Hit them all yet?
  892. ble,pt %icc, 1b ! Not yet
  893. nop
  894. wrpr %g1, %tl ! Restore original trap level
  895. do_icpe_tl1_nonfatal: /* Ok we may use interrupt globals safely. */
  896. sethi %hi(icache_parity_tl1_occurred), %g2
  897. lduw [%g2 + %lo(icache_parity_tl1_occurred)], %g1
  898. add %g1, 1, %g1
  899. stw %g1, [%g2 + %lo(icache_parity_tl1_occurred)]
  900. /* Flush I-cache */
  901. sethi %hi(1 << 15), %g1 ! I-cache size
  902. mov (1 << 5), %g2 ! I-cache line size
  903. sub %g1, %g2, %g1
  904. 1: or %g1, (2 << 3), %g3
  905. stxa %g0, [%g3] ASI_IC_TAG
  906. membar #Sync
  907. subcc %g1, %g2, %g1
  908. bge,pt %icc, 1b
  909. nop
  910. ba,pt %xcc, dcpe_icpe_tl1_common
  911. nop
  912. do_icpe_tl1_fatal:
  913. sethi %hi(1f), %g7
  914. ba,pt %xcc, etraptl1
  915. 1: or %g7, %lo(1b), %g7
  916. mov 0x3, %o0
  917. call cheetah_plus_parity_error
  918. add %sp, PTREGS_OFF, %o1
  919. ba,pt %xcc, rtrap
  920. clr %l6
  921. dcpe_icpe_tl1_common:
  922. /* Flush D-cache, re-enable D/I caches in DCU and finally
  923. * retry the trapping instruction.
  924. */
  925. sethi %hi(1 << 16), %g1 ! D-cache size
  926. mov (1 << 5), %g2 ! D-cache line size
  927. sub %g1, %g2, %g1
  928. 1: stxa %g0, [%g1] ASI_DCACHE_TAG
  929. membar #Sync
  930. subcc %g1, %g2, %g1
  931. bge,pt %icc, 1b
  932. nop
  933. ldxa [%g0] ASI_DCU_CONTROL_REG, %g1
  934. or %g1, (DCU_DC | DCU_IC), %g1
  935. stxa %g1, [%g0] ASI_DCU_CONTROL_REG
  936. membar #Sync
  937. retry
  938. /* Capture I/D/E-cache state into per-cpu error scoreboard.
  939. *
  940. * %g1: (TL>=0) ? 1 : 0
  941. * %g2: scratch
  942. * %g3: scratch
  943. * %g4: AFSR
  944. * %g5: AFAR
  945. * %g6: current thread ptr
  946. * %g7: scratch
  947. */
  948. __cheetah_log_error:
  949. /* Put "TL1" software bit into AFSR. */
  950. and %g1, 0x1, %g1
  951. sllx %g1, 63, %g2
  952. or %g4, %g2, %g4
  953. /* Get log entry pointer for this cpu at this trap level. */
  954. BRANCH_IF_JALAPENO(g2,g3,50f)
  955. ldxa [%g0] ASI_SAFARI_CONFIG, %g2
  956. srlx %g2, 17, %g2
  957. ba,pt %xcc, 60f
  958. and %g2, 0x3ff, %g2
  959. 50: ldxa [%g0] ASI_JBUS_CONFIG, %g2
  960. srlx %g2, 17, %g2
  961. and %g2, 0x1f, %g2
  962. 60: sllx %g2, 9, %g2
  963. sethi %hi(cheetah_error_log), %g3
  964. ldx [%g3 + %lo(cheetah_error_log)], %g3
  965. brz,pn %g3, 80f
  966. nop
  967. add %g3, %g2, %g3
  968. sllx %g1, 8, %g1
  969. add %g3, %g1, %g1
  970. /* %g1 holds pointer to the top of the logging scoreboard */
  971. ldx [%g1 + 0x0], %g7
  972. cmp %g7, -1
  973. bne,pn %xcc, 80f
  974. nop
  975. stx %g4, [%g1 + 0x0]
  976. stx %g5, [%g1 + 0x8]
  977. add %g1, 0x10, %g1
  978. /* %g1 now points to D-cache logging area */
  979. set 0x3ff8, %g2 /* DC_addr mask */
  980. and %g5, %g2, %g2 /* DC_addr bits of AFAR */
  981. srlx %g5, 12, %g3
  982. or %g3, 1, %g3 /* PHYS tag + valid */
  983. 10: ldxa [%g2] ASI_DCACHE_TAG, %g7
  984. cmp %g3, %g7 /* TAG match? */
  985. bne,pt %xcc, 13f
  986. nop
  987. /* Yep, what we want, capture state. */
  988. stx %g2, [%g1 + 0x20]
  989. stx %g7, [%g1 + 0x28]
  990. /* A membar Sync is required before and after utag access. */
  991. membar #Sync
  992. ldxa [%g2] ASI_DCACHE_UTAG, %g7
  993. membar #Sync
  994. stx %g7, [%g1 + 0x30]
  995. ldxa [%g2] ASI_DCACHE_SNOOP_TAG, %g7
  996. stx %g7, [%g1 + 0x38]
  997. clr %g3
  998. 12: ldxa [%g2 + %g3] ASI_DCACHE_DATA, %g7
  999. stx %g7, [%g1]
  1000. add %g3, (1 << 5), %g3
  1001. cmp %g3, (4 << 5)
  1002. bl,pt %xcc, 12b
  1003. add %g1, 0x8, %g1
  1004. ba,pt %xcc, 20f
  1005. add %g1, 0x20, %g1
  1006. 13: sethi %hi(1 << 14), %g7
  1007. add %g2, %g7, %g2
  1008. srlx %g2, 14, %g7
  1009. cmp %g7, 4
  1010. bl,pt %xcc, 10b
  1011. nop
  1012. add %g1, 0x40, %g1
  1013. /* %g1 now points to I-cache logging area */
  1014. 20: set 0x1fe0, %g2 /* IC_addr mask */
  1015. and %g5, %g2, %g2 /* IC_addr bits of AFAR */
  1016. sllx %g2, 1, %g2 /* IC_addr[13:6]==VA[12:5] */
  1017. srlx %g5, (13 - 8), %g3 /* Make PTAG */
  1018. andn %g3, 0xff, %g3 /* Mask off undefined bits */
  1019. 21: ldxa [%g2] ASI_IC_TAG, %g7
  1020. andn %g7, 0xff, %g7
  1021. cmp %g3, %g7
  1022. bne,pt %xcc, 23f
  1023. nop
  1024. /* Yep, what we want, capture state. */
  1025. stx %g2, [%g1 + 0x40]
  1026. stx %g7, [%g1 + 0x48]
  1027. add %g2, (1 << 3), %g2
  1028. ldxa [%g2] ASI_IC_TAG, %g7
  1029. add %g2, (1 << 3), %g2
  1030. stx %g7, [%g1 + 0x50]
  1031. ldxa [%g2] ASI_IC_TAG, %g7
  1032. add %g2, (1 << 3), %g2
  1033. stx %g7, [%g1 + 0x60]
  1034. ldxa [%g2] ASI_IC_TAG, %g7
  1035. stx %g7, [%g1 + 0x68]
  1036. sub %g2, (3 << 3), %g2
  1037. ldxa [%g2] ASI_IC_STAG, %g7
  1038. stx %g7, [%g1 + 0x58]
  1039. clr %g3
  1040. srlx %g2, 2, %g2
  1041. 22: ldxa [%g2 + %g3] ASI_IC_INSTR, %g7
  1042. stx %g7, [%g1]
  1043. add %g3, (1 << 3), %g3
  1044. cmp %g3, (8 << 3)
  1045. bl,pt %xcc, 22b
  1046. add %g1, 0x8, %g1
  1047. ba,pt %xcc, 30f
  1048. add %g1, 0x30, %g1
  1049. 23: sethi %hi(1 << 14), %g7
  1050. add %g2, %g7, %g2
  1051. srlx %g2, 14, %g7
  1052. cmp %g7, 4
  1053. bl,pt %xcc, 21b
  1054. nop
  1055. add %g1, 0x70, %g1
  1056. /* %g1 now points to E-cache logging area */
  1057. 30: andn %g5, (32 - 1), %g2
  1058. stx %g2, [%g1 + 0x20]
  1059. ldxa [%g2] ASI_EC_TAG_DATA, %g7
  1060. stx %g7, [%g1 + 0x28]
  1061. ldxa [%g2] ASI_EC_R, %g0
  1062. clr %g3
  1063. 31: ldxa [%g3] ASI_EC_DATA, %g7
  1064. stx %g7, [%g1 + %g3]
  1065. add %g3, 0x8, %g3
  1066. cmp %g3, 0x20
  1067. bl,pt %xcc, 31b
  1068. nop
  1069. 80:
  1070. rdpr %tt, %g2
  1071. cmp %g2, 0x70
  1072. be c_fast_ecc
  1073. cmp %g2, 0x63
  1074. be c_cee
  1075. nop
  1076. ba,pt %xcc, c_deferred
  1077. /* Cheetah FECC trap handling, we get here from tl{0,1}_fecc
  1078. * in the trap table. That code has done a memory barrier
  1079. * and has disabled both the I-cache and D-cache in the DCU
  1080. * control register. The I-cache is disabled so that we may
  1081. * capture the corrupted cache line, and the D-cache is disabled
  1082. * because corrupt data may have been placed there and we don't
  1083. * want to reference it.
  1084. *
  1085. * %g1 is one if this trap occurred at %tl >= 1.
  1086. *
  1087. * Next, we turn off error reporting so that we don't recurse.
  1088. */
  1089. .globl cheetah_fast_ecc
  1090. cheetah_fast_ecc:
  1091. ldxa [%g0] ASI_ESTATE_ERROR_EN, %g2
  1092. andn %g2, ESTATE_ERROR_NCEEN | ESTATE_ERROR_CEEN, %g2
  1093. stxa %g2, [%g0] ASI_ESTATE_ERROR_EN
  1094. membar #Sync
  1095. /* Fetch and clear AFSR/AFAR */
  1096. ldxa [%g0] ASI_AFSR, %g4
  1097. ldxa [%g0] ASI_AFAR, %g5
  1098. stxa %g4, [%g0] ASI_AFSR
  1099. membar #Sync
  1100. ba,pt %xcc, __cheetah_log_error
  1101. nop
  1102. c_fast_ecc:
  1103. rdpr %pil, %g2
  1104. wrpr %g0, 15, %pil
  1105. ba,pt %xcc, etrap_irq
  1106. rd %pc, %g7
  1107. mov %l4, %o1
  1108. mov %l5, %o2
  1109. call cheetah_fecc_handler
  1110. add %sp, PTREGS_OFF, %o0
  1111. ba,a,pt %xcc, rtrap_irq
  1112. /* Our caller has disabled I-cache and performed membar Sync. */
  1113. .globl cheetah_cee
  1114. cheetah_cee:
  1115. ldxa [%g0] ASI_ESTATE_ERROR_EN, %g2
  1116. andn %g2, ESTATE_ERROR_CEEN, %g2
  1117. stxa %g2, [%g0] ASI_ESTATE_ERROR_EN
  1118. membar #Sync
  1119. /* Fetch and clear AFSR/AFAR */
  1120. ldxa [%g0] ASI_AFSR, %g4
  1121. ldxa [%g0] ASI_AFAR, %g5
  1122. stxa %g4, [%g0] ASI_AFSR
  1123. membar #Sync
  1124. ba,pt %xcc, __cheetah_log_error
  1125. nop
  1126. c_cee:
  1127. rdpr %pil, %g2
  1128. wrpr %g0, 15, %pil
  1129. ba,pt %xcc, etrap_irq
  1130. rd %pc, %g7
  1131. mov %l4, %o1
  1132. mov %l5, %o2
  1133. call cheetah_cee_handler
  1134. add %sp, PTREGS_OFF, %o0
  1135. ba,a,pt %xcc, rtrap_irq
  1136. /* Our caller has disabled I-cache+D-cache and performed membar Sync. */
  1137. .globl cheetah_deferred_trap
  1138. cheetah_deferred_trap:
  1139. ldxa [%g0] ASI_ESTATE_ERROR_EN, %g2
  1140. andn %g2, ESTATE_ERROR_NCEEN | ESTATE_ERROR_CEEN, %g2
  1141. stxa %g2, [%g0] ASI_ESTATE_ERROR_EN
  1142. membar #Sync
  1143. /* Fetch and clear AFSR/AFAR */
  1144. ldxa [%g0] ASI_AFSR, %g4
  1145. ldxa [%g0] ASI_AFAR, %g5
  1146. stxa %g4, [%g0] ASI_AFSR
  1147. membar #Sync
  1148. ba,pt %xcc, __cheetah_log_error
  1149. nop
  1150. c_deferred:
  1151. rdpr %pil, %g2
  1152. wrpr %g0, 15, %pil
  1153. ba,pt %xcc, etrap_irq
  1154. rd %pc, %g7
  1155. mov %l4, %o1
  1156. mov %l5, %o2
  1157. call cheetah_deferred_handler
  1158. add %sp, PTREGS_OFF, %o0
  1159. ba,a,pt %xcc, rtrap_irq
  1160. .globl __do_privact
  1161. __do_privact:
  1162. mov TLB_SFSR, %g3
  1163. stxa %g0, [%g3] ASI_DMMU ! Clear FaultValid bit
  1164. membar #Sync
  1165. sethi %hi(109f), %g7
  1166. ba,pt %xcc, etrap
  1167. 109: or %g7, %lo(109b), %g7
  1168. call do_privact
  1169. add %sp, PTREGS_OFF, %o0
  1170. ba,pt %xcc, rtrap
  1171. clr %l6
  1172. .globl do_mna
  1173. do_mna:
  1174. rdpr %tl, %g3
  1175. cmp %g3, 1
  1176. /* Setup %g4/%g5 now as they are used in the
  1177. * winfixup code.
  1178. */
  1179. mov TLB_SFSR, %g3
  1180. mov DMMU_SFAR, %g4
  1181. ldxa [%g4] ASI_DMMU, %g4
  1182. ldxa [%g3] ASI_DMMU, %g5
  1183. stxa %g0, [%g3] ASI_DMMU ! Clear FaultValid bit
  1184. membar #Sync
  1185. bgu,pn %icc, winfix_mna
  1186. rdpr %tpc, %g3
  1187. 1: sethi %hi(109f), %g7
  1188. ba,pt %xcc, etrap
  1189. 109: or %g7, %lo(109b), %g7
  1190. mov %l4, %o1
  1191. mov %l5, %o2
  1192. call mem_address_unaligned
  1193. add %sp, PTREGS_OFF, %o0
  1194. ba,pt %xcc, rtrap
  1195. clr %l6
  1196. .globl do_lddfmna
  1197. do_lddfmna:
  1198. sethi %hi(109f), %g7
  1199. mov TLB_SFSR, %g4
  1200. ldxa [%g4] ASI_DMMU, %g5
  1201. stxa %g0, [%g4] ASI_DMMU ! Clear FaultValid bit
  1202. membar #Sync
  1203. mov DMMU_SFAR, %g4
  1204. ldxa [%g4] ASI_DMMU, %g4
  1205. ba,pt %xcc, etrap
  1206. 109: or %g7, %lo(109b), %g7
  1207. mov %l4, %o1
  1208. mov %l5, %o2
  1209. call handle_lddfmna
  1210. add %sp, PTREGS_OFF, %o0
  1211. ba,pt %xcc, rtrap
  1212. clr %l6
  1213. .globl do_stdfmna
  1214. do_stdfmna:
  1215. sethi %hi(109f), %g7
  1216. mov TLB_SFSR, %g4
  1217. ldxa [%g4] ASI_DMMU, %g5
  1218. stxa %g0, [%g4] ASI_DMMU ! Clear FaultValid bit
  1219. membar #Sync
  1220. mov DMMU_SFAR, %g4
  1221. ldxa [%g4] ASI_DMMU, %g4
  1222. ba,pt %xcc, etrap
  1223. 109: or %g7, %lo(109b), %g7
  1224. mov %l4, %o1
  1225. mov %l5, %o2
  1226. call handle_stdfmna
  1227. add %sp, PTREGS_OFF, %o0
  1228. ba,pt %xcc, rtrap
  1229. clr %l6
  1230. .globl breakpoint_trap
  1231. breakpoint_trap:
  1232. call sparc_breakpoint
  1233. add %sp, PTREGS_OFF, %o0
  1234. ba,pt %xcc, rtrap
  1235. nop
  1236. #if defined(CONFIG_SUNOS_EMUL) || defined(CONFIG_SOLARIS_EMUL) || \
  1237. defined(CONFIG_SOLARIS_EMUL_MODULE)
  1238. /* SunOS uses syscall zero as the 'indirect syscall' it looks
  1239. * like indir_syscall(scall_num, arg0, arg1, arg2...); etc.
  1240. * This is complete brain damage.
  1241. */
  1242. .globl sunos_indir
  1243. sunos_indir:
  1244. srl %o0, 0, %o0
  1245. mov %o7, %l4
  1246. cmp %o0, NR_SYSCALLS
  1247. blu,a,pt %icc, 1f
  1248. sll %o0, 0x2, %o0
  1249. sethi %hi(sunos_nosys), %l6
  1250. b,pt %xcc, 2f
  1251. or %l6, %lo(sunos_nosys), %l6
  1252. 1: sethi %hi(sunos_sys_table), %l7
  1253. or %l7, %lo(sunos_sys_table), %l7
  1254. lduw [%l7 + %o0], %l6
  1255. 2: mov %o1, %o0
  1256. mov %o2, %o1
  1257. mov %o3, %o2
  1258. mov %o4, %o3
  1259. mov %o5, %o4
  1260. call %l6
  1261. mov %l4, %o7
  1262. .globl sunos_getpid
  1263. sunos_getpid:
  1264. call sys_getppid
  1265. nop
  1266. call sys_getpid
  1267. stx %o0, [%sp + PTREGS_OFF + PT_V9_I1]
  1268. b,pt %xcc, ret_sys_call
  1269. stx %o0, [%sp + PTREGS_OFF + PT_V9_I0]
  1270. /* SunOS getuid() returns uid in %o0 and euid in %o1 */
  1271. .globl sunos_getuid
  1272. sunos_getuid:
  1273. call sys32_geteuid16
  1274. nop
  1275. call sys32_getuid16
  1276. stx %o0, [%sp + PTREGS_OFF + PT_V9_I1]
  1277. b,pt %xcc, ret_sys_call
  1278. stx %o0, [%sp + PTREGS_OFF + PT_V9_I0]
  1279. /* SunOS getgid() returns gid in %o0 and egid in %o1 */
  1280. .globl sunos_getgid
  1281. sunos_getgid:
  1282. call sys32_getegid16
  1283. nop
  1284. call sys32_getgid16
  1285. stx %o0, [%sp + PTREGS_OFF + PT_V9_I1]
  1286. b,pt %xcc, ret_sys_call
  1287. stx %o0, [%sp + PTREGS_OFF + PT_V9_I0]
  1288. #endif
  1289. /* SunOS's execv() call only specifies the argv argument, the
  1290. * environment settings are the same as the calling processes.
  1291. */
  1292. .globl sunos_execv
  1293. sys_execve:
  1294. sethi %hi(sparc_execve), %g1
  1295. ba,pt %xcc, execve_merge
  1296. or %g1, %lo(sparc_execve), %g1
  1297. #ifdef CONFIG_COMPAT
  1298. .globl sys_execve
  1299. sunos_execv:
  1300. stx %g0, [%sp + PTREGS_OFF + PT_V9_I2]
  1301. .globl sys32_execve
  1302. sys32_execve:
  1303. sethi %hi(sparc32_execve), %g1
  1304. or %g1, %lo(sparc32_execve), %g1
  1305. #endif
  1306. execve_merge:
  1307. flushw
  1308. jmpl %g1, %g0
  1309. add %sp, PTREGS_OFF, %o0
  1310. .globl sys_pipe, sys_sigpause, sys_nis_syscall
  1311. .globl sys_rt_sigreturn
  1312. .globl sys_ptrace
  1313. .globl sys_sigaltstack
  1314. .align 32
  1315. sys_pipe: ba,pt %xcc, sparc_pipe
  1316. add %sp, PTREGS_OFF, %o0
  1317. sys_nis_syscall:ba,pt %xcc, c_sys_nis_syscall
  1318. add %sp, PTREGS_OFF, %o0
  1319. sys_memory_ordering:
  1320. ba,pt %xcc, sparc_memory_ordering
  1321. add %sp, PTREGS_OFF, %o1
  1322. sys_sigaltstack:ba,pt %xcc, do_sigaltstack
  1323. add %i6, STACK_BIAS, %o2
  1324. #ifdef CONFIG_COMPAT
  1325. .globl sys32_sigstack
  1326. sys32_sigstack: ba,pt %xcc, do_sys32_sigstack
  1327. mov %i6, %o2
  1328. .globl sys32_sigaltstack
  1329. sys32_sigaltstack:
  1330. ba,pt %xcc, do_sys32_sigaltstack
  1331. mov %i6, %o2
  1332. #endif
  1333. .align 32
  1334. #ifdef CONFIG_COMPAT
  1335. .globl sys32_sigreturn
  1336. sys32_sigreturn:
  1337. add %sp, PTREGS_OFF, %o0
  1338. call do_sigreturn32
  1339. add %o7, 1f-.-4, %o7
  1340. nop
  1341. #endif
  1342. sys_rt_sigreturn:
  1343. add %sp, PTREGS_OFF, %o0
  1344. call do_rt_sigreturn
  1345. add %o7, 1f-.-4, %o7
  1346. nop
  1347. #ifdef CONFIG_COMPAT
  1348. .globl sys32_rt_sigreturn
  1349. sys32_rt_sigreturn:
  1350. add %sp, PTREGS_OFF, %o0
  1351. call do_rt_sigreturn32
  1352. add %o7, 1f-.-4, %o7
  1353. nop
  1354. #endif
  1355. sys_ptrace: add %sp, PTREGS_OFF, %o0
  1356. call do_ptrace
  1357. add %o7, 1f-.-4, %o7
  1358. nop
  1359. .align 32
  1360. 1: ldx [%curptr + TI_FLAGS], %l5
  1361. andcc %l5, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT), %g0
  1362. be,pt %icc, rtrap
  1363. clr %l6
  1364. add %sp, PTREGS_OFF, %o0
  1365. call syscall_trace
  1366. mov 1, %o1
  1367. ba,pt %xcc, rtrap
  1368. clr %l6
  1369. /* This is how fork() was meant to be done, 8 instruction entry.
  1370. *
  1371. * I questioned the following code briefly, let me clear things
  1372. * up so you must not reason on it like I did.
  1373. *
  1374. * Know the fork_kpsr etc. we use in the sparc32 port? We don't
  1375. * need it here because the only piece of window state we copy to
  1376. * the child is the CWP register. Even if the parent sleeps,
  1377. * we are safe because we stuck it into pt_regs of the parent
  1378. * so it will not change.
  1379. *
  1380. * XXX This raises the question, whether we can do the same on
  1381. * XXX sparc32 to get rid of fork_kpsr _and_ fork_kwim. The
  1382. * XXX answer is yes. We stick fork_kpsr in UREG_G0 and
  1383. * XXX fork_kwim in UREG_G1 (global registers are considered
  1384. * XXX volatile across a system call in the sparc ABI I think
  1385. * XXX if it isn't we can use regs->y instead, anyone who depends
  1386. * XXX upon the Y register being preserved across a fork deserves
  1387. * XXX to lose).
  1388. *
  1389. * In fact we should take advantage of that fact for other things
  1390. * during system calls...
  1391. */
  1392. .globl sys_fork, sys_vfork, sys_clone, sparc_exit
  1393. .globl ret_from_syscall
  1394. .align 32
  1395. sys_vfork: /* Under Linux, vfork and fork are just special cases of clone. */
  1396. sethi %hi(0x4000 | 0x0100 | SIGCHLD), %o0
  1397. or %o0, %lo(0x4000 | 0x0100 | SIGCHLD), %o0
  1398. ba,pt %xcc, sys_clone
  1399. sys_fork: clr %o1
  1400. mov SIGCHLD, %o0
  1401. sys_clone: flushw
  1402. movrz %o1, %fp, %o1
  1403. mov 0, %o3
  1404. ba,pt %xcc, sparc_do_fork
  1405. add %sp, PTREGS_OFF, %o2
  1406. ret_from_syscall:
  1407. /* Clear current_thread_info()->new_child, and
  1408. * check performance counter stuff too.
  1409. */
  1410. stb %g0, [%g6 + TI_NEW_CHILD]
  1411. ldx [%g6 + TI_FLAGS], %l0
  1412. call schedule_tail
  1413. mov %g7, %o0
  1414. andcc %l0, _TIF_PERFCTR, %g0
  1415. be,pt %icc, 1f
  1416. nop
  1417. ldx [%g6 + TI_PCR], %o7
  1418. wr %g0, %o7, %pcr
  1419. /* Blackbird errata workaround. See commentary in
  1420. * smp.c:smp_percpu_timer_interrupt() for more
  1421. * information.
  1422. */
  1423. ba,pt %xcc, 99f
  1424. nop
  1425. .align 64
  1426. 99: wr %g0, %g0, %pic
  1427. rd %pic, %g0
  1428. 1: b,pt %xcc, ret_sys_call
  1429. ldx [%sp + PTREGS_OFF + PT_V9_I0], %o0
  1430. sparc_exit: wrpr %g0, (PSTATE_RMO | PSTATE_PEF | PSTATE_PRIV), %pstate
  1431. rdpr %otherwin, %g1
  1432. rdpr %cansave, %g3
  1433. add %g3, %g1, %g3
  1434. wrpr %g3, 0x0, %cansave
  1435. wrpr %g0, 0x0, %otherwin
  1436. wrpr %g0, (PSTATE_RMO | PSTATE_PEF | PSTATE_PRIV | PSTATE_IE), %pstate
  1437. ba,pt %xcc, sys_exit
  1438. stb %g0, [%g6 + TI_WSAVED]
  1439. linux_sparc_ni_syscall:
  1440. sethi %hi(sys_ni_syscall), %l7
  1441. b,pt %xcc, 4f
  1442. or %l7, %lo(sys_ni_syscall), %l7
  1443. linux_syscall_trace32:
  1444. add %sp, PTREGS_OFF, %o0
  1445. call syscall_trace
  1446. clr %o1
  1447. srl %i0, 0, %o0
  1448. srl %i4, 0, %o4
  1449. srl %i1, 0, %o1
  1450. srl %i2, 0, %o2
  1451. b,pt %xcc, 2f
  1452. srl %i3, 0, %o3
  1453. linux_syscall_trace:
  1454. add %sp, PTREGS_OFF, %o0
  1455. call syscall_trace
  1456. clr %o1
  1457. mov %i0, %o0
  1458. mov %i1, %o1
  1459. mov %i2, %o2
  1460. mov %i3, %o3
  1461. b,pt %xcc, 2f
  1462. mov %i4, %o4
  1463. /* Linux 32-bit and SunOS system calls enter here... */
  1464. .align 32
  1465. .globl linux_sparc_syscall32
  1466. linux_sparc_syscall32:
  1467. /* Direct access to user regs, much faster. */
  1468. cmp %g1, NR_SYSCALLS ! IEU1 Group
  1469. bgeu,pn %xcc, linux_sparc_ni_syscall ! CTI
  1470. srl %i0, 0, %o0 ! IEU0
  1471. sll %g1, 2, %l4 ! IEU0 Group
  1472. srl %i4, 0, %o4 ! IEU1
  1473. lduw [%l7 + %l4], %l7 ! Load
  1474. srl %i1, 0, %o1 ! IEU0 Group
  1475. ldx [%curptr + TI_FLAGS], %l0 ! Load
  1476. srl %i5, 0, %o5 ! IEU1
  1477. srl %i2, 0, %o2 ! IEU0 Group
  1478. andcc %l0, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT), %g0
  1479. bne,pn %icc, linux_syscall_trace32 ! CTI
  1480. mov %i0, %l5 ! IEU1
  1481. call %l7 ! CTI Group brk forced
  1482. srl %i3, 0, %o3 ! IEU0
  1483. ba,a,pt %xcc, 3f
  1484. /* Linux native and SunOS system calls enter here... */
  1485. .align 32
  1486. .globl linux_sparc_syscall, ret_sys_call
  1487. linux_sparc_syscall:
  1488. /* Direct access to user regs, much faster. */
  1489. cmp %g1, NR_SYSCALLS ! IEU1 Group
  1490. bgeu,pn %xcc, linux_sparc_ni_syscall ! CTI
  1491. mov %i0, %o0 ! IEU0
  1492. sll %g1, 2, %l4 ! IEU0 Group
  1493. mov %i1, %o1 ! IEU1
  1494. lduw [%l7 + %l4], %l7 ! Load
  1495. 4: mov %i2, %o2 ! IEU0 Group
  1496. ldx [%curptr + TI_FLAGS], %l0 ! Load
  1497. mov %i3, %o3 ! IEU1
  1498. mov %i4, %o4 ! IEU0 Group
  1499. andcc %l0, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT), %g0
  1500. bne,pn %icc, linux_syscall_trace ! CTI Group
  1501. mov %i0, %l5 ! IEU0
  1502. 2: call %l7 ! CTI Group brk forced
  1503. mov %i5, %o5 ! IEU0
  1504. nop
  1505. 3: stx %o0, [%sp + PTREGS_OFF + PT_V9_I0]
  1506. ret_sys_call:
  1507. ldx [%sp + PTREGS_OFF + PT_V9_TSTATE], %g3
  1508. ldx [%sp + PTREGS_OFF + PT_V9_TNPC], %l1 ! pc = npc
  1509. sra %o0, 0, %o0
  1510. mov %ulo(TSTATE_XCARRY | TSTATE_ICARRY), %g2
  1511. sllx %g2, 32, %g2
  1512. /* Check if force_successful_syscall_return()
  1513. * was invoked.
  1514. */
  1515. ldub [%curptr + TI_SYS_NOERROR], %l2
  1516. brnz,a,pn %l2, 80f
  1517. stb %g0, [%curptr + TI_SYS_NOERROR]
  1518. cmp %o0, -ERESTART_RESTARTBLOCK
  1519. bgeu,pn %xcc, 1f
  1520. andcc %l0, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT), %l6
  1521. 80:
  1522. /* System call success, clear Carry condition code. */
  1523. andn %g3, %g2, %g3
  1524. stx %g3, [%sp + PTREGS_OFF + PT_V9_TSTATE]
  1525. bne,pn %icc, linux_syscall_trace2
  1526. add %l1, 0x4, %l2 ! npc = npc+4
  1527. stx %l1, [%sp + PTREGS_OFF + PT_V9_TPC]
  1528. ba,pt %xcc, rtrap_clr_l6
  1529. stx %l2, [%sp + PTREGS_OFF + PT_V9_TNPC]
  1530. 1:
  1531. /* System call failure, set Carry condition code.
  1532. * Also, get abs(errno) to return to the process.
  1533. */
  1534. andcc %l0, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT), %l6
  1535. sub %g0, %o0, %o0
  1536. or %g3, %g2, %g3
  1537. stx %o0, [%sp + PTREGS_OFF + PT_V9_I0]
  1538. mov 1, %l6
  1539. stx %g3, [%sp + PTREGS_OFF + PT_V9_TSTATE]
  1540. bne,pn %icc, linux_syscall_trace2
  1541. add %l1, 0x4, %l2 ! npc = npc+4
  1542. stx %l1, [%sp + PTREGS_OFF + PT_V9_TPC]
  1543. b,pt %xcc, rtrap
  1544. stx %l2, [%sp + PTREGS_OFF + PT_V9_TNPC]
  1545. linux_syscall_trace2:
  1546. add %sp, PTREGS_OFF, %o0
  1547. call syscall_trace
  1548. mov 1, %o1
  1549. stx %l1, [%sp + PTREGS_OFF + PT_V9_TPC]
  1550. ba,pt %xcc, rtrap
  1551. stx %l2, [%sp + PTREGS_OFF + PT_V9_TNPC]
  1552. .align 32
  1553. .globl __flushw_user
  1554. __flushw_user:
  1555. rdpr %otherwin, %g1
  1556. brz,pn %g1, 2f
  1557. clr %g2
  1558. 1: save %sp, -128, %sp
  1559. rdpr %otherwin, %g1
  1560. brnz,pt %g1, 1b
  1561. add %g2, 1, %g2
  1562. 1: sub %g2, 1, %g2
  1563. brnz,pt %g2, 1b
  1564. restore %g0, %g0, %g0
  1565. 2: retl
  1566. nop