| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: intr.c,v 1.20 2008/01/02 11:48:27 ad Exp $ */ | | 1 | /* $NetBSD: intr.c,v 1.21 2009/01/04 15:34:18 tsutsui Exp $ */ |
2 | | | 2 | |
3 | /* | | 3 | /* |
4 | * Copyright 2002 Wasabi Systems, Inc. | | 4 | * Copyright 2002 Wasabi Systems, Inc. |
5 | * All rights reserved. | | 5 | * All rights reserved. |
6 | * | | 6 | * |
7 | * Written by Eduardo Horvath and Simon Burge for Wasabi Systems, Inc. | | 7 | * Written by Eduardo Horvath and Simon Burge for Wasabi Systems, Inc. |
8 | * | | 8 | * |
9 | * Redistribution and use in source and binary forms, with or without | | 9 | * Redistribution and use in source and binary forms, with or without |
10 | * modification, are permitted provided that the following conditions | | 10 | * modification, are permitted provided that the following conditions |
11 | * are met: | | 11 | * are met: |
12 | * 1. Redistributions of source code must retain the above copyright | | 12 | * 1. Redistributions of source code must retain the above copyright |
13 | * notice, this list of conditions and the following disclaimer. | | 13 | * notice, this list of conditions and the following disclaimer. |
14 | * 2. Redistributions in binary form must reproduce the above copyright | | 14 | * 2. Redistributions in binary form must reproduce the above copyright |
| @@ -26,27 +26,27 @@ | | | @@ -26,27 +26,27 @@ |
26 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED | | 26 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED |
27 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | | 27 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
28 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL WASABI SYSTEMS, INC | | 28 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL WASABI SYSTEMS, INC |
29 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | | 29 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
30 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | | 30 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
31 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | | 31 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
32 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | | 32 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
33 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | | 33 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
34 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | | 34 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
35 | * POSSIBILITY OF SUCH DAMAGE. | | 35 | * POSSIBILITY OF SUCH DAMAGE. |
36 | */ | | 36 | */ |
37 | | | 37 | |
38 | #include <sys/cdefs.h> | | 38 | #include <sys/cdefs.h> |
39 | __KERNEL_RCSID(0, "$NetBSD: intr.c,v 1.20 2008/01/02 11:48:27 ad Exp $"); | | 39 | __KERNEL_RCSID(0, "$NetBSD: intr.c,v 1.21 2009/01/04 15:34:18 tsutsui Exp $"); |
40 | | | 40 | |
41 | #include <sys/param.h> | | 41 | #include <sys/param.h> |
42 | #include <sys/malloc.h> | | 42 | #include <sys/malloc.h> |
43 | #include <sys/kernel.h> | | 43 | #include <sys/kernel.h> |
44 | #include <sys/evcnt.h> | | 44 | #include <sys/evcnt.h> |
45 | | | 45 | |
46 | #include <uvm/uvm_extern.h> | | 46 | #include <uvm/uvm_extern.h> |
47 | | | 47 | |
48 | #include <machine/intr.h> | | 48 | #include <machine/intr.h> |
49 | #include <machine/psl.h> | | 49 | #include <machine/psl.h> |
50 | | | 50 | |
51 | #include <powerpc/cpu.h> | | 51 | #include <powerpc/cpu.h> |
52 | #include <powerpc/spr.h> | | 52 | #include <powerpc/spr.h> |
| @@ -241,47 +241,49 @@ ext_intr(void) | | | @@ -241,47 +241,49 @@ ext_intr(void) |
241 | bits_to_clear = int_state; | | 241 | bits_to_clear = int_state; |
242 | | | 242 | |
243 | while (int_state) { | | 243 | while (int_state) { |
244 | i = IRQ_OF_MASK(int_state); | | 244 | i = IRQ_OF_MASK(int_state); |
245 | | | 245 | |
246 | r_imen = IRQ_TO_MASK(i); | | 246 | r_imen = IRQ_TO_MASK(i); |
247 | int_state &= ~r_imen; | | 247 | int_state &= ~r_imen; |
248 | | | 248 | |
249 | if ((pcpl & r_imen) != 0) { | | 249 | if ((pcpl & r_imen) != 0) { |
250 | /* Masked! Mark as pending */ | | 250 | /* Masked! Mark as pending */ |
251 | ci->ci_ipending |= r_imen; | | 251 | ci->ci_ipending |= r_imen; |
252 | disable_irq(i); | | 252 | disable_irq(i); |
253 | } else { | | 253 | } else { |
| | | 254 | ci->ci_idepth++; |
254 | splraise(intrs[i].is_mask); | | 255 | splraise(intrs[i].is_mask); |
255 | if (intrs[i].is_type == IST_LEVEL) | | 256 | if (intrs[i].is_type == IST_LEVEL) |
256 | disable_irq(i); | | 257 | disable_irq(i); |
257 | wrteei(1); | | 258 | wrteei(1); |
258 | | | 259 | |
259 | ih = intrs[i].is_head; | | 260 | ih = intrs[i].is_head; |
260 | while (ih) { | | 261 | while (ih) { |
261 | if (ih->ih_level == IPL_VM) | | 262 | if (ih->ih_level == IPL_VM) |
262 | KERNEL_LOCK(1, NULL); | | 263 | KERNEL_LOCK(1, NULL); |
263 | (*ih->ih_fun)(ih->ih_arg); | | 264 | (*ih->ih_fun)(ih->ih_arg); |
264 | ih = ih->ih_next; | | 265 | ih = ih->ih_next; |
265 | if (ih->ih_level == IPL_VM) | | 266 | if (ih->ih_level == IPL_VM) |
266 | KERNEL_UNLOCK_ONE(NULL); | | 267 | KERNEL_UNLOCK_ONE(NULL); |
267 | } | | 268 | } |
268 | | | 269 | |
269 | mtmsr(msr); | | 270 | mtmsr(msr); |
270 | if (intrs[i].is_type == IST_LEVEL) | | 271 | if (intrs[i].is_type == IST_LEVEL) |
271 | enable_irq(i); | | 272 | enable_irq(i); |
272 | ci->ci_cpl = pcpl; | | 273 | ci->ci_cpl = pcpl; |
273 | uvmexp.intrs++; | | 274 | uvmexp.intrs++; |
274 | intrs[i].is_evcnt.ev_count++; | | 275 | intrs[i].is_evcnt.ev_count++; |
| | | 276 | ci->ci_idepth--; |
275 | } | | 277 | } |
276 | } | | 278 | } |
277 | mtdcr(INTR_ACK, bits_to_clear); /* Acknowledge all pending interrupts */ | | 279 | mtdcr(INTR_ACK, bits_to_clear); /* Acknowledge all pending interrupts */ |
278 | | | 280 | |
279 | wrteei(1); | | 281 | wrteei(1); |
280 | splx(pcpl); | | 282 | splx(pcpl); |
281 | mtmsr(msr); | | 283 | mtmsr(msr); |
282 | } | | 284 | } |
283 | | | 285 | |
284 | static inline void | | 286 | static inline void |
285 | disable_irq(int irq) | | 287 | disable_irq(int irq) |
286 | { | | 288 | { |
287 | int mask, omask; | | 289 | int mask, omask; |