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>
14 /* Head offset in %g2, tail offset in %g4.
15 * If they are the same, no work.
17 mov INTRQ_CPU_MONDO_HEAD, %g2
18 ldxa [%g2] ASI_QUEUE, %g2
19 mov INTRQ_CPU_MONDO_TAIL, %g4
20 ldxa [%g4] ASI_QUEUE, %g4
22 be,pn %xcc, sun4v_cpu_mondo_queue_empty
25 /* Get &trap_block[smp_processor_id()] into %g3. */
26 ldxa [%g0] ASI_SCRATCHPAD, %g3
27 sub %g3, TRAP_PER_CPU_FAULT_INFO, %g3
29 /* Get CPU mondo queue base phys address into %g7. */
30 ldx [%g3 + TRAP_PER_CPU_CPU_MONDO_PA], %g7
32 /* Now get the cross-call arguments and handler PC, same
35 * 1st 64-bit word: low half is 32-bit PC, put into %g3 and jmpl to it
36 * high half is context arg to MMU flushes, into %g5
37 * 2nd 64-bit word: 64-bit arg, load into %g1
38 * 3rd 64-bit word: 64-bit arg, load into %g7
40 ldxa [%g7 + %g2] ASI_PHYS_USE_EC, %g3
43 ldxa [%g7 + %g2] ASI_PHYS_USE_EC, %g1
46 ldxa [%g7 + %g2] ASI_PHYS_USE_EC, %g7
47 add %g2, 0x40 - 0x8 - 0x8, %g2
49 /* Update queue head pointer. */
50 sethi %hi(8192 - 1), %g4
51 or %g4, %lo(8192 - 1), %g4
54 mov INTRQ_CPU_MONDO_HEAD, %g4
55 stxa %g2, [%g4] ASI_QUEUE
61 sun4v_cpu_mondo_queue_empty:
65 /* Head offset in %g2, tail offset in %g4. */
66 mov INTRQ_DEVICE_MONDO_HEAD, %g2
67 ldxa [%g2] ASI_QUEUE, %g2
68 mov INTRQ_DEVICE_MONDO_TAIL, %g4
69 ldxa [%g4] ASI_QUEUE, %g4
71 be,pn %xcc, sun4v_dev_mondo_queue_empty
74 /* Get &trap_block[smp_processor_id()] into %g3. */
75 ldxa [%g0] ASI_SCRATCHPAD, %g3
76 sub %g3, TRAP_PER_CPU_FAULT_INFO, %g3
78 /* Get DEV mondo queue base phys address into %g5. */
79 ldx [%g3 + TRAP_PER_CPU_DEV_MONDO_PA], %g5
81 /* Load IVEC into %g3. */
82 ldxa [%g5 + %g2] ASI_PHYS_USE_EC, %g3
85 /* XXX There can be a full 64-byte block of data here.
86 * XXX This is how we can get at MSI vector data.
87 * XXX Current we do not capture this, but when we do we'll
88 * XXX need to add a 64-byte storage area in the struct ino_bucket
89 * XXX or the struct irq_desc.
92 /* Update queue head pointer, this frees up some registers. */
93 sethi %hi(8192 - 1), %g4
94 or %g4, %lo(8192 - 1), %g4
97 mov INTRQ_DEVICE_MONDO_HEAD, %g4
98 stxa %g2, [%g4] ASI_QUEUE
101 /* Get &__irq_work[smp_processor_id()] into %g1. */
102 TRAP_LOAD_IRQ_WORK(%g1, %g4)
104 /* Get &ivector_table[IVEC] into %g4. */
105 sethi %hi(ivector_table), %g4
107 or %g4, %lo(ivector_table), %g4
110 /* Insert ivector_table[] entry into __irq_work[] queue. */
111 lduw [%g1], %g2 /* g2 = irq_work(cpu) */
112 stw %g2, [%g4 + 0x00] /* bucket->irq_chain = g2 */
113 stw %g4, [%g1] /* irq_work(cpu) = bucket */
115 /* Signal the interrupt by setting (1 << pil) in %softint. */
116 wr %g0, 1 << PIL_DEVICE_IRQ, %set_softint
118 sun4v_dev_mondo_queue_empty:
122 /* Head offset in %g2, tail offset in %g4. */
123 mov INTRQ_RESUM_MONDO_HEAD, %g2
124 ldxa [%g2] ASI_QUEUE, %g2
125 mov INTRQ_RESUM_MONDO_TAIL, %g4
126 ldxa [%g4] ASI_QUEUE, %g4
128 be,pn %xcc, sun4v_res_mondo_queue_empty
131 /* Get &trap_block[smp_processor_id()] into %g3. */
132 ldxa [%g0] ASI_SCRATCHPAD, %g3
133 sub %g3, TRAP_PER_CPU_FAULT_INFO, %g3
135 /* Get RES mondo queue base phys address into %g5. */
136 ldx [%g3 + TRAP_PER_CPU_RESUM_MONDO_PA], %g5
138 /* Get RES kernel buffer base phys address into %g7. */
139 ldx [%g3 + TRAP_PER_CPU_RESUM_KBUF_PA], %g7
141 /* If the first word is non-zero, queue is full. */
142 ldxa [%g7 + %g2] ASI_PHYS_USE_EC, %g1
143 brnz,pn %g1, sun4v_res_mondo_queue_full
146 /* Remember this entry's offset in %g1. */
149 /* Copy 64-byte queue entry into kernel buffer. */
150 ldxa [%g5 + %g2] ASI_PHYS_USE_EC, %g3
151 stxa %g3, [%g7 + %g2] ASI_PHYS_USE_EC
153 ldxa [%g5 + %g2] ASI_PHYS_USE_EC, %g3
154 stxa %g3, [%g7 + %g2] ASI_PHYS_USE_EC
156 ldxa [%g5 + %g2] ASI_PHYS_USE_EC, %g3
157 stxa %g3, [%g7 + %g2] ASI_PHYS_USE_EC
159 ldxa [%g5 + %g2] ASI_PHYS_USE_EC, %g3
160 stxa %g3, [%g7 + %g2] ASI_PHYS_USE_EC
162 ldxa [%g5 + %g2] ASI_PHYS_USE_EC, %g3
163 stxa %g3, [%g7 + %g2] ASI_PHYS_USE_EC
165 ldxa [%g5 + %g2] ASI_PHYS_USE_EC, %g3
166 stxa %g3, [%g7 + %g2] ASI_PHYS_USE_EC
168 ldxa [%g5 + %g2] ASI_PHYS_USE_EC, %g3
169 stxa %g3, [%g7 + %g2] ASI_PHYS_USE_EC
171 ldxa [%g5 + %g2] ASI_PHYS_USE_EC, %g3
172 stxa %g3, [%g7 + %g2] ASI_PHYS_USE_EC
175 /* Update queue head pointer. */
176 sethi %hi(8192 - 1), %g4
177 or %g4, %lo(8192 - 1), %g4
180 mov INTRQ_RESUM_MONDO_HEAD, %g4
181 stxa %g2, [%g4] ASI_QUEUE
184 /* Disable interrupts and save register state so we can call
185 * C code. The etrap handling will leave %g4 in %l4 for us
191 ba,pt %xcc, etrap_irq
195 add %sp, PTREGS_OFF, %o0
196 call sun4v_resum_error
199 /* Return from trap. */
200 ba,pt %xcc, rtrap_irq
203 sun4v_res_mondo_queue_empty:
206 sun4v_res_mondo_queue_full:
207 /* The queue is full, consolidate our damage by setting
208 * the head equal to the tail. We'll just trap again otherwise.
209 * Call C code to log the event.
211 mov INTRQ_RESUM_MONDO_HEAD, %g2
212 stxa %g4, [%g2] ASI_QUEUE
217 ba,pt %xcc, etrap_irq
220 call sun4v_resum_overflow
221 add %sp, PTREGS_OFF, %o0
223 ba,pt %xcc, rtrap_irq
227 /* Head offset in %g2, tail offset in %g4. */
228 mov INTRQ_NONRESUM_MONDO_HEAD, %g2
229 ldxa [%g2] ASI_QUEUE, %g2
230 mov INTRQ_NONRESUM_MONDO_TAIL, %g4
231 ldxa [%g4] ASI_QUEUE, %g4
233 be,pn %xcc, sun4v_nonres_mondo_queue_empty
236 /* Get &trap_block[smp_processor_id()] into %g3. */
237 ldxa [%g0] ASI_SCRATCHPAD, %g3
238 sub %g3, TRAP_PER_CPU_FAULT_INFO, %g3
240 /* Get RES mondo queue base phys address into %g5. */
241 ldx [%g3 + TRAP_PER_CPU_NONRESUM_MONDO_PA], %g5
243 /* Get RES kernel buffer base phys address into %g7. */
244 ldx [%g3 + TRAP_PER_CPU_NONRESUM_KBUF_PA], %g7
246 /* If the first word is non-zero, queue is full. */
247 ldxa [%g7 + %g2] ASI_PHYS_USE_EC, %g1
248 brnz,pn %g1, sun4v_nonres_mondo_queue_full
251 /* Remember this entry's offset in %g1. */
254 /* Copy 64-byte queue entry into kernel buffer. */
255 ldxa [%g5 + %g2] ASI_PHYS_USE_EC, %g3
256 stxa %g3, [%g7 + %g2] ASI_PHYS_USE_EC
258 ldxa [%g5 + %g2] ASI_PHYS_USE_EC, %g3
259 stxa %g3, [%g7 + %g2] ASI_PHYS_USE_EC
261 ldxa [%g5 + %g2] ASI_PHYS_USE_EC, %g3
262 stxa %g3, [%g7 + %g2] ASI_PHYS_USE_EC
264 ldxa [%g5 + %g2] ASI_PHYS_USE_EC, %g3
265 stxa %g3, [%g7 + %g2] ASI_PHYS_USE_EC
267 ldxa [%g5 + %g2] ASI_PHYS_USE_EC, %g3
268 stxa %g3, [%g7 + %g2] ASI_PHYS_USE_EC
270 ldxa [%g5 + %g2] ASI_PHYS_USE_EC, %g3
271 stxa %g3, [%g7 + %g2] ASI_PHYS_USE_EC
273 ldxa [%g5 + %g2] ASI_PHYS_USE_EC, %g3
274 stxa %g3, [%g7 + %g2] ASI_PHYS_USE_EC
276 ldxa [%g5 + %g2] ASI_PHYS_USE_EC, %g3
277 stxa %g3, [%g7 + %g2] ASI_PHYS_USE_EC
280 /* Update queue head pointer. */
281 sethi %hi(8192 - 1), %g4
282 or %g4, %lo(8192 - 1), %g4
285 mov INTRQ_NONRESUM_MONDO_HEAD, %g4
286 stxa %g2, [%g4] ASI_QUEUE
289 /* Disable interrupts and save register state so we can call
290 * C code. The etrap handling will leave %g4 in %l4 for us
296 ba,pt %xcc, etrap_irq
300 add %sp, PTREGS_OFF, %o0
301 call sun4v_nonresum_error
304 /* Return from trap. */
305 ba,pt %xcc, rtrap_irq
308 sun4v_nonres_mondo_queue_empty:
311 sun4v_nonres_mondo_queue_full:
312 /* The queue is full, consolidate our damage by setting
313 * the head equal to the tail. We'll just trap again otherwise.
314 * Call C code to log the event.
316 mov INTRQ_NONRESUM_MONDO_HEAD, %g2
317 stxa %g4, [%g2] ASI_QUEUE
322 ba,pt %xcc, etrap_irq
325 call sun4v_nonresum_overflow
326 add %sp, PTREGS_OFF, %o0
328 ba,pt %xcc, rtrap_irq