intr.h must not include cpu due to deadly embrace with SOFTINT_COUNT. Cleanup intr.h so MD definitions can overload common definitions. Rototill pic/intr.c. Virtual IRQs can now be reclaimed. separate virq from hwirq from picirq. Redo intr mask calculations. tested on pmppc and macppc (MP).diff -r1.24 -r1.25 src/sys/arch/amigappc/include/intr.h
(matt)
--- src/sys/arch/amigappc/include/intr.h 2010/11/13 13:34:00 1.24
+++ src/sys/arch/amigappc/include/intr.h 2011/06/17 23:36:17 1.25
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: intr.h,v 1.24 2010/11/13 13:34:00 uebayasi Exp $ */ | 1 | /* $NetBSD: intr.h,v 1.25 2011/06/17 23:36:17 matt Exp $ */ | |
2 | 2 | |||
3 | /*- | 3 | /*- | |
4 | * Copyright (c) 1997 The NetBSD Foundation, Inc. | 4 | * Copyright (c) 1997 The NetBSD Foundation, Inc. | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * This code is derived from software contributed to The NetBSD Foundation | 7 | * This code is derived from software contributed to The NetBSD Foundation | |
8 | * by Ignatios Souvatzis. | 8 | * by Ignatios Souvatzis. | |
9 | * | 9 | * | |
10 | * Redistribution and use in source and binary forms, with or without | 10 | * Redistribution and use in source and binary forms, with or without | |
11 | * modification, are permitted provided that the following conditions | 11 | * modification, are permitted provided that the following conditions | |
12 | * are met: | 12 | * are met: | |
13 | * 1. Redistributions of source code must retain the above copyright | 13 | * 1. Redistributions of source code must retain the above copyright | |
14 | * notice, this list of conditions and the following disclaimer. | 14 | * notice, this list of conditions and the following disclaimer. | |
@@ -34,18 +34,14 @@ | @@ -34,18 +34,14 @@ | |||
34 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | 34 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
35 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | 35 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | |
36 | * POSSIBILITY OF SUCH DAMAGE. | 36 | * POSSIBILITY OF SUCH DAMAGE. | |
37 | */ | 37 | */ | |
38 | 38 | |||
39 | #ifndef _AMIGAPPC_INTR_H_ | 39 | #ifndef _AMIGAPPC_INTR_H_ | |
40 | #define _AMIGAPPC_INTR_H_ | 40 | #define _AMIGAPPC_INTR_H_ | |
41 | 41 | |||
42 | #ifdef _KERNEL | 42 | #ifdef _KERNEL | |
43 | #include <amiga/amiga/isr.h> | 43 | #include <amiga/amiga/isr.h> | |
44 | #endif | 44 | #endif | |
45 | #include <powerpc/intr.h> | 45 | #include <powerpc/intr.h> | |
46 | 46 | |||
47 | #ifndef _LOCORE | |||
48 | #include <machine/cpu.h> | |||
49 | #endif /* _LOCORE */ | |||
50 | ||||
51 | #endif /* !_AMIGAPPC_INTR_H_ */ | 47 | #endif /* !_AMIGAPPC_INTR_H_ */ |
--- src/sys/arch/bebox/include/intr.h 2010/04/24 09:39:56 1.29
+++ src/sys/arch/bebox/include/intr.h 2011/06/17 23:36:17 1.30
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: intr.h,v 1.29 2010/04/24 09:39:56 kiyohara Exp $ */ | 1 | /* $NetBSD: intr.h,v 1.30 2011/06/17 23:36:17 matt Exp $ */ | |
2 | 2 | |||
3 | /*- | 3 | /*- | |
4 | * Copyright (c) 1998 The NetBSD Foundation, Inc. | 4 | * Copyright (c) 1998 The NetBSD Foundation, Inc. | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * This code is derived from software contributed to The NetBSD Foundation | 7 | * This code is derived from software contributed to The NetBSD Foundation | |
8 | * by Charles M. Hannum. | 8 | * by Charles M. Hannum. | |
9 | * | 9 | * | |
10 | * Redistribution and use in source and binary forms, with or without | 10 | * Redistribution and use in source and binary forms, with or without | |
11 | * modification, are permitted provided that the following conditions | 11 | * modification, are permitted provided that the following conditions | |
12 | * are met: | 12 | * are met: | |
13 | * 1. Redistributions of source code must retain the above copyright | 13 | * 1. Redistributions of source code must retain the above copyright | |
14 | * notice, this list of conditions and the following disclaimer. | 14 | * notice, this list of conditions and the following disclaimer. | |
@@ -32,23 +32,23 @@ | @@ -32,23 +32,23 @@ | |||
32 | 32 | |||
33 | #ifndef _BEBOX_INTR_H_ | 33 | #ifndef _BEBOX_INTR_H_ | |
34 | #define _BEBOX_INTR_H_ | 34 | #define _BEBOX_INTR_H_ | |
35 | 35 | |||
36 | #include <powerpc/intr.h> | 36 | #include <powerpc/intr.h> | |
37 | 37 | |||
38 | #ifndef _LOCORE | 38 | #ifndef _LOCORE | |
39 | 39 | |||
40 | void enable_intr(void); | 40 | void enable_intr(void); | |
41 | void disable_intr(void); | 41 | void disable_intr(void); | |
42 | 42 | |||
43 | extern paddr_t bebox_mb_reg; | 43 | extern paddr_t bebox_mb_reg; | |
44 | 44 | |||
45 | #define ICU_LEN 32 | 45 | #define ICU_LEN 32 | |
46 | #define IRQ_SLAVE 2 | 46 | #define IRQ_SLAVE 2 | |
47 | #define LEGAL_IRQ(x) ((x) >= 0 && (x) < ICU_LEN && (x) != IRQ_SLAVE) | 47 | #define LEGAL_HWIRQ_P(x) ((u_int)(x) < ICU_LEN && (x) != IRQ_SLAVE) | |
48 | 48 | |||
49 | #define BEBOX_INTR_REG 0x7ffff000 | 49 | #define BEBOX_INTR_REG 0x7ffff000 | |
50 | #define INTR_VECTOR_REG 0xff0 | 50 | #define INTR_VECTOR_REG 0xff0 | |
51 | 51 | |||
52 | #endif /* !_LOCORE */ | 52 | #endif /* !_LOCORE */ | |
53 | 53 | |||
54 | #endif /* !_BEBOX_INTR_H_ */ | 54 | #endif /* !_BEBOX_INTR_H_ */ |
--- src/sys/arch/evbppc/include/pmppc_intr.h 2008/04/28 20:23:17 1.3
+++ src/sys/arch/evbppc/include/pmppc_intr.h 2011/06/17 23:36:17 1.4
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: pmppc_intr.h,v 1.3 2008/04/28 20:23:17 martin Exp $ */ | 1 | /* $NetBSD: pmppc_intr.h,v 1.4 2011/06/17 23:36:17 matt Exp $ */ | |
2 | 2 | |||
3 | /*- | 3 | /*- | |
4 | * Copyright (c) 1998 The NetBSD Foundation, Inc. | 4 | * Copyright (c) 1998 The NetBSD Foundation, Inc. | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * This code is derived from software contributed to The NetBSD Foundation | 7 | * This code is derived from software contributed to The NetBSD Foundation | |
8 | * by Charles M. Hannum. | 8 | * by Charles M. Hannum. | |
9 | * | 9 | * | |
10 | * Redistribution and use in source and binary forms, with or without | 10 | * Redistribution and use in source and binary forms, with or without | |
11 | * modification, are permitted provided that the following conditions | 11 | * modification, are permitted provided that the following conditions | |
12 | * are met: | 12 | * are met: | |
13 | * 1. Redistributions of source code must retain the above copyright | 13 | * 1. Redistributions of source code must retain the above copyright | |
14 | * notice, this list of conditions and the following disclaimer. | 14 | * notice, this list of conditions and the following disclaimer. | |
@@ -34,18 +34,18 @@ | @@ -34,18 +34,18 @@ | |||
34 | 34 | |||
35 | #include <powerpc/intr.h> | 35 | #include <powerpc/intr.h> | |
36 | 36 | |||
37 | #ifndef _LOCORE | 37 | #ifndef _LOCORE | |
38 | 38 | |||
39 | struct pic_ops *setup_cpc700(void); | 39 | struct pic_ops *setup_cpc700(void); | |
40 | 40 | |||
41 | /* | 41 | /* | |
42 | * IBM CPC700 interrupts | 42 | * IBM CPC700 interrupts | |
43 | */ | 43 | */ | |
44 | #define ICU_LEN 32 | 44 | #define ICU_LEN 32 | |
45 | #define ICU_MASK 0x1f000fc0 | 45 | #define ICU_MASK 0x1f000fc0 | |
46 | 46 | |||
47 | #define LEGAL_IRQ(x) ((x) >= 0 && (x) <= 31 && (ICU_MASK & (0x80000000 >> (x)))) | 47 | #define LEGAL_HWIRQ_P(x) ((u_int)(x) < ICU_LEN && (ICU_MASK & (0x80000000 >> (x)))) | |
48 | 48 | |||
49 | #endif /* !_LOCORE */ | 49 | #endif /* !_LOCORE */ | |
50 | 50 | |||
51 | #endif /* !_PMPPC_INTR_H_ */ | 51 | #endif /* !_PMPPC_INTR_H_ */ |
--- src/sys/arch/ibmnws/include/intr.h 2010/11/13 14:07:07 1.14
+++ src/sys/arch/ibmnws/include/intr.h 2011/06/17 23:36:17 1.15
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: intr.h,v 1.14 2010/11/13 14:07:07 uebayasi Exp $ */ | 1 | /* $NetBSD: intr.h,v 1.15 2011/06/17 23:36:17 matt Exp $ */ | |
2 | 2 | |||
3 | /*- | 3 | /*- | |
4 | * Copyright (c) 1998 The NetBSD Foundation, Inc. | 4 | * Copyright (c) 1998 The NetBSD Foundation, Inc. | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * This code is derived from software contributed to The NetBSD Foundation | 7 | * This code is derived from software contributed to The NetBSD Foundation | |
8 | * by Charles M. Hannum. | 8 | * by Charles M. Hannum. | |
9 | * | 9 | * | |
10 | * Redistribution and use in source and binary forms, with or without | 10 | * Redistribution and use in source and binary forms, with or without | |
11 | * modification, are permitted provided that the following conditions | 11 | * modification, are permitted provided that the following conditions | |
12 | * are met: | 12 | * are met: | |
13 | * 1. Redistributions of source code must retain the above copyright | 13 | * 1. Redistributions of source code must retain the above copyright | |
14 | * notice, this list of conditions and the following disclaimer. | 14 | * notice, this list of conditions and the following disclaimer. | |
@@ -22,39 +22,37 @@ | @@ -22,39 +22,37 @@ | |||
22 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS | 22 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS | |
23 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | 23 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | |
24 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | 24 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | |
25 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | 25 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | |
26 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | 26 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | |
27 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | 27 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
28 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | 28 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | |
29 | * POSSIBILITY OF SUCH DAMAGE. | 29 | * POSSIBILITY OF SUCH DAMAGE. | |
30 | */ | 30 | */ | |
31 | 31 | |||
32 | #ifndef _IBMNWS_INTR_H_ | 32 | #ifndef _IBMNWS_INTR_H_ | |
33 | #define _IBMNWS_INTR_H_ | 33 | #define _IBMNWS_INTR_H_ | |
34 | 34 | |||
35 | #include <powerpc/intr.h> | |||
36 | ||||
37 | #ifndef _LOCORE | 35 | #ifndef _LOCORE | |
38 | #include <machine/cpu.h> | |||
39 | ||||
40 | void init_intr_ivr(void); | 36 | void init_intr_ivr(void); | |
41 | void init_intr_openpic(void); | 37 | void init_intr_openpic(void); | |
42 | void openpic_init(unsigned char *); | 38 | void openpic_init(unsigned char *); | |
43 | void enable_intr(void); | 39 | void enable_intr(void); | |
44 | void disable_intr(void); | 40 | void disable_intr(void); | |
45 | 41 | |||
46 | extern vaddr_t prep_intr_reg; | 42 | extern vaddr_t prep_intr_reg; | |
47 | extern uint32_t prep_intr_reg_off; | 43 | extern uint32_t prep_intr_reg_off; | |
48 | 44 | |||
49 | #define ICU_LEN 32 | 45 | #define ICU_LEN 32 | |
50 | 46 | |||
51 | #define IRQ_SLAVE 2 | 47 | #define IRQ_SLAVE 2 | |
52 | #define LEGAL_IRQ(x) ((x) >= 0 && (x) < ICU_LEN && (x) != IRQ_SLAVE) | 48 | #define LEGAL_HWIRQ_P(x) ((u_int)(x) < ICU_LEN && (x) != IRQ_SLAVE) | |
53 | #define I8259_INTR_NUM 16 | 49 | #define I8259_INTR_NUM 16 | |
54 | 50 | |||
55 | #define PREP_INTR_REG 0xbffff000 | 51 | #define PREP_INTR_REG 0xbffff000 | |
56 | #define INTR_VECTOR_REG 0xff0 | 52 | #define INTR_VECTOR_REG 0xff0 | |
57 | 53 | |||
58 | #endif /* !_LOCORE */ | 54 | #endif /* !_LOCORE */ | |
59 | 55 | |||
56 | #include <powerpc/intr.h> | |||
57 | ||||
60 | #endif /* !_IBMNWS_INTR_H_ */ | 58 | #endif /* !_IBMNWS_INTR_H_ */ |
--- src/sys/arch/macppc/include/intr.h 2011/06/17 05:18:10 1.29
+++ src/sys/arch/macppc/include/intr.h 2011/06/17 23:36:17 1.30
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: intr.h,v 1.29 2011/06/17 05:18:10 matt Exp $ */ | 1 | /* $NetBSD: intr.h,v 1.30 2011/06/17 23:36:17 matt Exp $ */ | |
2 | 2 | |||
3 | /*- | 3 | /*- | |
4 | * Copyright (c) 1998 The NetBSD Foundation, Inc. | 4 | * Copyright (c) 1998 The NetBSD Foundation, Inc. | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * This code is derived from software contributed to The NetBSD Foundation | 7 | * This code is derived from software contributed to The NetBSD Foundation | |
8 | * by Charles M. Hannum. | 8 | * by Charles M. Hannum. | |
9 | * | 9 | * | |
10 | * Redistribution and use in source and binary forms, with or without | 10 | * Redistribution and use in source and binary forms, with or without | |
11 | * modification, are permitted provided that the following conditions | 11 | * modification, are permitted provided that the following conditions | |
12 | * are met: | 12 | * are met: | |
13 | * 1. Redistributions of source code must retain the above copyright | 13 | * 1. Redistributions of source code must retain the above copyright | |
14 | * notice, this list of conditions and the following disclaimer. | 14 | * notice, this list of conditions and the following disclaimer. | |
@@ -22,41 +22,41 @@ | @@ -22,41 +22,41 @@ | |||
22 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS | 22 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS | |
23 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | 23 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | |
24 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | 24 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | |
25 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | 25 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | |
26 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | 26 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | |
27 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | 27 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
28 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | 28 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | |
29 | * POSSIBILITY OF SUCH DAMAGE. | 29 | * POSSIBILITY OF SUCH DAMAGE. | |
30 | */ | 30 | */ | |
31 | 31 | |||
32 | #ifndef _MACPPC_INTR_H_ | 32 | #ifndef _MACPPC_INTR_H_ | |
33 | #define _MACPPC_INTR_H_ | 33 | #define _MACPPC_INTR_H_ | |
34 | 34 | |||
35 | #include <powerpc/intr.h> | |||
36 | ||||
37 | #ifdef _KERNEL_OPT | 35 | #ifdef _KERNEL_OPT | |
38 | #include "opt_multiprocessor.h" | 36 | #include "opt_multiprocessor.h" | |
39 | #endif | 37 | #endif | |
40 | 38 | |||
41 | #ifndef _LOCORE | 39 | #ifndef _LOCORE | |
42 | 40 | |||
43 | #define ICU_LEN 64 | 41 | #define ICU_LEN 64 | |
44 | 42 | |||
45 | #ifdef MULTIPROCESSOR | 43 | #ifdef MULTIPROCESSOR | |
46 | struct cpu_info; | 44 | struct cpu_info; | |
47 | 45 | |||
48 | #include <powerpc/pic/ipivar.h> | 46 | #include <powerpc/pic/ipivar.h> | |
49 | #endif /* MULTIPROCESSOR */ | 47 | #endif /* MULTIPROCESSOR */ | |
50 | 48 | |||
51 | 49 | |||
52 | #ifdef _KERNEL | 50 | #ifdef _KERNEL | |
53 | 51 | |||
54 | /* probe for a PIC and set it up, return TRUE on success */ | 52 | /* probe for a PIC and set it up, return TRUE on success */ | |
55 | int init_ohare(void); | 53 | int init_ohare(void); | |
56 | int init_heathrow(void); | 54 | int init_heathrow(void); | |
57 | int init_grandcentral(void); | 55 | int init_grandcentral(void); | |
58 | void setup_hammerhead_ipi(void); | 56 | void setup_hammerhead_ipi(void); | |
59 | #endif | 57 | #endif | |
60 | #endif /* _LOCORE */ | 58 | #endif /* _LOCORE */ | |
61 | 59 | |||
60 | #include <powerpc/intr.h> | |||
61 | ||||
62 | #endif /* _MACPPC_INTR_H_ */ | 62 | #endif /* _MACPPC_INTR_H_ */ |
--- src/sys/arch/mvmeppc/include/intr.h 2010/04/24 09:39:57 1.14
+++ src/sys/arch/mvmeppc/include/intr.h 2011/06/17 23:36:17 1.15
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: intr.h,v 1.14 2010/04/24 09:39:57 kiyohara Exp $ */ | 1 | /* $NetBSD: intr.h,v 1.15 2011/06/17 23:36:17 matt Exp $ */ | |
2 | 2 | |||
3 | /*- | 3 | /*- | |
4 | * Copyright (c) 1998 The NetBSD Foundation, Inc. | 4 | * Copyright (c) 1998 The NetBSD Foundation, Inc. | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * This code is derived from software contributed to The NetBSD Foundation | 7 | * This code is derived from software contributed to The NetBSD Foundation | |
8 | * by Charles M. Hannum. | 8 | * by Charles M. Hannum. | |
9 | * | 9 | * | |
10 | * Redistribution and use in source and binary forms, with or without | 10 | * Redistribution and use in source and binary forms, with or without | |
11 | * modification, are permitted provided that the following conditions | 11 | * modification, are permitted provided that the following conditions | |
12 | * are met: | 12 | * are met: | |
13 | * 1. Redistributions of source code must retain the above copyright | 13 | * 1. Redistributions of source code must retain the above copyright | |
14 | * notice, this list of conditions and the following disclaimer. | 14 | * notice, this list of conditions and the following disclaimer. | |
@@ -22,32 +22,32 @@ | @@ -22,32 +22,32 @@ | |||
22 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS | 22 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS | |
23 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | 23 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | |
24 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | 24 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | |
25 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | 25 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | |
26 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | 26 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | |
27 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | 27 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
28 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | 28 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | |
29 | * POSSIBILITY OF SUCH DAMAGE. | 29 | * POSSIBILITY OF SUCH DAMAGE. | |
30 | */ | 30 | */ | |
31 | 31 | |||
32 | #ifndef _MVMEPPC_INTR_H_ | 32 | #ifndef _MVMEPPC_INTR_H_ | |
33 | #define _MVMEPPC_INTR_H_ | 33 | #define _MVMEPPC_INTR_H_ | |
34 | 34 | |||
35 | #include <powerpc/intr.h> | |||
36 | ||||
37 | #ifndef _LOCORE | 35 | #ifndef _LOCORE | |
38 | 36 | |||
39 | void enable_intr(void); | 37 | void enable_intr(void); | |
40 | void disable_intr(void); | 38 | void disable_intr(void); | |
41 | 39 | |||
42 | extern vaddr_t mvmeppc_intr_reg; | 40 | extern vaddr_t mvmeppc_intr_reg; | |
43 | 41 | |||
44 | #define ICU_LEN 32 | 42 | #define ICU_LEN 32 | |
45 | #define IRQ_SLAVE 2 | 43 | #define IRQ_SLAVE 2 | |
46 | #define LEGAL_IRQ(x) ((x) >= 0 && (x) < ICU_LEN && (x) != IRQ_SLAVE) | 44 | #define LEGAL_HWIRQ_P(x) ((u_int)(x) < ICU_LEN && (x) != IRQ_SLAVE) | |
47 | 45 | |||
48 | #define MVMEPPC_INTR_REG 0xbffff000 | 46 | #define MVMEPPC_INTR_REG 0xbffff000 | |
49 | #define INTR_VECTOR_REG 0xff0 | 47 | #define INTR_VECTOR_REG 0xff0 | |
50 | 48 | |||
51 | #endif /* !_LOCORE */ | 49 | #endif /* !_LOCORE */ | |
52 | 50 | |||
51 | #include <powerpc/intr.h> | |||
52 | ||||
53 | #endif /* !_MVMEPPC_INTR_H_ */ | 53 | #endif /* !_MVMEPPC_INTR_H_ */ |
--- src/sys/arch/ofppc/include/intr.h 2011/06/05 16:52:24 1.15
+++ src/sys/arch/ofppc/include/intr.h 2011/06/17 23:36:17 1.16
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: intr.h,v 1.15 2011/06/05 16:52:24 matt Exp $ */ | 1 | /* $NetBSD: intr.h,v 1.16 2011/06/17 23:36:17 matt Exp $ */ | |
2 | 2 | |||
3 | /*- | 3 | /*- | |
4 | * Copyright (c) 2007 The NetBSD Foundation, Inc. | 4 | * Copyright (c) 2007 The NetBSD Foundation, Inc. | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * This code is derived from software contributed to The NetBSD Foundation | 7 | * This code is derived from software contributed to The NetBSD Foundation | |
8 | * by Tim Rightnour | 8 | * by Tim Rightnour | |
9 | * | 9 | * | |
10 | * Redistribution and use in source and binary forms, with or without | 10 | * Redistribution and use in source and binary forms, with or without | |
11 | * modification, are permitted provided that the following conditions | 11 | * modification, are permitted provided that the following conditions | |
12 | * are met: | 12 | * are met: | |
13 | * 1. Redistributions of source code must retain the above copyright | 13 | * 1. Redistributions of source code must retain the above copyright | |
14 | * notice, this list of conditions and the following disclaimer. | 14 | * notice, this list of conditions and the following disclaimer. | |
@@ -22,31 +22,29 @@ | @@ -22,31 +22,29 @@ | |||
22 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS | 22 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS | |
23 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | 23 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | |
24 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | 24 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | |
25 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | 25 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | |
26 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | 26 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | |
27 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | 27 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
28 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | 28 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | |
29 | * POSSIBILITY OF SUCH DAMAGE. | 29 | * POSSIBILITY OF SUCH DAMAGE. | |
30 | */ | 30 | */ | |
31 | 31 | |||
32 | #ifndef _OFPPC_INTR_H_ | 32 | #ifndef _OFPPC_INTR_H_ | |
33 | #define _OFPPC_INTR_H_ | 33 | #define _OFPPC_INTR_H_ | |
34 | 34 | |||
35 | #ifndef _LOCORE | |||
35 | #ifdef _KERNEL_OPT | 36 | #ifdef _KERNEL_OPT | |
36 | #include "opt_multiprocessor.h" | 37 | #include "opt_multiprocessor.h" | |
37 | #endif | 38 | #endif | |
38 | ||||
39 | #include <powerpc/intr.h> | |||
40 | ||||
41 | #ifndef _LOCORE | |||
42 | #ifdef MULTIPROCESSOR | 39 | #ifdef MULTIPROCESSOR | |
43 | #include <powerpc/pic/ipivar.h> | 40 | #include <powerpc/pic/ipivar.h> | |
44 | #endif | 41 | #endif | |
45 | #include <machine/cpu.h> | |||
46 | 42 | |||
47 | #define ICU_LEN 32 | 43 | #define ICU_LEN 32 | |
48 | #define IRQ_SLAVE 2 | 44 | #define IRQ_SLAVE 2 | |
49 | 45 | |||
50 | #endif | 46 | #endif | |
51 | 47 | |||
48 | #include <powerpc/intr.h> | |||
49 | ||||
52 | #endif /* _OFPPC_INTR_H_ */ | 50 | #endif /* _OFPPC_INTR_H_ */ |
--- src/sys/arch/powerpc/include/intr.h 2011/06/17 05:15:22 1.7
+++ src/sys/arch/powerpc/include/intr.h 2011/06/17 23:36:17 1.8
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: intr.h,v 1.7 2011/06/17 05:15:22 matt Exp $ */ | 1 | /* $NetBSD: intr.h,v 1.8 2011/06/17 23:36:17 matt Exp $ */ | |
2 | 2 | |||
3 | /*- | 3 | /*- | |
4 | * Copyright (c) 2007 Michael Lorenz | 4 | * Copyright (c) 2007 Michael Lorenz | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * Redistribution and use in source and binary forms, with or without | 7 | * Redistribution and use in source and binary forms, with or without | |
8 | * modification, are permitted provided that the following conditions | 8 | * modification, are permitted provided that the following conditions | |
9 | * are met: | 9 | * are met: | |
10 | * 1. Redistributions of source code must retain the above copyright | 10 | * 1. Redistributions of source code must retain the above copyright | |
11 | * notice, this list of conditions and the following disclaimer. | 11 | * notice, this list of conditions and the following disclaimer. | |
12 | * 2. Redistributions in binary form must reproduce the above copyright | 12 | * 2. Redistributions in binary form must reproduce the above copyright | |
13 | * notice, this list of conditions and the following disclaimer in the | 13 | * notice, this list of conditions and the following disclaimer in the | |
14 | * documentation and/or other materials provided with the distribution. | 14 | * documentation and/or other materials provided with the distribution. | |
@@ -18,27 +18,27 @@ | @@ -18,27 +18,27 @@ | |||
18 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | 18 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | |
19 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS | 19 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS | |
20 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | 20 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | |
21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | 21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | |
22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | 22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | |
23 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | 23 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | |
24 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | 24 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
25 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | 25 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | |
26 | * POSSIBILITY OF SUCH DAMAGE. | 26 | * POSSIBILITY OF SUCH DAMAGE. | |
27 | */ | 27 | */ | |
28 | 28 | |||
29 | #ifndef _LOCORE | 29 | #ifndef _LOCORE | |
30 | #include <sys/cdefs.h> | 30 | #include <sys/cdefs.h> | |
31 | __KERNEL_RCSID(0, "$NetBSD: intr.h,v 1.7 2011/06/17 05:15:22 matt Exp $"); | 31 | __KERNEL_RCSID(0, "$NetBSD: intr.h,v 1.8 2011/06/17 23:36:17 matt Exp $"); | |
32 | #endif | 32 | #endif | |
33 | 33 | |||
34 | #ifndef POWERPC_INTR_MACHDEP_H | 34 | #ifndef POWERPC_INTR_MACHDEP_H | |
35 | #define POWERPC_INTR_MACHDEP_H | 35 | #define POWERPC_INTR_MACHDEP_H | |
36 | 36 | |||
37 | #define __HAVE_FAST_SOFTINTS 1 | 37 | #define __HAVE_FAST_SOFTINTS 1 | |
38 | 38 | |||
39 | #ifndef _LOCORE | 39 | #ifndef _LOCORE | |
40 | void *intr_establish(int, int, int, int (*)(void *), void *); | 40 | void *intr_establish(int, int, int, int (*)(void *), void *); | |
41 | void intr_disestablish(void *); | 41 | void intr_disestablish(void *); | |
42 | const char *intr_typename(int); | 42 | const char *intr_typename(int); | |
43 | void genppc_cpu_configure(void); | 43 | void genppc_cpu_configure(void); | |
44 | #endif | 44 | #endif | |
@@ -50,62 +50,66 @@ void genppc_cpu_configure(void); | @@ -50,62 +50,66 @@ void genppc_cpu_configure(void); | |||
50 | #define IPL_SOFTNET 3 /* protocol stacks */ | 50 | #define IPL_SOFTNET 3 /* protocol stacks */ | |
51 | #define IPL_SOFTSERIAL 4 /* serial */ | 51 | #define IPL_SOFTSERIAL 4 /* serial */ | |
52 | #define IPL_VM 5 /* memory allocation */ | 52 | #define IPL_VM 5 /* memory allocation */ | |
53 | #define IPL_SCHED 6 | 53 | #define IPL_SCHED 6 | |
54 | #define IPL_HIGH 7 /* everything */ | 54 | #define IPL_HIGH 7 /* everything */ | |
55 | #define NIPL 8 | 55 | #define NIPL 8 | |
56 | 56 | |||
57 | /* Interrupt sharing types. */ | 57 | /* Interrupt sharing types. */ | |
58 | #define IST_NONE 0 /* none */ | 58 | #define IST_NONE 0 /* none */ | |
59 | #define IST_PULSE 1 /* pulsed */ | 59 | #define IST_PULSE 1 /* pulsed */ | |
60 | #define IST_EDGE 2 /* edge-triggered */ | 60 | #define IST_EDGE 2 /* edge-triggered */ | |
61 | #define IST_LEVEL 3 /* level-triggered */ | 61 | #define IST_LEVEL 3 /* level-triggered */ | |
62 | 62 | |||
63 | #ifdef _LOCORE | |||
64 | #define splhigh __splhigh | |||
65 | #endif | |||
66 | ||||
67 | #ifndef _LOCORE | 63 | #ifndef _LOCORE | |
68 | /* | 64 | /* | |
69 | * Interrupt handler chains. intr_establish() inserts a handler into | 65 | * Interrupt handler chains. intr_establish() inserts a handler into | |
70 | * the list. The handler is called with its (single) argument. | 66 | * the list. The handler is called with its (single) argument. | |
71 | */ | 67 | */ | |
72 | struct intrhand { | 68 | struct intrhand { | |
73 | int (*ih_fun)(void *); | 69 | int (*ih_fun)(void *); | |
74 | void *ih_arg; | 70 | void *ih_arg; | |
75 | struct intrhand *ih_next; | 71 | struct intrhand *ih_next; | |
76 | int ih_ipl; | 72 | int ih_ipl; | |
77 | int ih_irq; | 73 | int ih_virq; | |
78 | }; | 74 | }; | |
79 | 75 | |||
80 | int splraise(int); | 76 | int splraise(int); | |
81 | int spllower(int); | 77 | int spllower(int); | |
82 | void splx(int); | 78 | void splx(int); | |
83 | 79 | |||
84 | void softint_fast_dispatch(struct lwp *, int); | 80 | void softint_fast_dispatch(struct lwp *, int); | |
85 | 81 | |||
86 | #define softint_init_md powerpc_softint_init_md | 82 | #define softint_init_md powerpc_softint_init_md | |
87 | #define softint_trigger powerpc_softint_trigger | 83 | #define softint_trigger powerpc_softint_trigger | |
88 | 84 | |||
89 | typedef u_int imask_t; | 85 | #ifdef __IMASK_T | |
86 | typedef __IMASK_T imask_t; | |||
87 | #else | |||
88 | typedef uint32_t imask_t; | |||
89 | #endif | |||
90 | ||||
90 | extern imask_t imask[]; | 91 | extern imask_t imask[]; | |
91 | 92 | |||
92 | #define NVIRQ 32 /* 32 virtual IRQs */ | 93 | #define NVIRQ (sizeof(imask_t)*8) /* 32 virtual IRQs */ | |
94 | #ifndef NIRQ | |||
93 | #define NIRQ 128 /* up to 128 HW IRQs */ | 95 | #define NIRQ 128 /* up to 128 HW IRQs */ | |
96 | #endif | |||
94 | 97 | |||
95 | #define HWIRQ_MAX (NVIRQ - 5 - 1) | 98 | #define HWIRQ_MAX (NVIRQ - 1) | |
96 | #define HWIRQ_MASK 0x07ffffff | 99 | #define HWIRQ_MASK (~(imask_t)0 >> 1) | |
97 | 100 | |||
98 | #define MS_PENDING(p) (31 - cntlzw(p)) | 101 | #define PIC_VIRQ_TO_MASK(v) __BIT(HWIRQ_MAX - (v)) | |
102 | #define PIC_VIRQ_MS_PENDING(p) __builtin_clz(p) | |||
99 | 103 | |||
100 | #define spl0() spllower(0) | 104 | #define spl0() spllower(0) | |
101 | 105 | |||
102 | typedef int ipl_t; | 106 | typedef int ipl_t; | |
103 | typedef struct { | 107 | typedef struct { | |
104 | ipl_t _ipl; | 108 | ipl_t _ipl; | |
105 | } ipl_cookie_t; | 109 | } ipl_cookie_t; | |
106 | 110 | |||
107 | static inline ipl_cookie_t | 111 | static inline ipl_cookie_t | |
108 | makeiplcookie(ipl_t ipl) | 112 | makeiplcookie(ipl_t ipl) | |
109 | { | 113 | { | |
110 | 114 | |||
111 | return (ipl_cookie_t){._ipl = ipl}; | 115 | return (ipl_cookie_t){._ipl = ipl}; |
--- src/sys/arch/powerpc/pic/files.pic 2011/06/16 02:43:43 1.6
+++ src/sys/arch/powerpc/pic/files.pic 2011/06/17 23:36:18 1.7
@@ -1,20 +1,19 @@ | @@ -1,20 +1,19 @@ | |||
1 | # | 1 | # | |
2 | # $NetBSD: files.pic,v 1.6 2011/06/16 02:43:43 macallan Exp $ | 2 | # $NetBSD: files.pic,v 1.7 2011/06/17 23:36:18 matt Exp $ | |
3 | # | 3 | # | |
4 | # generic PIC abstraction | 4 | # generic PIC abstraction | |
5 | 5 | |||
6 | file arch/powerpc/pic/intr.c | 6 | file arch/powerpc/pic/intr.c | |
7 | file arch/powerpc/pic/pic_subr.c | |||
8 | 7 | |||
9 | defflag opt_pic.h PIC_DEBUG | 8 | defflag opt_pic.h PIC_DEBUG | |
10 | 9 | |||
11 | define pic_openpic | 10 | define pic_openpic | |
12 | define pic_distopenpic | 11 | define pic_distopenpic | |
13 | define pic_prepivr | 12 | define pic_prepivr | |
14 | define pic_i8259 | 13 | define pic_i8259 | |
15 | define pic_mpcsoc | 14 | define pic_mpcsoc | |
16 | 15 | |||
17 | defflag opt_interrupt.h PIC_OPENPIC: pic_openpic | 16 | defflag opt_interrupt.h PIC_OPENPIC: pic_openpic | |
18 | defflag opt_interrupt.h PIC_DISTOPENPIC: pic_distopenpic | 17 | defflag opt_interrupt.h PIC_DISTOPENPIC: pic_distopenpic | |
19 | defflag opt_interrupt.h PIC_PREPIVR: pic_prepivr | 18 | defflag opt_interrupt.h PIC_PREPIVR: pic_prepivr | |
20 | defflag opt_interrupt.h PIC_I8259: pic_i8259 | 19 | defflag opt_interrupt.h PIC_I8259: pic_i8259 |
--- src/sys/arch/powerpc/pic/intr.c 2011/06/17 05:15:23 1.14
+++ src/sys/arch/powerpc/pic/intr.c 2011/06/17 23:36:18 1.15
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: intr.c,v 1.14 2011/06/17 05:15:23 matt Exp $ */ | 1 | /* $NetBSD: intr.c,v 1.15 2011/06/17 23:36:18 matt Exp $ */ | |
2 | 2 | |||
3 | /*- | 3 | /*- | |
4 | * Copyright (c) 2007 Michael Lorenz | 4 | * Copyright (c) 2007 Michael Lorenz | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * Redistribution and use in source and binary forms, with or without | 7 | * Redistribution and use in source and binary forms, with or without | |
8 | * modification, are permitted provided that the following conditions | 8 | * modification, are permitted provided that the following conditions | |
9 | * are met: | 9 | * are met: | |
10 | * 1. Redistributions of source code must retain the above copyright | 10 | * 1. Redistributions of source code must retain the above copyright | |
11 | * notice, this list of conditions and the following disclaimer. | 11 | * notice, this list of conditions and the following disclaimer. | |
12 | * 2. Redistributions in binary form must reproduce the above copyright | 12 | * 2. Redistributions in binary form must reproduce the above copyright | |
13 | * notice, this list of conditions and the following disclaimer in the | 13 | * notice, this list of conditions and the following disclaimer in the | |
14 | * documentation and/or other materials provided with the distribution. | 14 | * documentation and/or other materials provided with the distribution. | |
@@ -17,27 +17,27 @@ | @@ -17,27 +17,27 @@ | |||
17 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED | 17 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED | |
18 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | 18 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | |
19 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS | 19 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS | |
20 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | 20 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | |
21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | 21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | |
22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | 22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | |
23 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | 23 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | |
24 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | 24 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
25 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | 25 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | |
26 | * POSSIBILITY OF SUCH DAMAGE. | 26 | * POSSIBILITY OF SUCH DAMAGE. | |
27 | */ | 27 | */ | |
28 | 28 | |||
29 | #include <sys/cdefs.h> | 29 | #include <sys/cdefs.h> | |
30 | __KERNEL_RCSID(0, "$NetBSD: intr.c,v 1.14 2011/06/17 05:15:23 matt Exp $"); | 30 | __KERNEL_RCSID(0, "$NetBSD: intr.c,v 1.15 2011/06/17 23:36:18 matt Exp $"); | |
31 | 31 | |||
32 | #include "opt_multiprocessor.h" | 32 | #include "opt_multiprocessor.h" | |
33 | 33 | |||
34 | #define __INTR_PRIVATE | 34 | #define __INTR_PRIVATE | |
35 | 35 | |||
36 | #include <sys/param.h> | 36 | #include <sys/param.h> | |
37 | #include <sys/malloc.h> | 37 | #include <sys/malloc.h> | |
38 | #include <sys/kernel.h> | 38 | #include <sys/kernel.h> | |
39 | #include <sys/cpu.h> | 39 | #include <sys/cpu.h> | |
40 | 40 | |||
41 | #include <arch/powerpc/pic/picvar.h> | 41 | #include <arch/powerpc/pic/picvar.h> | |
42 | #include "opt_pic.h" | 42 | #include "opt_pic.h" | |
43 | #include "opt_interrupt.h" | 43 | #include "opt_interrupt.h" | |
@@ -45,147 +45,142 @@ __KERNEL_RCSID(0, "$NetBSD: intr.c,v 1.1 | @@ -45,147 +45,142 @@ __KERNEL_RCSID(0, "$NetBSD: intr.c,v 1.1 | |||
45 | #include <machine/isa_machdep.h> | 45 | #include <machine/isa_machdep.h> | |
46 | #endif | 46 | #endif | |
47 | 47 | |||
48 | #ifdef MULTIPROCESSOR | 48 | #ifdef MULTIPROCESSOR | |
49 | #include <arch/powerpc/pic/ipivar.h> | 49 | #include <arch/powerpc/pic/ipivar.h> | |
50 | #endif | 50 | #endif | |
51 | 51 | |||
52 | #ifdef __HAVE_FAST_SOFTINTS | 52 | #ifdef __HAVE_FAST_SOFTINTS | |
53 | #include <powerpc/softint.h> | 53 | #include <powerpc/softint.h> | |
54 | #endif | 54 | #endif | |
55 | 55 | |||
56 | #define MAX_PICS 8 /* 8 PICs ought to be enough for everyone */ | 56 | #define MAX_PICS 8 /* 8 PICs ought to be enough for everyone */ | |
57 | 57 | |||
58 | #define LEGAL_VIRQ(x) ((x) >= 0 && (x) < NVIRQ) | 58 | #define PIC_VIRQ_LEGAL_P(x) ((u_int)(x) < NVIRQ) | |
59 | 59 | |||
60 | struct pic_ops *pics[MAX_PICS]; | 60 | struct pic_ops *pics[MAX_PICS]; | |
61 | int num_pics = 0; | 61 | int num_pics = 0; | |
62 | int max_base = 0; | 62 | int max_base = 0; | |
63 | uint8_t virq[NIRQ]; | 63 | uint8_t virq_map[NIRQ]; | |
64 | int virq_max = 0; | 64 | imask_t virq_mask = HWIRQ_MASK; | |
65 | imask_t imask[NIPL]; | 65 | imask_t imask[NIPL]; | |
66 | int primary_pic = 0; | 66 | int primary_pic = 0; | |
67 | 67 | |||
68 | static int fakeintr(void *); | 68 | static int fakeintr(void *); | |
69 | static int mapirq(uint32_t); | 69 | static int mapirq(int); | |
70 | static void intr_calculatemasks(void); | 70 | static void intr_calculatemasks(void); | |
71 | static struct pic_ops *find_pic_by_irq(int); | 71 | static struct pic_ops *find_pic_by_hwirq(int); | |
72 | 72 | |||
73 | static struct intr_source intrsources[NVIRQ]; | 73 | static struct intr_source intrsources[NVIRQ]; | |
74 | 74 | |||
75 | void | 75 | void | |
76 | pic_init(void) | 76 | pic_init(void) | |
77 | { | 77 | { | |
78 | for (u_int i = 0; i < NIRQ; i++) | 78 | /* everything is in bss, no reason to zero it. */ | |
79 | virq[i] = 0; | |||
80 | memset(intrsources, 0, sizeof(intrsources)); | |||
81 | } | 79 | } | |
82 | 80 | |||
83 | int | 81 | int | |
84 | pic_add(struct pic_ops *pic) | 82 | pic_add(struct pic_ops *pic) | |
85 | { | 83 | { | |
86 | 84 | |||
87 | if (num_pics >= MAX_PICS) | 85 | if (num_pics >= MAX_PICS) | |
88 | return -1; | 86 | return -1; | |
89 | 87 | |||
90 | pics[num_pics] = pic; | 88 | pics[num_pics] = pic; | |
91 | pic->pic_intrbase = max_base; | 89 | pic->pic_intrbase = max_base; | |
92 | max_base += pic->pic_numintrs; | 90 | max_base += pic->pic_numintrs; | |
93 | num_pics++; | 91 | num_pics++; | |
94 | 92 | |||
95 | return pic->pic_intrbase; | 93 | return pic->pic_intrbase; | |
96 | } | 94 | } | |
97 | 95 | |||
98 | void | 96 | void | |
99 | pic_finish_setup(void) | 97 | pic_finish_setup(void) | |
100 | { | 98 | { | |
101 | struct pic_ops *pic; | 99 | for (size_t i = 0; i < num_pics; i++) { | |
102 | int i; | 100 | struct pic_ops * const pic = pics[i]; | |
103 | ||||
104 | for (i = 0; i < num_pics; i++) { | |||
105 | pic = pics[i]; | |||
106 | if (pic->pic_finish_setup != NULL) | 101 | if (pic->pic_finish_setup != NULL) | |
107 | pic->pic_finish_setup(pic); | 102 | pic->pic_finish_setup(pic); | |
108 | } | 103 | } | |
109 | } | 104 | } | |
110 | 105 | |||
111 | static struct pic_ops * | 106 | static struct pic_ops * | |
112 | find_pic_by_irq(int irq) | 107 | find_pic_by_hwirq(int hwirq) | |
113 | { | 108 | { | |
114 | for (u_int base = 0; base < num_pics; base++) { | 109 | for (u_int base = 0; base < num_pics; base++) { | |
115 | struct pic_ops * const pic = pics[base]; | 110 | struct pic_ops * const pic = pics[base]; | |
116 | if (pic->pic_intrbase <= irq | 111 | if (pic->pic_intrbase <= hwirq | |
117 | && irq < pic->pic_intrbase + pic->pic_numintrs) { | 112 | && hwirq < pic->pic_intrbase + pic->pic_numintrs) { | |
118 | return pic; | 113 | return pic; | |
119 | } | 114 | } | |
120 | } | 115 | } | |
121 | return NULL; | 116 | return NULL; | |
122 | } | 117 | } | |
123 | 118 | |||
124 | static int | 119 | static int | |
125 | fakeintr(void *arg) | 120 | fakeintr(void *arg) | |
126 | { | 121 | { | |
127 | 122 | |||
128 | return 0; | 123 | return 0; | |
129 | } | 124 | } | |
130 | 125 | |||
131 | /* | 126 | /* | |
132 | * Register an interrupt handler. | 127 | * Register an interrupt handler. | |
133 | */ | 128 | */ | |
134 | void * | 129 | void * | |
135 | intr_establish(int hwirq, int type, int ipl, int (*ih_fun)(void *), | 130 | intr_establish(int hwirq, int type, int ipl, int (*ih_fun)(void *), | |
136 | void *ih_arg) | 131 | void *ih_arg) | |
137 | { | 132 | { | |
138 | struct intrhand **p, *q, *ih; | 133 | struct intrhand **p, *q, *ih; | |
139 | struct intr_source *is; | |||
140 | struct pic_ops *pic; | 134 | struct pic_ops *pic; | |
141 | static struct intrhand fakehand; | 135 | static struct intrhand fakehand; | |
142 | int irq, maxipl = ipl; | 136 | int maxipl = ipl; | |
143 | 137 | |||
144 | if (maxipl == IPL_NONE) | 138 | if (maxipl == IPL_NONE) | |
145 | maxipl = IPL_HIGH; | 139 | maxipl = IPL_HIGH; | |
146 | 140 | |||
147 | if (hwirq >= max_base) { | 141 | if (hwirq >= max_base) { | |
148 | ||||
149 | panic("%s: bogus IRQ %d, max is %d", __func__, hwirq, | 142 | panic("%s: bogus IRQ %d, max is %d", __func__, hwirq, | |
150 | max_base - 1); | 143 | max_base - 1); | |
151 | } | 144 | } | |
152 | 145 | |||
153 | pic = find_pic_by_irq(hwirq); | 146 | pic = find_pic_by_hwirq(hwirq); | |
154 | if (pic == NULL) { | 147 | if (pic == NULL) { | |
155 | 148 | |||
156 | panic("%s: cannot find a pic for IRQ %d", __func__, hwirq); | 149 | panic("%s: cannot find a pic for IRQ %d", __func__, hwirq); | |
157 | } | 150 | } | |
158 | 151 | |||
159 | irq = mapirq(hwirq); | 152 | const int virq = mapirq(hwirq); | |
160 | 153 | |||
161 | /* no point in sleeping unless someone can free memory. */ | 154 | /* no point in sleeping unless someone can free memory. */ | |
162 | ih = malloc(sizeof *ih, M_DEVBUF, cold ? M_NOWAIT : M_WAITOK); | 155 | ih = malloc(sizeof *ih, M_DEVBUF, cold ? M_NOWAIT : M_WAITOK); | |
163 | if (ih == NULL) | 156 | if (ih == NULL) | |
164 | panic("intr_establish: can't malloc handler info"); | 157 | panic("intr_establish: can't malloc handler info"); | |
165 | 158 | |||
166 | if (!LEGAL_VIRQ(irq) || type == IST_NONE) | 159 | if (!PIC_VIRQ_LEGAL_P(virq) || type == IST_NONE) | |
167 | panic("intr_establish: bogus irq (%d) or type (%d)", irq, type); | 160 | panic("intr_establish: bogus irq (%d) or type (%d)", | |
161 | hwirq, type); | |||
168 | 162 | |||
169 | is = &intrsources[irq]; | 163 | struct intr_source * const is = &intrsources[virq]; | |
170 | 164 | |||
171 | switch (is->is_type) { | 165 | switch (is->is_type) { | |
172 | case IST_NONE: | 166 | case IST_NONE: | |
173 | is->is_type = type; | 167 | is->is_type = type; | |
174 | break; | 168 | break; | |
175 | case IST_EDGE: | 169 | case IST_EDGE: | |
176 | case IST_LEVEL: | 170 | case IST_LEVEL: | |
177 | if (type == is->is_type) | 171 | if (type == is->is_type) | |
178 | break; | 172 | break; | |
173 | /* FALLTHROUGH */ | |||
179 | case IST_PULSE: | 174 | case IST_PULSE: | |
180 | if (type != IST_NONE) | 175 | if (type != IST_NONE) | |
181 | panic("intr_establish: can't share %s with %s", | 176 | panic("intr_establish: can't share %s with %s", | |
182 | intr_typename(is->is_type), | 177 | intr_typename(is->is_type), | |
183 | intr_typename(type)); | 178 | intr_typename(type)); | |
184 | break; | 179 | break; | |
185 | } | 180 | } | |
186 | if (is->is_hand == NULL) { | 181 | if (is->is_hand == NULL) { | |
187 | snprintf(is->is_source, sizeof(is->is_source), "irq %d", | 182 | snprintf(is->is_source, sizeof(is->is_source), "irq %d", | |
188 | is->is_hwirq); | 183 | is->is_hwirq); | |
189 | evcnt_attach_dynamic(&is->is_ev, EVCNT_TYPE_INTR, NULL, | 184 | evcnt_attach_dynamic(&is->is_ev, EVCNT_TYPE_INTR, NULL, | |
190 | pic->pic_name, is->is_source); | 185 | pic->pic_name, is->is_source); | |
191 | } | 186 | } | |
@@ -205,27 +200,27 @@ intr_establish(int hwirq, int type, int | @@ -205,27 +200,27 @@ intr_establish(int hwirq, int type, int | |||
205 | * until masking is set up. | 200 | * until masking is set up. | |
206 | */ | 201 | */ | |
207 | fakehand.ih_ipl = ipl; | 202 | fakehand.ih_ipl = ipl; | |
208 | fakehand.ih_fun = fakeintr; | 203 | fakehand.ih_fun = fakeintr; | |
209 | *p = &fakehand; | 204 | *p = &fakehand; | |
210 | 205 | |||
211 | /* | 206 | /* | |
212 | * Poke the real handler in now. | 207 | * Poke the real handler in now. | |
213 | */ | 208 | */ | |
214 | ih->ih_fun = ih_fun; | 209 | ih->ih_fun = ih_fun; | |
215 | ih->ih_arg = ih_arg; | 210 | ih->ih_arg = ih_arg; | |
216 | ih->ih_next = NULL; | 211 | ih->ih_next = NULL; | |
217 | ih->ih_ipl = ipl; | 212 | ih->ih_ipl = ipl; | |
218 | ih->ih_irq = irq; | 213 | ih->ih_virq = virq; | |
219 | *p = ih; | 214 | *p = ih; | |
220 | 215 | |||
221 | if (pic->pic_establish_irq != NULL) | 216 | if (pic->pic_establish_irq != NULL) | |
222 | pic->pic_establish_irq(pic, hwirq - pic->pic_intrbase, | 217 | pic->pic_establish_irq(pic, hwirq - pic->pic_intrbase, | |
223 | is->is_type, maxipl); | 218 | is->is_type, maxipl); | |
224 | 219 | |||
225 | /* | 220 | /* | |
226 | * Remember the highest IPL used by this handler. | 221 | * Remember the highest IPL used by this handler. | |
227 | */ | 222 | */ | |
228 | is->is_ipl = maxipl; | 223 | is->is_ipl = maxipl; | |
229 | 224 | |||
230 | /* | 225 | /* | |
231 | * now that the handler is established we're actually ready to | 226 | * now that the handler is established we're actually ready to | |
@@ -239,33 +234,33 @@ intr_establish(int hwirq, int type, int | @@ -239,33 +234,33 @@ intr_establish(int hwirq, int type, int | |||
239 | 234 | |||
240 | void | 235 | void | |
241 | dummy_pic_establish_intr(struct pic_ops *pic, int irq, int type, int pri) | 236 | dummy_pic_establish_intr(struct pic_ops *pic, int irq, int type, int pri) | |
242 | { | 237 | { | |
243 | } | 238 | } | |
244 | 239 | |||
245 | /* | 240 | /* | |
246 | * Deregister an interrupt handler. | 241 | * Deregister an interrupt handler. | |
247 | */ | 242 | */ | |
248 | void | 243 | void | |
249 | intr_disestablish(void *arg) | 244 | intr_disestablish(void *arg) | |
250 | { | 245 | { | |
251 | struct intrhand * const ih = arg; | 246 | struct intrhand * const ih = arg; | |
252 | const int irq = ih->ih_irq; | 247 | const int virq = ih->ih_virq; | |
253 | struct intr_source * const is = &intrsources[irq]; | 248 | struct intr_source * const is = &intrsources[virq]; | |
254 | struct intrhand **p, **q; | 249 | struct intrhand **p, **q; | |
255 | int maxipl = IPL_NONE; | 250 | int maxipl = IPL_NONE; | |
256 | 251 | |||
257 | if (!LEGAL_VIRQ(irq)) | 252 | if (!PIC_VIRQ_LEGAL_P(virq)) | |
258 | panic("intr_disestablish: bogus irq %d", irq); | 253 | panic("intr_disestablish: bogus virq %d", virq); | |
259 | 254 | |||
260 | /* | 255 | /* | |
261 | * Remove the handler from the chain. | 256 | * Remove the handler from the chain. | |
262 | * This is O(n^2), too. | 257 | * This is O(n^2), too. | |
263 | */ | 258 | */ | |
264 | for (p = &is->is_hand, q = NULL; (*p) != NULL; p = &(*p)->ih_next) { | 259 | for (p = &is->is_hand, q = NULL; (*p) != NULL; p = &(*p)->ih_next) { | |
265 | struct intrhand * const tmp_ih = *p; | 260 | struct intrhand * const tmp_ih = *p; | |
266 | if (tmp_ih == ih) { | 261 | if (tmp_ih == ih) { | |
267 | q = p; | 262 | q = p; | |
268 | } else { | 263 | } else { | |
269 | maxipl = max(maxipl, tmp_ih->ih_ipl); | 264 | maxipl = max(maxipl, tmp_ih->ih_ipl); | |
270 | } | 265 | } | |
271 | } | 266 | } | |
@@ -275,59 +270,66 @@ intr_disestablish(void *arg) | @@ -275,59 +270,66 @@ intr_disestablish(void *arg) | |||
275 | panic("intr_disestablish: handler not registered"); | 270 | panic("intr_disestablish: handler not registered"); | |
276 | free((void *)ih, M_DEVBUF); | 271 | free((void *)ih, M_DEVBUF); | |
277 | 272 | |||
278 | /* | 273 | /* | |
279 | * Reset the IPL for this source now that we've removed a handler. | 274 | * Reset the IPL for this source now that we've removed a handler. | |
280 | */ | 275 | */ | |
281 | is->is_ipl = maxipl; | 276 | is->is_ipl = maxipl; | |
282 | 277 | |||
283 | intr_calculatemasks(); | 278 | intr_calculatemasks(); | |
284 | 279 | |||
285 | if (is->is_hand == NULL) { | 280 | if (is->is_hand == NULL) { | |
286 | is->is_type = IST_NONE; | 281 | is->is_type = IST_NONE; | |
287 | evcnt_detach(&is->is_ev); | 282 | evcnt_detach(&is->is_ev); | |
283 | /* | |||
284 | * Make the virutal IRQ available again. | |||
285 | */ | |||
286 | virq_map[virq] = 0; | |||
287 | virq_mask |= PIC_VIRQ_TO_MASK(virq); | |||
288 | } | 288 | } | |
289 | } | 289 | } | |
290 | 290 | |||
291 | /* | 291 | /* | |
292 | * Map max_base irqs into 32 (bits). | 292 | * Map max_base irqs into 32 (bits). | |
293 | */ | 293 | */ | |
294 | static int | 294 | static int | |
295 | mapirq(uint32_t irq) | 295 | mapirq(int hwirq) | |
296 | { | 296 | { | |
297 | struct pic_ops *pic; | 297 | struct pic_ops *pic; | |
298 | int v; | |||
299 | 298 | |||
300 | if (irq >= max_base) | 299 | if (hwirq >= max_base) | |
301 | panic("invalid irq %d", irq); | 300 | panic("invalid irq %d", hwirq); | |
302 | 301 | |||
303 | if ((pic = find_pic_by_irq(irq)) == NULL) | 302 | if ((pic = find_pic_by_hwirq(hwirq)) == NULL) | |
304 | panic("%s: cannot find PIC for IRQ %d", __func__, irq); | 303 | panic("%s: cannot find PIC for HWIRQ %d", __func__, hwirq); | |
305 | 304 | |||
306 | if (virq[irq]) | 305 | if (virq_map[hwirq]) | |
307 | return virq[irq]; | 306 | return virq_map[hwirq]; | |
308 | 307 | |||
309 | virq_max++; | 308 | if (virq_mask == 0) | |
310 | v = virq_max; | |||
311 | if (v > HWIRQ_MAX) | |||
312 | panic("virq overflow"); | 309 | panic("virq overflow"); | |
313 | 310 | |||
314 | intrsources[v].is_hwirq = irq; | 311 | const int virq = PIC_VIRQ_MS_PENDING(virq_mask); | |
315 | intrsources[v].is_pic = pic; | 312 | struct intr_source * const is = intrsources + virq; | |
316 | virq[irq] = v; | 313 | ||
314 | virq_mask &= ~PIC_VIRQ_TO_MASK(virq); | |||
315 | ||||
316 | is->is_hwirq = hwirq; | |||
317 | is->is_pic = pic; | |||
318 | virq_map[hwirq] = virq; | |||
317 | #ifdef PIC_DEBUG | 319 | #ifdef PIC_DEBUG | |
318 | printf("mapping irq %d to virq %d\n", irq, v); | 320 | printf("mapping hwirq %d to virq %d\n", irq, virq); | |
319 | #endif | 321 | #endif | |
320 | return v; | 322 | return virq; | |
321 | } | 323 | } | |
322 | 324 | |||
323 | static const char * const intr_typenames[] = { | 325 | static const char * const intr_typenames[] = { | |
324 | [IST_NONE] = "none", | 326 | [IST_NONE] = "none", | |
325 | [IST_PULSE] = "pulsed", | 327 | [IST_PULSE] = "pulsed", | |
326 | [IST_EDGE] = "edge-triggered", | 328 | [IST_EDGE] = "edge-triggered", | |
327 | [IST_LEVEL] = "level-triggered", | 329 | [IST_LEVEL] = "level-triggered", | |
328 | }; | 330 | }; | |
329 | 331 | |||
330 | const char * | 332 | const char * | |
331 | intr_typename(int type) | 333 | intr_typename(int type) | |
332 | { | 334 | { | |
333 | KASSERT((unsigned int) type < __arraycount(intr_typenames)); | 335 | KASSERT((unsigned int) type < __arraycount(intr_typenames)); | |
@@ -344,27 +346,27 @@ intr_typename(int type) | @@ -344,27 +346,27 @@ intr_typename(int type) | |||
344 | static void | 346 | static void | |
345 | intr_calculatemasks(void) | 347 | intr_calculatemasks(void) | |
346 | { | 348 | { | |
347 | imask_t newmask[NIPL] = { [IPL_NONE...IPL_HIGH] = 0 }; | 349 | imask_t newmask[NIPL] = { [IPL_NONE...IPL_HIGH] = 0 }; | |
348 | struct intr_source *is; | 350 | struct intr_source *is; | |
349 | int irq; | 351 | int irq; | |
350 | 352 | |||
351 | for (u_int ipl = IPL_NONE; ipl < NIPL; ipl++) { | 353 | for (u_int ipl = IPL_NONE; ipl < NIPL; ipl++) { | |
352 | newmask[ipl] = 0; | 354 | newmask[ipl] = 0; | |
353 | } | 355 | } | |
354 | 356 | |||
355 | /* First, figure out which ipl each IRQ uses. */ | 357 | /* First, figure out which ipl each IRQ uses. */ | |
356 | for (irq = 0, is = intrsources; irq < NVIRQ; irq++, is++) { | 358 | for (irq = 0, is = intrsources; irq < NVIRQ; irq++, is++) { | |
357 | newmask[is->is_ipl] |= 1ULL << irq; | 359 | newmask[is->is_ipl] |= PIC_VIRQ_TO_MASK(irq); | |
358 | } | 360 | } | |
359 | 361 | |||
360 | /* | 362 | /* | |
361 | * IPL_NONE is used for hardware interrupts that are never blocked, | 363 | * IPL_NONE is used for hardware interrupts that are never blocked, | |
362 | * and do not block anything else. | 364 | * and do not block anything else. | |
363 | */ | 365 | */ | |
364 | newmask[IPL_NONE] = 0; | 366 | newmask[IPL_NONE] = 0; | |
365 | 367 | |||
366 | /* | 368 | /* | |
367 | * strict hierarchy - all IPLs block everything blocked by any lower | 369 | * strict hierarchy - all IPLs block everything blocked by any lower | |
368 | * IPL | 370 | * IPL | |
369 | */ | 371 | */ | |
370 | for (u_int ipl = 1; ipl < NIPL; ipl++) { | 372 | for (u_int ipl = 1; ipl < NIPL; ipl++) { | |
@@ -394,259 +396,191 @@ intr_calculatemasks(void) | @@ -394,259 +396,191 @@ intr_calculatemasks(void) | |||
394 | imask[ipl] = newmask[ipl]; | 396 | imask[ipl] = newmask[ipl]; | |
395 | } | 397 | } | |
396 | 398 | |||
397 | /* | 399 | /* | |
398 | * Lastly, enable IRQs actually in use. | 400 | * Lastly, enable IRQs actually in use. | |
399 | */ | 401 | */ | |
400 | for (irq = 0, is = intrsources; irq < NVIRQ; irq++, is++) { | 402 | for (irq = 0, is = intrsources; irq < NVIRQ; irq++, is++) { | |
401 | if (is->is_hand) | 403 | if (is->is_hand) | |
402 | pic_enable_irq(is->is_hwirq); | 404 | pic_enable_irq(is->is_hwirq); | |
403 | } | 405 | } | |
404 | } | 406 | } | |
405 | 407 | |||
406 | void | 408 | void | |
407 | pic_enable_irq(int num) | 409 | pic_enable_irq(int hwirq) | |
408 | { | 410 | { | |
409 | struct pic_ops *current; | 411 | struct pic_ops * const pic = find_pic_by_hwirq(hwirq); | |
410 | int type; | 412 | if (pic == NULL) | |
411 | 413 | panic("%s: bogus IRQ %d", __func__, hwirq); | ||
412 | current = find_pic_by_irq(num); | 414 | const int type = intrsources[virq_map[hwirq]].is_type; | |
413 | if (current == NULL) | 415 | (*pic->pic_enable_irq)(pic, hwirq - pic->pic_intrbase, type); | |
414 | panic("%s: bogus IRQ %d", __func__, num); | |||
415 | type = intrsources[virq[num]].is_type; | |||
416 | current->pic_enable_irq(current, num - current->pic_intrbase, type); | |||
417 | } | 416 | } | |
418 | 417 | |||
419 | void | 418 | void | |
420 | pic_mark_pending(int irq) | 419 | pic_mark_pending(int hwirq) | |
421 | { | 420 | { | |
422 | struct cpu_info * const ci = curcpu(); | 421 | struct cpu_info * const ci = curcpu(); | |
423 | int v, msr; | |||
424 | 422 | |||
425 | v = virq[irq]; | 423 | const int virq = virq_map[hwirq]; | |
426 | if (v == 0) | 424 | if (virq == 0) | |
427 | printf("IRQ %d maps to 0\n", irq); | 425 | printf("IRQ %d maps to 0\n", hwirq); | |
428 | 426 | |||
429 | msr = mfmsr(); | 427 | const register_t msr = mfmsr(); | |
430 | mtmsr(msr & ~PSL_EE); | 428 | mtmsr(msr & ~PSL_EE); | |
431 | ci->ci_ipending |= 1ULL << v; | 429 | ci->ci_ipending |= PIC_VIRQ_TO_MASK(virq); | |
432 | mtmsr(msr); | 430 | mtmsr(msr); | |
433 | } | 431 | } | |
434 | 432 | |||
433 | static void | |||
434 | intr_deliver(struct intr_source *is, int virq) | |||
435 | { | |||
436 | bool locked = false; | |||
437 | for (struct intrhand *ih = is->is_hand; ih != NULL; ih = ih->ih_next) { | |||
438 | KASSERTMSG(ih->ih_fun != NULL, | |||
439 | ("%s: irq %d, hwirq %d, is %p ih %p: " | |||
440 | "NULL interrupt handler!\n", __func__, | |||
441 | virq, is->is_hwirq, is, ih)); | |||
442 | if (ih->ih_ipl == IPL_VM) { | |||
443 | if (!locked) { | |||
444 | KERNEL_LOCK(1, NULL); | |||
445 | locked = true; | |||
446 | } | |||
447 | } else if (locked) { | |||
448 | KERNEL_UNLOCK_ONE(NULL); | |||
449 | locked = false; | |||
450 | } | |||
451 | (*ih->ih_fun)(ih->ih_arg); | |||
452 | } | |||
453 | if (locked) { | |||
454 | KERNEL_UNLOCK_ONE(NULL); | |||
455 | } | |||
456 | is->is_ev.ev_count++; | |||
457 | } | |||
458 | ||||
435 | void | 459 | void | |
436 | pic_do_pending_int(void) | 460 | pic_do_pending_int(void) | |
437 | { | 461 | { | |
438 | struct cpu_info * const ci = curcpu(); | 462 | struct cpu_info * const ci = curcpu(); | |
439 | struct intr_source *is; | 463 | imask_t vpend; | |
440 | struct intrhand *ih; | |||
441 | struct pic_ops *pic; | |||
442 | int irq; | |||
443 | int pcpl; | |||
444 | imask_t hwpend; | |||
445 | int emsr, dmsr; | |||
446 | 464 | |||
447 | if (ci->ci_iactive) | 465 | if (ci->ci_iactive) | |
448 | return; | 466 | return; | |
449 | 467 | |||
450 | ci->ci_iactive = 1; | 468 | ci->ci_iactive = 1; | |
451 | emsr = mfmsr(); | 469 | ||
470 | const register_t emsr = mfmsr(); | |||
471 | const register_t dmsr = emsr & ~PSL_EE; | |||
472 | ||||
452 | KASSERT(emsr & PSL_EE); | 473 | KASSERT(emsr & PSL_EE); | |
453 | dmsr = emsr & ~PSL_EE; | |||
454 | mtmsr(dmsr); | 474 | mtmsr(dmsr); | |
455 | 475 | |||
456 | pcpl = ci->ci_cpl; | 476 | const int pcpl = ci->ci_cpl; | |
457 | #ifdef __HAVE_FAST_SOFTINTS | 477 | #ifdef __HAVE_FAST_SOFTINTS | |
458 | #if 0 | |||
459 | again: | 478 | again: | |
460 | #endif | 479 | #endif | |
461 | #endif | |||
462 | 480 | |||
463 | /* Do now unmasked pendings */ | 481 | /* Do now unmasked pendings */ | |
464 | while ((hwpend = (ci->ci_ipending & ~imask[pcpl] & HWIRQ_MASK)) != 0) { | 482 | while ((vpend = (ci->ci_ipending & ~imask[pcpl])) != 0) { | |
465 | ci->ci_idepth++; | 483 | ci->ci_idepth++; | |
484 | KASSERT((PIC_VIRQ_TO_MASK(0) & ci->ci_ipending) == 0); | |||
485 | ||||
466 | /* Get most significant pending bit */ | 486 | /* Get most significant pending bit */ | |
467 | irq = MS_PENDING(hwpend); | 487 | const int virq = PIC_VIRQ_MS_PENDING(vpend); | |
468 | KASSERT(irq <= virq_max); | 488 | ci->ci_ipending &= ~PIC_VIRQ_TO_MASK(virq); | |
469 | ci->ci_ipending &= ~(1ULL << irq); | 489 | ||
470 | if (irq == 0) { | 490 | struct intr_source * const is = &intrsources[virq]; | |
471 | printf("VIRQ0"); | 491 | struct pic_ops * const pic = is->is_pic; | |
472 | continue; | |||
473 | } | |||
474 | is = &intrsources[irq]; | |||
475 | pic = is->is_pic; | |||
476 | 492 | |||
477 | splraise(is->is_ipl); | 493 | splraise(is->is_ipl); | |
478 | mtmsr(emsr); | 494 | mtmsr(emsr); | |
479 | ih = is->is_hand; | 495 | intr_deliver(is, virq); | |
480 | while (ih) { | |||
481 | #ifdef DIAGNOSTIC | |||
482 | if (!ih->ih_fun) { | |||
483 | printf("NULL interrupt handler!\n"); | |||
484 | panic("irq %02d, hwirq %02d, is %p\n", | |||
485 | irq, is->is_hwirq, is); | |||
486 | } | |||
487 | #endif | |||
488 | if (ih->ih_ipl == IPL_VM) { | |||
489 | KERNEL_LOCK(1, NULL); | |||
490 | } | |||
491 | (*ih->ih_fun)(ih->ih_arg); | |||
492 | if (ih->ih_ipl == IPL_VM) { | |||
493 | KERNEL_UNLOCK_ONE(NULL); | |||
494 | } | |||
495 | ih = ih->ih_next; | |||
496 | } | |||
497 | mtmsr(dmsr); | 496 | mtmsr(dmsr); | |
498 | ci->ci_cpl = pcpl; | 497 | ci->ci_cpl = pcpl; /* Don't use splx... we are here already! */ | |
499 | 498 | |||
500 | is->is_ev.ev_count++; | |||
501 | pic->pic_reenable_irq(pic, is->is_hwirq - pic->pic_intrbase, | 499 | pic->pic_reenable_irq(pic, is->is_hwirq - pic->pic_intrbase, | |
502 | is->is_type); | 500 | is->is_type); | |
503 | ci->ci_idepth--; | 501 | ci->ci_idepth--; | |
504 | } | 502 | } | |
505 | 503 | |||
506 | #ifdef __HAVE_FAST_SOFTINTS | 504 | #ifdef __HAVE_FAST_SOFTINTS | |
507 | #if 0 | |||
508 | if ((ci->ci_ipending & ~pcpl) & (1ULL << SIR_SERIAL)) { | |||
509 | ci->ci_ipending &= ~(1ULL << SIR_SERIAL); | |||
510 | splsoftserial(); | |||
511 | mtmsr(emsr); | |||
512 | softintr__run(IPL_SOFTSERIAL); | |||
513 | mtmsr(dmsr); | |||
514 | ci->ci_cpl = pcpl; | |||
515 | ci->ci_ev_softserial.ev_count++; | |||
516 | goto again; | |||
517 | } | |||
518 | if ((ci->ci_ipending & ~pcpl) & (1ULL << SIR_NET)) { | |||
519 | ci->ci_ipending &= ~(1ULL << SIR_NET); | |||
520 | splsoftnet(); | |||
521 | mtmsr(emsr); | |||
522 | softintr__run(IPL_SOFTNET); | |||
523 | mtmsr(dmsr); | |||
524 | ci->ci_cpl = pcpl; | |||
525 | ci->ci_ev_softnet.ev_count++; | |||
526 | goto again; | |||
527 | } | |||
528 | if ((ci->ci_ipending & ~pcpl) & (1ULL << SIR_CLOCK)) { | |||
529 | ci->ci_ipending &= ~(1ULL << SIR_CLOCK); | |||
530 | splsoftclock(); | |||
531 | mtmsr(emsr); | |||
532 | softintr__run(IPL_SOFTCLOCK); | |||
533 | mtmsr(dmsr); | |||
534 | ci->ci_cpl = pcpl; | |||
535 | ci->ci_ev_softclock.ev_count++; | |||
536 | goto again; | |||
537 | } | |||
538 | #else | |||
539 | const u_int softints = (ci->ci_data.cpu_softints << pcpl) & IPL_SOFTMASK; | 505 | const u_int softints = (ci->ci_data.cpu_softints << pcpl) & IPL_SOFTMASK; | |
540 | 506 | |||
541 | if (__predict_false(softints != 0)) { | 507 | if (__predict_false(softints != 0)) { | |
542 | splhigh(); | 508 | ci->ci_cpl = IPL_HIGH; | |
509 | mtmsr(emsr); | |||
543 | powerpc_softint(ci, pcpl, | 510 | powerpc_softint(ci, pcpl, | |
544 | (vaddr_t)__builtin_return_address(0)); | 511 | (vaddr_t)__builtin_return_address(0)); | |
512 | mtmsr(dmsr); | |||
545 | ci->ci_cpl = pcpl; | 513 | ci->ci_cpl = pcpl; | |
514 | if (__predict_false(ci->ci_ipending & ~imask[pcpl])) | |||
515 | goto again; | |||
546 | } | 516 | } | |
547 | #endif | 517 | #endif | |
548 | #endif | |||
549 | 518 | |||
550 | ci->ci_cpl = pcpl; /* Don't use splx... we are here already! */ | |||
551 | ci->ci_iactive = 0; | 519 | ci->ci_iactive = 0; | |
552 | mtmsr(emsr); | 520 | mtmsr(emsr); | |
553 | } | 521 | } | |
554 | 522 | |||
555 | int | 523 | int | |
556 | pic_handle_intr(void *cookie) | 524 | pic_handle_intr(void *cookie) | |
557 | { | 525 | { | |
558 | struct pic_ops *pic = cookie; | 526 | struct pic_ops *pic = cookie; | |
559 | struct cpu_info *ci = curcpu(); | 527 | struct cpu_info *ci = curcpu(); | |
560 | struct intr_source *is; | 528 | int picirq; | |
561 | struct intrhand *ih; | |||
562 | int irq, realirq; | |||
563 | int pcpl, msr, bail; | |||
564 | imask_t r_imen; | |||
565 | 529 | |||
566 | realirq = pic->pic_get_irq(pic, PIC_GET_IRQ); | 530 | picirq = pic->pic_get_irq(pic, PIC_GET_IRQ); | |
567 | if (realirq == 255) | 531 | if (picirq == 255) | |
568 | return 0; | 532 | return 0; | |
569 | 533 | |||
570 | msr = mfmsr(); | 534 | const register_t msr = mfmsr(); | |
571 | pcpl = ci->ci_cpl; | 535 | const int pcpl = ci->ci_cpl; | |
572 | ||||
573 | start: | |||
574 | 536 | |||
537 | do { | |||
575 | #ifdef MULTIPROCESSOR | 538 | #ifdef MULTIPROCESSOR | |
576 | /* THIS IS WRONG XXX */ | 539 | /* THIS IS WRONG XXX */ | |
577 | while (realirq == ipiops.ppc_ipi_vector) { | 540 | if (picirq == ipiops.ppc_ipi_vector) { | |
578 | ipi_intr(NULL); | 541 | ci->ci_cpl = IPL_HIGH; | |
579 | pic->pic_ack_irq(pic, realirq); | 542 | ipi_intr(NULL); | |
580 | realirq = pic->pic_get_irq(pic, PIC_GET_RECHECK); | 543 | ci->ci_cpl = pcpl; | |
581 | } | 544 | pic->pic_ack_irq(pic, picirq); | |
582 | if (realirq == 255) { | 545 | continue; | |
583 | return 0; | 546 | } | |
584 | } | |||
585 | #endif | 547 | #endif | |
586 | 548 | |||
587 | irq = virq[realirq + pic->pic_intrbase]; | 549 | const int virq = virq_map[picirq + pic->pic_intrbase]; | |
588 | #ifdef PIC_DEBUG | 550 | KASSERT(virq != 0); | |
589 | if (irq == 0) { | 551 | KASSERT(picirq < pic->pic_numintrs); | |
590 | printf("%s: %d virq 0\n", pic->pic_name, realirq); | 552 | imask_t v_imen = PIC_VIRQ_TO_MASK(virq); | |
591 | goto boo; | 553 | struct intr_source * const is = &intrsources[virq]; | |
592 | } | 554 | ||
593 | #endif /* PIC_DEBUG */ | 555 | if ((imask[pcpl] & v_imen) != 0) { | |
594 | KASSERT(realirq < pic->pic_numintrs); | 556 | ci->ci_ipending |= v_imen; /* Masked! Mark this as pending */ | |
595 | r_imen = 1ULL << irq; | 557 | pic->pic_disable_irq(pic, picirq); | |
596 | is = &intrsources[irq]; | 558 | } else { | |
597 | 559 | /* this interrupt is no longer pending */ | ||
598 | if ((imask[pcpl] & r_imen) != 0) { | 560 | ci->ci_ipending &= ~v_imen; | |
599 | 561 | ci->ci_idepth++; | ||
600 | ci->ci_ipending |= r_imen; /* Masked! Mark this as pending */ | 562 | ||
601 | pic->pic_disable_irq(pic, realirq); | 563 | splraise(is->is_ipl); | |
602 | } else { | 564 | mtmsr(msr | PSL_EE); | |
603 | 565 | intr_deliver(is, virq); | ||
604 | /* this interrupt is no longer pending */ | 566 | mtmsr(msr); | |
605 | ci->ci_ipending &= ~r_imen; | 567 | ci->ci_cpl = pcpl; | |
606 | ci->ci_idepth++; | |||
607 | 568 | |||
608 | splraise(is->is_ipl); | 569 | ci->ci_data.cpu_nintr++; | |
609 | mtmsr(msr | PSL_EE); | 570 | ci->ci_idepth--; | |
610 | ih = is->is_hand; | |||
611 | bail = 0; | |||
612 | while ((ih != NULL) && (bail < 10)) { | |||
613 | if (ih->ih_fun == NULL) | |||
614 | panic("bogus handler for IRQ %s %d", | |||
615 | pic->pic_name, realirq); | |||
616 | if (ih->ih_ipl == IPL_VM) { | |||
617 | KERNEL_LOCK(1, NULL); | |||
618 | } | |||
619 | (*ih->ih_fun)(ih->ih_arg); | |||
620 | if (ih->ih_ipl == IPL_VM) { | |||
621 | KERNEL_UNLOCK_ONE(NULL); | |||
622 | } | |||
623 | ih = ih->ih_next; | |||
624 | bail++; | |||
625 | } | 571 | } | |
626 | mtmsr(msr); | 572 | pic->pic_ack_irq(pic, picirq); | |
627 | ci->ci_cpl = pcpl; | 573 | } while ((picirq = pic->pic_get_irq(pic, PIC_GET_RECHECK)) != 255); | |
628 | ||||
629 | ci->ci_data.cpu_nintr++; | |||
630 | is->is_ev.ev_count++; | |||
631 | ci->ci_idepth--; | |||
632 | } | |||
633 | #ifdef PIC_DEBUG | |||
634 | boo: | |||
635 | #endif /* PIC_DEBUG */ | |||
636 | pic->pic_ack_irq(pic, realirq); | |||
637 | realirq = pic->pic_get_irq(pic, PIC_GET_RECHECK); | |||
638 | if (realirq != 255) | |||
639 | goto start; | |||
640 | 574 | |||
641 | mtmsr(msr | PSL_EE); | 575 | mtmsr(msr | PSL_EE); | |
642 | splx(pcpl); /* Process pendings. */ | 576 | splx(pcpl); /* Process pendings. */ | |
643 | mtmsr(msr); | 577 | mtmsr(msr); | |
644 | 578 | |||
645 | return 0; | 579 | return 0; | |
646 | } | 580 | } | |
647 | 581 | |||
648 | void | 582 | void | |
649 | pic_ext_intr(void) | 583 | pic_ext_intr(void) | |
650 | { | 584 | { | |
651 | 585 | |||
652 | KASSERT(pics[primary_pic] != NULL); | 586 | KASSERT(pics[primary_pic] != NULL); | |
@@ -737,27 +671,27 @@ genppc_isa_intr_alloc(isa_chipset_tag_t | @@ -737,27 +671,27 @@ genppc_isa_intr_alloc(isa_chipset_tag_t | |||
737 | { | 671 | { | |
738 | int irq, vi; | 672 | int irq, vi; | |
739 | int maybe_irq = -1; | 673 | int maybe_irq = -1; | |
740 | int shared_depth = 0; | 674 | int shared_depth = 0; | |
741 | struct intr_source *is; | 675 | struct intr_source *is; | |
742 | 676 | |||
743 | if (pic == NULL) | 677 | if (pic == NULL) | |
744 | return 1; | 678 | return 1; | |
745 | 679 | |||
746 | for (irq = 0; (mask != 0 && irq < pic->pic_numintrs); | 680 | for (irq = 0; (mask != 0 && irq < pic->pic_numintrs); | |
747 | mask >>= 1, irq++) { | 681 | mask >>= 1, irq++) { | |
748 | if ((mask & 1) == 0) | 682 | if ((mask & 1) == 0) | |
749 | continue; | 683 | continue; | |
750 | vi = virq[irq + pic->pic_intrbase]; | 684 | vi = virq_map[irq + pic->pic_intrbase]; | |
751 | if (!vi) { | 685 | if (!vi) { | |
752 | *irq_p = irq; | 686 | *irq_p = irq; | |
753 | return 0; | 687 | return 0; | |
754 | } | 688 | } | |
755 | is = &intrsources[vi]; | 689 | is = &intrsources[vi]; | |
756 | if (is->is_type == IST_NONE) { | 690 | if (is->is_type == IST_NONE) { | |
757 | *irq_p = irq; | 691 | *irq_p = irq; | |
758 | return 0; | 692 | return 0; | |
759 | } | 693 | } | |
760 | /* Level interrupts can be shared */ | 694 | /* Level interrupts can be shared */ | |
761 | if (type == IST_LEVEL && is->is_type == IST_LEVEL) { | 695 | if (type == IST_LEVEL && is->is_type == IST_LEVEL) { | |
762 | struct intrhand *ih = is->is_hand; | 696 | struct intrhand *ih = is->is_hand; | |
763 | int depth; | 697 | int depth; |
--- src/sys/arch/prep/include/intr.h 2010/11/13 14:07:07 1.33
+++ src/sys/arch/prep/include/intr.h 2011/06/17 23:36:18 1.34
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: intr.h,v 1.33 2010/11/13 14:07:07 uebayasi Exp $ */ | 1 | /* $NetBSD: intr.h,v 1.34 2011/06/17 23:36:18 matt Exp $ */ | |
2 | 2 | |||
3 | /*- | 3 | /*- | |
4 | * Copyright (c) 2007 The NetBSD Foundation, Inc. | 4 | * Copyright (c) 2007 The NetBSD Foundation, Inc. | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * This code is derived from software contributed to The NetBSD Foundation | 7 | * This code is derived from software contributed to The NetBSD Foundation | |
8 | * by Tim Rightnour | 8 | * by Tim Rightnour | |
9 | * | 9 | * | |
10 | * Redistribution and use in source and binary forms, with or without | 10 | * Redistribution and use in source and binary forms, with or without | |
11 | * modification, are permitted provided that the following conditions | 11 | * modification, are permitted provided that the following conditions | |
12 | * are met: | 12 | * are met: | |
13 | * 1. Redistributions of source code must retain the above copyright | 13 | * 1. Redistributions of source code must retain the above copyright | |
14 | * notice, this list of conditions and the following disclaimer. | 14 | * notice, this list of conditions and the following disclaimer. | |
@@ -22,40 +22,39 @@ | @@ -22,40 +22,39 @@ | |||
22 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS | 22 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS | |
23 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | 23 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | |
24 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | 24 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | |
25 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | 25 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | |
26 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | 26 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | |
27 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | 27 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
28 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | 28 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | |
29 | * POSSIBILITY OF SUCH DAMAGE. | 29 | * POSSIBILITY OF SUCH DAMAGE. | |
30 | */ | 30 | */ | |
31 | 31 | |||
32 | #ifndef _PREP_INTR_H_ | 32 | #ifndef _PREP_INTR_H_ | |
33 | #define _PREP_INTR_H_ | 33 | #define _PREP_INTR_H_ | |
34 | 34 | |||
35 | #include <powerpc/intr.h> | |||
36 | ||||
37 | #ifndef _LOCORE | 35 | #ifndef _LOCORE | |
38 | #include <machine/cpu.h> | |||
39 | 36 | |||
40 | void init_intr_ivr(void); | 37 | void init_intr_ivr(void); | |
41 | void init_intr_openpic(void); | 38 | void init_intr_openpic(void); | |
42 | void openpic_init(unsigned char *); | 39 | void openpic_init(unsigned char *); | |
43 | void enable_intr(void); | 40 | void enable_intr(void); | |
44 | void disable_intr(void); | 41 | void disable_intr(void); | |
45 | 42 | |||
46 | extern vaddr_t prep_intr_reg; | 43 | extern vaddr_t prep_intr_reg; | |
47 | extern uint32_t prep_intr_reg_off; | 44 | extern uint32_t prep_intr_reg_off; | |
48 | 45 | |||
49 | #define ICU_LEN 32 | 46 | #define ICU_LEN 32 | |
50 | 47 | |||
51 | #define IRQ_SLAVE 2 | 48 | #define IRQ_SLAVE 2 | |
52 | #define LEGAL_IRQ(x) ((x) >= 0 && (x) < ICU_LEN && (x) != IRQ_SLAVE) | 49 | #define LEGAL_HWIRQ_P(x) ((u_int)(x) < ICU_LEN && (x) != IRQ_SLAVE) | |
53 | #define I8259_INTR_NUM 16 | 50 | #define I8259_INTR_NUM 16 | |
54 | #define OPENPIC_INTR_NUM ((ICU_LEN)-(I8259_INTR_NUM)) | 51 | #define OPENPIC_INTR_NUM ((ICU_LEN)-(I8259_INTR_NUM)) | |
55 | 52 | |||
56 | #define PREP_INTR_REG 0xbffff000 | 53 | #define PREP_INTR_REG 0xbffff000 | |
57 | #define INTR_VECTOR_REG 0xff0 | 54 | #define INTR_VECTOR_REG 0xff0 | |
58 | 55 | |||
59 | #endif /* !_LOCORE */ | 56 | #endif /* !_LOCORE */ | |
60 | 57 | |||
58 | #include <powerpc/intr.h> | |||
59 | ||||
61 | #endif /* !_PREP_INTR_H_ */ | 60 | #endif /* !_PREP_INTR_H_ */ |
--- src/sys/arch/prep/pnpbus/if_we_pnpbus.c 2009/03/14 21:04:14 1.5
+++ src/sys/arch/prep/pnpbus/if_we_pnpbus.c 2011/06/17 23:36:18 1.6
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: if_we_pnpbus.c,v 1.5 2009/03/14 21:04:14 dsl Exp $ */ | 1 | /* $NetBSD: if_we_pnpbus.c,v 1.6 2011/06/17 23:36:18 matt Exp $ */ | |
2 | 2 | |||
3 | /*- | 3 | /*- | |
4 | * Copyright (c) 1997, 1998 The NetBSD Foundation, Inc. | 4 | * Copyright (c) 1997, 1998 The NetBSD Foundation, Inc. | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * This code is derived from software contributed to The NetBSD Foundation | 7 | * This code is derived from software contributed to The NetBSD Foundation | |
8 | * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility, | 8 | * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility, | |
9 | * NASA Ames Research Center. | 9 | * NASA Ames Research Center. | |
10 | * | 10 | * | |
11 | * Redistribution and use in source and binary forms, with or without | 11 | * Redistribution and use in source and binary forms, with or without | |
12 | * modification, are permitted provided that the following conditions | 12 | * modification, are permitted provided that the following conditions | |
13 | * are met: | 13 | * are met: | |
14 | * 1. Redistributions of source code must retain the above copyright | 14 | * 1. Redistributions of source code must retain the above copyright | |
@@ -39,27 +39,27 @@ | @@ -39,27 +39,27 @@ | |||
39 | * Copyright (C) 1993, David Greenman. This software may be used, modified, | 39 | * Copyright (C) 1993, David Greenman. This software may be used, modified, | |
40 | * copied, distributed, and sold, in both source and binary form provided that | 40 | * copied, distributed, and sold, in both source and binary form provided that | |
41 | * the above copyright and these terms are retained. Under no circumstances is | 41 | * the above copyright and these terms are retained. Under no circumstances is | |
42 | * the author responsible for the proper functioning of this software, nor does | 42 | * the author responsible for the proper functioning of this software, nor does | |
43 | * the author assume any responsibility for damages incurred with its use. | 43 | * the author assume any responsibility for damages incurred with its use. | |
44 | */ | 44 | */ | |
45 | 45 | |||
46 | /* | 46 | /* | |
47 | * Device driver for the Western Digital/SMC 8003 and 8013 series, | 47 | * Device driver for the Western Digital/SMC 8003 and 8013 series, | |
48 | * and the SMC Elite Ultra (8216). | 48 | * and the SMC Elite Ultra (8216). | |
49 | */ | 49 | */ | |
50 | 50 | |||
51 | #include <sys/cdefs.h> | 51 | #include <sys/cdefs.h> | |
52 | __KERNEL_RCSID(0, "$NetBSD: if_we_pnpbus.c,v 1.5 2009/03/14 21:04:14 dsl Exp $"); | 52 | __KERNEL_RCSID(0, "$NetBSD: if_we_pnpbus.c,v 1.6 2011/06/17 23:36:18 matt Exp $"); | |
53 | 53 | |||
54 | #include <sys/types.h> | 54 | #include <sys/types.h> | |
55 | #include <sys/param.h> | 55 | #include <sys/param.h> | |
56 | #include <sys/systm.h> | 56 | #include <sys/systm.h> | |
57 | #include <sys/device.h> | 57 | #include <sys/device.h> | |
58 | #include <sys/socket.h> | 58 | #include <sys/socket.h> | |
59 | #include <sys/mbuf.h> | 59 | #include <sys/mbuf.h> | |
60 | #include <sys/syslog.h> | 60 | #include <sys/syslog.h> | |
61 | #include <sys/bswap.h> | 61 | #include <sys/bswap.h> | |
62 | 62 | |||
63 | #include <net/if.h> | 63 | #include <net/if.h> | |
64 | #include <net/if_dl.h> | 64 | #include <net/if_dl.h> | |
65 | #include <net/if_types.h> | 65 | #include <net/if_types.h> | |
@@ -228,27 +228,27 @@ we_pnpbus_attach(struct device *parent, | @@ -228,27 +228,27 @@ we_pnpbus_attach(struct device *parent, | |||
228 | bus_space_read_1(asict, asich, WE_IRR) | WE_IRR_IEN); | 228 | bus_space_read_1(asict, asich, WE_IRR) | WE_IRR_IEN); | |
229 | #endif | 229 | #endif | |
230 | 230 | |||
231 | /* | 231 | /* | |
232 | * Establish interrupt handler. | 232 | * Establish interrupt handler. | |
233 | * Loop through all probed IRQs until one looks sane. | 233 | * Loop through all probed IRQs until one looks sane. | |
234 | */ | 234 | */ | |
235 | for (i = 0, irq = SIMPLEQ_FIRST(&pna->pna_res.irq); | 235 | for (i = 0, irq = SIMPLEQ_FIRST(&pna->pna_res.irq); | |
236 | i < pna->pna_res.numirq; i++, irq = SIMPLEQ_NEXT(irq, next)) { | 236 | i < pna->pna_res.numirq; i++, irq = SIMPLEQ_NEXT(irq, next)) { | |
237 | irqnum = ffs(irq->mask) - 1; | 237 | irqnum = ffs(irq->mask) - 1; | |
238 | /* some cards think they are level. force them to edge */ | 238 | /* some cards think they are level. force them to edge */ | |
239 | if (irq->flags & 0x0c) | 239 | if (irq->flags & 0x0c) | |
240 | irq->flags = 0x01; | 240 | irq->flags = 0x01; | |
241 | if (!LEGAL_IRQ(irqnum)) | 241 | if (!LEGAL_HWIRQ_P(irqnum)) | |
242 | continue; | 242 | continue; | |
243 | if (irqnum < 2) | 243 | if (irqnum < 2) | |
244 | continue; | 244 | continue; | |
245 | break; | 245 | break; | |
246 | } | 246 | } | |
247 | wsc->sc_ih = pnpbus_intr_establish(i, IPL_NET, IST_PNP, dp8390_intr, sc, | 247 | wsc->sc_ih = pnpbus_intr_establish(i, IPL_NET, IST_PNP, dp8390_intr, sc, | |
248 | &pna->pna_res); | 248 | &pna->pna_res); | |
249 | if (wsc->sc_ih == NULL) | 249 | if (wsc->sc_ih == NULL) | |
250 | aprint_error("%s: can't establish interrupt\n", | 250 | aprint_error("%s: can't establish interrupt\n", | |
251 | device_xname(self)); | 251 | device_xname(self)); | |
252 | } | 252 | } | |
253 | 253 | |||
254 | static const char * | 254 | static const char * |
--- src/sys/arch/rs6000/include/intr.h 2010/11/13 14:07:08 1.4
+++ src/sys/arch/rs6000/include/intr.h 2011/06/17 23:36:18 1.5
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: intr.h,v 1.4 2010/11/13 14:07:08 uebayasi Exp $ */ | 1 | /* $NetBSD: intr.h,v 1.5 2011/06/17 23:36:18 matt Exp $ */ | |
2 | 2 | |||
3 | /*- | 3 | /*- | |
4 | * Copyright (c) 1998 The NetBSD Foundation, Inc. | 4 | * Copyright (c) 1998 The NetBSD Foundation, Inc. | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * This code is derived from software contributed to The NetBSD Foundation | 7 | * This code is derived from software contributed to The NetBSD Foundation | |
8 | * by Charles M. Hannum. | 8 | * by Charles M. Hannum. | |
9 | * | 9 | * | |
10 | * Redistribution and use in source and binary forms, with or without | 10 | * Redistribution and use in source and binary forms, with or without | |
11 | * modification, are permitted provided that the following conditions | 11 | * modification, are permitted provided that the following conditions | |
12 | * are met: | 12 | * are met: | |
13 | * 1. Redistributions of source code must retain the above copyright | 13 | * 1. Redistributions of source code must retain the above copyright | |
14 | * notice, this list of conditions and the following disclaimer. | 14 | * notice, this list of conditions and the following disclaimer. | |
@@ -22,23 +22,22 @@ | @@ -22,23 +22,22 @@ | |||
22 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS | 22 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS | |
23 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | 23 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | |
24 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | 24 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | |
25 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | 25 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | |
26 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | 26 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | |
27 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | 27 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
28 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | 28 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | |
29 | * POSSIBILITY OF SUCH DAMAGE. | 29 | * POSSIBILITY OF SUCH DAMAGE. | |
30 | */ | 30 | */ | |
31 | 31 | |||
32 | #ifndef _RS6000_INTR_H_ | 32 | #ifndef _RS6000_INTR_H_ | |
33 | #define _RS6000_INTR_H_ | 33 | #define _RS6000_INTR_H_ | |
34 | 34 | |||
35 | #include <powerpc/intr.h> | |||
36 | ||||
37 | #ifndef _LOCORE | 35 | #ifndef _LOCORE | |
38 | #include <machine/cpu.h> | |||
39 | 36 | |||
40 | #define ICU_LEN 16 | 37 | #define ICU_LEN 16 | |
41 | 38 | |||
42 | #endif /* _LOCORE */ | 39 | #endif /* _LOCORE */ | |
43 | 40 | |||
41 | #include <powerpc/intr.h> | |||
42 | ||||
44 | #endif /* _RS6000_INTR_H_ */ | 43 | #endif /* _RS6000_INTR_H_ */ |
--- src/sys/arch/sandpoint/include/intr.h 2010/11/13 14:07:08 1.18
+++ src/sys/arch/sandpoint/include/intr.h 2011/06/17 23:36:18 1.19
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: intr.h,v 1.18 2010/11/13 14:07:08 uebayasi Exp $ */ | 1 | /* $NetBSD: intr.h,v 1.19 2011/06/17 23:36:18 matt Exp $ */ | |
2 | 2 | |||
3 | /*- | 3 | /*- | |
4 | * Copyright (c) 2007 The NetBSD Foundation, Inc. | 4 | * Copyright (c) 2007 The NetBSD Foundation, Inc. | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * This code is derived from software contributed to The NetBSD Foundation | 7 | * This code is derived from software contributed to The NetBSD Foundation | |
8 | * by Tim Rightnour | 8 | * by Tim Rightnour | |
9 | * | 9 | * | |
10 | * Redistribution and use in source and binary forms, with or without | 10 | * Redistribution and use in source and binary forms, with or without | |
11 | * modification, are permitted provided that the following conditions | 11 | * modification, are permitted provided that the following conditions | |
12 | * are met: | 12 | * are met: | |
13 | * 1. Redistributions of source code must retain the above copyright | 13 | * 1. Redistributions of source code must retain the above copyright | |
14 | * notice, this list of conditions and the following disclaimer. | 14 | * notice, this list of conditions and the following disclaimer. | |
@@ -25,27 +25,26 @@ | @@ -25,27 +25,26 @@ | |||
25 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | 25 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | |
26 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | 26 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | |
27 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | 27 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
28 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | 28 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | |
29 | * POSSIBILITY OF SUCH DAMAGE. | 29 | * POSSIBILITY OF SUCH DAMAGE. | |
30 | */ | 30 | */ | |
31 | 31 | |||
32 | #ifndef _MACHINE_INTR_H_ | 32 | #ifndef _MACHINE_INTR_H_ | |
33 | #define _MACHINE_INTR_H_ | 33 | #define _MACHINE_INTR_H_ | |
34 | 34 | |||
35 | #include <powerpc/intr.h> | 35 | #include <powerpc/intr.h> | |
36 | 36 | |||
37 | #ifndef _LOCORE | 37 | #ifndef _LOCORE | |
38 | #include <machine/cpu.h> | |||
39 | 38 | |||
40 | void enable_intr(void); | 39 | void enable_intr(void); | |
41 | void disable_intr(void); | 40 | void disable_intr(void); | |
42 | 41 | |||
43 | #define ICU_LEN 64 | 42 | #define ICU_LEN 64 | |
44 | #define IRQ_SLAVE 2 | 43 | #define IRQ_SLAVE 2 | |
45 | 44 | |||
46 | #define I8259_ICU 16 | 45 | #define I8259_ICU 16 | |
47 | #define OPENPIC_ICU 26 | 46 | #define OPENPIC_ICU 26 | |
48 | 47 | |||
49 | #endif /* !_LOCORE */ | 48 | #endif /* !_LOCORE */ | |
50 | 49 | |||
51 | #endif /* !_MACHINE_INTR_H_ */ | 50 | #endif /* !_MACHINE_INTR_H_ */ |