1 /* sun4v_ivec.S: Sun4v interrupt vector handling.
3 * Copyright (C) 2006 <davem@davemloft.net>
6 #include <asm/cpudata.h>
7 #include <asm/intr_queue.h>
13 /* Head offset in %g2, tail offset in %g4.
14 * If they are the same, no work.
16 mov INTRQ_CPU_MONDO_HEAD, %g2
17 ldxa [%g2] ASI_QUEUE, %g2
18 mov INTRQ_CPU_MONDO_TAIL, %g4
19 ldxa [%g4] ASI_QUEUE, %g4
21 be,pn %xcc, sun4v_cpu_mondo_queue_empty
24 /* Get &trap_block[smp_processor_id()] into %g3. */
25 ldxa [%g0] ASI_SCRATCHPAD, %g3
26 sub %g3, TRAP_PER_CPU_FAULT_INFO, %g3
28 /* Get CPU mondo queue base phys address into %g7. */
29 ldx [%g3 + TRAP_PER_CPU_CPU_MONDO_PA], %g7
31 /* Now get the cross-call arguments and handler PC, same
34 * 1st 64-bit word: low half is 32-bit PC, put into %g3 and jmpl to it
35 * high half is context arg to MMU flushes, into %g5
36 * 2nd 64-bit word: 64-bit arg, load into %g1
37 * 3rd 64-bit word: 64-bit arg, load into %g7
39 ldxa [%g7 + %g2] ASI_PHYS_USE_EC, %g3
42 ldxa [%g7 + %g2] ASI_PHYS_USE_EC, %g1
45 ldxa [%g7 + %g2] ASI_PHYS_USE_EC, %g7
46 add %g2, 0x40 - 0x8 - 0x8, %g2
48 /* Update queue head pointer. */
49 sethi %hi(8192 - 1), %g4
50 or %g4, %lo(8192 - 1), %g4
53 mov INTRQ_CPU_MONDO_HEAD, %g4
54 stxa %g2, [%g4] ASI_QUEUE
60 sun4v_cpu_mondo_queue_empty:
64 /* Head offset in %g2, tail offset in %g4. */
65 mov INTRQ_DEVICE_MONDO_HEAD, %g2
66 ldxa [%g2] ASI_QUEUE, %g2
67 mov INTRQ_DEVICE_MONDO_TAIL, %g4
68 ldxa [%g4] ASI_QUEUE, %g4
70 be,pn %xcc, sun4v_dev_mondo_queue_empty
73 /* Get &trap_block[smp_processor_id()] into %g3. */
74 ldxa [%g0] ASI_SCRATCHPAD, %g3
75 sub %g3, TRAP_PER_CPU_FAULT_INFO, %g3
77 /* Get DEV mondo queue base phys address into %g5. */
78 ldx [%g3 + TRAP_PER_CPU_DEV_MONDO_PA], %g5
80 /* Load IVEC into %g3. */
81 ldxa [%g5 + %g2] ASI_PHYS_USE_EC, %g3
84 /* XXX There can be a full 64-byte block of data here.
85 * XXX This is how we can get at MSI vector data.
86 * XXX Current we do not capture this, but when we do we'll
87 * XXX need to add a 64-byte storage area in the struct ino_bucket
88 * XXX or the struct irq_desc.
91 /* Update queue head pointer, this frees up some registers. */
92 sethi %hi(8192 - 1), %g4
93 or %g4, %lo(8192 - 1), %g4
96 mov INTRQ_DEVICE_MONDO_HEAD, %g4
97 stxa %g2, [%g4] ASI_QUEUE
100 /* Get &__irq_work[smp_processor_id()] into %g1. */
101 sethi %hi(__irq_work), %g4
103 or %g4, %lo(__irq_work), %g4
106 /* Get &ivector_table[IVEC] into %g4. */
107 sethi %hi(ivector_table), %g4
109 or %g4, %lo(ivector_table), %g4
112 /* Load IRQ %pil into %g5. */
113 ldub [%g4 + 0x04], %g5
115 /* Insert ivector_table[] entry into __irq_work[] queue. */
117 lduw [%g1 + %g3], %g2 /* g2 = irq_work(cpu, pil) */
118 stw %g2, [%g4 + 0x00] /* bucket->irq_chain = g2 */
119 stw %g4, [%g1 + %g3] /* irq_work(cpu, pil) = bucket */
121 /* Signal the interrupt by setting (1 << pil) in %softint. */
124 wr %g2, 0x0, %set_softint
126 sun4v_dev_mondo_queue_empty:
130 /* Head offset in %g2, tail offset in %g4. */
131 mov INTRQ_RESUM_MONDO_HEAD, %g2
132 ldxa [%g2] ASI_QUEUE, %g2
133 mov INTRQ_RESUM_MONDO_TAIL, %g4
134 ldxa [%g4] ASI_QUEUE, %g4
136 be,pn %xcc, sun4v_res_mondo_queue_empty
139 /* Get &trap_block[smp_processor_id()] into %g3. */
140 ldxa [%g0] ASI_SCRATCHPAD, %g3
141 sub %g3, TRAP_PER_CPU_FAULT_INFO, %g3
143 /* Get RES mondo queue base phys address into %g5. */
144 ldx [%g3 + TRAP_PER_CPU_RESUM_MONDO_PA], %g5
146 /* Get RES kernel buffer base phys address into %g7. */
147 ldx [%g3 + TRAP_PER_CPU_RESUM_KBUF_PA], %g7
149 /* If the first word is non-zero, queue is full. */
150 ldxa [%g7 + %g2] ASI_PHYS_USE_EC, %g1
151 brnz,pn %g1, sun4v_res_mondo_queue_full
154 /* Remember this entry's offset in %g1. */
157 /* Copy 64-byte queue entry into kernel buffer. */
158 ldxa [%g5 + %g2] ASI_PHYS_USE_EC, %g3
159 stxa %g3, [%g7 + %g2] ASI_PHYS_USE_EC
161 ldxa [%g5 + %g2] ASI_PHYS_USE_EC, %g3
162 stxa %g3, [%g7 + %g2] ASI_PHYS_USE_EC
164 ldxa [%g5 + %g2] ASI_PHYS_USE_EC, %g3
165 stxa %g3, [%g7 + %g2] ASI_PHYS_USE_EC
167 ldxa [%g5 + %g2] ASI_PHYS_USE_EC, %g3
168 stxa %g3, [%g7 + %g2] ASI_PHYS_USE_EC
170 ldxa [%g5 + %g2] ASI_PHYS_USE_EC, %g3
171 stxa %g3, [%g7 + %g2] ASI_PHYS_USE_EC
173 ldxa [%g5 + %g2] ASI_PHYS_USE_EC, %g3
174 stxa %g3, [%g7 + %g2] ASI_PHYS_USE_EC
176 ldxa [%g5 + %g2] ASI_PHYS_USE_EC, %g3
177 stxa %g3, [%g7 + %g2] ASI_PHYS_USE_EC
179 ldxa [%g5 + %g2] ASI_PHYS_USE_EC, %g3
180 stxa %g3, [%g7 + %g2] ASI_PHYS_USE_EC
183 /* Update queue head pointer. */
184 sethi %hi(8192 - 1), %g4
185 or %g4, %lo(8192 - 1), %g4
188 mov INTRQ_RESUM_MONDO_HEAD, %g4
189 stxa %g2, [%g4] ASI_QUEUE
192 /* Disable interrupts and save register state so we can call
193 * C code. The etrap handling will leave %g4 in %l4 for us
199 ba,pt %xcc, etrap_irq
203 add %sp, PTREGS_OFF, %o0
204 call sun4v_resum_error
207 /* Return from trap. */
208 ba,pt %xcc, rtrap_irq
211 sun4v_res_mondo_queue_empty:
214 sun4v_res_mondo_queue_full:
215 /* The queue is full, consolidate our damage by setting
216 * the head equal to the tail. We'll just trap again otherwise.
217 * Call C code to log the event.
219 mov INTRQ_RESUM_MONDO_HEAD, %g2
220 stxa %g4, [%g2] ASI_QUEUE
225 ba,pt %xcc, etrap_irq
228 call sun4v_resum_overflow
229 add %sp, PTREGS_OFF, %o0
231 ba,pt %xcc, rtrap_irq
235 /* Head offset in %g2, tail offset in %g4. */
236 mov INTRQ_NONRESUM_MONDO_HEAD, %g2
237 ldxa [%g2] ASI_QUEUE, %g2
238 mov INTRQ_NONRESUM_MONDO_TAIL, %g4
239 ldxa [%g4] ASI_QUEUE, %g4
241 be,pn %xcc, sun4v_nonres_mondo_queue_empty
244 /* Get &trap_block[smp_processor_id()] into %g3. */
245 ldxa [%g0] ASI_SCRATCHPAD, %g3
246 sub %g3, TRAP_PER_CPU_FAULT_INFO, %g3
248 /* Get RES mondo queue base phys address into %g5. */
249 ldx [%g3 + TRAP_PER_CPU_NONRESUM_MONDO_PA], %g5
251 /* Get RES kernel buffer base phys address into %g7. */
252 ldx [%g3 + TRAP_PER_CPU_NONRESUM_KBUF_PA], %g7
254 /* If the first word is non-zero, queue is full. */
255 ldxa [%g7 + %g2] ASI_PHYS_USE_EC, %g1
256 brnz,pn %g1, sun4v_nonres_mondo_queue_full
259 /* Remember this entry's offset in %g1. */
262 /* Copy 64-byte queue entry into kernel buffer. */
263 ldxa [%g5 + %g2] ASI_PHYS_USE_EC, %g3
264 stxa %g3, [%g7 + %g2] ASI_PHYS_USE_EC
266 ldxa [%g5 + %g2] ASI_PHYS_USE_EC, %g3
267 stxa %g3, [%g7 + %g2] ASI_PHYS_USE_EC
269 ldxa [%g5 + %g2] ASI_PHYS_USE_EC, %g3
270 stxa %g3, [%g7 + %g2] ASI_PHYS_USE_EC
272 ldxa [%g5 + %g2] ASI_PHYS_USE_EC, %g3
273 stxa %g3, [%g7 + %g2] ASI_PHYS_USE_EC
275 ldxa [%g5 + %g2] ASI_PHYS_USE_EC, %g3
276 stxa %g3, [%g7 + %g2] ASI_PHYS_USE_EC
278 ldxa [%g5 + %g2] ASI_PHYS_USE_EC, %g3
279 stxa %g3, [%g7 + %g2] ASI_PHYS_USE_EC
281 ldxa [%g5 + %g2] ASI_PHYS_USE_EC, %g3
282 stxa %g3, [%g7 + %g2] ASI_PHYS_USE_EC
284 ldxa [%g5 + %g2] ASI_PHYS_USE_EC, %g3
285 stxa %g3, [%g7 + %g2] ASI_PHYS_USE_EC
288 /* Update queue head pointer. */
289 sethi %hi(8192 - 1), %g4
290 or %g4, %lo(8192 - 1), %g4
293 mov INTRQ_NONRESUM_MONDO_HEAD, %g4
294 stxa %g2, [%g4] ASI_QUEUE
297 /* Disable interrupts and save register state so we can call
298 * C code. The etrap handling will leave %g4 in %l4 for us
304 ba,pt %xcc, etrap_irq
308 add %sp, PTREGS_OFF, %o0
309 call sun4v_nonresum_error
312 /* Return from trap. */
313 ba,pt %xcc, rtrap_irq
316 sun4v_nonres_mondo_queue_empty:
319 sun4v_nonres_mondo_queue_full:
320 /* The queue is full, consolidate our damage by setting
321 * the head equal to the tail. We'll just trap again otherwise.
322 * Call C code to log the event.
324 mov INTRQ_NONRESUM_MONDO_HEAD, %g2
325 stxa %g4, [%g2] ASI_QUEUE
330 ba,pt %xcc, etrap_irq
333 call sun4v_nonresum_overflow
334 add %sp, PTREGS_OFF, %o0
336 ba,pt %xcc, rtrap_irq