entry.S 28 KB

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