isa_irq.S revision 1.1.14.2 1 1.1.14.2 jdolecek /* $NetBSD: isa_irq.S,v 1.1.14.2 2002/06/23 17:41:21 jdolecek Exp $ */
2 1.1.14.2 jdolecek
3 1.1.14.2 jdolecek /*
4 1.1.14.2 jdolecek * Copyright 1997
5 1.1.14.2 jdolecek * Digital Equipment Corporation. All rights reserved.
6 1.1.14.2 jdolecek *
7 1.1.14.2 jdolecek * This software is furnished under license and may be used and
8 1.1.14.2 jdolecek * copied only in accordance with the following terms and conditions.
9 1.1.14.2 jdolecek * Subject to these conditions, you may download, copy, install,
10 1.1.14.2 jdolecek * use, modify and distribute this software in source and/or binary
11 1.1.14.2 jdolecek * form. No title or ownership is transferred hereby.
12 1.1.14.2 jdolecek *
13 1.1.14.2 jdolecek * 1) Any source code used, modified or distributed must reproduce
14 1.1.14.2 jdolecek * and retain this copyright notice and list of conditions as
15 1.1.14.2 jdolecek * they appear in the source file.
16 1.1.14.2 jdolecek *
17 1.1.14.2 jdolecek * 2) No right is granted to use any trade name, trademark, or logo of
18 1.1.14.2 jdolecek * Digital Equipment Corporation. Neither the "Digital Equipment
19 1.1.14.2 jdolecek * Corporation" name nor any trademark or logo of Digital Equipment
20 1.1.14.2 jdolecek * Corporation may be used to endorse or promote products derived
21 1.1.14.2 jdolecek * from this software without the prior written permission of
22 1.1.14.2 jdolecek * Digital Equipment Corporation.
23 1.1.14.2 jdolecek *
24 1.1.14.2 jdolecek * 3) This software is provided "AS-IS" and any express or implied
25 1.1.14.2 jdolecek * warranties, including but not limited to, any implied warranties
26 1.1.14.2 jdolecek * of merchantability, fitness for a particular purpose, or
27 1.1.14.2 jdolecek * non-infringement are disclaimed. In no event shall DIGITAL be
28 1.1.14.2 jdolecek * liable for any damages whatsoever, and in particular, DIGITAL
29 1.1.14.2 jdolecek * shall not be liable for special, indirect, consequential, or
30 1.1.14.2 jdolecek * incidental damages or damages for lost profits, loss of
31 1.1.14.2 jdolecek * revenue or loss of use, whether such damages arise in contract,
32 1.1.14.2 jdolecek * negligence, tort, under statute, in equity, at law or otherwise,
33 1.1.14.2 jdolecek * even if advised of the possibility of such damage.
34 1.1.14.2 jdolecek */
35 1.1.14.2 jdolecek
36 1.1.14.2 jdolecek /*
37 1.1.14.2 jdolecek * Copyright (c) 1994-1998 Mark Brinicombe.
38 1.1.14.2 jdolecek * Copyright (c) 1994 Brini.
39 1.1.14.2 jdolecek * All rights reserved.
40 1.1.14.2 jdolecek *
41 1.1.14.2 jdolecek * This code is derived from software written for Brini by Mark Brinicombe
42 1.1.14.2 jdolecek *
43 1.1.14.2 jdolecek * Redistribution and use in source and binary forms, with or without
44 1.1.14.2 jdolecek * modification, are permitted provided that the following conditions
45 1.1.14.2 jdolecek * are met:
46 1.1.14.2 jdolecek * 1. Redistributions of source code must retain the above copyright
47 1.1.14.2 jdolecek * notice, this list of conditions and the following disclaimer.
48 1.1.14.2 jdolecek * 2. Redistributions in binary form must reproduce the above copyright
49 1.1.14.2 jdolecek * notice, this list of conditions and the following disclaimer in the
50 1.1.14.2 jdolecek * documentation and/or other materials provided with the distribution.
51 1.1.14.2 jdolecek * 3. All advertising materials mentioning features or use of this software
52 1.1.14.2 jdolecek * must display the following acknowledgement:
53 1.1.14.2 jdolecek * This product includes software developed by Mark Brinicombe
54 1.1.14.2 jdolecek * for the NetBSD Project.
55 1.1.14.2 jdolecek * 4. The name of the company nor the name of the author may be used to
56 1.1.14.2 jdolecek * endorse or promote products derived from this software without specific
57 1.1.14.2 jdolecek * prior written permission.
58 1.1.14.2 jdolecek *
59 1.1.14.2 jdolecek * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
60 1.1.14.2 jdolecek * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
61 1.1.14.2 jdolecek * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
62 1.1.14.2 jdolecek * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
63 1.1.14.2 jdolecek * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
64 1.1.14.2 jdolecek * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
65 1.1.14.2 jdolecek * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
66 1.1.14.2 jdolecek * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
67 1.1.14.2 jdolecek * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
68 1.1.14.2 jdolecek * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
69 1.1.14.2 jdolecek *
70 1.1.14.2 jdolecek * from: irq.S
71 1.1.14.2 jdolecek *
72 1.1.14.2 jdolecek * Low level irq and fiq handlers
73 1.1.14.2 jdolecek *
74 1.1.14.2 jdolecek * Created : 27/09/94
75 1.1.14.2 jdolecek */
76 1.1.14.2 jdolecek
77 1.1.14.2 jdolecek #include "opt_irqstats.h"
78 1.1.14.2 jdolecek
79 1.1.14.2 jdolecek #include "assym.h"
80 1.1.14.2 jdolecek #include <machine/asm.h>
81 1.1.14.2 jdolecek #include <machine/cpu.h>
82 1.1.14.2 jdolecek #include <machine/frame.h>
83 1.1.14.2 jdolecek #include <dev/isa/isareg.h>
84 1.1.14.2 jdolecek #include <shark/isa/icu.h>
85 1.1.14.2 jdolecek #include <machine/irqhandler.h>
86 1.1.14.2 jdolecek
87 1.1.14.2 jdolecek .text
88 1.1.14.2 jdolecek .align 0
89 1.1.14.2 jdolecek
90 1.1.14.2 jdolecek /*
91 1.1.14.2 jdolecek *
92 1.1.14.2 jdolecek * irq_entry
93 1.1.14.2 jdolecek *
94 1.1.14.2 jdolecek * Main entry point for the IRQ vector
95 1.1.14.2 jdolecek *
96 1.1.14.2 jdolecek * This function reads the irq request bits in the IOMD registers
97 1.1.14.2 jdolecek * IRQRQA, IRQRQB and DMARQ
98 1.1.14.2 jdolecek * It then calls an installed handler for each bit that is set.
99 1.1.14.2 jdolecek * The function stray_irqhandler is called if a handler is not defined
100 1.1.14.2 jdolecek * for a particular interrupt.
101 1.1.14.2 jdolecek * If a interrupt handler is found then it is called with r0 containing
102 1.1.14.2 jdolecek * the argument defined in the handler structure. If the field ih_arg
103 1.1.14.2 jdolecek * is zero then a pointer to the IRQ frame on the stack is passed instead.
104 1.1.14.2 jdolecek */
105 1.1.14.2 jdolecek
106 1.1.14.2 jdolecek Ldisabled_mask:
107 1.1.14.2 jdolecek .word _C_LABEL(disabled_mask)
108 1.1.14.2 jdolecek
109 1.1.14.2 jdolecek Lcurrent_spl_level:
110 1.1.14.2 jdolecek .word _C_LABEL(current_spl_level)
111 1.1.14.2 jdolecek
112 1.1.14.2 jdolecek Lcurrent_intr_depth:
113 1.1.14.2 jdolecek .word _C_LABEL(current_intr_depth)
114 1.1.14.2 jdolecek
115 1.1.14.2 jdolecek Lvam_io_data:
116 1.1.14.2 jdolecek .word _C_LABEL(isa_io_bs_tag)
117 1.1.14.2 jdolecek
118 1.1.14.2 jdolecek Lspl_masks:
119 1.1.14.2 jdolecek .word _C_LABEL(spl_masks)
120 1.1.14.2 jdolecek
121 1.1.14.2 jdolecek /*
122 1.1.14.2 jdolecek * Register usage
123 1.1.14.2 jdolecek *
124 1.1.14.2 jdolecek * r6 - Address of current handler
125 1.1.14.2 jdolecek * r7 - Pointer to handler pointer list
126 1.1.14.2 jdolecek * r8 - Current IRQ requests.
127 1.1.14.2 jdolecek * r9 - Used to count through possible IRQ bits.
128 1.1.14.2 jdolecek * r10 - Base address of IOMD
129 1.1.14.2 jdolecek */
130 1.1.14.2 jdolecek
131 1.1.14.2 jdolecek /* Some documentation is in isa_machdep.c */
132 1.1.14.2 jdolecek ASENTRY_NP(irq_entry)
133 1.1.14.2 jdolecek sub lr, lr, #0x00000004 /* Adjust the lr */
134 1.1.14.2 jdolecek
135 1.1.14.2 jdolecek PUSHFRAMEINSVC /* Push an interrupt frame */
136 1.1.14.2 jdolecek
137 1.1.14.2 jdolecek /* Load r8 with the ISA 8259 irqs */
138 1.1.14.2 jdolecek /* r8 <- irq's pending [15:0] */
139 1.1.14.2 jdolecek
140 1.1.14.2 jdolecek /* address of 8259 #1 */
141 1.1.14.2 jdolecek ldr r0, Lvam_io_data
142 1.1.14.2 jdolecek ldr r0, [r0]
143 1.1.14.2 jdolecek ldrb r8, [r0, #IO_ICU1] /* ocw3 = irr */
144 1.1.14.2 jdolecek
145 1.1.14.2 jdolecek /* clear the IRR bits that are currently masked. */
146 1.1.14.2 jdolecek ldr r2, Li8259_mask
147 1.1.14.2 jdolecek ldr r2, [r2]
148 1.1.14.2 jdolecek mvn r2, r2 /* disabled -> enabled */
149 1.1.14.2 jdolecek
150 1.1.14.2 jdolecek /* address of 8259 #2 */
151 1.1.14.2 jdolecek tst r2, #(1 << IRQ_SLAVE) /* if slave is enabled */
152 1.1.14.2 jdolecek tstne r8, #(1 << IRQ_SLAVE) /* anything from slave? */
153 1.1.14.2 jdolecek ldrneb r1, [r0, #IO_ICU2] /* ocw3 = irr */
154 1.1.14.2 jdolecek orrne r8, r8, r1, lsl #8
155 1.1.14.2 jdolecek
156 1.1.14.2 jdolecek and r8, r8, r2 /* clear disabled */
157 1.1.14.2 jdolecek
158 1.1.14.2 jdolecek /* clear IRQ 2, which is only used for slave 8259 */
159 1.1.14.2 jdolecek bic r8, r8, #(1 << IRQ_SLAVE)
160 1.1.14.2 jdolecek
161 1.1.14.2 jdolecek /*
162 1.1.14.2 jdolecek * Note that we have entered the IRQ handler.
163 1.1.14.2 jdolecek * We are in SVC mode so we cannot use the processor mode
164 1.1.14.2 jdolecek * to determine if we are in an IRQ. Instead we will count the
165 1.1.14.2 jdolecek * each time the interrupt handler is nested.
166 1.1.14.2 jdolecek */
167 1.1.14.2 jdolecek
168 1.1.14.2 jdolecek ldr r0, Lcurrent_intr_depth
169 1.1.14.2 jdolecek ldr r1, [r0]
170 1.1.14.2 jdolecek add r1, r1, #1
171 1.1.14.2 jdolecek str r1, [r0]
172 1.1.14.2 jdolecek
173 1.1.14.2 jdolecek /* Block the current requested interrupts */
174 1.1.14.2 jdolecek
175 1.1.14.2 jdolecek ldr r1, Ldisabled_mask
176 1.1.14.2 jdolecek ldr r0, [r1]
177 1.1.14.2 jdolecek stmfd sp!, {r0}
178 1.1.14.2 jdolecek orr r0, r0, r8
179 1.1.14.2 jdolecek
180 1.1.14.2 jdolecek /*
181 1.1.14.2 jdolecek * Need to block all interrupts at the IPL or lower for
182 1.1.14.2 jdolecek * all asserted interrupts.
183 1.1.14.2 jdolecek * This basically emulates hardware interrupt priority levels.
184 1.1.14.2 jdolecek * Means we need to go through the interrupt mask and for
185 1.1.14.2 jdolecek * every asserted interrupt we need to mask out all other
186 1.1.14.2 jdolecek * interrupts at the same or lower IPL.
187 1.1.14.2 jdolecek * If only we could wait until the main loop but we need to sort
188 1.1.14.2 jdolecek * this out first so interrupts can be re-enabled.
189 1.1.14.2 jdolecek *
190 1.1.14.2 jdolecek * This would benefit from a special ffs type routine
191 1.1.14.2 jdolecek */
192 1.1.14.2 jdolecek
193 1.1.14.2 jdolecek mov r9, #(_SPL_LEVELS - 1)
194 1.1.14.2 jdolecek ldr r7, Lspl_masks
195 1.1.14.2 jdolecek
196 1.1.14.2 jdolecek Lfind_highest_ipl:
197 1.1.14.2 jdolecek ldr r2, [r7, r9, lsl #2]
198 1.1.14.2 jdolecek tst r8, r2
199 1.1.14.2 jdolecek subeq r9, r9, #1
200 1.1.14.2 jdolecek beq Lfind_highest_ipl
201 1.1.14.2 jdolecek
202 1.1.14.2 jdolecek /* r9 = SPL level of highest priority interrupt */
203 1.1.14.2 jdolecek add r9, r9, #1
204 1.1.14.2 jdolecek ldr r2, [r7, r9, lsl #2]
205 1.1.14.2 jdolecek mvn r2, r2
206 1.1.14.2 jdolecek orr r0, r0, r2
207 1.1.14.2 jdolecek
208 1.1.14.2 jdolecek str r0, [r1]
209 1.1.14.2 jdolecek
210 1.1.14.2 jdolecek ldr r0, Lcurrent_spl_level
211 1.1.14.2 jdolecek ldr r1, [r0]
212 1.1.14.2 jdolecek str r9, [r0]
213 1.1.14.2 jdolecek stmfd sp!, {r1}
214 1.1.14.2 jdolecek
215 1.1.14.2 jdolecek /* Update the IOMD irq masks */
216 1.1.14.2 jdolecek bl _C_LABEL(irq_setmasks)
217 1.1.14.2 jdolecek
218 1.1.14.2 jdolecek mrs r0, cpsr_all /* Enable IRQ's */
219 1.1.14.2 jdolecek bic r0, r0, #I32_bit
220 1.1.14.2 jdolecek msr cpsr_all, r0
221 1.1.14.2 jdolecek
222 1.1.14.2 jdolecek ldr r7, [pc, #Lirqhandlers - . - 8]
223 1.1.14.2 jdolecek mov r9, #0x00000001
224 1.1.14.2 jdolecek
225 1.1.14.2 jdolecek irqloop:
226 1.1.14.2 jdolecek /* This would benefit from a special ffs type routine */
227 1.1.14.2 jdolecek tst r8, r9 /* Is a bit set ? */
228 1.1.14.2 jdolecek beq nextirq /* No ? try next bit */
229 1.1.14.2 jdolecek
230 1.1.14.2 jdolecek ldr r6, [r7] /* Get address of first handler structure */
231 1.1.14.2 jdolecek
232 1.1.14.2 jdolecek teq r6, #0x00000000 /* Do we have a handler */
233 1.1.14.2 jdolecek moveq r0, r8 /* IRQ requests as arg 0 */
234 1.1.14.2 jdolecek beq _C_LABEL(stray_irqhandler) /* call special handler */
235 1.1.14.2 jdolecek
236 1.1.14.2 jdolecek ldr r0, Lcnt
237 1.1.14.2 jdolecek ldr r1, [r0, #(V_INTR)]
238 1.1.14.2 jdolecek add r1, r1, #0x00000001
239 1.1.14.2 jdolecek str r1, [r0, #(V_INTR)]
240 1.1.14.2 jdolecek
241 1.1.14.2 jdolecek /*
242 1.1.14.2 jdolecek * XXX: Should stats be accumlated for every interrupt routine called
243 1.1.14.2 jdolecek * or for every physical interrupt that is serviced.
244 1.1.14.2 jdolecek */
245 1.1.14.2 jdolecek
246 1.1.14.2 jdolecek #ifdef IRQSTATS
247 1.1.14.2 jdolecek ldr r0, Lintrcnt
248 1.1.14.2 jdolecek ldr r1, [r6, #(IH_NUM)]
249 1.1.14.2 jdolecek
250 1.1.14.2 jdolecek add r0, r0, r1, lsl #2
251 1.1.14.2 jdolecek ldr r1, [r0]
252 1.1.14.2 jdolecek add r1, r1, #0x00000001
253 1.1.14.2 jdolecek str r1, [r0]
254 1.1.14.2 jdolecek #endif /* IRQSTATS */
255 1.1.14.2 jdolecek
256 1.1.14.2 jdolecek irqchainloop:
257 1.1.14.2 jdolecek add lr, pc, #nextinchain - . - 8 /* return address */
258 1.1.14.2 jdolecek ldr r0, [r6, #(IH_ARG)] /* Get argument pointer */
259 1.1.14.2 jdolecek teq r0, #0x00000000 /* If arg is zero pass stack frame */
260 1.1.14.2 jdolecek addeq r0, sp, #8 /* ... stack frame */
261 1.1.14.2 jdolecek ldr pc, [r6, #(IH_FUNC)] /* Call handler */
262 1.1.14.2 jdolecek
263 1.1.14.2 jdolecek nextinchain:
264 1.1.14.2 jdolecek teq r0, #0x00000001 /* Was the irq serviced ? */
265 1.1.14.2 jdolecek beq irqdone
266 1.1.14.2 jdolecek
267 1.1.14.2 jdolecek ldr r6, [r6, #(IH_NEXT)]
268 1.1.14.2 jdolecek teq r6, #0x00000000
269 1.1.14.2 jdolecek bne irqchainloop
270 1.1.14.2 jdolecek
271 1.1.14.2 jdolecek irqdone:
272 1.1.14.2 jdolecek nextirq:
273 1.1.14.2 jdolecek add r7, r7, #0x00000004 /* update pointer to handlers */
274 1.1.14.2 jdolecek mov r9, r9, lsl #1 /* move on to next bit */
275 1.1.14.2 jdolecek teq r9, #(1 << 16) /* done the last bit ? */
276 1.1.14.2 jdolecek bne irqloop /* no - loop back. */
277 1.1.14.2 jdolecek
278 1.1.14.2 jdolecek ldmfd sp!, {r2}
279 1.1.14.2 jdolecek ldr r1, Lcurrent_spl_level
280 1.1.14.2 jdolecek str r2, [r1]
281 1.1.14.2 jdolecek
282 1.1.14.2 jdolecek /* Restore previous disabled mask */
283 1.1.14.2 jdolecek ldmfd sp!, {r2}
284 1.1.14.2 jdolecek ldr r1, Ldisabled_mask
285 1.1.14.2 jdolecek str r2, [r1]
286 1.1.14.2 jdolecek bl _C_LABEL(irq_setmasks)
287 1.1.14.2 jdolecek
288 1.1.14.2 jdolecek bl _C_LABEL(dosoftints) /* Handle the soft interrupts */
289 1.1.14.2 jdolecek
290 1.1.14.2 jdolecek /* Manage AST's. Maybe this should be done as a soft interrupt ? */
291 1.1.14.2 jdolecek ldr r0, [sp] /* Get the SPSR from stack */
292 1.1.14.2 jdolecek
293 1.1.14.2 jdolecek and r0, r0, #(PSR_MODE) /* Test for USR32 mode before the IRQ */
294 1.1.14.2 jdolecek teq r0, #(PSR_USR32_MODE)
295 1.1.14.2 jdolecek ldreq r0, Lastpending /* Do we have an AST pending ? */
296 1.1.14.2 jdolecek ldreq r1, [r0]
297 1.1.14.2 jdolecek teqeq r1, #0x00000001
298 1.1.14.2 jdolecek
299 1.1.14.2 jdolecek beq irqast /* call the AST handler */
300 1.1.14.2 jdolecek
301 1.1.14.2 jdolecek /* Kill IRQ's in preparation for exit */
302 1.1.14.2 jdolecek mrs r0, cpsr_all
303 1.1.14.2 jdolecek orr r0, r0, #(I32_bit)
304 1.1.14.2 jdolecek msr cpsr_all, r0
305 1.1.14.2 jdolecek
306 1.1.14.2 jdolecek /* Decrement the nest count */
307 1.1.14.2 jdolecek ldr r0, Lcurrent_intr_depth
308 1.1.14.2 jdolecek ldr r1, [r0]
309 1.1.14.2 jdolecek sub r1, r1, #1
310 1.1.14.2 jdolecek str r1, [r0]
311 1.1.14.2 jdolecek
312 1.1.14.2 jdolecek PULLFRAMEFROMSVCANDEXIT
313 1.1.14.2 jdolecek
314 1.1.14.2 jdolecek /* NOT REACHED */
315 1.1.14.2 jdolecek b . - 8
316 1.1.14.2 jdolecek
317 1.1.14.2 jdolecek /*
318 1.1.14.2 jdolecek * Ok, snag with current intr depth ...
319 1.1.14.2 jdolecek * If ast() calls mi_sleep() the current_intr_depth will not be
320 1.1.14.2 jdolecek * decremented until the process is woken up. This can result
321 1.1.14.2 jdolecek * in the system believing it is still in the interrupt handler.
322 1.1.14.2 jdolecek * If we are calling ast() then correct the current_intr_depth
323 1.1.14.2 jdolecek * before the call.
324 1.1.14.2 jdolecek */
325 1.1.14.2 jdolecek irqast:
326 1.1.14.2 jdolecek mov r1, #0x00000000 /* Clear ast_pending */
327 1.1.14.2 jdolecek str r1, [r0]
328 1.1.14.2 jdolecek
329 1.1.14.2 jdolecek /* Kill IRQ's so we atomically decrement current_intr_depth */
330 1.1.14.2 jdolecek mrs r2, cpsr_all
331 1.1.14.2 jdolecek orr r3, r2, #(I32_bit)
332 1.1.14.2 jdolecek msr cpsr_all, r3
333 1.1.14.2 jdolecek
334 1.1.14.2 jdolecek /* Decrement the nest count */
335 1.1.14.2 jdolecek ldr r0, Lcurrent_intr_depth
336 1.1.14.2 jdolecek ldr r1, [r0]
337 1.1.14.2 jdolecek sub r1, r1, #1
338 1.1.14.2 jdolecek str r1, [r0]
339 1.1.14.2 jdolecek
340 1.1.14.2 jdolecek /* Restore IRQ's */
341 1.1.14.2 jdolecek msr cpsr_all, r2
342 1.1.14.2 jdolecek
343 1.1.14.2 jdolecek mov r0, sp
344 1.1.14.2 jdolecek bl _C_LABEL(ast)
345 1.1.14.2 jdolecek
346 1.1.14.2 jdolecek /* Kill IRQ's in preparation for exit */
347 1.1.14.2 jdolecek mrs r0, cpsr_all
348 1.1.14.2 jdolecek orr r0, r0, #(I32_bit)
349 1.1.14.2 jdolecek msr cpsr_all, r0
350 1.1.14.2 jdolecek
351 1.1.14.2 jdolecek PULLFRAMEFROMSVCANDEXIT
352 1.1.14.2 jdolecek
353 1.1.14.2 jdolecek /* NOT REACHED */
354 1.1.14.2 jdolecek b . - 8
355 1.1.14.2 jdolecek
356 1.1.14.2 jdolecek
357 1.1.14.2 jdolecek Lspl_mask:
358 1.1.14.2 jdolecek .word _C_LABEL(spl_mask) /* irq's allowed at current spl level */
359 1.1.14.2 jdolecek
360 1.1.14.2 jdolecek Lcurrent_mask:
361 1.1.14.2 jdolecek .word _C_LABEL(current_mask) /* irq's that are usable */
362 1.1.14.2 jdolecek
363 1.1.14.2 jdolecek ENTRY(irq_setmasks)
364 1.1.14.2 jdolecek /* Disable interrupts */
365 1.1.14.2 jdolecek mrs r3, cpsr_all
366 1.1.14.2 jdolecek orr r1, r3, #(I32_bit)
367 1.1.14.2 jdolecek msr cpsr_all, r1
368 1.1.14.2 jdolecek
369 1.1.14.2 jdolecek /* Calculate interrupt mask */
370 1.1.14.2 jdolecek ldr r1, Lcurrent_mask /* All the enabled interrupts */
371 1.1.14.2 jdolecek ldrh r1, [r1] /* get hardware bits of mask */
372 1.1.14.2 jdolecek /* .word 0xe0d110b0 */ /* hand-assembled ldrh r1, [r1] */
373 1.1.14.2 jdolecek ldr r2, Lspl_mask /* Block due to current spl level */
374 1.1.14.2 jdolecek ldr r2, [r2]
375 1.1.14.2 jdolecek and r1, r1, r2
376 1.1.14.2 jdolecek ldr r2, Ldisabled_mask /* Block due to active interrupts */
377 1.1.14.2 jdolecek ldr r2, [r2]
378 1.1.14.2 jdolecek bic r1, r1, r2
379 1.1.14.2 jdolecek
380 1.1.14.2 jdolecek /* since 8259's are so slow to access, this code does everything
381 1.1.14.2 jdolecek possible to avoid them */
382 1.1.14.2 jdolecek
383 1.1.14.2 jdolecek /* get current mask: these are the bits */
384 1.1.14.2 jdolecek ldr r0, Li8259_mask
385 1.1.14.2 jdolecek ldr r2, [r0]
386 1.1.14.2 jdolecek /* r2 = 0000.0000.0000.0000.ZZZZ.ZZZZ.ZZZZ.ZZZZ */
387 1.1.14.2 jdolecek
388 1.1.14.2 jdolecek /* see if there's anything enabled on 8259 #2 */
389 1.1.14.2 jdolecek tst r1, #0xff00
390 1.1.14.2 jdolecek
391 1.1.14.2 jdolecek biceq r1, r1, #(1 << IRQ_SLAVE) /* no, so disable it */
392 1.1.14.2 jdolecek orrne r1, r1, #(1 << IRQ_SLAVE) /* yes, so enable it */
393 1.1.14.2 jdolecek /* eq => r1 = 0000.0000.0000.0000.0000.0000.MMMM.M0MM
394 1.1.14.2 jdolecek ne => r1 = 0000.0000.0000.0000.MMMM.MMMM.MMMM.M1MM */
395 1.1.14.2 jdolecek
396 1.1.14.2 jdolecek /* 8259 bit high => disable */
397 1.1.14.2 jdolecek mvn r1, r1
398 1.1.14.2 jdolecek /* eq => r1 = 1111.1111.1111.1111.1111.1111.YYYY.Y1YY
399 1.1.14.2 jdolecek ne => r1 = 1111.1111.1111.1111.YYYY.YYYY.YYYY.Y0YY
400 1.1.14.2 jdolecek (for each bit position Y = !M) */
401 1.1.14.2 jdolecek
402 1.1.14.2 jdolecek orreq r1, r2, r1, lsl #16
403 1.1.14.2 jdolecek /* eq => r1 = 1111.1111.YYYY.Y1YY.ZZZZ.ZZZZ.ZZZZ.ZZZZ
404 1.1.14.2 jdolecek ne => r1 = 1111.1111.1111.1111.YYYY.YYYY.YYYY.Y0YY */
405 1.1.14.2 jdolecek orreq r1, r1, #0x000000FF
406 1.1.14.2 jdolecek /* eq => r1 = 1111.1111.YYYY.Y1YY.ZZZZ.ZZZZ.1111.1111
407 1.1.14.2 jdolecek ne => r1 = 1111.1111.1111.1111.YYYY.YYYY.YYYY.Y0YY */
408 1.1.14.2 jdolecek and r1, r1, r1, lsr #16
409 1.1.14.2 jdolecek /* eq => r1 = 0000.0000.0000.0000.ZZZZ.ZZZZ.YYYY.Y1YY
410 1.1.14.2 jdolecek ne => r1 = 0000.0000.0000.0000.YYYY.YYYY.YYYY.Y0YY */
411 1.1.14.2 jdolecek
412 1.1.14.2 jdolecek /* if old = new, don't bother to set again.
413 1.1.14.2 jdolecek fast path to exit, since 8259's are so slow anyway */
414 1.1.14.2 jdolecek eors r2, r1, r2 /* which bits are different? */
415 1.1.14.2 jdolecek msreq cpsr_all, r3 /* no bits are different, return */
416 1.1.14.2 jdolecek moveq pc, lr
417 1.1.14.2 jdolecek
418 1.1.14.2 jdolecek /* have to set at least one of the 8259's, store new mask */
419 1.1.14.2 jdolecek str r1, [r0]
420 1.1.14.2 jdolecek ldr r0, Lvam_io_data
421 1.1.14.2 jdolecek ldr r0, [r0]
422 1.1.14.2 jdolecek
423 1.1.14.2 jdolecek /* see if there's any change for 8259 #1 (master) */
424 1.1.14.2 jdolecek tst r2, #0x00FF /* bottom 8 bits different? */
425 1.1.14.2 jdolecek strneb r1, [r0, #(IO_ICU1 + 1)] /* icu1 / ocw1 */
426 1.1.14.2 jdolecek
427 1.1.14.2 jdolecek /* anything for 8259 #2? */
428 1.1.14.2 jdolecek tst r2, #0xFF00
429 1.1.14.2 jdolecek mov r1, r1, lsr #8 /* next byte */
430 1.1.14.2 jdolecek strneb r1, [r0, #(IO_ICU2 + 1)] /* icu2 / ocw1 */
431 1.1.14.2 jdolecek
432 1.1.14.2 jdolecek /* Restore old cpsr and exit */
433 1.1.14.2 jdolecek msr cpsr_all, r3
434 1.1.14.2 jdolecek mov pc, lr
435 1.1.14.2 jdolecek
436 1.1.14.2 jdolecek Lcnt:
437 1.1.14.2 jdolecek .word _C_LABEL(uvmexp)
438 1.1.14.2 jdolecek
439 1.1.14.2 jdolecek Lintrcnt:
440 1.1.14.2 jdolecek .word _C_LABEL(intrcnt)
441 1.1.14.2 jdolecek
442 1.1.14.2 jdolecek Li8259_mask:
443 1.1.14.2 jdolecek .word _C_LABEL(i8259_mask)
444 1.1.14.2 jdolecek
445 1.1.14.2 jdolecek Lirqhandlers:
446 1.1.14.2 jdolecek .word _C_LABEL(irqhandlers) /* Pointer to array of irqhandlers */
447 1.1.14.2 jdolecek
448 1.1.14.2 jdolecek Lastpending:
449 1.1.14.2 jdolecek .word _C_LABEL(astpending)
450 1.1.14.2 jdolecek
451 1.1.14.2 jdolecek #ifdef IRQSTATS
452 1.1.14.2 jdolecek /* These symbols are used by vmstat */
453 1.1.14.2 jdolecek
454 1.1.14.2 jdolecek .text
455 1.1.14.2 jdolecek .global _C_LABEL(_intrnames)
456 1.1.14.2 jdolecek _C_LABEL(_intrnames):
457 1.1.14.2 jdolecek .word _C_LABEL(intrnames)
458 1.1.14.2 jdolecek
459 1.1.14.2 jdolecek .data
460 1.1.14.2 jdolecek
461 1.1.14.2 jdolecek /* XXX fix */
462 1.1.14.2 jdolecek .globl _C_LABEL(intrnames), _C_LABEL(eintrnames), _C_LABEL(intrcnt), _C_LABEL(sintrcnt), _C_LABEL(eintrcnt)
463 1.1.14.2 jdolecek _C_LABEL(intrnames):
464 1.1.14.2 jdolecek .asciz "interrupt 0 "
465 1.1.14.2 jdolecek .asciz "interrupt 1 "
466 1.1.14.2 jdolecek .asciz "interrupt 2 "
467 1.1.14.2 jdolecek .asciz "interrupt 3 "
468 1.1.14.2 jdolecek .asciz "interrupt 4 "
469 1.1.14.2 jdolecek .asciz "interrupt 5 "
470 1.1.14.2 jdolecek .asciz "interrupt 6 "
471 1.1.14.2 jdolecek .asciz "interrupt 7 "
472 1.1.14.2 jdolecek .asciz "interrupt 8 "
473 1.1.14.2 jdolecek .asciz "interrupt 9 "
474 1.1.14.2 jdolecek .asciz "interrupt 10 "
475 1.1.14.2 jdolecek .asciz "interrupt 11 "
476 1.1.14.2 jdolecek .asciz "interrupt 12 "
477 1.1.14.2 jdolecek .asciz "interrupt 13 "
478 1.1.14.2 jdolecek .asciz "interrupt 14 "
479 1.1.14.2 jdolecek .asciz "interrupt 15 "
480 1.1.14.2 jdolecek .asciz "interrupt 16 "
481 1.1.14.2 jdolecek .asciz "interrupt 17 "
482 1.1.14.2 jdolecek .asciz "interrupt 18 "
483 1.1.14.2 jdolecek .asciz "interrupt 19 "
484 1.1.14.2 jdolecek .asciz "interrupt 20 "
485 1.1.14.2 jdolecek .asciz "interrupt 21 "
486 1.1.14.2 jdolecek .asciz "interrupt 22 "
487 1.1.14.2 jdolecek .asciz "interrupt 23 "
488 1.1.14.2 jdolecek .asciz "interrupt 24 "
489 1.1.14.2 jdolecek .asciz "interrupt 25 "
490 1.1.14.2 jdolecek .asciz "interrupt 26 "
491 1.1.14.2 jdolecek .asciz "interrupt 27 "
492 1.1.14.2 jdolecek .asciz "interrupt 28 "
493 1.1.14.2 jdolecek .asciz "interrupt 29 "
494 1.1.14.2 jdolecek .asciz "interrupt 30 "
495 1.1.14.2 jdolecek .asciz "interrupt 31 "
496 1.1.14.2 jdolecek
497 1.1.14.2 jdolecek _C_LABEL(sintrnames):
498 1.1.14.2 jdolecek .asciz "soft int 0 "
499 1.1.14.2 jdolecek .asciz "soft int 1 "
500 1.1.14.2 jdolecek .asciz "soft int 2 "
501 1.1.14.2 jdolecek .asciz "soft int 3 "
502 1.1.14.2 jdolecek .asciz "soft int 4 "
503 1.1.14.2 jdolecek .asciz "soft int 5 "
504 1.1.14.2 jdolecek .asciz "soft int 6 "
505 1.1.14.2 jdolecek .asciz "soft int 7 "
506 1.1.14.2 jdolecek .asciz "soft int 8 "
507 1.1.14.2 jdolecek .asciz "soft int 9 "
508 1.1.14.2 jdolecek .asciz "soft int 10 "
509 1.1.14.2 jdolecek .asciz "soft int 11 "
510 1.1.14.2 jdolecek .asciz "soft int 12 "
511 1.1.14.2 jdolecek .asciz "soft int 13 "
512 1.1.14.2 jdolecek .asciz "soft int 14 "
513 1.1.14.2 jdolecek .asciz "soft int 15 "
514 1.1.14.2 jdolecek .asciz "soft int 16 "
515 1.1.14.2 jdolecek .asciz "soft int 17 "
516 1.1.14.2 jdolecek .asciz "soft int 18 "
517 1.1.14.2 jdolecek .asciz "soft int 19 "
518 1.1.14.2 jdolecek .asciz "soft int 20 "
519 1.1.14.2 jdolecek .asciz "soft int 21 "
520 1.1.14.2 jdolecek .asciz "soft int 22 "
521 1.1.14.2 jdolecek .asciz "soft int 23 "
522 1.1.14.2 jdolecek .asciz "soft int 24 "
523 1.1.14.2 jdolecek .asciz "soft int 25 "
524 1.1.14.2 jdolecek .asciz "soft int 26 "
525 1.1.14.2 jdolecek .asciz "soft int 27 "
526 1.1.14.2 jdolecek .asciz "soft int 28 "
527 1.1.14.2 jdolecek .asciz "soft int 29 "
528 1.1.14.2 jdolecek .asciz "soft int 30 "
529 1.1.14.2 jdolecek .asciz "soft int 31 "
530 1.1.14.2 jdolecek _C_LABEL(eintrnames):
531 1.1.14.2 jdolecek
532 1.1.14.2 jdolecek .bss
533 1.1.14.2 jdolecek .align 0
534 1.1.14.2 jdolecek _C_LABEL(intrcnt):
535 1.1.14.2 jdolecek .space 32*4 /* XXX Should be linked to number of interrupts */
536 1.1.14.2 jdolecek _C_LABEL(sintrcnt):
537 1.1.14.2 jdolecek .space 32*4 /* XXX Should be linked to number of soft ints */
538 1.1.14.2 jdolecek _C_LABEL(eintrcnt):
539 1.1.14.2 jdolecek
540 1.1.14.2 jdolecek #else /* IRQSTATS */
541 1.1.14.2 jdolecek /* Dummy entries to keep vmstat happy */
542 1.1.14.2 jdolecek
543 1.1.14.2 jdolecek .text
544 1.1.14.2 jdolecek .globl _C_LABEL(intrnames), _C_LABEL(eintrnames), _C_LABEL(intrcnt), _C_LABEL(eintrcnt)
545 1.1.14.2 jdolecek _C_LABEL(intrnames):
546 1.1.14.2 jdolecek .long 0
547 1.1.14.2 jdolecek _C_LABEL(eintrnames):
548 1.1.14.2 jdolecek
549 1.1.14.2 jdolecek _C_LABEL(intrcnt):
550 1.1.14.2 jdolecek .long 0
551 1.1.14.2 jdolecek _C_LABEL(eintrcnt):
552 1.1.14.2 jdolecek #endif /* IRQSTATS */
553