entry.S 39 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886
  1. /* arch/sparc/kernel/entry.S: Sparc trap low-level entry points.
  2. *
  3. * Copyright (C) 1995, 2007 David S. Miller (davem@davemloft.net)
  4. * Copyright (C) 1996 Eddie C. Dost (ecd@skynet.be)
  5. * Copyright (C) 1996 Miguel de Icaza (miguel@nuclecu.unam.mx)
  6. * Copyright (C) 1996-1999 Jakub Jelinek (jj@sunsite.mff.cuni.cz)
  7. * Copyright (C) 1997 Anton Blanchard (anton@progsoc.uts.edu.au)
  8. */
  9. #include <linux/errno.h>
  10. #include <asm/head.h>
  11. #include <asm/asi.h>
  12. #include <asm/smp.h>
  13. #include <asm/kgdb.h>
  14. #include <asm/contregs.h>
  15. #include <asm/ptrace.h>
  16. #include <asm/asm-offsets.h>
  17. #include <asm/psr.h>
  18. #include <asm/vaddrs.h>
  19. #include <asm/memreg.h>
  20. #include <asm/page.h>
  21. #ifdef CONFIG_SUN4
  22. #include <asm/pgtsun4.h>
  23. #else
  24. #include <asm/pgtsun4c.h>
  25. #endif
  26. #include <asm/winmacro.h>
  27. #include <asm/signal.h>
  28. #include <asm/obio.h>
  29. #include <asm/mxcc.h>
  30. #include <asm/thread_info.h>
  31. #include <asm/param.h>
  32. #include <asm/unistd.h>
  33. #include <asm/asmmacro.h>
  34. #define curptr g6
  35. /* These are just handy. */
  36. #define _SV save %sp, -STACKFRAME_SZ, %sp
  37. #define _RS restore
  38. #define FLUSH_ALL_KERNEL_WINDOWS \
  39. _SV; _SV; _SV; _SV; _SV; _SV; _SV; \
  40. _RS; _RS; _RS; _RS; _RS; _RS; _RS;
  41. /* First, KGDB low level things. This is a rewrite
  42. * of the routines found in the sparc-stub.c asm() statement
  43. * from the gdb distribution. This is also dual-purpose
  44. * as a software trap for userlevel programs.
  45. */
  46. .data
  47. .align 4
  48. in_trap_handler:
  49. .word 0
  50. .text
  51. .align 4
  52. #if 0 /* kgdb is dropped from 2.5.33 */
  53. ! This function is called when any SPARC trap (except window overflow or
  54. ! underflow) occurs. It makes sure that the invalid register window is still
  55. ! available before jumping into C code. It will also restore the world if you
  56. ! return from handle_exception.
  57. .globl trap_low
  58. trap_low:
  59. rd %wim, %l3
  60. SAVE_ALL
  61. sethi %hi(in_trap_handler), %l4
  62. ld [%lo(in_trap_handler) + %l4], %l5
  63. inc %l5
  64. st %l5, [%lo(in_trap_handler) + %l4]
  65. /* Make sure kgdb sees the same state we just saved. */
  66. LOAD_PT_GLOBALS(sp)
  67. LOAD_PT_INS(sp)
  68. ld [%sp + STACKFRAME_SZ + PT_Y], %l4
  69. ld [%sp + STACKFRAME_SZ + PT_WIM], %l3
  70. ld [%sp + STACKFRAME_SZ + PT_PSR], %l0
  71. ld [%sp + STACKFRAME_SZ + PT_PC], %l1
  72. ld [%sp + STACKFRAME_SZ + PT_NPC], %l2
  73. rd %tbr, %l5 /* Never changes... */
  74. /* Make kgdb exception frame. */
  75. sub %sp,(16+1+6+1+72)*4,%sp ! Make room for input & locals
  76. ! + hidden arg + arg spill
  77. ! + doubleword alignment
  78. ! + registers[72] local var
  79. SAVE_KGDB_GLOBALS(sp)
  80. SAVE_KGDB_INS(sp)
  81. SAVE_KGDB_SREGS(sp, l4, l0, l3, l5, l1, l2)
  82. /* We are increasing PIL, so two writes. */
  83. or %l0, PSR_PIL, %l0
  84. wr %l0, 0, %psr
  85. WRITE_PAUSE
  86. wr %l0, PSR_ET, %psr
  87. WRITE_PAUSE
  88. call handle_exception
  89. add %sp, STACKFRAME_SZ, %o0 ! Pass address of registers
  90. /* Load new kgdb register set. */
  91. LOAD_KGDB_GLOBALS(sp)
  92. LOAD_KGDB_INS(sp)
  93. LOAD_KGDB_SREGS(sp, l4, l0, l3, l5, l1, l2)
  94. wr %l4, 0x0, %y
  95. sethi %hi(in_trap_handler), %l4
  96. ld [%lo(in_trap_handler) + %l4], %l5
  97. dec %l5
  98. st %l5, [%lo(in_trap_handler) + %l4]
  99. add %sp,(16+1+6+1+72)*4,%sp ! Undo the kgdb trap frame.
  100. /* Now take what kgdb did and place it into the pt_regs
  101. * frame which SparcLinux RESTORE_ALL understands.,
  102. */
  103. STORE_PT_INS(sp)
  104. STORE_PT_GLOBALS(sp)
  105. STORE_PT_YREG(sp, g2)
  106. STORE_PT_PRIV(sp, l0, l1, l2)
  107. RESTORE_ALL
  108. #endif
  109. #if defined(CONFIG_BLK_DEV_FD) || defined(CONFIG_BLK_DEV_FD_MODULE)
  110. .text
  111. .align 4
  112. .globl floppy_hardint
  113. floppy_hardint:
  114. /*
  115. * This code cannot touch registers %l0 %l1 and %l2
  116. * because SAVE_ALL depends on their values. It depends
  117. * on %l3 also, but we regenerate it before a call.
  118. * Other registers are:
  119. * %l3 -- base address of fdc registers
  120. * %l4 -- pdma_vaddr
  121. * %l5 -- scratch for ld/st address
  122. * %l6 -- pdma_size
  123. * %l7 -- scratch [floppy byte, ld/st address, aux. data]
  124. */
  125. /* Do we have work to do? */
  126. sethi %hi(doing_pdma), %l7
  127. ld [%l7 + %lo(doing_pdma)], %l7
  128. cmp %l7, 0
  129. be floppy_dosoftint
  130. nop
  131. /* Load fdc register base */
  132. sethi %hi(fdc_status), %l3
  133. ld [%l3 + %lo(fdc_status)], %l3
  134. /* Setup register addresses */
  135. sethi %hi(pdma_vaddr), %l5 ! transfer buffer
  136. ld [%l5 + %lo(pdma_vaddr)], %l4
  137. sethi %hi(pdma_size), %l5 ! bytes to go
  138. ld [%l5 + %lo(pdma_size)], %l6
  139. next_byte:
  140. ldub [%l3], %l7
  141. andcc %l7, 0x80, %g0 ! Does fifo still have data
  142. bz floppy_fifo_emptied ! fifo has been emptied...
  143. andcc %l7, 0x20, %g0 ! in non-dma mode still?
  144. bz floppy_overrun ! nope, overrun
  145. andcc %l7, 0x40, %g0 ! 0=write 1=read
  146. bz floppy_write
  147. sub %l6, 0x1, %l6
  148. /* Ok, actually read this byte */
  149. ldub [%l3 + 1], %l7
  150. orcc %g0, %l6, %g0
  151. stb %l7, [%l4]
  152. bne next_byte
  153. add %l4, 0x1, %l4
  154. b floppy_tdone
  155. nop
  156. floppy_write:
  157. /* Ok, actually write this byte */
  158. ldub [%l4], %l7
  159. orcc %g0, %l6, %g0
  160. stb %l7, [%l3 + 1]
  161. bne next_byte
  162. add %l4, 0x1, %l4
  163. /* fall through... */
  164. floppy_tdone:
  165. sethi %hi(pdma_vaddr), %l5
  166. st %l4, [%l5 + %lo(pdma_vaddr)]
  167. sethi %hi(pdma_size), %l5
  168. st %l6, [%l5 + %lo(pdma_size)]
  169. /* Flip terminal count pin */
  170. set auxio_register, %l7
  171. ld [%l7], %l7
  172. set sparc_cpu_model, %l5
  173. ld [%l5], %l5
  174. subcc %l5, 1, %g0 /* enum { sun4c = 1 }; */
  175. be 1f
  176. ldub [%l7], %l5
  177. or %l5, 0xc2, %l5
  178. stb %l5, [%l7]
  179. andn %l5, 0x02, %l5
  180. b 2f
  181. nop
  182. 1:
  183. or %l5, 0xf4, %l5
  184. stb %l5, [%l7]
  185. andn %l5, 0x04, %l5
  186. 2:
  187. /* Kill some time so the bits set */
  188. WRITE_PAUSE
  189. WRITE_PAUSE
  190. stb %l5, [%l7]
  191. /* Prevent recursion */
  192. sethi %hi(doing_pdma), %l7
  193. b floppy_dosoftint
  194. st %g0, [%l7 + %lo(doing_pdma)]
  195. /* We emptied the FIFO, but we haven't read everything
  196. * as of yet. Store the current transfer address and
  197. * bytes left to read so we can continue when the next
  198. * fast IRQ comes in.
  199. */
  200. floppy_fifo_emptied:
  201. sethi %hi(pdma_vaddr), %l5
  202. st %l4, [%l5 + %lo(pdma_vaddr)]
  203. sethi %hi(pdma_size), %l7
  204. st %l6, [%l7 + %lo(pdma_size)]
  205. /* Restore condition codes */
  206. wr %l0, 0x0, %psr
  207. WRITE_PAUSE
  208. jmp %l1
  209. rett %l2
  210. floppy_overrun:
  211. sethi %hi(pdma_vaddr), %l5
  212. st %l4, [%l5 + %lo(pdma_vaddr)]
  213. sethi %hi(pdma_size), %l5
  214. st %l6, [%l5 + %lo(pdma_size)]
  215. /* Prevent recursion */
  216. sethi %hi(doing_pdma), %l7
  217. st %g0, [%l7 + %lo(doing_pdma)]
  218. /* fall through... */
  219. floppy_dosoftint:
  220. rd %wim, %l3
  221. SAVE_ALL
  222. /* Set all IRQs off. */
  223. or %l0, PSR_PIL, %l4
  224. wr %l4, 0x0, %psr
  225. WRITE_PAUSE
  226. wr %l4, PSR_ET, %psr
  227. WRITE_PAUSE
  228. mov 11, %o0 ! floppy irq level (unused anyway)
  229. mov %g0, %o1 ! devid is not used in fast interrupts
  230. call sparc_floppy_irq
  231. add %sp, STACKFRAME_SZ, %o2 ! struct pt_regs *regs
  232. RESTORE_ALL
  233. #endif /* (CONFIG_BLK_DEV_FD) */
  234. /* Bad trap handler */
  235. .globl bad_trap_handler
  236. bad_trap_handler:
  237. SAVE_ALL
  238. wr %l0, PSR_ET, %psr
  239. WRITE_PAUSE
  240. add %sp, STACKFRAME_SZ, %o0 ! pt_regs
  241. call do_hw_interrupt
  242. mov %l7, %o1 ! trap number
  243. RESTORE_ALL
  244. /* For now all IRQ's not registered get sent here. handler_irq() will
  245. * see if a routine is registered to handle this interrupt and if not
  246. * it will say so on the console.
  247. */
  248. .align 4
  249. .globl real_irq_entry, patch_handler_irq
  250. real_irq_entry:
  251. SAVE_ALL
  252. #ifdef CONFIG_SMP
  253. .globl patchme_maybe_smp_msg
  254. cmp %l7, 12
  255. patchme_maybe_smp_msg:
  256. bgu maybe_smp4m_msg
  257. nop
  258. #endif
  259. real_irq_continue:
  260. or %l0, PSR_PIL, %g2
  261. wr %g2, 0x0, %psr
  262. WRITE_PAUSE
  263. wr %g2, PSR_ET, %psr
  264. WRITE_PAUSE
  265. mov %l7, %o0 ! irq level
  266. patch_handler_irq:
  267. call handler_irq
  268. add %sp, STACKFRAME_SZ, %o1 ! pt_regs ptr
  269. or %l0, PSR_PIL, %g2 ! restore PIL after handler_irq
  270. wr %g2, PSR_ET, %psr ! keep ET up
  271. WRITE_PAUSE
  272. RESTORE_ALL
  273. #ifdef CONFIG_SMP
  274. /* SMP per-cpu ticker interrupts are handled specially. */
  275. smp4m_ticker:
  276. bne real_irq_continue+4
  277. or %l0, PSR_PIL, %g2
  278. wr %g2, 0x0, %psr
  279. WRITE_PAUSE
  280. wr %g2, PSR_ET, %psr
  281. WRITE_PAUSE
  282. call smp4m_percpu_timer_interrupt
  283. add %sp, STACKFRAME_SZ, %o0
  284. wr %l0, PSR_ET, %psr
  285. WRITE_PAUSE
  286. RESTORE_ALL
  287. /* Here is where we check for possible SMP IPI passed to us
  288. * on some level other than 15 which is the NMI and only used
  289. * for cross calls. That has a separate entry point below.
  290. */
  291. maybe_smp4m_msg:
  292. GET_PROCESSOR4M_ID(o3)
  293. set sun4m_interrupts, %l5
  294. ld [%l5], %o5
  295. sethi %hi(0x40000000), %o2
  296. sll %o3, 12, %o3
  297. ld [%o5 + %o3], %o1
  298. andcc %o1, %o2, %g0
  299. be,a smp4m_ticker
  300. cmp %l7, 14
  301. st %o2, [%o5 + 0x4]
  302. WRITE_PAUSE
  303. ld [%o5], %g0
  304. WRITE_PAUSE
  305. or %l0, PSR_PIL, %l4
  306. wr %l4, 0x0, %psr
  307. WRITE_PAUSE
  308. wr %l4, PSR_ET, %psr
  309. WRITE_PAUSE
  310. call smp_reschedule_irq
  311. nop
  312. RESTORE_ALL
  313. .align 4
  314. .globl linux_trap_ipi15_sun4m
  315. linux_trap_ipi15_sun4m:
  316. SAVE_ALL
  317. sethi %hi(0x80000000), %o2
  318. GET_PROCESSOR4M_ID(o0)
  319. set sun4m_interrupts, %l5
  320. ld [%l5], %o5
  321. sll %o0, 12, %o0
  322. add %o5, %o0, %o5
  323. ld [%o5], %o3
  324. andcc %o3, %o2, %g0
  325. be 1f ! Must be an NMI async memory error
  326. st %o2, [%o5 + 4]
  327. WRITE_PAUSE
  328. ld [%o5], %g0
  329. WRITE_PAUSE
  330. or %l0, PSR_PIL, %l4
  331. wr %l4, 0x0, %psr
  332. WRITE_PAUSE
  333. wr %l4, PSR_ET, %psr
  334. WRITE_PAUSE
  335. call smp4m_cross_call_irq
  336. nop
  337. b ret_trap_lockless_ipi
  338. clr %l6
  339. 1:
  340. /* NMI async memory error handling. */
  341. sethi %hi(0x80000000), %l4
  342. sethi %hi(0x4000), %o3
  343. sub %o5, %o0, %o5
  344. add %o5, %o3, %l5
  345. st %l4, [%l5 + 0xc]
  346. WRITE_PAUSE
  347. ld [%l5], %g0
  348. WRITE_PAUSE
  349. or %l0, PSR_PIL, %l4
  350. wr %l4, 0x0, %psr
  351. WRITE_PAUSE
  352. wr %l4, PSR_ET, %psr
  353. WRITE_PAUSE
  354. call sun4m_nmi
  355. nop
  356. st %l4, [%l5 + 0x8]
  357. WRITE_PAUSE
  358. ld [%l5], %g0
  359. WRITE_PAUSE
  360. RESTORE_ALL
  361. .globl smp4d_ticker
  362. /* SMP per-cpu ticker interrupts are handled specially. */
  363. smp4d_ticker:
  364. SAVE_ALL
  365. or %l0, PSR_PIL, %g2
  366. sethi %hi(CC_ICLR), %o0
  367. sethi %hi(1 << 14), %o1
  368. or %o0, %lo(CC_ICLR), %o0
  369. stha %o1, [%o0] ASI_M_MXCC /* Clear PIL 14 in MXCC's ICLR */
  370. wr %g2, 0x0, %psr
  371. WRITE_PAUSE
  372. wr %g2, PSR_ET, %psr
  373. WRITE_PAUSE
  374. call smp4d_percpu_timer_interrupt
  375. add %sp, STACKFRAME_SZ, %o0
  376. wr %l0, PSR_ET, %psr
  377. WRITE_PAUSE
  378. RESTORE_ALL
  379. .align 4
  380. .globl linux_trap_ipi15_sun4d
  381. linux_trap_ipi15_sun4d:
  382. SAVE_ALL
  383. sethi %hi(CC_BASE), %o4
  384. sethi %hi(MXCC_ERR_ME|MXCC_ERR_PEW|MXCC_ERR_ASE|MXCC_ERR_PEE), %o2
  385. or %o4, (CC_EREG - CC_BASE), %o0
  386. ldda [%o0] ASI_M_MXCC, %o0
  387. andcc %o0, %o2, %g0
  388. bne 1f
  389. sethi %hi(BB_STAT2), %o2
  390. lduba [%o2] ASI_M_CTL, %o2
  391. andcc %o2, BB_STAT2_MASK, %g0
  392. bne 2f
  393. or %o4, (CC_ICLR - CC_BASE), %o0
  394. sethi %hi(1 << 15), %o1
  395. stha %o1, [%o0] ASI_M_MXCC /* Clear PIL 15 in MXCC's ICLR */
  396. or %l0, PSR_PIL, %l4
  397. wr %l4, 0x0, %psr
  398. WRITE_PAUSE
  399. wr %l4, PSR_ET, %psr
  400. WRITE_PAUSE
  401. call smp4d_cross_call_irq
  402. nop
  403. b ret_trap_lockless_ipi
  404. clr %l6
  405. 1: /* MXCC error */
  406. 2: /* BB error */
  407. /* Disable PIL 15 */
  408. set CC_IMSK, %l4
  409. lduha [%l4] ASI_M_MXCC, %l5
  410. sethi %hi(1 << 15), %l7
  411. or %l5, %l7, %l5
  412. stha %l5, [%l4] ASI_M_MXCC
  413. /* FIXME */
  414. 1: b,a 1b
  415. #endif /* CONFIG_SMP */
  416. /* This routine handles illegal instructions and privileged
  417. * instruction attempts from user code.
  418. */
  419. .align 4
  420. .globl bad_instruction
  421. bad_instruction:
  422. sethi %hi(0xc1f80000), %l4
  423. ld [%l1], %l5
  424. sethi %hi(0x81d80000), %l7
  425. and %l5, %l4, %l5
  426. cmp %l5, %l7
  427. be 1f
  428. SAVE_ALL
  429. wr %l0, PSR_ET, %psr ! re-enable traps
  430. WRITE_PAUSE
  431. add %sp, STACKFRAME_SZ, %o0
  432. mov %l1, %o1
  433. mov %l2, %o2
  434. call do_illegal_instruction
  435. mov %l0, %o3
  436. RESTORE_ALL
  437. 1: /* unimplemented flush - just skip */
  438. jmpl %l2, %g0
  439. rett %l2 + 4
  440. .align 4
  441. .globl priv_instruction
  442. priv_instruction:
  443. SAVE_ALL
  444. wr %l0, PSR_ET, %psr
  445. WRITE_PAUSE
  446. add %sp, STACKFRAME_SZ, %o0
  447. mov %l1, %o1
  448. mov %l2, %o2
  449. call do_priv_instruction
  450. mov %l0, %o3
  451. RESTORE_ALL
  452. /* This routine handles unaligned data accesses. */
  453. .align 4
  454. .globl mna_handler
  455. mna_handler:
  456. andcc %l0, PSR_PS, %g0
  457. be mna_fromuser
  458. nop
  459. SAVE_ALL
  460. wr %l0, PSR_ET, %psr
  461. WRITE_PAUSE
  462. ld [%l1], %o1
  463. call kernel_unaligned_trap
  464. add %sp, STACKFRAME_SZ, %o0
  465. RESTORE_ALL
  466. mna_fromuser:
  467. SAVE_ALL
  468. wr %l0, PSR_ET, %psr ! re-enable traps
  469. WRITE_PAUSE
  470. ld [%l1], %o1
  471. call user_unaligned_trap
  472. add %sp, STACKFRAME_SZ, %o0
  473. RESTORE_ALL
  474. /* This routine handles floating point disabled traps. */
  475. .align 4
  476. .globl fpd_trap_handler
  477. fpd_trap_handler:
  478. SAVE_ALL
  479. wr %l0, PSR_ET, %psr ! re-enable traps
  480. WRITE_PAUSE
  481. add %sp, STACKFRAME_SZ, %o0
  482. mov %l1, %o1
  483. mov %l2, %o2
  484. call do_fpd_trap
  485. mov %l0, %o3
  486. RESTORE_ALL
  487. /* This routine handles Floating Point Exceptions. */
  488. .align 4
  489. .globl fpe_trap_handler
  490. fpe_trap_handler:
  491. set fpsave_magic, %l5
  492. cmp %l1, %l5
  493. be 1f
  494. sethi %hi(fpsave), %l5
  495. or %l5, %lo(fpsave), %l5
  496. cmp %l1, %l5
  497. bne 2f
  498. sethi %hi(fpsave_catch2), %l5
  499. or %l5, %lo(fpsave_catch2), %l5
  500. wr %l0, 0x0, %psr
  501. WRITE_PAUSE
  502. jmp %l5
  503. rett %l5 + 4
  504. 1:
  505. sethi %hi(fpsave_catch), %l5
  506. or %l5, %lo(fpsave_catch), %l5
  507. wr %l0, 0x0, %psr
  508. WRITE_PAUSE
  509. jmp %l5
  510. rett %l5 + 4
  511. 2:
  512. SAVE_ALL
  513. wr %l0, PSR_ET, %psr ! re-enable traps
  514. WRITE_PAUSE
  515. add %sp, STACKFRAME_SZ, %o0
  516. mov %l1, %o1
  517. mov %l2, %o2
  518. call do_fpe_trap
  519. mov %l0, %o3
  520. RESTORE_ALL
  521. /* This routine handles Tag Overflow Exceptions. */
  522. .align 4
  523. .globl do_tag_overflow
  524. do_tag_overflow:
  525. SAVE_ALL
  526. wr %l0, PSR_ET, %psr ! re-enable traps
  527. WRITE_PAUSE
  528. add %sp, STACKFRAME_SZ, %o0
  529. mov %l1, %o1
  530. mov %l2, %o2
  531. call handle_tag_overflow
  532. mov %l0, %o3
  533. RESTORE_ALL
  534. /* This routine handles Watchpoint Exceptions. */
  535. .align 4
  536. .globl do_watchpoint
  537. do_watchpoint:
  538. SAVE_ALL
  539. wr %l0, PSR_ET, %psr ! re-enable traps
  540. WRITE_PAUSE
  541. add %sp, STACKFRAME_SZ, %o0
  542. mov %l1, %o1
  543. mov %l2, %o2
  544. call handle_watchpoint
  545. mov %l0, %o3
  546. RESTORE_ALL
  547. /* This routine handles Register Access Exceptions. */
  548. .align 4
  549. .globl do_reg_access
  550. do_reg_access:
  551. SAVE_ALL
  552. wr %l0, PSR_ET, %psr ! re-enable traps
  553. WRITE_PAUSE
  554. add %sp, STACKFRAME_SZ, %o0
  555. mov %l1, %o1
  556. mov %l2, %o2
  557. call handle_reg_access
  558. mov %l0, %o3
  559. RESTORE_ALL
  560. /* This routine handles Co-Processor Disabled Exceptions. */
  561. .align 4
  562. .globl do_cp_disabled
  563. do_cp_disabled:
  564. SAVE_ALL
  565. wr %l0, PSR_ET, %psr ! re-enable traps
  566. WRITE_PAUSE
  567. add %sp, STACKFRAME_SZ, %o0
  568. mov %l1, %o1
  569. mov %l2, %o2
  570. call handle_cp_disabled
  571. mov %l0, %o3
  572. RESTORE_ALL
  573. /* This routine handles Co-Processor Exceptions. */
  574. .align 4
  575. .globl do_cp_exception
  576. do_cp_exception:
  577. SAVE_ALL
  578. wr %l0, PSR_ET, %psr ! re-enable traps
  579. WRITE_PAUSE
  580. add %sp, STACKFRAME_SZ, %o0
  581. mov %l1, %o1
  582. mov %l2, %o2
  583. call handle_cp_exception
  584. mov %l0, %o3
  585. RESTORE_ALL
  586. /* This routine handles Hardware Divide By Zero Exceptions. */
  587. .align 4
  588. .globl do_hw_divzero
  589. do_hw_divzero:
  590. SAVE_ALL
  591. wr %l0, PSR_ET, %psr ! re-enable traps
  592. WRITE_PAUSE
  593. add %sp, STACKFRAME_SZ, %o0
  594. mov %l1, %o1
  595. mov %l2, %o2
  596. call handle_hw_divzero
  597. mov %l0, %o3
  598. RESTORE_ALL
  599. .align 4
  600. .globl do_flush_windows
  601. do_flush_windows:
  602. SAVE_ALL
  603. wr %l0, PSR_ET, %psr
  604. WRITE_PAUSE
  605. andcc %l0, PSR_PS, %g0
  606. bne dfw_kernel
  607. nop
  608. call flush_user_windows
  609. nop
  610. /* Advance over the trap instruction. */
  611. ld [%sp + STACKFRAME_SZ + PT_NPC], %l1
  612. add %l1, 0x4, %l2
  613. st %l1, [%sp + STACKFRAME_SZ + PT_PC]
  614. st %l2, [%sp + STACKFRAME_SZ + PT_NPC]
  615. RESTORE_ALL
  616. .globl flush_patch_one
  617. /* We get these for debugging routines using __builtin_return_address() */
  618. dfw_kernel:
  619. flush_patch_one:
  620. FLUSH_ALL_KERNEL_WINDOWS
  621. /* Advance over the trap instruction. */
  622. ld [%sp + STACKFRAME_SZ + PT_NPC], %l1
  623. add %l1, 0x4, %l2
  624. st %l1, [%sp + STACKFRAME_SZ + PT_PC]
  625. st %l2, [%sp + STACKFRAME_SZ + PT_NPC]
  626. RESTORE_ALL
  627. /* The getcc software trap. The user wants the condition codes from
  628. * the %psr in register %g1.
  629. */
  630. .align 4
  631. .globl getcc_trap_handler
  632. getcc_trap_handler:
  633. srl %l0, 20, %g1 ! give user
  634. and %g1, 0xf, %g1 ! only ICC bits in %psr
  635. jmp %l2 ! advance over trap instruction
  636. rett %l2 + 0x4 ! like this...
  637. /* The setcc software trap. The user has condition codes in %g1
  638. * that it would like placed in the %psr. Be careful not to flip
  639. * any unintentional bits!
  640. */
  641. .align 4
  642. .globl setcc_trap_handler
  643. setcc_trap_handler:
  644. sll %g1, 0x14, %l4
  645. set PSR_ICC, %l5
  646. andn %l0, %l5, %l0 ! clear ICC bits in %psr
  647. and %l4, %l5, %l4 ! clear non-ICC bits in user value
  648. or %l4, %l0, %l4 ! or them in... mix mix mix
  649. wr %l4, 0x0, %psr ! set new %psr
  650. WRITE_PAUSE ! TI scumbags...
  651. jmp %l2 ! advance over trap instruction
  652. rett %l2 + 0x4 ! like this...
  653. .align 4
  654. .globl linux_trap_nmi_sun4c
  655. linux_trap_nmi_sun4c:
  656. SAVE_ALL
  657. /* Ugh, we need to clear the IRQ line. This is now
  658. * a very sun4c specific trap handler...
  659. */
  660. sethi %hi(interrupt_enable), %l5
  661. ld [%l5 + %lo(interrupt_enable)], %l5
  662. ldub [%l5], %l6
  663. andn %l6, INTS_ENAB, %l6
  664. stb %l6, [%l5]
  665. /* Now it is safe to re-enable traps without recursion. */
  666. or %l0, PSR_PIL, %l0
  667. wr %l0, PSR_ET, %psr
  668. WRITE_PAUSE
  669. /* Now call the c-code with the pt_regs frame ptr and the
  670. * memory error registers as arguments. The ordering chosen
  671. * here is due to unlatching semantics.
  672. */
  673. sethi %hi(AC_SYNC_ERR), %o0
  674. add %o0, 0x4, %o0
  675. lda [%o0] ASI_CONTROL, %o2 ! sync vaddr
  676. sub %o0, 0x4, %o0
  677. lda [%o0] ASI_CONTROL, %o1 ! sync error
  678. add %o0, 0xc, %o0
  679. lda [%o0] ASI_CONTROL, %o4 ! async vaddr
  680. sub %o0, 0x4, %o0
  681. lda [%o0] ASI_CONTROL, %o3 ! async error
  682. call sparc_lvl15_nmi
  683. add %sp, STACKFRAME_SZ, %o0
  684. RESTORE_ALL
  685. .align 4
  686. .globl invalid_segment_patch1_ff
  687. .globl invalid_segment_patch2_ff
  688. invalid_segment_patch1_ff: cmp %l4, 0xff
  689. invalid_segment_patch2_ff: mov 0xff, %l3
  690. .align 4
  691. .globl invalid_segment_patch1_1ff
  692. .globl invalid_segment_patch2_1ff
  693. invalid_segment_patch1_1ff: cmp %l4, 0x1ff
  694. invalid_segment_patch2_1ff: mov 0x1ff, %l3
  695. .align 4
  696. .globl num_context_patch1_16, num_context_patch2_16
  697. num_context_patch1_16: mov 0x10, %l7
  698. num_context_patch2_16: mov 0x10, %l7
  699. .align 4
  700. .globl vac_linesize_patch_32
  701. vac_linesize_patch_32: subcc %l7, 32, %l7
  702. .align 4
  703. .globl vac_hwflush_patch1_on, vac_hwflush_patch2_on
  704. /*
  705. * Ugly, but we cant use hardware flushing on the sun4 and we'd require
  706. * two instructions (Anton)
  707. */
  708. #ifdef CONFIG_SUN4
  709. vac_hwflush_patch1_on: nop
  710. #else
  711. vac_hwflush_patch1_on: addcc %l7, -PAGE_SIZE, %l7
  712. #endif
  713. vac_hwflush_patch2_on: sta %g0, [%l3 + %l7] ASI_HWFLUSHSEG
  714. .globl invalid_segment_patch1, invalid_segment_patch2
  715. .globl num_context_patch1
  716. .globl vac_linesize_patch, vac_hwflush_patch1
  717. .globl vac_hwflush_patch2
  718. .align 4
  719. .globl sun4c_fault
  720. ! %l0 = %psr
  721. ! %l1 = %pc
  722. ! %l2 = %npc
  723. ! %l3 = %wim
  724. ! %l7 = 1 for textfault
  725. ! We want error in %l5, vaddr in %l6
  726. sun4c_fault:
  727. #ifdef CONFIG_SUN4
  728. sethi %hi(sun4c_memerr_reg), %l4
  729. ld [%l4+%lo(sun4c_memerr_reg)], %l4 ! memerr ctrl reg addr
  730. ld [%l4], %l6 ! memerr ctrl reg
  731. ld [%l4 + 4], %l5 ! memerr vaddr reg
  732. andcc %l6, 0x80, %g0 ! check for error type
  733. st %g0, [%l4 + 4] ! clear the error
  734. be 0f ! normal error
  735. sethi %hi(AC_BUS_ERROR), %l4 ! bus err reg addr
  736. call prom_halt ! something weird happened
  737. ! what exactly did happen?
  738. ! what should we do here?
  739. 0: or %l4, %lo(AC_BUS_ERROR), %l4 ! bus err reg addr
  740. lduba [%l4] ASI_CONTROL, %l6 ! bus err reg
  741. cmp %l7, 1 ! text fault?
  742. be 1f ! yes
  743. nop
  744. ld [%l1], %l4 ! load instruction that caused fault
  745. srl %l4, 21, %l4
  746. andcc %l4, 1, %g0 ! store instruction?
  747. be 1f ! no
  748. sethi %hi(SUN4C_SYNC_BADWRITE), %l4 ! yep
  749. ! %lo(SUN4C_SYNC_BADWRITE) = 0
  750. or %l4, %l6, %l6 ! set write bit to emulate sun4c
  751. 1:
  752. #else
  753. sethi %hi(AC_SYNC_ERR), %l4
  754. add %l4, 0x4, %l6 ! AC_SYNC_VA in %l6
  755. lda [%l6] ASI_CONTROL, %l5 ! Address
  756. lda [%l4] ASI_CONTROL, %l6 ! Error, retained for a bit
  757. #endif
  758. andn %l5, 0xfff, %l5 ! Encode all info into l7
  759. srl %l6, 14, %l4
  760. and %l4, 2, %l4
  761. or %l5, %l4, %l4
  762. or %l4, %l7, %l7 ! l7 = [addr,write,txtfault]
  763. andcc %l0, PSR_PS, %g0
  764. be sun4c_fault_fromuser
  765. andcc %l7, 1, %g0 ! Text fault?
  766. be 1f
  767. sethi %hi(KERNBASE), %l4
  768. mov %l1, %l5 ! PC
  769. 1:
  770. cmp %l5, %l4
  771. blu sun4c_fault_fromuser
  772. sethi %hi(~((1 << SUN4C_REAL_PGDIR_SHIFT) - 1)), %l4
  773. /* If the kernel references a bum kernel pointer, or a pte which
  774. * points to a non existant page in ram, we will run this code
  775. * _forever_ and lock up the machine!!!!! So we must check for
  776. * this condition, the AC_SYNC_ERR bits are what we must examine.
  777. * Also a parity error would make this happen as well. So we just
  778. * check that we are in fact servicing a tlb miss and not some
  779. * other type of fault for the kernel.
  780. */
  781. andcc %l6, 0x80, %g0
  782. be sun4c_fault_fromuser
  783. and %l5, %l4, %l5
  784. /* Test for NULL pte_t * in vmalloc area. */
  785. sethi %hi(VMALLOC_START), %l4
  786. cmp %l5, %l4
  787. blu,a invalid_segment_patch1
  788. lduXa [%l5] ASI_SEGMAP, %l4
  789. sethi %hi(swapper_pg_dir), %l4
  790. srl %l5, SUN4C_PGDIR_SHIFT, %l6
  791. or %l4, %lo(swapper_pg_dir), %l4
  792. sll %l6, 2, %l6
  793. ld [%l4 + %l6], %l4
  794. #ifdef CONFIG_SUN4
  795. sethi %hi(PAGE_MASK), %l6
  796. andcc %l4, %l6, %g0
  797. #else
  798. andcc %l4, PAGE_MASK, %g0
  799. #endif
  800. be sun4c_fault_fromuser
  801. lduXa [%l5] ASI_SEGMAP, %l4
  802. invalid_segment_patch1:
  803. cmp %l4, 0x7f
  804. bne 1f
  805. sethi %hi(sun4c_kfree_ring), %l4
  806. or %l4, %lo(sun4c_kfree_ring), %l4
  807. ld [%l4 + 0x18], %l3
  808. deccc %l3 ! do we have a free entry?
  809. bcs,a 2f ! no, unmap one.
  810. sethi %hi(sun4c_kernel_ring), %l4
  811. st %l3, [%l4 + 0x18] ! sun4c_kfree_ring.num_entries--
  812. ld [%l4 + 0x00], %l6 ! entry = sun4c_kfree_ring.ringhd.next
  813. st %l5, [%l6 + 0x08] ! entry->vaddr = address
  814. ld [%l6 + 0x00], %l3 ! next = entry->next
  815. ld [%l6 + 0x04], %l7 ! entry->prev
  816. st %l7, [%l3 + 0x04] ! next->prev = entry->prev
  817. st %l3, [%l7 + 0x00] ! entry->prev->next = next
  818. sethi %hi(sun4c_kernel_ring), %l4
  819. or %l4, %lo(sun4c_kernel_ring), %l4
  820. ! head = &sun4c_kernel_ring.ringhd
  821. ld [%l4 + 0x00], %l7 ! head->next
  822. st %l4, [%l6 + 0x04] ! entry->prev = head
  823. st %l7, [%l6 + 0x00] ! entry->next = head->next
  824. st %l6, [%l7 + 0x04] ! head->next->prev = entry
  825. st %l6, [%l4 + 0x00] ! head->next = entry
  826. ld [%l4 + 0x18], %l3
  827. inc %l3 ! sun4c_kernel_ring.num_entries++
  828. st %l3, [%l4 + 0x18]
  829. b 4f
  830. ld [%l6 + 0x08], %l5
  831. 2:
  832. or %l4, %lo(sun4c_kernel_ring), %l4
  833. ! head = &sun4c_kernel_ring.ringhd
  834. ld [%l4 + 0x04], %l6 ! entry = head->prev
  835. ld [%l6 + 0x08], %l3 ! tmp = entry->vaddr
  836. ! Flush segment from the cache.
  837. #ifdef CONFIG_SUN4
  838. sethi %hi((128 * 1024)), %l7
  839. #else
  840. sethi %hi((64 * 1024)), %l7
  841. #endif
  842. 9:
  843. vac_hwflush_patch1:
  844. vac_linesize_patch:
  845. subcc %l7, 16, %l7
  846. bne 9b
  847. vac_hwflush_patch2:
  848. sta %g0, [%l3 + %l7] ASI_FLUSHSEG
  849. st %l5, [%l6 + 0x08] ! entry->vaddr = address
  850. ld [%l6 + 0x00], %l5 ! next = entry->next
  851. ld [%l6 + 0x04], %l7 ! entry->prev
  852. st %l7, [%l5 + 0x04] ! next->prev = entry->prev
  853. st %l5, [%l7 + 0x00] ! entry->prev->next = next
  854. st %l4, [%l6 + 0x04] ! entry->prev = head
  855. ld [%l4 + 0x00], %l7 ! head->next
  856. st %l7, [%l6 + 0x00] ! entry->next = head->next
  857. st %l6, [%l7 + 0x04] ! head->next->prev = entry
  858. st %l6, [%l4 + 0x00] ! head->next = entry
  859. mov %l3, %l5 ! address = tmp
  860. 4:
  861. num_context_patch1:
  862. mov 0x08, %l7
  863. ld [%l6 + 0x08], %l4
  864. ldub [%l6 + 0x0c], %l3
  865. or %l4, %l3, %l4 ! encode new vaddr/pseg into l4
  866. sethi %hi(AC_CONTEXT), %l3
  867. lduba [%l3] ASI_CONTROL, %l6
  868. /* Invalidate old mapping, instantiate new mapping,
  869. * for each context. Registers l6/l7 are live across
  870. * this loop.
  871. */
  872. 3: deccc %l7
  873. sethi %hi(AC_CONTEXT), %l3
  874. stba %l7, [%l3] ASI_CONTROL
  875. invalid_segment_patch2:
  876. mov 0x7f, %l3
  877. stXa %l3, [%l5] ASI_SEGMAP
  878. andn %l4, 0x1ff, %l3
  879. bne 3b
  880. stXa %l4, [%l3] ASI_SEGMAP
  881. sethi %hi(AC_CONTEXT), %l3
  882. stba %l6, [%l3] ASI_CONTROL
  883. andn %l4, 0x1ff, %l5
  884. 1:
  885. sethi %hi(VMALLOC_START), %l4
  886. cmp %l5, %l4
  887. bgeu 1f
  888. mov 1 << (SUN4C_REAL_PGDIR_SHIFT - PAGE_SHIFT), %l7
  889. sethi %hi(KERNBASE), %l6
  890. sub %l5, %l6, %l4
  891. srl %l4, PAGE_SHIFT, %l4
  892. sethi %hi((SUN4C_PAGE_KERNEL & 0xf4000000)), %l3
  893. or %l3, %l4, %l3
  894. sethi %hi(PAGE_SIZE), %l4
  895. 2:
  896. sta %l3, [%l5] ASI_PTE
  897. deccc %l7
  898. inc %l3
  899. bne 2b
  900. add %l5, %l4, %l5
  901. b 7f
  902. sethi %hi(sun4c_kernel_faults), %l4
  903. 1:
  904. srl %l5, SUN4C_PGDIR_SHIFT, %l3
  905. sethi %hi(swapper_pg_dir), %l4
  906. or %l4, %lo(swapper_pg_dir), %l4
  907. sll %l3, 2, %l3
  908. ld [%l4 + %l3], %l4
  909. #ifndef CONFIG_SUN4
  910. and %l4, PAGE_MASK, %l4
  911. #else
  912. sethi %hi(PAGE_MASK), %l6
  913. and %l4, %l6, %l4
  914. #endif
  915. srl %l5, (PAGE_SHIFT - 2), %l6
  916. and %l6, ((SUN4C_PTRS_PER_PTE - 1) << 2), %l6
  917. add %l6, %l4, %l6
  918. sethi %hi(PAGE_SIZE), %l4
  919. 2:
  920. ld [%l6], %l3
  921. deccc %l7
  922. sta %l3, [%l5] ASI_PTE
  923. add %l6, 0x4, %l6
  924. bne 2b
  925. add %l5, %l4, %l5
  926. sethi %hi(sun4c_kernel_faults), %l4
  927. 7:
  928. ld [%l4 + %lo(sun4c_kernel_faults)], %l3
  929. inc %l3
  930. st %l3, [%l4 + %lo(sun4c_kernel_faults)]
  931. /* Restore condition codes */
  932. wr %l0, 0x0, %psr
  933. WRITE_PAUSE
  934. jmp %l1
  935. rett %l2
  936. sun4c_fault_fromuser:
  937. SAVE_ALL
  938. nop
  939. mov %l7, %o1 ! Decode the info from %l7
  940. mov %l7, %o2
  941. and %o1, 1, %o1 ! arg2 = text_faultp
  942. mov %l7, %o3
  943. and %o2, 2, %o2 ! arg3 = writep
  944. andn %o3, 0xfff, %o3 ! arg4 = faulting address
  945. wr %l0, PSR_ET, %psr
  946. WRITE_PAUSE
  947. call do_sun4c_fault
  948. add %sp, STACKFRAME_SZ, %o0 ! arg1 = pt_regs ptr
  949. RESTORE_ALL
  950. .align 4
  951. .globl srmmu_fault
  952. srmmu_fault:
  953. mov 0x400, %l5
  954. mov 0x300, %l4
  955. lda [%l5] ASI_M_MMUREGS, %l6 ! read sfar first
  956. lda [%l4] ASI_M_MMUREGS, %l5 ! read sfsr last
  957. andn %l6, 0xfff, %l6
  958. srl %l5, 6, %l5 ! and encode all info into l7
  959. and %l5, 2, %l5
  960. or %l5, %l6, %l6
  961. or %l6, %l7, %l7 ! l7 = [addr,write,txtfault]
  962. SAVE_ALL
  963. mov %l7, %o1
  964. mov %l7, %o2
  965. and %o1, 1, %o1 ! arg2 = text_faultp
  966. mov %l7, %o3
  967. and %o2, 2, %o2 ! arg3 = writep
  968. andn %o3, 0xfff, %o3 ! arg4 = faulting address
  969. wr %l0, PSR_ET, %psr
  970. WRITE_PAUSE
  971. call do_sparc_fault
  972. add %sp, STACKFRAME_SZ, %o0 ! arg1 = pt_regs ptr
  973. RESTORE_ALL
  974. #ifdef CONFIG_SUNOS_EMUL
  975. /* SunOS uses syscall zero as the 'indirect syscall' it looks
  976. * like indir_syscall(scall_num, arg0, arg1, arg2...); etc.
  977. * This is complete brain damage.
  978. */
  979. .globl sunos_indir
  980. sunos_indir:
  981. mov %o7, %l4
  982. cmp %o0, NR_SYSCALLS
  983. blu,a 1f
  984. sll %o0, 0x2, %o0
  985. sethi %hi(sunos_nosys), %l6
  986. b 2f
  987. or %l6, %lo(sunos_nosys), %l6
  988. 1:
  989. set sunos_sys_table, %l7
  990. ld [%l7 + %o0], %l6
  991. 2:
  992. mov %o1, %o0
  993. mov %o2, %o1
  994. mov %o3, %o2
  995. mov %o4, %o3
  996. mov %o5, %o4
  997. call %l6
  998. mov %l4, %o7
  999. #endif
  1000. .align 4
  1001. .globl sys_nis_syscall
  1002. sys_nis_syscall:
  1003. mov %o7, %l5
  1004. add %sp, STACKFRAME_SZ, %o0 ! pt_regs *regs arg
  1005. call c_sys_nis_syscall
  1006. mov %l5, %o7
  1007. .align 4
  1008. .globl sys_execve
  1009. sys_execve:
  1010. mov %o7, %l5
  1011. add %sp, STACKFRAME_SZ, %o0 ! pt_regs *regs arg
  1012. call sparc_execve
  1013. mov %l5, %o7
  1014. .align 4
  1015. .globl sys_pipe
  1016. sys_pipe:
  1017. mov %o7, %l5
  1018. add %sp, STACKFRAME_SZ, %o0 ! pt_regs *regs arg
  1019. call sparc_pipe
  1020. mov %l5, %o7
  1021. .align 4
  1022. .globl sys_sigaltstack
  1023. sys_sigaltstack:
  1024. mov %o7, %l5
  1025. mov %fp, %o2
  1026. call do_sigaltstack
  1027. mov %l5, %o7
  1028. .align 4
  1029. .globl sys_sigstack
  1030. sys_sigstack:
  1031. mov %o7, %l5
  1032. mov %fp, %o2
  1033. call do_sys_sigstack
  1034. mov %l5, %o7
  1035. .align 4
  1036. .globl sys_sigreturn
  1037. sys_sigreturn:
  1038. call do_sigreturn
  1039. add %sp, STACKFRAME_SZ, %o0
  1040. ld [%curptr + TI_FLAGS], %l5
  1041. andcc %l5, _TIF_SYSCALL_TRACE, %g0
  1042. be 1f
  1043. nop
  1044. call syscall_trace
  1045. nop
  1046. 1:
  1047. /* We don't want to muck with user registers like a
  1048. * normal syscall, just return.
  1049. */
  1050. RESTORE_ALL
  1051. .align 4
  1052. .globl sys_rt_sigreturn
  1053. sys_rt_sigreturn:
  1054. call do_rt_sigreturn
  1055. add %sp, STACKFRAME_SZ, %o0
  1056. ld [%curptr + TI_FLAGS], %l5
  1057. andcc %l5, _TIF_SYSCALL_TRACE, %g0
  1058. be 1f
  1059. nop
  1060. call syscall_trace
  1061. nop
  1062. 1:
  1063. /* We are returning to a signal handler. */
  1064. RESTORE_ALL
  1065. /* Now that we have a real sys_clone, sys_fork() is
  1066. * implemented in terms of it. Our _real_ implementation
  1067. * of SunOS vfork() will use sys_vfork().
  1068. *
  1069. * XXX These three should be consolidated into mostly shared
  1070. * XXX code just like on sparc64... -DaveM
  1071. */
  1072. .align 4
  1073. .globl sys_fork, flush_patch_two
  1074. sys_fork:
  1075. mov %o7, %l5
  1076. flush_patch_two:
  1077. FLUSH_ALL_KERNEL_WINDOWS;
  1078. ld [%curptr + TI_TASK], %o4
  1079. rd %psr, %g4
  1080. WRITE_PAUSE
  1081. mov SIGCHLD, %o0 ! arg0: clone flags
  1082. rd %wim, %g5
  1083. WRITE_PAUSE
  1084. mov %fp, %o1 ! arg1: usp
  1085. std %g4, [%o4 + AOFF_task_thread + AOFF_thread_fork_kpsr]
  1086. add %sp, STACKFRAME_SZ, %o2 ! arg2: pt_regs ptr
  1087. mov 0, %o3
  1088. call sparc_do_fork
  1089. mov %l5, %o7
  1090. /* Whee, kernel threads! */
  1091. .globl sys_clone, flush_patch_three
  1092. sys_clone:
  1093. mov %o7, %l5
  1094. flush_patch_three:
  1095. FLUSH_ALL_KERNEL_WINDOWS;
  1096. ld [%curptr + TI_TASK], %o4
  1097. rd %psr, %g4
  1098. WRITE_PAUSE
  1099. /* arg0,1: flags,usp -- loaded already */
  1100. cmp %o1, 0x0 ! Is new_usp NULL?
  1101. rd %wim, %g5
  1102. WRITE_PAUSE
  1103. be,a 1f
  1104. mov %fp, %o1 ! yes, use callers usp
  1105. andn %o1, 7, %o1 ! no, align to 8 bytes
  1106. 1:
  1107. std %g4, [%o4 + AOFF_task_thread + AOFF_thread_fork_kpsr]
  1108. add %sp, STACKFRAME_SZ, %o2 ! arg2: pt_regs ptr
  1109. mov 0, %o3
  1110. call sparc_do_fork
  1111. mov %l5, %o7
  1112. /* Whee, real vfork! */
  1113. .globl sys_vfork, flush_patch_four
  1114. sys_vfork:
  1115. flush_patch_four:
  1116. FLUSH_ALL_KERNEL_WINDOWS;
  1117. ld [%curptr + TI_TASK], %o4
  1118. rd %psr, %g4
  1119. WRITE_PAUSE
  1120. rd %wim, %g5
  1121. WRITE_PAUSE
  1122. std %g4, [%o4 + AOFF_task_thread + AOFF_thread_fork_kpsr]
  1123. sethi %hi(0x4000 | 0x0100 | SIGCHLD), %o0
  1124. mov %fp, %o1
  1125. or %o0, %lo(0x4000 | 0x0100 | SIGCHLD), %o0
  1126. sethi %hi(sparc_do_fork), %l1
  1127. mov 0, %o3
  1128. jmpl %l1 + %lo(sparc_do_fork), %g0
  1129. add %sp, STACKFRAME_SZ, %o2
  1130. .align 4
  1131. linux_sparc_ni_syscall:
  1132. sethi %hi(sys_ni_syscall), %l7
  1133. b syscall_is_too_hard
  1134. or %l7, %lo(sys_ni_syscall), %l7
  1135. linux_fast_syscall:
  1136. andn %l7, 3, %l7
  1137. mov %i0, %o0
  1138. mov %i1, %o1
  1139. mov %i2, %o2
  1140. jmpl %l7 + %g0, %g0
  1141. mov %i3, %o3
  1142. linux_syscall_trace:
  1143. call syscall_trace
  1144. nop
  1145. mov %i0, %o0
  1146. mov %i1, %o1
  1147. mov %i2, %o2
  1148. mov %i3, %o3
  1149. b 2f
  1150. mov %i4, %o4
  1151. .globl ret_from_fork
  1152. ret_from_fork:
  1153. call schedule_tail
  1154. mov %g3, %o0
  1155. b ret_sys_call
  1156. ld [%sp + STACKFRAME_SZ + PT_I0], %o0
  1157. /* Linux native and SunOS system calls enter here... */
  1158. .align 4
  1159. .globl linux_sparc_syscall
  1160. linux_sparc_syscall:
  1161. /* Direct access to user regs, must faster. */
  1162. cmp %g1, NR_SYSCALLS
  1163. bgeu linux_sparc_ni_syscall
  1164. sll %g1, 2, %l4
  1165. ld [%l7 + %l4], %l7
  1166. andcc %l7, 1, %g0
  1167. bne linux_fast_syscall
  1168. /* Just do first insn from SAVE_ALL in the delay slot */
  1169. .globl syscall_is_too_hard
  1170. syscall_is_too_hard:
  1171. SAVE_ALL_HEAD
  1172. rd %wim, %l3
  1173. wr %l0, PSR_ET, %psr
  1174. mov %i0, %o0
  1175. mov %i1, %o1
  1176. mov %i2, %o2
  1177. ld [%curptr + TI_FLAGS], %l5
  1178. mov %i3, %o3
  1179. andcc %l5, _TIF_SYSCALL_TRACE, %g0
  1180. mov %i4, %o4
  1181. bne linux_syscall_trace
  1182. mov %i0, %l5
  1183. 2:
  1184. call %l7
  1185. mov %i5, %o5
  1186. st %o0, [%sp + STACKFRAME_SZ + PT_I0]
  1187. .globl ret_sys_call
  1188. ret_sys_call:
  1189. ld [%curptr + TI_FLAGS], %l6
  1190. cmp %o0, -ERESTART_RESTARTBLOCK
  1191. ld [%sp + STACKFRAME_SZ + PT_PSR], %g3
  1192. set PSR_C, %g2
  1193. bgeu 1f
  1194. andcc %l6, _TIF_SYSCALL_TRACE, %g0
  1195. /* System call success, clear Carry condition code. */
  1196. andn %g3, %g2, %g3
  1197. clr %l6
  1198. st %g3, [%sp + STACKFRAME_SZ + PT_PSR]
  1199. bne linux_syscall_trace2
  1200. ld [%sp + STACKFRAME_SZ + PT_NPC], %l1 /* pc = npc */
  1201. add %l1, 0x4, %l2 /* npc = npc+4 */
  1202. st %l1, [%sp + STACKFRAME_SZ + PT_PC]
  1203. b ret_trap_entry
  1204. st %l2, [%sp + STACKFRAME_SZ + PT_NPC]
  1205. 1:
  1206. /* System call failure, set Carry condition code.
  1207. * Also, get abs(errno) to return to the process.
  1208. */
  1209. sub %g0, %o0, %o0
  1210. or %g3, %g2, %g3
  1211. st %o0, [%sp + STACKFRAME_SZ + PT_I0]
  1212. mov 1, %l6
  1213. st %g3, [%sp + STACKFRAME_SZ + PT_PSR]
  1214. bne linux_syscall_trace2
  1215. ld [%sp + STACKFRAME_SZ + PT_NPC], %l1 /* pc = npc */
  1216. add %l1, 0x4, %l2 /* npc = npc+4 */
  1217. st %l1, [%sp + STACKFRAME_SZ + PT_PC]
  1218. b ret_trap_entry
  1219. st %l2, [%sp + STACKFRAME_SZ + PT_NPC]
  1220. linux_syscall_trace2:
  1221. call syscall_trace
  1222. add %l1, 0x4, %l2 /* npc = npc+4 */
  1223. st %l1, [%sp + STACKFRAME_SZ + PT_PC]
  1224. b ret_trap_entry
  1225. st %l2, [%sp + STACKFRAME_SZ + PT_NPC]
  1226. /*
  1227. * Solaris system calls and indirect system calls enter here.
  1228. *
  1229. * I have named the solaris indirect syscalls like that because
  1230. * it seems like Solaris has some fast path syscalls that can
  1231. * be handled as indirect system calls. - mig
  1232. */
  1233. linux_syscall_for_solaris:
  1234. sethi %hi(sys_call_table), %l7
  1235. b linux_sparc_syscall
  1236. or %l7, %lo(sys_call_table), %l7
  1237. .align 4
  1238. .globl solaris_syscall
  1239. solaris_syscall:
  1240. cmp %g1,59
  1241. be linux_syscall_for_solaris
  1242. cmp %g1,2
  1243. be linux_syscall_for_solaris
  1244. cmp %g1,42
  1245. be linux_syscall_for_solaris
  1246. cmp %g1,119
  1247. be,a linux_syscall_for_solaris
  1248. mov 2, %g1
  1249. 1:
  1250. SAVE_ALL_HEAD
  1251. rd %wim, %l3
  1252. wr %l0, PSR_ET, %psr
  1253. nop
  1254. nop
  1255. mov %i0, %l5
  1256. call do_solaris_syscall
  1257. add %sp, STACKFRAME_SZ, %o0
  1258. st %o0, [%sp + STACKFRAME_SZ + PT_I0]
  1259. set PSR_C, %g2
  1260. cmp %o0, -ERESTART_RESTARTBLOCK
  1261. bgeu 1f
  1262. ld [%sp + STACKFRAME_SZ + PT_PSR], %g3
  1263. /* System call success, clear Carry condition code. */
  1264. andn %g3, %g2, %g3
  1265. clr %l6
  1266. b 2f
  1267. st %g3, [%sp + STACKFRAME_SZ + PT_PSR]
  1268. 1:
  1269. /* System call failure, set Carry condition code.
  1270. * Also, get abs(errno) to return to the process.
  1271. */
  1272. sub %g0, %o0, %o0
  1273. mov 1, %l6
  1274. st %o0, [%sp + STACKFRAME_SZ + PT_I0]
  1275. or %g3, %g2, %g3
  1276. st %g3, [%sp + STACKFRAME_SZ + PT_PSR]
  1277. /* Advance the pc and npc over the trap instruction.
  1278. * If the npc is unaligned (has a 1 in the lower byte), it means
  1279. * the kernel does not want us to play magic (ie, skipping over
  1280. * traps). Mainly when the Solaris code wants to set some PC and
  1281. * nPC (setcontext).
  1282. */
  1283. 2:
  1284. ld [%sp + STACKFRAME_SZ + PT_NPC], %l1 /* pc = npc */
  1285. andcc %l1, 1, %g0
  1286. bne 1f
  1287. add %l1, 0x4, %l2 /* npc = npc+4 */
  1288. st %l1, [%sp + STACKFRAME_SZ + PT_PC]
  1289. b ret_trap_entry
  1290. st %l2, [%sp + STACKFRAME_SZ + PT_NPC]
  1291. /* kernel knows what it is doing, fixup npc and continue */
  1292. 1:
  1293. sub %l1, 1, %l1
  1294. b ret_trap_entry
  1295. st %l1, [%sp + STACKFRAME_SZ + PT_NPC]
  1296. #ifndef CONFIG_SUNOS_EMUL
  1297. .align 4
  1298. .globl sunos_syscall
  1299. sunos_syscall:
  1300. SAVE_ALL_HEAD
  1301. rd %wim, %l3
  1302. wr %l0, PSR_ET, %psr
  1303. nop
  1304. nop
  1305. mov %i0, %l5
  1306. call do_sunos_syscall
  1307. add %sp, STACKFRAME_SZ, %o0
  1308. #endif
  1309. /* {net, open}bsd system calls enter here... */
  1310. .align 4
  1311. .globl bsd_syscall
  1312. bsd_syscall:
  1313. /* Direct access to user regs, must faster. */
  1314. cmp %g1, NR_SYSCALLS
  1315. blu,a 1f
  1316. sll %g1, 2, %l4
  1317. set sys_ni_syscall, %l7
  1318. b bsd_is_too_hard
  1319. nop
  1320. 1:
  1321. ld [%l7 + %l4], %l7
  1322. .globl bsd_is_too_hard
  1323. bsd_is_too_hard:
  1324. rd %wim, %l3
  1325. SAVE_ALL
  1326. wr %l0, PSR_ET, %psr
  1327. WRITE_PAUSE
  1328. 2:
  1329. mov %i0, %o0
  1330. mov %i1, %o1
  1331. mov %i2, %o2
  1332. mov %i0, %l5
  1333. mov %i3, %o3
  1334. mov %i4, %o4
  1335. call %l7
  1336. mov %i5, %o5
  1337. st %o0, [%sp + STACKFRAME_SZ + PT_I0]
  1338. set PSR_C, %g2
  1339. cmp %o0, -ERESTART_RESTARTBLOCK
  1340. bgeu 1f
  1341. ld [%sp + STACKFRAME_SZ + PT_PSR], %g3
  1342. /* System call success, clear Carry condition code. */
  1343. andn %g3, %g2, %g3
  1344. clr %l6
  1345. b 2f
  1346. st %g3, [%sp + STACKFRAME_SZ + PT_PSR]
  1347. 1:
  1348. /* System call failure, set Carry condition code.
  1349. * Also, get abs(errno) to return to the process.
  1350. */
  1351. sub %g0, %o0, %o0
  1352. #if 0 /* XXX todo XXX */
  1353. sethi %hi(bsd_xlatb_rorl), %o3
  1354. or %o3, %lo(bsd_xlatb_rorl), %o3
  1355. sll %o0, 2, %o0
  1356. ld [%o3 + %o0], %o0
  1357. #endif
  1358. mov 1, %l6
  1359. st %o0, [%sp + STACKFRAME_SZ + PT_I0]
  1360. or %g3, %g2, %g3
  1361. st %g3, [%sp + STACKFRAME_SZ + PT_PSR]
  1362. /* Advance the pc and npc over the trap instruction. */
  1363. 2:
  1364. ld [%sp + STACKFRAME_SZ + PT_NPC], %l1 /* pc = npc */
  1365. add %l1, 0x4, %l2 /* npc = npc+4 */
  1366. st %l1, [%sp + STACKFRAME_SZ + PT_PC]
  1367. b ret_trap_entry
  1368. st %l2, [%sp + STACKFRAME_SZ + PT_NPC]
  1369. /* Saving and restoring the FPU state is best done from lowlevel code.
  1370. *
  1371. * void fpsave(unsigned long *fpregs, unsigned long *fsr,
  1372. * void *fpqueue, unsigned long *fpqdepth)
  1373. */
  1374. .globl fpsave
  1375. fpsave:
  1376. st %fsr, [%o1] ! this can trap on us if fpu is in bogon state
  1377. ld [%o1], %g1
  1378. set 0x2000, %g4
  1379. andcc %g1, %g4, %g0
  1380. be 2f
  1381. mov 0, %g2
  1382. /* We have an fpqueue to save. */
  1383. 1:
  1384. std %fq, [%o2]
  1385. fpsave_magic:
  1386. st %fsr, [%o1]
  1387. ld [%o1], %g3
  1388. andcc %g3, %g4, %g0
  1389. add %g2, 1, %g2
  1390. bne 1b
  1391. add %o2, 8, %o2
  1392. 2:
  1393. st %g2, [%o3]
  1394. std %f0, [%o0 + 0x00]
  1395. std %f2, [%o0 + 0x08]
  1396. std %f4, [%o0 + 0x10]
  1397. std %f6, [%o0 + 0x18]
  1398. std %f8, [%o0 + 0x20]
  1399. std %f10, [%o0 + 0x28]
  1400. std %f12, [%o0 + 0x30]
  1401. std %f14, [%o0 + 0x38]
  1402. std %f16, [%o0 + 0x40]
  1403. std %f18, [%o0 + 0x48]
  1404. std %f20, [%o0 + 0x50]
  1405. std %f22, [%o0 + 0x58]
  1406. std %f24, [%o0 + 0x60]
  1407. std %f26, [%o0 + 0x68]
  1408. std %f28, [%o0 + 0x70]
  1409. retl
  1410. std %f30, [%o0 + 0x78]
  1411. /* Thanks for Theo Deraadt and the authors of the Sprite/netbsd/openbsd
  1412. * code for pointing out this possible deadlock, while we save state
  1413. * above we could trap on the fsr store so our low level fpu trap
  1414. * code has to know how to deal with this.
  1415. */
  1416. fpsave_catch:
  1417. b fpsave_magic + 4
  1418. st %fsr, [%o1]
  1419. fpsave_catch2:
  1420. b fpsave + 4
  1421. st %fsr, [%o1]
  1422. /* void fpload(unsigned long *fpregs, unsigned long *fsr); */
  1423. .globl fpload
  1424. fpload:
  1425. ldd [%o0 + 0x00], %f0
  1426. ldd [%o0 + 0x08], %f2
  1427. ldd [%o0 + 0x10], %f4
  1428. ldd [%o0 + 0x18], %f6
  1429. ldd [%o0 + 0x20], %f8
  1430. ldd [%o0 + 0x28], %f10
  1431. ldd [%o0 + 0x30], %f12
  1432. ldd [%o0 + 0x38], %f14
  1433. ldd [%o0 + 0x40], %f16
  1434. ldd [%o0 + 0x48], %f18
  1435. ldd [%o0 + 0x50], %f20
  1436. ldd [%o0 + 0x58], %f22
  1437. ldd [%o0 + 0x60], %f24
  1438. ldd [%o0 + 0x68], %f26
  1439. ldd [%o0 + 0x70], %f28
  1440. ldd [%o0 + 0x78], %f30
  1441. ld [%o1], %fsr
  1442. retl
  1443. nop
  1444. /* __ndelay and __udelay take two arguments:
  1445. * 0 - nsecs or usecs to delay
  1446. * 1 - per_cpu udelay_val (loops per jiffy)
  1447. *
  1448. * Note that ndelay gives HZ times higher resolution but has a 10ms
  1449. * limit. udelay can handle up to 1s.
  1450. */
  1451. .globl __ndelay
  1452. __ndelay:
  1453. save %sp, -STACKFRAME_SZ, %sp
  1454. mov %i0, %o0
  1455. call .umul ! round multiplier up so large ns ok
  1456. mov 0x1ae, %o1 ! 2**32 / (1 000 000 000 / HZ)
  1457. call .umul
  1458. mov %i1, %o1 ! udelay_val
  1459. ba delay_continue
  1460. mov %o1, %o0 ! >>32 later for better resolution
  1461. .globl __udelay
  1462. __udelay:
  1463. save %sp, -STACKFRAME_SZ, %sp
  1464. mov %i0, %o0
  1465. sethi %hi(0x10c7), %o1 ! round multiplier up so large us ok
  1466. call .umul
  1467. or %o1, %lo(0x10c7), %o1 ! 2**32 / 1 000 000
  1468. call .umul
  1469. mov %i1, %o1 ! udelay_val
  1470. sethi %hi(0x028f4b62), %l0 ! Add in rounding constant * 2**32,
  1471. or %g0, %lo(0x028f4b62), %l0
  1472. addcc %o0, %l0, %o0 ! 2**32 * 0.009 999
  1473. bcs,a 3f
  1474. add %o1, 0x01, %o1
  1475. 3:
  1476. call .umul
  1477. mov HZ, %o0 ! >>32 earlier for wider range
  1478. delay_continue:
  1479. cmp %o0, 0x0
  1480. 1:
  1481. bne 1b
  1482. subcc %o0, 1, %o0
  1483. ret
  1484. restore
  1485. /* Handle a software breakpoint */
  1486. /* We have to inform parent that child has stopped */
  1487. .align 4
  1488. .globl breakpoint_trap
  1489. breakpoint_trap:
  1490. rd %wim,%l3
  1491. SAVE_ALL
  1492. wr %l0, PSR_ET, %psr
  1493. WRITE_PAUSE
  1494. st %i0, [%sp + STACKFRAME_SZ + PT_G0] ! for restarting syscalls
  1495. call sparc_breakpoint
  1496. add %sp, STACKFRAME_SZ, %o0
  1497. RESTORE_ALL
  1498. .align 4
  1499. .globl __handle_exception, flush_patch_exception
  1500. __handle_exception:
  1501. flush_patch_exception:
  1502. FLUSH_ALL_KERNEL_WINDOWS;
  1503. ldd [%o0], %o6
  1504. jmpl %o7 + 0xc, %g0 ! see asm-sparc/processor.h
  1505. mov 1, %g1 ! signal EFAULT condition
  1506. .align 4
  1507. .globl kill_user_windows, kuw_patch1_7win
  1508. .globl kuw_patch1
  1509. kuw_patch1_7win: sll %o3, 6, %o3
  1510. /* No matter how much overhead this routine has in the worst
  1511. * case scenerio, it is several times better than taking the
  1512. * traps with the old method of just doing flush_user_windows().
  1513. */
  1514. kill_user_windows:
  1515. ld [%g6 + TI_UWINMASK], %o0 ! get current umask
  1516. orcc %g0, %o0, %g0 ! if no bits set, we are done
  1517. be 3f ! nothing to do
  1518. rd %psr, %o5 ! must clear interrupts
  1519. or %o5, PSR_PIL, %o4 ! or else that could change
  1520. wr %o4, 0x0, %psr ! the uwinmask state
  1521. WRITE_PAUSE ! burn them cycles
  1522. 1:
  1523. ld [%g6 + TI_UWINMASK], %o0 ! get consistent state
  1524. orcc %g0, %o0, %g0 ! did an interrupt come in?
  1525. be 4f ! yep, we are done
  1526. rd %wim, %o3 ! get current wim
  1527. srl %o3, 1, %o4 ! simulate a save
  1528. kuw_patch1:
  1529. sll %o3, 7, %o3 ! compute next wim
  1530. or %o4, %o3, %o3 ! result
  1531. andncc %o0, %o3, %o0 ! clean this bit in umask
  1532. bne kuw_patch1 ! not done yet
  1533. srl %o3, 1, %o4 ! begin another save simulation
  1534. wr %o3, 0x0, %wim ! set the new wim
  1535. st %g0, [%g6 + TI_UWINMASK] ! clear uwinmask
  1536. 4:
  1537. wr %o5, 0x0, %psr ! re-enable interrupts
  1538. WRITE_PAUSE ! burn baby burn
  1539. 3:
  1540. retl ! return
  1541. st %g0, [%g6 + TI_W_SAVED] ! no windows saved
  1542. .align 4
  1543. .globl restore_current
  1544. restore_current:
  1545. LOAD_CURRENT(g6, o0)
  1546. retl
  1547. nop
  1548. #ifdef CONFIG_PCI
  1549. #include <asm/pcic.h>
  1550. .align 4
  1551. .globl linux_trap_ipi15_pcic
  1552. linux_trap_ipi15_pcic:
  1553. rd %wim, %l3
  1554. SAVE_ALL
  1555. /*
  1556. * First deactivate NMI
  1557. * or we cannot drop ET, cannot get window spill traps.
  1558. * The busy loop is necessary because the PIO error
  1559. * sometimes does not go away quickly and we trap again.
  1560. */
  1561. sethi %hi(pcic_regs), %o1
  1562. ld [%o1 + %lo(pcic_regs)], %o2
  1563. ! Get pending status for printouts later.
  1564. ld [%o2 + PCI_SYS_INT_PENDING], %o0
  1565. mov PCI_SYS_INT_PENDING_CLEAR_ALL, %o1
  1566. stb %o1, [%o2 + PCI_SYS_INT_PENDING_CLEAR]
  1567. 1:
  1568. ld [%o2 + PCI_SYS_INT_PENDING], %o1
  1569. andcc %o1, ((PCI_SYS_INT_PENDING_PIO|PCI_SYS_INT_PENDING_PCI)>>24), %g0
  1570. bne 1b
  1571. nop
  1572. or %l0, PSR_PIL, %l4
  1573. wr %l4, 0x0, %psr
  1574. WRITE_PAUSE
  1575. wr %l4, PSR_ET, %psr
  1576. WRITE_PAUSE
  1577. call pcic_nmi
  1578. add %sp, STACKFRAME_SZ, %o1 ! struct pt_regs *regs
  1579. RESTORE_ALL
  1580. .globl pcic_nmi_trap_patch
  1581. pcic_nmi_trap_patch:
  1582. sethi %hi(linux_trap_ipi15_pcic), %l3
  1583. jmpl %l3 + %lo(linux_trap_ipi15_pcic), %g0
  1584. rd %psr, %l0
  1585. .word 0
  1586. #endif /* CONFIG_PCI */
  1587. /* End of entry.S */