entry.S 28 KB

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