entry.S 29 KB

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