entry.S 29 KB

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