entry.S 42 KB

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