entry.S 29 KB

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