entry.S 42 KB

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