entry.S 28 KB

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