entry.S 40 KB

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