entry.S 39 KB

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