entry.S 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350
  1. /* arch/sparc/kernel/entry.S: Sparc trap low-level entry points.
  2. *
  3. * Copyright (C) 1995, 2007 David S. Miller (davem@davemloft.net)
  4. * Copyright (C) 1996 Eddie C. Dost (ecd@skynet.be)
  5. * Copyright (C) 1996 Miguel de Icaza (miguel@nuclecu.unam.mx)
  6. * Copyright (C) 1996-1999 Jakub Jelinek (jj@sunsite.mff.cuni.cz)
  7. * Copyright (C) 1997 Anton Blanchard (anton@progsoc.uts.edu.au)
  8. */
  9. #include <linux/errno.h>
  10. #include <asm/head.h>
  11. #include <asm/asi.h>
  12. #include <asm/smp.h>
  13. #include <asm/contregs.h>
  14. #include <asm/ptrace.h>
  15. #include <asm/asm-offsets.h>
  16. #include <asm/psr.h>
  17. #include <asm/vaddrs.h>
  18. #include <asm/page.h>
  19. #include <asm/pgtable.h>
  20. #include <asm/winmacro.h>
  21. #include <asm/signal.h>
  22. #include <asm/obio.h>
  23. #include <asm/mxcc.h>
  24. #include <asm/thread_info.h>
  25. #include <asm/param.h>
  26. #include <asm/unistd.h>
  27. #include <asm/asmmacro.h>
  28. #define curptr g6
  29. /* These are just handy. */
  30. #define _SV save %sp, -STACKFRAME_SZ, %sp
  31. #define _RS restore
  32. #define FLUSH_ALL_KERNEL_WINDOWS \
  33. _SV; _SV; _SV; _SV; _SV; _SV; _SV; \
  34. _RS; _RS; _RS; _RS; _RS; _RS; _RS;
  35. .text
  36. #ifdef CONFIG_KGDB
  37. .align 4
  38. .globl arch_kgdb_breakpoint
  39. .type arch_kgdb_breakpoint,#function
  40. arch_kgdb_breakpoint:
  41. ta 0x7d
  42. retl
  43. nop
  44. .size arch_kgdb_breakpoint,.-arch_kgdb_breakpoint
  45. #endif
  46. #if defined(CONFIG_BLK_DEV_FD) || defined(CONFIG_BLK_DEV_FD_MODULE)
  47. .align 4
  48. .globl floppy_hardint
  49. floppy_hardint:
  50. /*
  51. * This code cannot touch registers %l0 %l1 and %l2
  52. * because SAVE_ALL depends on their values. It depends
  53. * on %l3 also, but we regenerate it before a call.
  54. * Other registers are:
  55. * %l3 -- base address of fdc registers
  56. * %l4 -- pdma_vaddr
  57. * %l5 -- scratch for ld/st address
  58. * %l6 -- pdma_size
  59. * %l7 -- scratch [floppy byte, ld/st address, aux. data]
  60. */
  61. /* Do we have work to do? */
  62. sethi %hi(doing_pdma), %l7
  63. ld [%l7 + %lo(doing_pdma)], %l7
  64. cmp %l7, 0
  65. be floppy_dosoftint
  66. nop
  67. /* Load fdc register base */
  68. sethi %hi(fdc_status), %l3
  69. ld [%l3 + %lo(fdc_status)], %l3
  70. /* Setup register addresses */
  71. sethi %hi(pdma_vaddr), %l5 ! transfer buffer
  72. ld [%l5 + %lo(pdma_vaddr)], %l4
  73. sethi %hi(pdma_size), %l5 ! bytes to go
  74. ld [%l5 + %lo(pdma_size)], %l6
  75. next_byte:
  76. ldub [%l3], %l7
  77. andcc %l7, 0x80, %g0 ! Does fifo still have data
  78. bz floppy_fifo_emptied ! fifo has been emptied...
  79. andcc %l7, 0x20, %g0 ! in non-dma mode still?
  80. bz floppy_overrun ! nope, overrun
  81. andcc %l7, 0x40, %g0 ! 0=write 1=read
  82. bz floppy_write
  83. sub %l6, 0x1, %l6
  84. /* Ok, actually read this byte */
  85. ldub [%l3 + 1], %l7
  86. orcc %g0, %l6, %g0
  87. stb %l7, [%l4]
  88. bne next_byte
  89. add %l4, 0x1, %l4
  90. b floppy_tdone
  91. nop
  92. floppy_write:
  93. /* Ok, actually write this byte */
  94. ldub [%l4], %l7
  95. orcc %g0, %l6, %g0
  96. stb %l7, [%l3 + 1]
  97. bne next_byte
  98. add %l4, 0x1, %l4
  99. /* fall through... */
  100. floppy_tdone:
  101. sethi %hi(pdma_vaddr), %l5
  102. st %l4, [%l5 + %lo(pdma_vaddr)]
  103. sethi %hi(pdma_size), %l5
  104. st %l6, [%l5 + %lo(pdma_size)]
  105. /* Flip terminal count pin */
  106. set auxio_register, %l7
  107. ld [%l7], %l7
  108. ldub [%l7], %l5
  109. or %l5, 0xc2, %l5
  110. stb %l5, [%l7]
  111. andn %l5, 0x02, %l5
  112. 2:
  113. /* Kill some time so the bits set */
  114. WRITE_PAUSE
  115. WRITE_PAUSE
  116. stb %l5, [%l7]
  117. /* Prevent recursion */
  118. sethi %hi(doing_pdma), %l7
  119. b floppy_dosoftint
  120. st %g0, [%l7 + %lo(doing_pdma)]
  121. /* We emptied the FIFO, but we haven't read everything
  122. * as of yet. Store the current transfer address and
  123. * bytes left to read so we can continue when the next
  124. * fast IRQ comes in.
  125. */
  126. floppy_fifo_emptied:
  127. sethi %hi(pdma_vaddr), %l5
  128. st %l4, [%l5 + %lo(pdma_vaddr)]
  129. sethi %hi(pdma_size), %l7
  130. st %l6, [%l7 + %lo(pdma_size)]
  131. /* Restore condition codes */
  132. wr %l0, 0x0, %psr
  133. WRITE_PAUSE
  134. jmp %l1
  135. rett %l2
  136. floppy_overrun:
  137. sethi %hi(pdma_vaddr), %l5
  138. st %l4, [%l5 + %lo(pdma_vaddr)]
  139. sethi %hi(pdma_size), %l5
  140. st %l6, [%l5 + %lo(pdma_size)]
  141. /* Prevent recursion */
  142. sethi %hi(doing_pdma), %l7
  143. st %g0, [%l7 + %lo(doing_pdma)]
  144. /* fall through... */
  145. floppy_dosoftint:
  146. rd %wim, %l3
  147. SAVE_ALL
  148. /* Set all IRQs off. */
  149. or %l0, PSR_PIL, %l4
  150. wr %l4, 0x0, %psr
  151. WRITE_PAUSE
  152. wr %l4, PSR_ET, %psr
  153. WRITE_PAUSE
  154. mov 11, %o0 ! floppy irq level (unused anyway)
  155. mov %g0, %o1 ! devid is not used in fast interrupts
  156. call sparc_floppy_irq
  157. add %sp, STACKFRAME_SZ, %o2 ! struct pt_regs *regs
  158. RESTORE_ALL
  159. #endif /* (CONFIG_BLK_DEV_FD) */
  160. /* Bad trap handler */
  161. .globl bad_trap_handler
  162. bad_trap_handler:
  163. SAVE_ALL
  164. wr %l0, PSR_ET, %psr
  165. WRITE_PAUSE
  166. add %sp, STACKFRAME_SZ, %o0 ! pt_regs
  167. call do_hw_interrupt
  168. mov %l7, %o1 ! trap number
  169. RESTORE_ALL
  170. /* For now all IRQ's not registered get sent here. handler_irq() will
  171. * see if a routine is registered to handle this interrupt and if not
  172. * it will say so on the console.
  173. */
  174. .align 4
  175. .globl real_irq_entry, patch_handler_irq
  176. real_irq_entry:
  177. SAVE_ALL
  178. #ifdef CONFIG_SMP
  179. .globl patchme_maybe_smp_msg
  180. cmp %l7, 11
  181. patchme_maybe_smp_msg:
  182. bgu maybe_smp4m_msg
  183. nop
  184. #endif
  185. real_irq_continue:
  186. or %l0, PSR_PIL, %g2
  187. wr %g2, 0x0, %psr
  188. WRITE_PAUSE
  189. wr %g2, PSR_ET, %psr
  190. WRITE_PAUSE
  191. mov %l7, %o0 ! irq level
  192. patch_handler_irq:
  193. call handler_irq
  194. add %sp, STACKFRAME_SZ, %o1 ! pt_regs ptr
  195. or %l0, PSR_PIL, %g2 ! restore PIL after handler_irq
  196. wr %g2, PSR_ET, %psr ! keep ET up
  197. WRITE_PAUSE
  198. RESTORE_ALL
  199. #ifdef CONFIG_SMP
  200. /* SMP per-cpu ticker interrupts are handled specially. */
  201. smp4m_ticker:
  202. bne real_irq_continue+4
  203. or %l0, PSR_PIL, %g2
  204. wr %g2, 0x0, %psr
  205. WRITE_PAUSE
  206. wr %g2, PSR_ET, %psr
  207. WRITE_PAUSE
  208. call smp4m_percpu_timer_interrupt
  209. add %sp, STACKFRAME_SZ, %o0
  210. wr %l0, PSR_ET, %psr
  211. WRITE_PAUSE
  212. RESTORE_ALL
  213. /* Here is where we check for possible SMP IPI passed to us
  214. * on some level other than 15 which is the NMI and only used
  215. * for cross calls. That has a separate entry point below.
  216. *
  217. * IPIs are sent on Level 12, 13 and 14. See IRQ_IPI_*.
  218. */
  219. maybe_smp4m_msg:
  220. GET_PROCESSOR4M_ID(o3)
  221. sethi %hi(sun4m_irq_percpu), %l5
  222. sll %o3, 2, %o3
  223. or %l5, %lo(sun4m_irq_percpu), %o5
  224. sethi %hi(0x70000000), %o2 ! Check all soft-IRQs
  225. ld [%o5 + %o3], %o1
  226. ld [%o1 + 0x00], %o3 ! sun4m_irq_percpu[cpu]->pending
  227. andcc %o3, %o2, %g0
  228. be,a smp4m_ticker
  229. cmp %l7, 14
  230. /* Soft-IRQ IPI */
  231. st %o2, [%o1 + 0x04] ! sun4m_irq_percpu[cpu]->clear=0x70000000
  232. WRITE_PAUSE
  233. ld [%o1 + 0x00], %g0 ! sun4m_irq_percpu[cpu]->pending
  234. WRITE_PAUSE
  235. or %l0, PSR_PIL, %l4
  236. wr %l4, 0x0, %psr
  237. WRITE_PAUSE
  238. wr %l4, PSR_ET, %psr
  239. WRITE_PAUSE
  240. srl %o3, 28, %o2 ! shift for simpler checks below
  241. maybe_smp4m_msg_check_single:
  242. andcc %o2, 0x1, %g0
  243. beq,a maybe_smp4m_msg_check_mask
  244. andcc %o2, 0x2, %g0
  245. call smp_call_function_single_interrupt
  246. nop
  247. andcc %o2, 0x2, %g0
  248. maybe_smp4m_msg_check_mask:
  249. beq,a maybe_smp4m_msg_check_resched
  250. andcc %o2, 0x4, %g0
  251. call smp_call_function_interrupt
  252. nop
  253. andcc %o2, 0x4, %g0
  254. maybe_smp4m_msg_check_resched:
  255. /* rescheduling is done in RESTORE_ALL regardless, but incr stats */
  256. beq,a maybe_smp4m_msg_out
  257. nop
  258. call smp_resched_interrupt
  259. nop
  260. maybe_smp4m_msg_out:
  261. RESTORE_ALL
  262. .align 4
  263. .globl linux_trap_ipi15_sun4m
  264. linux_trap_ipi15_sun4m:
  265. SAVE_ALL
  266. sethi %hi(0x80000000), %o2
  267. GET_PROCESSOR4M_ID(o0)
  268. sethi %hi(sun4m_irq_percpu), %l5
  269. or %l5, %lo(sun4m_irq_percpu), %o5
  270. sll %o0, 2, %o0
  271. ld [%o5 + %o0], %o5
  272. ld [%o5 + 0x00], %o3 ! sun4m_irq_percpu[cpu]->pending
  273. andcc %o3, %o2, %g0
  274. be sun4m_nmi_error ! Must be an NMI async memory error
  275. st %o2, [%o5 + 0x04] ! sun4m_irq_percpu[cpu]->clear=0x80000000
  276. WRITE_PAUSE
  277. ld [%o5 + 0x00], %g0 ! sun4m_irq_percpu[cpu]->pending
  278. WRITE_PAUSE
  279. or %l0, PSR_PIL, %l4
  280. wr %l4, 0x0, %psr
  281. WRITE_PAUSE
  282. wr %l4, PSR_ET, %psr
  283. WRITE_PAUSE
  284. call smp4m_cross_call_irq
  285. nop
  286. b ret_trap_lockless_ipi
  287. clr %l6
  288. .globl smp4d_ticker
  289. /* SMP per-cpu ticker interrupts are handled specially. */
  290. smp4d_ticker:
  291. SAVE_ALL
  292. or %l0, PSR_PIL, %g2
  293. sethi %hi(CC_ICLR), %o0
  294. sethi %hi(1 << 14), %o1
  295. or %o0, %lo(CC_ICLR), %o0
  296. stha %o1, [%o0] ASI_M_MXCC /* Clear PIL 14 in MXCC's ICLR */
  297. wr %g2, 0x0, %psr
  298. WRITE_PAUSE
  299. wr %g2, PSR_ET, %psr
  300. WRITE_PAUSE
  301. call smp4d_percpu_timer_interrupt
  302. add %sp, STACKFRAME_SZ, %o0
  303. wr %l0, PSR_ET, %psr
  304. WRITE_PAUSE
  305. RESTORE_ALL
  306. .align 4
  307. .globl linux_trap_ipi15_sun4d
  308. linux_trap_ipi15_sun4d:
  309. SAVE_ALL
  310. sethi %hi(CC_BASE), %o4
  311. sethi %hi(MXCC_ERR_ME|MXCC_ERR_PEW|MXCC_ERR_ASE|MXCC_ERR_PEE), %o2
  312. or %o4, (CC_EREG - CC_BASE), %o0
  313. ldda [%o0] ASI_M_MXCC, %o0
  314. andcc %o0, %o2, %g0
  315. bne 1f
  316. sethi %hi(BB_STAT2), %o2
  317. lduba [%o2] ASI_M_CTL, %o2
  318. andcc %o2, BB_STAT2_MASK, %g0
  319. bne 2f
  320. or %o4, (CC_ICLR - CC_BASE), %o0
  321. sethi %hi(1 << 15), %o1
  322. stha %o1, [%o0] ASI_M_MXCC /* Clear PIL 15 in MXCC's ICLR */
  323. or %l0, PSR_PIL, %l4
  324. wr %l4, 0x0, %psr
  325. WRITE_PAUSE
  326. wr %l4, PSR_ET, %psr
  327. WRITE_PAUSE
  328. call smp4d_cross_call_irq
  329. nop
  330. b ret_trap_lockless_ipi
  331. clr %l6
  332. 1: /* MXCC error */
  333. 2: /* BB error */
  334. /* Disable PIL 15 */
  335. set CC_IMSK, %l4
  336. lduha [%l4] ASI_M_MXCC, %l5
  337. sethi %hi(1 << 15), %l7
  338. or %l5, %l7, %l5
  339. stha %l5, [%l4] ASI_M_MXCC
  340. /* FIXME */
  341. 1: b,a 1b
  342. #ifdef CONFIG_SPARC_LEON
  343. .globl smpleon_ipi
  344. .extern leon_ipi_interrupt
  345. /* SMP per-cpu IPI interrupts are handled specially. */
  346. smpleon_ipi:
  347. SAVE_ALL
  348. or %l0, PSR_PIL, %g2
  349. wr %g2, 0x0, %psr
  350. WRITE_PAUSE
  351. wr %g2, PSR_ET, %psr
  352. WRITE_PAUSE
  353. call leonsmp_ipi_interrupt
  354. add %sp, STACKFRAME_SZ, %o1 ! pt_regs
  355. wr %l0, PSR_ET, %psr
  356. WRITE_PAUSE
  357. RESTORE_ALL
  358. .align 4
  359. .globl linux_trap_ipi15_leon
  360. linux_trap_ipi15_leon:
  361. SAVE_ALL
  362. or %l0, PSR_PIL, %l4
  363. wr %l4, 0x0, %psr
  364. WRITE_PAUSE
  365. wr %l4, PSR_ET, %psr
  366. WRITE_PAUSE
  367. call leon_cross_call_irq
  368. nop
  369. b ret_trap_lockless_ipi
  370. clr %l6
  371. #endif /* CONFIG_SPARC_LEON */
  372. #endif /* CONFIG_SMP */
  373. /* This routine handles illegal instructions and privileged
  374. * instruction attempts from user code.
  375. */
  376. .align 4
  377. .globl bad_instruction
  378. bad_instruction:
  379. sethi %hi(0xc1f80000), %l4
  380. ld [%l1], %l5
  381. sethi %hi(0x81d80000), %l7
  382. and %l5, %l4, %l5
  383. cmp %l5, %l7
  384. be 1f
  385. SAVE_ALL
  386. wr %l0, PSR_ET, %psr ! re-enable traps
  387. WRITE_PAUSE
  388. add %sp, STACKFRAME_SZ, %o0
  389. mov %l1, %o1
  390. mov %l2, %o2
  391. call do_illegal_instruction
  392. mov %l0, %o3
  393. RESTORE_ALL
  394. 1: /* unimplemented flush - just skip */
  395. jmpl %l2, %g0
  396. rett %l2 + 4
  397. .align 4
  398. .globl priv_instruction
  399. priv_instruction:
  400. SAVE_ALL
  401. wr %l0, PSR_ET, %psr
  402. WRITE_PAUSE
  403. add %sp, STACKFRAME_SZ, %o0
  404. mov %l1, %o1
  405. mov %l2, %o2
  406. call do_priv_instruction
  407. mov %l0, %o3
  408. RESTORE_ALL
  409. /* This routine handles unaligned data accesses. */
  410. .align 4
  411. .globl mna_handler
  412. mna_handler:
  413. andcc %l0, PSR_PS, %g0
  414. be mna_fromuser
  415. nop
  416. SAVE_ALL
  417. wr %l0, PSR_ET, %psr
  418. WRITE_PAUSE
  419. ld [%l1], %o1
  420. call kernel_unaligned_trap
  421. add %sp, STACKFRAME_SZ, %o0
  422. RESTORE_ALL
  423. mna_fromuser:
  424. SAVE_ALL
  425. wr %l0, PSR_ET, %psr ! re-enable traps
  426. WRITE_PAUSE
  427. ld [%l1], %o1
  428. call user_unaligned_trap
  429. add %sp, STACKFRAME_SZ, %o0
  430. RESTORE_ALL
  431. /* This routine handles floating point disabled traps. */
  432. .align 4
  433. .globl fpd_trap_handler
  434. fpd_trap_handler:
  435. SAVE_ALL
  436. wr %l0, PSR_ET, %psr ! re-enable traps
  437. WRITE_PAUSE
  438. add %sp, STACKFRAME_SZ, %o0
  439. mov %l1, %o1
  440. mov %l2, %o2
  441. call do_fpd_trap
  442. mov %l0, %o3
  443. RESTORE_ALL
  444. /* This routine handles Floating Point Exceptions. */
  445. .align 4
  446. .globl fpe_trap_handler
  447. fpe_trap_handler:
  448. set fpsave_magic, %l5
  449. cmp %l1, %l5
  450. be 1f
  451. sethi %hi(fpsave), %l5
  452. or %l5, %lo(fpsave), %l5
  453. cmp %l1, %l5
  454. bne 2f
  455. sethi %hi(fpsave_catch2), %l5
  456. or %l5, %lo(fpsave_catch2), %l5
  457. wr %l0, 0x0, %psr
  458. WRITE_PAUSE
  459. jmp %l5
  460. rett %l5 + 4
  461. 1:
  462. sethi %hi(fpsave_catch), %l5
  463. or %l5, %lo(fpsave_catch), %l5
  464. wr %l0, 0x0, %psr
  465. WRITE_PAUSE
  466. jmp %l5
  467. rett %l5 + 4
  468. 2:
  469. SAVE_ALL
  470. wr %l0, PSR_ET, %psr ! re-enable traps
  471. WRITE_PAUSE
  472. add %sp, STACKFRAME_SZ, %o0
  473. mov %l1, %o1
  474. mov %l2, %o2
  475. call do_fpe_trap
  476. mov %l0, %o3
  477. RESTORE_ALL
  478. /* This routine handles Tag Overflow Exceptions. */
  479. .align 4
  480. .globl do_tag_overflow
  481. do_tag_overflow:
  482. SAVE_ALL
  483. wr %l0, PSR_ET, %psr ! re-enable traps
  484. WRITE_PAUSE
  485. add %sp, STACKFRAME_SZ, %o0
  486. mov %l1, %o1
  487. mov %l2, %o2
  488. call handle_tag_overflow
  489. mov %l0, %o3
  490. RESTORE_ALL
  491. /* This routine handles Watchpoint Exceptions. */
  492. .align 4
  493. .globl do_watchpoint
  494. do_watchpoint:
  495. SAVE_ALL
  496. wr %l0, PSR_ET, %psr ! re-enable traps
  497. WRITE_PAUSE
  498. add %sp, STACKFRAME_SZ, %o0
  499. mov %l1, %o1
  500. mov %l2, %o2
  501. call handle_watchpoint
  502. mov %l0, %o3
  503. RESTORE_ALL
  504. /* This routine handles Register Access Exceptions. */
  505. .align 4
  506. .globl do_reg_access
  507. do_reg_access:
  508. SAVE_ALL
  509. wr %l0, PSR_ET, %psr ! re-enable traps
  510. WRITE_PAUSE
  511. add %sp, STACKFRAME_SZ, %o0
  512. mov %l1, %o1
  513. mov %l2, %o2
  514. call handle_reg_access
  515. mov %l0, %o3
  516. RESTORE_ALL
  517. /* This routine handles Co-Processor Disabled Exceptions. */
  518. .align 4
  519. .globl do_cp_disabled
  520. do_cp_disabled:
  521. SAVE_ALL
  522. wr %l0, PSR_ET, %psr ! re-enable traps
  523. WRITE_PAUSE
  524. add %sp, STACKFRAME_SZ, %o0
  525. mov %l1, %o1
  526. mov %l2, %o2
  527. call handle_cp_disabled
  528. mov %l0, %o3
  529. RESTORE_ALL
  530. /* This routine handles Co-Processor Exceptions. */
  531. .align 4
  532. .globl do_cp_exception
  533. do_cp_exception:
  534. SAVE_ALL
  535. wr %l0, PSR_ET, %psr ! re-enable traps
  536. WRITE_PAUSE
  537. add %sp, STACKFRAME_SZ, %o0
  538. mov %l1, %o1
  539. mov %l2, %o2
  540. call handle_cp_exception
  541. mov %l0, %o3
  542. RESTORE_ALL
  543. /* This routine handles Hardware Divide By Zero Exceptions. */
  544. .align 4
  545. .globl do_hw_divzero
  546. do_hw_divzero:
  547. SAVE_ALL
  548. wr %l0, PSR_ET, %psr ! re-enable traps
  549. WRITE_PAUSE
  550. add %sp, STACKFRAME_SZ, %o0
  551. mov %l1, %o1
  552. mov %l2, %o2
  553. call handle_hw_divzero
  554. mov %l0, %o3
  555. RESTORE_ALL
  556. .align 4
  557. .globl do_flush_windows
  558. do_flush_windows:
  559. SAVE_ALL
  560. wr %l0, PSR_ET, %psr
  561. WRITE_PAUSE
  562. andcc %l0, PSR_PS, %g0
  563. bne dfw_kernel
  564. nop
  565. call flush_user_windows
  566. nop
  567. /* Advance over the trap instruction. */
  568. ld [%sp + STACKFRAME_SZ + PT_NPC], %l1
  569. add %l1, 0x4, %l2
  570. st %l1, [%sp + STACKFRAME_SZ + PT_PC]
  571. st %l2, [%sp + STACKFRAME_SZ + PT_NPC]
  572. RESTORE_ALL
  573. .globl flush_patch_one
  574. /* We get these for debugging routines using __builtin_return_address() */
  575. dfw_kernel:
  576. flush_patch_one:
  577. FLUSH_ALL_KERNEL_WINDOWS
  578. /* Advance over the trap instruction. */
  579. ld [%sp + STACKFRAME_SZ + PT_NPC], %l1
  580. add %l1, 0x4, %l2
  581. st %l1, [%sp + STACKFRAME_SZ + PT_PC]
  582. st %l2, [%sp + STACKFRAME_SZ + PT_NPC]
  583. RESTORE_ALL
  584. /* The getcc software trap. The user wants the condition codes from
  585. * the %psr in register %g1.
  586. */
  587. .align 4
  588. .globl getcc_trap_handler
  589. getcc_trap_handler:
  590. srl %l0, 20, %g1 ! give user
  591. and %g1, 0xf, %g1 ! only ICC bits in %psr
  592. jmp %l2 ! advance over trap instruction
  593. rett %l2 + 0x4 ! like this...
  594. /* The setcc software trap. The user has condition codes in %g1
  595. * that it would like placed in the %psr. Be careful not to flip
  596. * any unintentional bits!
  597. */
  598. .align 4
  599. .globl setcc_trap_handler
  600. setcc_trap_handler:
  601. sll %g1, 0x14, %l4
  602. set PSR_ICC, %l5
  603. andn %l0, %l5, %l0 ! clear ICC bits in %psr
  604. and %l4, %l5, %l4 ! clear non-ICC bits in user value
  605. or %l4, %l0, %l4 ! or them in... mix mix mix
  606. wr %l4, 0x0, %psr ! set new %psr
  607. WRITE_PAUSE ! TI scumbags...
  608. jmp %l2 ! advance over trap instruction
  609. rett %l2 + 0x4 ! like this...
  610. sun4m_nmi_error:
  611. /* NMI async memory error handling. */
  612. sethi %hi(0x80000000), %l4
  613. sethi %hi(sun4m_irq_global), %o5
  614. ld [%o5 + %lo(sun4m_irq_global)], %l5
  615. st %l4, [%l5 + 0x0c] ! sun4m_irq_global->mask_set=0x80000000
  616. WRITE_PAUSE
  617. ld [%l5 + 0x00], %g0 ! sun4m_irq_global->pending
  618. WRITE_PAUSE
  619. or %l0, PSR_PIL, %l4
  620. wr %l4, 0x0, %psr
  621. WRITE_PAUSE
  622. wr %l4, PSR_ET, %psr
  623. WRITE_PAUSE
  624. call sun4m_nmi
  625. nop
  626. st %l4, [%l5 + 0x08] ! sun4m_irq_global->mask_clear=0x80000000
  627. WRITE_PAUSE
  628. ld [%l5 + 0x00], %g0 ! sun4m_irq_global->pending
  629. WRITE_PAUSE
  630. RESTORE_ALL
  631. #ifndef CONFIG_SMP
  632. .align 4
  633. .globl linux_trap_ipi15_sun4m
  634. linux_trap_ipi15_sun4m:
  635. SAVE_ALL
  636. ba sun4m_nmi_error
  637. nop
  638. #endif /* CONFIG_SMP */
  639. .align 4
  640. .globl srmmu_fault
  641. srmmu_fault:
  642. mov 0x400, %l5
  643. mov 0x300, %l4
  644. lda [%l5] ASI_M_MMUREGS, %l6 ! read sfar first
  645. lda [%l4] ASI_M_MMUREGS, %l5 ! read sfsr last
  646. andn %l6, 0xfff, %l6
  647. srl %l5, 6, %l5 ! and encode all info into l7
  648. and %l5, 2, %l5
  649. or %l5, %l6, %l6
  650. or %l6, %l7, %l7 ! l7 = [addr,write,txtfault]
  651. SAVE_ALL
  652. mov %l7, %o1
  653. mov %l7, %o2
  654. and %o1, 1, %o1 ! arg2 = text_faultp
  655. mov %l7, %o3
  656. and %o2, 2, %o2 ! arg3 = writep
  657. andn %o3, 0xfff, %o3 ! arg4 = faulting address
  658. wr %l0, PSR_ET, %psr
  659. WRITE_PAUSE
  660. call do_sparc_fault
  661. add %sp, STACKFRAME_SZ, %o0 ! arg1 = pt_regs ptr
  662. RESTORE_ALL
  663. .align 4
  664. .globl sys_nis_syscall
  665. sys_nis_syscall:
  666. mov %o7, %l5
  667. add %sp, STACKFRAME_SZ, %o0 ! pt_regs *regs arg
  668. call c_sys_nis_syscall
  669. mov %l5, %o7
  670. .align 4
  671. .globl sys_execve
  672. sys_execve:
  673. mov %o7, %l5
  674. add %sp, STACKFRAME_SZ, %o0 ! pt_regs *regs arg
  675. call sparc_execve
  676. mov %l5, %o7
  677. .globl sunos_execv
  678. sunos_execv:
  679. st %g0, [%sp + STACKFRAME_SZ + PT_I2]
  680. call sparc_execve
  681. add %sp, STACKFRAME_SZ, %o0
  682. b ret_sys_call
  683. ld [%sp + STACKFRAME_SZ + PT_I0], %o0
  684. .align 4
  685. .globl sys_sparc_pipe
  686. sys_sparc_pipe:
  687. mov %o7, %l5
  688. add %sp, STACKFRAME_SZ, %o0 ! pt_regs *regs arg
  689. call sparc_pipe
  690. mov %l5, %o7
  691. .align 4
  692. .globl sys_sigaltstack
  693. sys_sigaltstack:
  694. mov %o7, %l5
  695. mov %fp, %o2
  696. call do_sigaltstack
  697. mov %l5, %o7
  698. .align 4
  699. .globl sys_sigstack
  700. sys_sigstack:
  701. mov %o7, %l5
  702. mov %fp, %o2
  703. call do_sys_sigstack
  704. mov %l5, %o7
  705. .align 4
  706. .globl sys_sigreturn
  707. sys_sigreturn:
  708. call do_sigreturn
  709. add %sp, STACKFRAME_SZ, %o0
  710. ld [%curptr + TI_FLAGS], %l5
  711. andcc %l5, _TIF_SYSCALL_TRACE, %g0
  712. be 1f
  713. nop
  714. call syscall_trace
  715. nop
  716. 1:
  717. /* We don't want to muck with user registers like a
  718. * normal syscall, just return.
  719. */
  720. RESTORE_ALL
  721. .align 4
  722. .globl sys_rt_sigreturn
  723. sys_rt_sigreturn:
  724. call do_rt_sigreturn
  725. add %sp, STACKFRAME_SZ, %o0
  726. ld [%curptr + TI_FLAGS], %l5
  727. andcc %l5, _TIF_SYSCALL_TRACE, %g0
  728. be 1f
  729. nop
  730. add %sp, STACKFRAME_SZ, %o0
  731. call syscall_trace
  732. mov 1, %o1
  733. 1:
  734. /* We are returning to a signal handler. */
  735. RESTORE_ALL
  736. /* Now that we have a real sys_clone, sys_fork() is
  737. * implemented in terms of it. Our _real_ implementation
  738. * of SunOS vfork() will use sys_vfork().
  739. *
  740. * XXX These three should be consolidated into mostly shared
  741. * XXX code just like on sparc64... -DaveM
  742. */
  743. .align 4
  744. .globl sys_fork, flush_patch_two
  745. sys_fork:
  746. mov %o7, %l5
  747. flush_patch_two:
  748. FLUSH_ALL_KERNEL_WINDOWS;
  749. ld [%curptr + TI_TASK], %o4
  750. rd %psr, %g4
  751. WRITE_PAUSE
  752. mov SIGCHLD, %o0 ! arg0: clone flags
  753. rd %wim, %g5
  754. WRITE_PAUSE
  755. mov %fp, %o1 ! arg1: usp
  756. std %g4, [%o4 + AOFF_task_thread + AOFF_thread_fork_kpsr]
  757. add %sp, STACKFRAME_SZ, %o2 ! arg2: pt_regs ptr
  758. mov 0, %o3
  759. call sparc_do_fork
  760. mov %l5, %o7
  761. /* Whee, kernel threads! */
  762. .globl sys_clone, flush_patch_three
  763. sys_clone:
  764. mov %o7, %l5
  765. flush_patch_three:
  766. FLUSH_ALL_KERNEL_WINDOWS;
  767. ld [%curptr + TI_TASK], %o4
  768. rd %psr, %g4
  769. WRITE_PAUSE
  770. /* arg0,1: flags,usp -- loaded already */
  771. cmp %o1, 0x0 ! Is new_usp NULL?
  772. rd %wim, %g5
  773. WRITE_PAUSE
  774. be,a 1f
  775. mov %fp, %o1 ! yes, use callers usp
  776. andn %o1, 7, %o1 ! no, align to 8 bytes
  777. 1:
  778. std %g4, [%o4 + AOFF_task_thread + AOFF_thread_fork_kpsr]
  779. add %sp, STACKFRAME_SZ, %o2 ! arg2: pt_regs ptr
  780. mov 0, %o3
  781. call sparc_do_fork
  782. mov %l5, %o7
  783. /* Whee, real vfork! */
  784. .globl sys_vfork, flush_patch_four
  785. sys_vfork:
  786. flush_patch_four:
  787. FLUSH_ALL_KERNEL_WINDOWS;
  788. ld [%curptr + TI_TASK], %o4
  789. rd %psr, %g4
  790. WRITE_PAUSE
  791. rd %wim, %g5
  792. WRITE_PAUSE
  793. std %g4, [%o4 + AOFF_task_thread + AOFF_thread_fork_kpsr]
  794. sethi %hi(0x4000 | 0x0100 | SIGCHLD), %o0
  795. mov %fp, %o1
  796. or %o0, %lo(0x4000 | 0x0100 | SIGCHLD), %o0
  797. sethi %hi(sparc_do_fork), %l1
  798. mov 0, %o3
  799. jmpl %l1 + %lo(sparc_do_fork), %g0
  800. add %sp, STACKFRAME_SZ, %o2
  801. .align 4
  802. linux_sparc_ni_syscall:
  803. sethi %hi(sys_ni_syscall), %l7
  804. b syscall_is_too_hard
  805. or %l7, %lo(sys_ni_syscall), %l7
  806. linux_fast_syscall:
  807. andn %l7, 3, %l7
  808. mov %i0, %o0
  809. mov %i1, %o1
  810. mov %i2, %o2
  811. jmpl %l7 + %g0, %g0
  812. mov %i3, %o3
  813. linux_syscall_trace:
  814. add %sp, STACKFRAME_SZ, %o0
  815. call syscall_trace
  816. mov 0, %o1
  817. cmp %o0, 0
  818. bne 3f
  819. mov -ENOSYS, %o0
  820. mov %i0, %o0
  821. mov %i1, %o1
  822. mov %i2, %o2
  823. mov %i3, %o3
  824. b 2f
  825. mov %i4, %o4
  826. .globl ret_from_fork
  827. ret_from_fork:
  828. call schedule_tail
  829. ld [%g3 + TI_TASK], %o0
  830. b ret_sys_call
  831. ld [%sp + STACKFRAME_SZ + PT_I0], %o0
  832. /* Linux native system calls enter here... */
  833. .align 4
  834. .globl linux_sparc_syscall
  835. linux_sparc_syscall:
  836. sethi %hi(PSR_SYSCALL), %l4
  837. or %l0, %l4, %l0
  838. /* Direct access to user regs, must faster. */
  839. cmp %g1, NR_syscalls
  840. bgeu linux_sparc_ni_syscall
  841. sll %g1, 2, %l4
  842. ld [%l7 + %l4], %l7
  843. andcc %l7, 1, %g0
  844. bne linux_fast_syscall
  845. /* Just do first insn from SAVE_ALL in the delay slot */
  846. syscall_is_too_hard:
  847. SAVE_ALL_HEAD
  848. rd %wim, %l3
  849. wr %l0, PSR_ET, %psr
  850. mov %i0, %o0
  851. mov %i1, %o1
  852. mov %i2, %o2
  853. ld [%curptr + TI_FLAGS], %l5
  854. mov %i3, %o3
  855. andcc %l5, _TIF_SYSCALL_TRACE, %g0
  856. mov %i4, %o4
  857. bne linux_syscall_trace
  858. mov %i0, %l5
  859. 2:
  860. call %l7
  861. mov %i5, %o5
  862. 3:
  863. st %o0, [%sp + STACKFRAME_SZ + PT_I0]
  864. ret_sys_call:
  865. ld [%curptr + TI_FLAGS], %l6
  866. cmp %o0, -ERESTART_RESTARTBLOCK
  867. ld [%sp + STACKFRAME_SZ + PT_PSR], %g3
  868. set PSR_C, %g2
  869. bgeu 1f
  870. andcc %l6, _TIF_SYSCALL_TRACE, %g0
  871. /* System call success, clear Carry condition code. */
  872. andn %g3, %g2, %g3
  873. clr %l6
  874. st %g3, [%sp + STACKFRAME_SZ + PT_PSR]
  875. bne linux_syscall_trace2
  876. ld [%sp + STACKFRAME_SZ + PT_NPC], %l1 /* pc = npc */
  877. add %l1, 0x4, %l2 /* npc = npc+4 */
  878. st %l1, [%sp + STACKFRAME_SZ + PT_PC]
  879. b ret_trap_entry
  880. st %l2, [%sp + STACKFRAME_SZ + PT_NPC]
  881. 1:
  882. /* System call failure, set Carry condition code.
  883. * Also, get abs(errno) to return to the process.
  884. */
  885. sub %g0, %o0, %o0
  886. or %g3, %g2, %g3
  887. st %o0, [%sp + STACKFRAME_SZ + PT_I0]
  888. mov 1, %l6
  889. st %g3, [%sp + STACKFRAME_SZ + PT_PSR]
  890. bne linux_syscall_trace2
  891. ld [%sp + STACKFRAME_SZ + PT_NPC], %l1 /* pc = npc */
  892. add %l1, 0x4, %l2 /* npc = npc+4 */
  893. st %l1, [%sp + STACKFRAME_SZ + PT_PC]
  894. b ret_trap_entry
  895. st %l2, [%sp + STACKFRAME_SZ + PT_NPC]
  896. linux_syscall_trace2:
  897. add %sp, STACKFRAME_SZ, %o0
  898. mov 1, %o1
  899. call syscall_trace
  900. add %l1, 0x4, %l2 /* npc = npc+4 */
  901. st %l1, [%sp + STACKFRAME_SZ + PT_PC]
  902. b ret_trap_entry
  903. st %l2, [%sp + STACKFRAME_SZ + PT_NPC]
  904. /* Saving and restoring the FPU state is best done from lowlevel code.
  905. *
  906. * void fpsave(unsigned long *fpregs, unsigned long *fsr,
  907. * void *fpqueue, unsigned long *fpqdepth)
  908. */
  909. .globl fpsave
  910. fpsave:
  911. st %fsr, [%o1] ! this can trap on us if fpu is in bogon state
  912. ld [%o1], %g1
  913. set 0x2000, %g4
  914. andcc %g1, %g4, %g0
  915. be 2f
  916. mov 0, %g2
  917. /* We have an fpqueue to save. */
  918. 1:
  919. std %fq, [%o2]
  920. fpsave_magic:
  921. st %fsr, [%o1]
  922. ld [%o1], %g3
  923. andcc %g3, %g4, %g0
  924. add %g2, 1, %g2
  925. bne 1b
  926. add %o2, 8, %o2
  927. 2:
  928. st %g2, [%o3]
  929. std %f0, [%o0 + 0x00]
  930. std %f2, [%o0 + 0x08]
  931. std %f4, [%o0 + 0x10]
  932. std %f6, [%o0 + 0x18]
  933. std %f8, [%o0 + 0x20]
  934. std %f10, [%o0 + 0x28]
  935. std %f12, [%o0 + 0x30]
  936. std %f14, [%o0 + 0x38]
  937. std %f16, [%o0 + 0x40]
  938. std %f18, [%o0 + 0x48]
  939. std %f20, [%o0 + 0x50]
  940. std %f22, [%o0 + 0x58]
  941. std %f24, [%o0 + 0x60]
  942. std %f26, [%o0 + 0x68]
  943. std %f28, [%o0 + 0x70]
  944. retl
  945. std %f30, [%o0 + 0x78]
  946. /* Thanks for Theo Deraadt and the authors of the Sprite/netbsd/openbsd
  947. * code for pointing out this possible deadlock, while we save state
  948. * above we could trap on the fsr store so our low level fpu trap
  949. * code has to know how to deal with this.
  950. */
  951. fpsave_catch:
  952. b fpsave_magic + 4
  953. st %fsr, [%o1]
  954. fpsave_catch2:
  955. b fpsave + 4
  956. st %fsr, [%o1]
  957. /* void fpload(unsigned long *fpregs, unsigned long *fsr); */
  958. .globl fpload
  959. fpload:
  960. ldd [%o0 + 0x00], %f0
  961. ldd [%o0 + 0x08], %f2
  962. ldd [%o0 + 0x10], %f4
  963. ldd [%o0 + 0x18], %f6
  964. ldd [%o0 + 0x20], %f8
  965. ldd [%o0 + 0x28], %f10
  966. ldd [%o0 + 0x30], %f12
  967. ldd [%o0 + 0x38], %f14
  968. ldd [%o0 + 0x40], %f16
  969. ldd [%o0 + 0x48], %f18
  970. ldd [%o0 + 0x50], %f20
  971. ldd [%o0 + 0x58], %f22
  972. ldd [%o0 + 0x60], %f24
  973. ldd [%o0 + 0x68], %f26
  974. ldd [%o0 + 0x70], %f28
  975. ldd [%o0 + 0x78], %f30
  976. ld [%o1], %fsr
  977. retl
  978. nop
  979. /* __ndelay and __udelay take two arguments:
  980. * 0 - nsecs or usecs to delay
  981. * 1 - per_cpu udelay_val (loops per jiffy)
  982. *
  983. * Note that ndelay gives HZ times higher resolution but has a 10ms
  984. * limit. udelay can handle up to 1s.
  985. */
  986. .globl __ndelay
  987. __ndelay:
  988. save %sp, -STACKFRAME_SZ, %sp
  989. mov %i0, %o0
  990. call .umul ! round multiplier up so large ns ok
  991. mov 0x1ae, %o1 ! 2**32 / (1 000 000 000 / HZ)
  992. call .umul
  993. mov %i1, %o1 ! udelay_val
  994. ba delay_continue
  995. mov %o1, %o0 ! >>32 later for better resolution
  996. .globl __udelay
  997. __udelay:
  998. save %sp, -STACKFRAME_SZ, %sp
  999. mov %i0, %o0
  1000. sethi %hi(0x10c7), %o1 ! round multiplier up so large us ok
  1001. call .umul
  1002. or %o1, %lo(0x10c7), %o1 ! 2**32 / 1 000 000
  1003. call .umul
  1004. mov %i1, %o1 ! udelay_val
  1005. sethi %hi(0x028f4b62), %l0 ! Add in rounding constant * 2**32,
  1006. or %g0, %lo(0x028f4b62), %l0
  1007. addcc %o0, %l0, %o0 ! 2**32 * 0.009 999
  1008. bcs,a 3f
  1009. add %o1, 0x01, %o1
  1010. 3:
  1011. call .umul
  1012. mov HZ, %o0 ! >>32 earlier for wider range
  1013. delay_continue:
  1014. cmp %o0, 0x0
  1015. 1:
  1016. bne 1b
  1017. subcc %o0, 1, %o0
  1018. ret
  1019. restore
  1020. /* Handle a software breakpoint */
  1021. /* We have to inform parent that child has stopped */
  1022. .align 4
  1023. .globl breakpoint_trap
  1024. breakpoint_trap:
  1025. rd %wim,%l3
  1026. SAVE_ALL
  1027. wr %l0, PSR_ET, %psr
  1028. WRITE_PAUSE
  1029. st %i0, [%sp + STACKFRAME_SZ + PT_G0] ! for restarting syscalls
  1030. call sparc_breakpoint
  1031. add %sp, STACKFRAME_SZ, %o0
  1032. RESTORE_ALL
  1033. #ifdef CONFIG_KGDB
  1034. .align 4
  1035. .globl kgdb_trap_low
  1036. .type kgdb_trap_low,#function
  1037. kgdb_trap_low:
  1038. rd %wim,%l3
  1039. SAVE_ALL
  1040. wr %l0, PSR_ET, %psr
  1041. WRITE_PAUSE
  1042. call kgdb_trap
  1043. add %sp, STACKFRAME_SZ, %o0
  1044. RESTORE_ALL
  1045. .size kgdb_trap_low,.-kgdb_trap_low
  1046. #endif
  1047. .align 4
  1048. .globl flush_patch_exception
  1049. flush_patch_exception:
  1050. FLUSH_ALL_KERNEL_WINDOWS;
  1051. ldd [%o0], %o6
  1052. jmpl %o7 + 0xc, %g0 ! see asm-sparc/processor.h
  1053. mov 1, %g1 ! signal EFAULT condition
  1054. .align 4
  1055. .globl kill_user_windows, kuw_patch1_7win
  1056. .globl kuw_patch1
  1057. kuw_patch1_7win: sll %o3, 6, %o3
  1058. /* No matter how much overhead this routine has in the worst
  1059. * case scenerio, it is several times better than taking the
  1060. * traps with the old method of just doing flush_user_windows().
  1061. */
  1062. kill_user_windows:
  1063. ld [%g6 + TI_UWINMASK], %o0 ! get current umask
  1064. orcc %g0, %o0, %g0 ! if no bits set, we are done
  1065. be 3f ! nothing to do
  1066. rd %psr, %o5 ! must clear interrupts
  1067. or %o5, PSR_PIL, %o4 ! or else that could change
  1068. wr %o4, 0x0, %psr ! the uwinmask state
  1069. WRITE_PAUSE ! burn them cycles
  1070. 1:
  1071. ld [%g6 + TI_UWINMASK], %o0 ! get consistent state
  1072. orcc %g0, %o0, %g0 ! did an interrupt come in?
  1073. be 4f ! yep, we are done
  1074. rd %wim, %o3 ! get current wim
  1075. srl %o3, 1, %o4 ! simulate a save
  1076. kuw_patch1:
  1077. sll %o3, 7, %o3 ! compute next wim
  1078. or %o4, %o3, %o3 ! result
  1079. andncc %o0, %o3, %o0 ! clean this bit in umask
  1080. bne kuw_patch1 ! not done yet
  1081. srl %o3, 1, %o4 ! begin another save simulation
  1082. wr %o3, 0x0, %wim ! set the new wim
  1083. st %g0, [%g6 + TI_UWINMASK] ! clear uwinmask
  1084. 4:
  1085. wr %o5, 0x0, %psr ! re-enable interrupts
  1086. WRITE_PAUSE ! burn baby burn
  1087. 3:
  1088. retl ! return
  1089. st %g0, [%g6 + TI_W_SAVED] ! no windows saved
  1090. .align 4
  1091. .globl restore_current
  1092. restore_current:
  1093. LOAD_CURRENT(g6, o0)
  1094. retl
  1095. nop
  1096. #ifdef CONFIG_PCIC_PCI
  1097. #include <asm/pcic.h>
  1098. .align 4
  1099. .globl linux_trap_ipi15_pcic
  1100. linux_trap_ipi15_pcic:
  1101. rd %wim, %l3
  1102. SAVE_ALL
  1103. /*
  1104. * First deactivate NMI
  1105. * or we cannot drop ET, cannot get window spill traps.
  1106. * The busy loop is necessary because the PIO error
  1107. * sometimes does not go away quickly and we trap again.
  1108. */
  1109. sethi %hi(pcic_regs), %o1
  1110. ld [%o1 + %lo(pcic_regs)], %o2
  1111. ! Get pending status for printouts later.
  1112. ld [%o2 + PCI_SYS_INT_PENDING], %o0
  1113. mov PCI_SYS_INT_PENDING_CLEAR_ALL, %o1
  1114. stb %o1, [%o2 + PCI_SYS_INT_PENDING_CLEAR]
  1115. 1:
  1116. ld [%o2 + PCI_SYS_INT_PENDING], %o1
  1117. andcc %o1, ((PCI_SYS_INT_PENDING_PIO|PCI_SYS_INT_PENDING_PCI)>>24), %g0
  1118. bne 1b
  1119. nop
  1120. or %l0, PSR_PIL, %l4
  1121. wr %l4, 0x0, %psr
  1122. WRITE_PAUSE
  1123. wr %l4, PSR_ET, %psr
  1124. WRITE_PAUSE
  1125. call pcic_nmi
  1126. add %sp, STACKFRAME_SZ, %o1 ! struct pt_regs *regs
  1127. RESTORE_ALL
  1128. .globl pcic_nmi_trap_patch
  1129. pcic_nmi_trap_patch:
  1130. sethi %hi(linux_trap_ipi15_pcic), %l3
  1131. jmpl %l3 + %lo(linux_trap_ipi15_pcic), %g0
  1132. rd %psr, %l0
  1133. .word 0
  1134. #endif /* CONFIG_PCIC_PCI */
  1135. .globl flushw_all
  1136. flushw_all:
  1137. save %sp, -0x40, %sp
  1138. save %sp, -0x40, %sp
  1139. save %sp, -0x40, %sp
  1140. save %sp, -0x40, %sp
  1141. save %sp, -0x40, %sp
  1142. save %sp, -0x40, %sp
  1143. save %sp, -0x40, %sp
  1144. restore
  1145. restore
  1146. restore
  1147. restore
  1148. restore
  1149. restore
  1150. ret
  1151. restore
  1152. /* End of entry.S */