entry.S 40 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903
  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_ptrace
  1009. sys_ptrace:
  1010. call do_ptrace
  1011. add %sp, STACKFRAME_SZ, %o0
  1012. ld [%curptr + TI_FLAGS], %l5
  1013. andcc %l5, _TIF_SYSCALL_TRACE, %g0
  1014. be 1f
  1015. nop
  1016. call syscall_trace
  1017. nop
  1018. 1:
  1019. RESTORE_ALL
  1020. .align 4
  1021. .globl sys_execve
  1022. sys_execve:
  1023. mov %o7, %l5
  1024. add %sp, STACKFRAME_SZ, %o0 ! pt_regs *regs arg
  1025. call sparc_execve
  1026. mov %l5, %o7
  1027. .align 4
  1028. .globl sys_pipe
  1029. sys_pipe:
  1030. mov %o7, %l5
  1031. add %sp, STACKFRAME_SZ, %o0 ! pt_regs *regs arg
  1032. call sparc_pipe
  1033. mov %l5, %o7
  1034. .align 4
  1035. .globl sys_sigaltstack
  1036. sys_sigaltstack:
  1037. mov %o7, %l5
  1038. mov %fp, %o2
  1039. call do_sigaltstack
  1040. mov %l5, %o7
  1041. .align 4
  1042. .globl sys_sigstack
  1043. sys_sigstack:
  1044. mov %o7, %l5
  1045. mov %fp, %o2
  1046. call do_sys_sigstack
  1047. mov %l5, %o7
  1048. .align 4
  1049. .globl sys_sigreturn
  1050. sys_sigreturn:
  1051. call do_sigreturn
  1052. add %sp, STACKFRAME_SZ, %o0
  1053. ld [%curptr + TI_FLAGS], %l5
  1054. andcc %l5, _TIF_SYSCALL_TRACE, %g0
  1055. be 1f
  1056. nop
  1057. call syscall_trace
  1058. nop
  1059. 1:
  1060. /* We don't want to muck with user registers like a
  1061. * normal syscall, just return.
  1062. */
  1063. RESTORE_ALL
  1064. .align 4
  1065. .globl sys_rt_sigreturn
  1066. sys_rt_sigreturn:
  1067. call do_rt_sigreturn
  1068. add %sp, STACKFRAME_SZ, %o0
  1069. ld [%curptr + TI_FLAGS], %l5
  1070. andcc %l5, _TIF_SYSCALL_TRACE, %g0
  1071. be 1f
  1072. nop
  1073. call syscall_trace
  1074. nop
  1075. 1:
  1076. /* We are returning to a signal handler. */
  1077. RESTORE_ALL
  1078. /* Now that we have a real sys_clone, sys_fork() is
  1079. * implemented in terms of it. Our _real_ implementation
  1080. * of SunOS vfork() will use sys_vfork().
  1081. *
  1082. * XXX These three should be consolidated into mostly shared
  1083. * XXX code just like on sparc64... -DaveM
  1084. */
  1085. .align 4
  1086. .globl sys_fork, flush_patch_two
  1087. sys_fork:
  1088. mov %o7, %l5
  1089. flush_patch_two:
  1090. FLUSH_ALL_KERNEL_WINDOWS;
  1091. ld [%curptr + TI_TASK], %o4
  1092. rd %psr, %g4
  1093. WRITE_PAUSE
  1094. mov SIGCHLD, %o0 ! arg0: clone flags
  1095. rd %wim, %g5
  1096. WRITE_PAUSE
  1097. mov %fp, %o1 ! arg1: usp
  1098. std %g4, [%o4 + AOFF_task_thread + AOFF_thread_fork_kpsr]
  1099. add %sp, STACKFRAME_SZ, %o2 ! arg2: pt_regs ptr
  1100. mov 0, %o3
  1101. call sparc_do_fork
  1102. mov %l5, %o7
  1103. /* Whee, kernel threads! */
  1104. .globl sys_clone, flush_patch_three
  1105. sys_clone:
  1106. mov %o7, %l5
  1107. flush_patch_three:
  1108. FLUSH_ALL_KERNEL_WINDOWS;
  1109. ld [%curptr + TI_TASK], %o4
  1110. rd %psr, %g4
  1111. WRITE_PAUSE
  1112. /* arg0,1: flags,usp -- loaded already */
  1113. cmp %o1, 0x0 ! Is new_usp NULL?
  1114. rd %wim, %g5
  1115. WRITE_PAUSE
  1116. be,a 1f
  1117. mov %fp, %o1 ! yes, use callers usp
  1118. andn %o1, 7, %o1 ! no, align to 8 bytes
  1119. 1:
  1120. std %g4, [%o4 + AOFF_task_thread + AOFF_thread_fork_kpsr]
  1121. add %sp, STACKFRAME_SZ, %o2 ! arg2: pt_regs ptr
  1122. mov 0, %o3
  1123. call sparc_do_fork
  1124. mov %l5, %o7
  1125. /* Whee, real vfork! */
  1126. .globl sys_vfork, flush_patch_four
  1127. sys_vfork:
  1128. flush_patch_four:
  1129. FLUSH_ALL_KERNEL_WINDOWS;
  1130. ld [%curptr + TI_TASK], %o4
  1131. rd %psr, %g4
  1132. WRITE_PAUSE
  1133. rd %wim, %g5
  1134. WRITE_PAUSE
  1135. std %g4, [%o4 + AOFF_task_thread + AOFF_thread_fork_kpsr]
  1136. sethi %hi(0x4000 | 0x0100 | SIGCHLD), %o0
  1137. mov %fp, %o1
  1138. or %o0, %lo(0x4000 | 0x0100 | SIGCHLD), %o0
  1139. sethi %hi(sparc_do_fork), %l1
  1140. mov 0, %o3
  1141. jmpl %l1 + %lo(sparc_do_fork), %g0
  1142. add %sp, STACKFRAME_SZ, %o2
  1143. .align 4
  1144. linux_sparc_ni_syscall:
  1145. sethi %hi(sys_ni_syscall), %l7
  1146. b syscall_is_too_hard
  1147. or %l7, %lo(sys_ni_syscall), %l7
  1148. linux_fast_syscall:
  1149. andn %l7, 3, %l7
  1150. mov %i0, %o0
  1151. mov %i1, %o1
  1152. mov %i2, %o2
  1153. jmpl %l7 + %g0, %g0
  1154. mov %i3, %o3
  1155. linux_syscall_trace:
  1156. call syscall_trace
  1157. nop
  1158. mov %i0, %o0
  1159. mov %i1, %o1
  1160. mov %i2, %o2
  1161. mov %i3, %o3
  1162. b 2f
  1163. mov %i4, %o4
  1164. .globl ret_from_fork
  1165. ret_from_fork:
  1166. call schedule_tail
  1167. mov %g3, %o0
  1168. b ret_sys_call
  1169. ld [%sp + STACKFRAME_SZ + PT_I0], %o0
  1170. /* Linux native and SunOS system calls enter here... */
  1171. .align 4
  1172. .globl linux_sparc_syscall
  1173. linux_sparc_syscall:
  1174. /* Direct access to user regs, must faster. */
  1175. cmp %g1, NR_SYSCALLS
  1176. bgeu linux_sparc_ni_syscall
  1177. sll %g1, 2, %l4
  1178. ld [%l7 + %l4], %l7
  1179. andcc %l7, 1, %g0
  1180. bne linux_fast_syscall
  1181. /* Just do first insn from SAVE_ALL in the delay slot */
  1182. .globl syscall_is_too_hard
  1183. syscall_is_too_hard:
  1184. SAVE_ALL_HEAD
  1185. rd %wim, %l3
  1186. wr %l0, PSR_ET, %psr
  1187. mov %i0, %o0
  1188. mov %i1, %o1
  1189. mov %i2, %o2
  1190. ld [%curptr + TI_FLAGS], %l5
  1191. mov %i3, %o3
  1192. andcc %l5, _TIF_SYSCALL_TRACE, %g0
  1193. mov %i4, %o4
  1194. bne linux_syscall_trace
  1195. mov %i0, %l5
  1196. 2:
  1197. call %l7
  1198. mov %i5, %o5
  1199. st %o0, [%sp + STACKFRAME_SZ + PT_I0]
  1200. .globl ret_sys_call
  1201. ret_sys_call:
  1202. ld [%curptr + TI_FLAGS], %l6
  1203. cmp %o0, -ERESTART_RESTARTBLOCK
  1204. ld [%sp + STACKFRAME_SZ + PT_PSR], %g3
  1205. set PSR_C, %g2
  1206. bgeu 1f
  1207. andcc %l6, _TIF_SYSCALL_TRACE, %g0
  1208. /* System call success, clear Carry condition code. */
  1209. andn %g3, %g2, %g3
  1210. clr %l6
  1211. st %g3, [%sp + STACKFRAME_SZ + PT_PSR]
  1212. bne linux_syscall_trace2
  1213. ld [%sp + STACKFRAME_SZ + PT_NPC], %l1 /* pc = npc */
  1214. add %l1, 0x4, %l2 /* npc = npc+4 */
  1215. st %l1, [%sp + STACKFRAME_SZ + PT_PC]
  1216. b ret_trap_entry
  1217. st %l2, [%sp + STACKFRAME_SZ + PT_NPC]
  1218. 1:
  1219. /* System call failure, set Carry condition code.
  1220. * Also, get abs(errno) to return to the process.
  1221. */
  1222. sub %g0, %o0, %o0
  1223. or %g3, %g2, %g3
  1224. st %o0, [%sp + STACKFRAME_SZ + PT_I0]
  1225. mov 1, %l6
  1226. st %g3, [%sp + STACKFRAME_SZ + PT_PSR]
  1227. bne linux_syscall_trace2
  1228. ld [%sp + STACKFRAME_SZ + PT_NPC], %l1 /* pc = npc */
  1229. add %l1, 0x4, %l2 /* npc = npc+4 */
  1230. st %l1, [%sp + STACKFRAME_SZ + PT_PC]
  1231. b ret_trap_entry
  1232. st %l2, [%sp + STACKFRAME_SZ + PT_NPC]
  1233. linux_syscall_trace2:
  1234. call syscall_trace
  1235. add %l1, 0x4, %l2 /* npc = npc+4 */
  1236. st %l1, [%sp + STACKFRAME_SZ + PT_PC]
  1237. b ret_trap_entry
  1238. st %l2, [%sp + STACKFRAME_SZ + PT_NPC]
  1239. /*
  1240. * Solaris system calls and indirect system calls enter here.
  1241. *
  1242. * I have named the solaris indirect syscalls like that because
  1243. * it seems like Solaris has some fast path syscalls that can
  1244. * be handled as indirect system calls. - mig
  1245. */
  1246. linux_syscall_for_solaris:
  1247. sethi %hi(sys_call_table), %l7
  1248. b linux_sparc_syscall
  1249. or %l7, %lo(sys_call_table), %l7
  1250. .align 4
  1251. .globl solaris_syscall
  1252. solaris_syscall:
  1253. cmp %g1,59
  1254. be linux_syscall_for_solaris
  1255. cmp %g1,2
  1256. be linux_syscall_for_solaris
  1257. cmp %g1,42
  1258. be linux_syscall_for_solaris
  1259. cmp %g1,119
  1260. be,a linux_syscall_for_solaris
  1261. mov 2, %g1
  1262. 1:
  1263. SAVE_ALL_HEAD
  1264. rd %wim, %l3
  1265. wr %l0, PSR_ET, %psr
  1266. nop
  1267. nop
  1268. mov %i0, %l5
  1269. call do_solaris_syscall
  1270. add %sp, STACKFRAME_SZ, %o0
  1271. st %o0, [%sp + STACKFRAME_SZ + PT_I0]
  1272. set PSR_C, %g2
  1273. cmp %o0, -ERESTART_RESTARTBLOCK
  1274. bgeu 1f
  1275. ld [%sp + STACKFRAME_SZ + PT_PSR], %g3
  1276. /* System call success, clear Carry condition code. */
  1277. andn %g3, %g2, %g3
  1278. clr %l6
  1279. b 2f
  1280. st %g3, [%sp + STACKFRAME_SZ + PT_PSR]
  1281. 1:
  1282. /* System call failure, set Carry condition code.
  1283. * Also, get abs(errno) to return to the process.
  1284. */
  1285. sub %g0, %o0, %o0
  1286. mov 1, %l6
  1287. st %o0, [%sp + STACKFRAME_SZ + PT_I0]
  1288. or %g3, %g2, %g3
  1289. st %g3, [%sp + STACKFRAME_SZ + PT_PSR]
  1290. /* Advance the pc and npc over the trap instruction.
  1291. * If the npc is unaligned (has a 1 in the lower byte), it means
  1292. * the kernel does not want us to play magic (ie, skipping over
  1293. * traps). Mainly when the Solaris code wants to set some PC and
  1294. * nPC (setcontext).
  1295. */
  1296. 2:
  1297. ld [%sp + STACKFRAME_SZ + PT_NPC], %l1 /* pc = npc */
  1298. andcc %l1, 1, %g0
  1299. bne 1f
  1300. add %l1, 0x4, %l2 /* npc = npc+4 */
  1301. st %l1, [%sp + STACKFRAME_SZ + PT_PC]
  1302. b ret_trap_entry
  1303. st %l2, [%sp + STACKFRAME_SZ + PT_NPC]
  1304. /* kernel knows what it is doing, fixup npc and continue */
  1305. 1:
  1306. sub %l1, 1, %l1
  1307. b ret_trap_entry
  1308. st %l1, [%sp + STACKFRAME_SZ + PT_NPC]
  1309. #ifndef CONFIG_SUNOS_EMUL
  1310. .align 4
  1311. .globl sunos_syscall
  1312. sunos_syscall:
  1313. SAVE_ALL_HEAD
  1314. rd %wim, %l3
  1315. wr %l0, PSR_ET, %psr
  1316. nop
  1317. nop
  1318. mov %i0, %l5
  1319. call do_sunos_syscall
  1320. add %sp, STACKFRAME_SZ, %o0
  1321. #endif
  1322. /* {net, open}bsd system calls enter here... */
  1323. .align 4
  1324. .globl bsd_syscall
  1325. bsd_syscall:
  1326. /* Direct access to user regs, must faster. */
  1327. cmp %g1, NR_SYSCALLS
  1328. blu,a 1f
  1329. sll %g1, 2, %l4
  1330. set sys_ni_syscall, %l7
  1331. b bsd_is_too_hard
  1332. nop
  1333. 1:
  1334. ld [%l7 + %l4], %l7
  1335. .globl bsd_is_too_hard
  1336. bsd_is_too_hard:
  1337. rd %wim, %l3
  1338. SAVE_ALL
  1339. wr %l0, PSR_ET, %psr
  1340. WRITE_PAUSE
  1341. 2:
  1342. mov %i0, %o0
  1343. mov %i1, %o1
  1344. mov %i2, %o2
  1345. mov %i0, %l5
  1346. mov %i3, %o3
  1347. mov %i4, %o4
  1348. call %l7
  1349. mov %i5, %o5
  1350. st %o0, [%sp + STACKFRAME_SZ + PT_I0]
  1351. set PSR_C, %g2
  1352. cmp %o0, -ERESTART_RESTARTBLOCK
  1353. bgeu 1f
  1354. ld [%sp + STACKFRAME_SZ + PT_PSR], %g3
  1355. /* System call success, clear Carry condition code. */
  1356. andn %g3, %g2, %g3
  1357. clr %l6
  1358. b 2f
  1359. st %g3, [%sp + STACKFRAME_SZ + PT_PSR]
  1360. 1:
  1361. /* System call failure, set Carry condition code.
  1362. * Also, get abs(errno) to return to the process.
  1363. */
  1364. sub %g0, %o0, %o0
  1365. #if 0 /* XXX todo XXX */
  1366. sethi %hi(bsd_xlatb_rorl), %o3
  1367. or %o3, %lo(bsd_xlatb_rorl), %o3
  1368. sll %o0, 2, %o0
  1369. ld [%o3 + %o0], %o0
  1370. #endif
  1371. mov 1, %l6
  1372. st %o0, [%sp + STACKFRAME_SZ + PT_I0]
  1373. or %g3, %g2, %g3
  1374. st %g3, [%sp + STACKFRAME_SZ + PT_PSR]
  1375. /* Advance the pc and npc over the trap instruction. */
  1376. 2:
  1377. ld [%sp + STACKFRAME_SZ + PT_NPC], %l1 /* pc = npc */
  1378. add %l1, 0x4, %l2 /* npc = npc+4 */
  1379. st %l1, [%sp + STACKFRAME_SZ + PT_PC]
  1380. b ret_trap_entry
  1381. st %l2, [%sp + STACKFRAME_SZ + PT_NPC]
  1382. /* Saving and restoring the FPU state is best done from lowlevel code.
  1383. *
  1384. * void fpsave(unsigned long *fpregs, unsigned long *fsr,
  1385. * void *fpqueue, unsigned long *fpqdepth)
  1386. */
  1387. .globl fpsave
  1388. fpsave:
  1389. st %fsr, [%o1] ! this can trap on us if fpu is in bogon state
  1390. ld [%o1], %g1
  1391. set 0x2000, %g4
  1392. andcc %g1, %g4, %g0
  1393. be 2f
  1394. mov 0, %g2
  1395. /* We have an fpqueue to save. */
  1396. 1:
  1397. std %fq, [%o2]
  1398. fpsave_magic:
  1399. st %fsr, [%o1]
  1400. ld [%o1], %g3
  1401. andcc %g3, %g4, %g0
  1402. add %g2, 1, %g2
  1403. bne 1b
  1404. add %o2, 8, %o2
  1405. 2:
  1406. st %g2, [%o3]
  1407. std %f0, [%o0 + 0x00]
  1408. std %f2, [%o0 + 0x08]
  1409. std %f4, [%o0 + 0x10]
  1410. std %f6, [%o0 + 0x18]
  1411. std %f8, [%o0 + 0x20]
  1412. std %f10, [%o0 + 0x28]
  1413. std %f12, [%o0 + 0x30]
  1414. std %f14, [%o0 + 0x38]
  1415. std %f16, [%o0 + 0x40]
  1416. std %f18, [%o0 + 0x48]
  1417. std %f20, [%o0 + 0x50]
  1418. std %f22, [%o0 + 0x58]
  1419. std %f24, [%o0 + 0x60]
  1420. std %f26, [%o0 + 0x68]
  1421. std %f28, [%o0 + 0x70]
  1422. retl
  1423. std %f30, [%o0 + 0x78]
  1424. /* Thanks for Theo Deraadt and the authors of the Sprite/netbsd/openbsd
  1425. * code for pointing out this possible deadlock, while we save state
  1426. * above we could trap on the fsr store so our low level fpu trap
  1427. * code has to know how to deal with this.
  1428. */
  1429. fpsave_catch:
  1430. b fpsave_magic + 4
  1431. st %fsr, [%o1]
  1432. fpsave_catch2:
  1433. b fpsave + 4
  1434. st %fsr, [%o1]
  1435. /* void fpload(unsigned long *fpregs, unsigned long *fsr); */
  1436. .globl fpload
  1437. fpload:
  1438. ldd [%o0 + 0x00], %f0
  1439. ldd [%o0 + 0x08], %f2
  1440. ldd [%o0 + 0x10], %f4
  1441. ldd [%o0 + 0x18], %f6
  1442. ldd [%o0 + 0x20], %f8
  1443. ldd [%o0 + 0x28], %f10
  1444. ldd [%o0 + 0x30], %f12
  1445. ldd [%o0 + 0x38], %f14
  1446. ldd [%o0 + 0x40], %f16
  1447. ldd [%o0 + 0x48], %f18
  1448. ldd [%o0 + 0x50], %f20
  1449. ldd [%o0 + 0x58], %f22
  1450. ldd [%o0 + 0x60], %f24
  1451. ldd [%o0 + 0x68], %f26
  1452. ldd [%o0 + 0x70], %f28
  1453. ldd [%o0 + 0x78], %f30
  1454. ld [%o1], %fsr
  1455. retl
  1456. nop
  1457. /* __ndelay and __udelay take two arguments:
  1458. * 0 - nsecs or usecs to delay
  1459. * 1 - per_cpu udelay_val (loops per jiffy)
  1460. *
  1461. * Note that ndelay gives HZ times higher resolution but has a 10ms
  1462. * limit. udelay can handle up to 1s.
  1463. */
  1464. .globl __ndelay
  1465. __ndelay:
  1466. save %sp, -STACKFRAME_SZ, %sp
  1467. mov %i0, %o0
  1468. call .umul ! round multiplier up so large ns ok
  1469. mov 0x1ae, %o1 ! 2**32 / (1 000 000 000 / HZ)
  1470. call .umul
  1471. mov %i1, %o1 ! udelay_val
  1472. ba delay_continue
  1473. mov %o1, %o0 ! >>32 later for better resolution
  1474. .globl __udelay
  1475. __udelay:
  1476. save %sp, -STACKFRAME_SZ, %sp
  1477. mov %i0, %o0
  1478. sethi %hi(0x10c7), %o1 ! round multiplier up so large us ok
  1479. call .umul
  1480. or %o1, %lo(0x10c7), %o1 ! 2**32 / 1 000 000
  1481. call .umul
  1482. mov %i1, %o1 ! udelay_val
  1483. sethi %hi(0x028f4b62), %l0 ! Add in rounding constant * 2**32,
  1484. or %g0, %lo(0x028f4b62), %l0
  1485. addcc %o0, %l0, %o0 ! 2**32 * 0.009 999
  1486. bcs,a 3f
  1487. add %o1, 0x01, %o1
  1488. 3:
  1489. call .umul
  1490. mov HZ, %o0 ! >>32 earlier for wider range
  1491. delay_continue:
  1492. cmp %o0, 0x0
  1493. 1:
  1494. bne 1b
  1495. subcc %o0, 1, %o0
  1496. ret
  1497. restore
  1498. /* Handle a software breakpoint */
  1499. /* We have to inform parent that child has stopped */
  1500. .align 4
  1501. .globl breakpoint_trap
  1502. breakpoint_trap:
  1503. rd %wim,%l3
  1504. SAVE_ALL
  1505. wr %l0, PSR_ET, %psr
  1506. WRITE_PAUSE
  1507. st %i0, [%sp + STACKFRAME_SZ + PT_G0] ! for restarting syscalls
  1508. call sparc_breakpoint
  1509. add %sp, STACKFRAME_SZ, %o0
  1510. RESTORE_ALL
  1511. .align 4
  1512. .globl __handle_exception, flush_patch_exception
  1513. __handle_exception:
  1514. flush_patch_exception:
  1515. FLUSH_ALL_KERNEL_WINDOWS;
  1516. ldd [%o0], %o6
  1517. jmpl %o7 + 0xc, %g0 ! see asm-sparc/processor.h
  1518. mov 1, %g1 ! signal EFAULT condition
  1519. .align 4
  1520. .globl kill_user_windows, kuw_patch1_7win
  1521. .globl kuw_patch1
  1522. kuw_patch1_7win: sll %o3, 6, %o3
  1523. /* No matter how much overhead this routine has in the worst
  1524. * case scenerio, it is several times better than taking the
  1525. * traps with the old method of just doing flush_user_windows().
  1526. */
  1527. kill_user_windows:
  1528. ld [%g6 + TI_UWINMASK], %o0 ! get current umask
  1529. orcc %g0, %o0, %g0 ! if no bits set, we are done
  1530. be 3f ! nothing to do
  1531. rd %psr, %o5 ! must clear interrupts
  1532. or %o5, PSR_PIL, %o4 ! or else that could change
  1533. wr %o4, 0x0, %psr ! the uwinmask state
  1534. WRITE_PAUSE ! burn them cycles
  1535. 1:
  1536. ld [%g6 + TI_UWINMASK], %o0 ! get consistent state
  1537. orcc %g0, %o0, %g0 ! did an interrupt come in?
  1538. be 4f ! yep, we are done
  1539. rd %wim, %o3 ! get current wim
  1540. srl %o3, 1, %o4 ! simulate a save
  1541. kuw_patch1:
  1542. sll %o3, 7, %o3 ! compute next wim
  1543. or %o4, %o3, %o3 ! result
  1544. andncc %o0, %o3, %o0 ! clean this bit in umask
  1545. bne kuw_patch1 ! not done yet
  1546. srl %o3, 1, %o4 ! begin another save simulation
  1547. wr %o3, 0x0, %wim ! set the new wim
  1548. st %g0, [%g6 + TI_UWINMASK] ! clear uwinmask
  1549. 4:
  1550. wr %o5, 0x0, %psr ! re-enable interrupts
  1551. WRITE_PAUSE ! burn baby burn
  1552. 3:
  1553. retl ! return
  1554. st %g0, [%g6 + TI_W_SAVED] ! no windows saved
  1555. .align 4
  1556. .globl restore_current
  1557. restore_current:
  1558. LOAD_CURRENT(g6, o0)
  1559. retl
  1560. nop
  1561. #ifdef CONFIG_PCI
  1562. #include <asm/pcic.h>
  1563. .align 4
  1564. .globl linux_trap_ipi15_pcic
  1565. linux_trap_ipi15_pcic:
  1566. rd %wim, %l3
  1567. SAVE_ALL
  1568. /*
  1569. * First deactivate NMI
  1570. * or we cannot drop ET, cannot get window spill traps.
  1571. * The busy loop is necessary because the PIO error
  1572. * sometimes does not go away quickly and we trap again.
  1573. */
  1574. sethi %hi(pcic_regs), %o1
  1575. ld [%o1 + %lo(pcic_regs)], %o2
  1576. ! Get pending status for printouts later.
  1577. ld [%o2 + PCI_SYS_INT_PENDING], %o0
  1578. mov PCI_SYS_INT_PENDING_CLEAR_ALL, %o1
  1579. stb %o1, [%o2 + PCI_SYS_INT_PENDING_CLEAR]
  1580. 1:
  1581. ld [%o2 + PCI_SYS_INT_PENDING], %o1
  1582. andcc %o1, ((PCI_SYS_INT_PENDING_PIO|PCI_SYS_INT_PENDING_PCI)>>24), %g0
  1583. bne 1b
  1584. nop
  1585. or %l0, PSR_PIL, %l4
  1586. wr %l4, 0x0, %psr
  1587. WRITE_PAUSE
  1588. wr %l4, PSR_ET, %psr
  1589. WRITE_PAUSE
  1590. call pcic_nmi
  1591. add %sp, STACKFRAME_SZ, %o1 ! struct pt_regs *regs
  1592. RESTORE_ALL
  1593. .globl pcic_nmi_trap_patch
  1594. pcic_nmi_trap_patch:
  1595. sethi %hi(linux_trap_ipi15_pcic), %l3
  1596. jmpl %l3 + %lo(linux_trap_ipi15_pcic), %g0
  1597. rd %psr, %l0
  1598. .word 0
  1599. #endif /* CONFIG_PCI */
  1600. /* End of entry.S */