entry.S 40 KB

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