locate PCI buses and determine their bus numbers using the info previously extracted from ACPICA rather than trying to figure it out again. allow PCI buses that don't have a _PRT method.diff -r1.5 -r1.6 src/sys/arch/ia64/acpi/acpi_machdep.c
(chs)
--- src/sys/arch/ia64/acpi/acpi_machdep.c 2011/06/12 11:31:30 1.5
+++ src/sys/arch/ia64/acpi/acpi_machdep.c 2012/09/23 00:31:05 1.6
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: acpi_machdep.c,v 1.5 2011/06/12 11:31:30 jruoho Exp $ */ | 1 | /* $NetBSD: acpi_machdep.c,v 1.6 2012/09/23 00:31:05 chs Exp $ */ | |
2 | /* | 2 | /* | |
3 | * Copyright (c) 2009 KIYOHARA Takashi | 3 | * Copyright (c) 2009 KIYOHARA Takashi | |
4 | * All rights reserved. | 4 | * All rights reserved. | |
5 | * | 5 | * | |
6 | * Redistribution and use in source and binary forms, with or without | 6 | * Redistribution and use in source and binary forms, with or without | |
7 | * modification, are permitted provided that the following conditions | 7 | * modification, are permitted provided that the following conditions | |
8 | * are met: | 8 | * are met: | |
9 | * 1. Redistributions of source code must retain the above copyright | 9 | * 1. Redistributions of source code must retain the above copyright | |
10 | * notice, this list of conditions and the following disclaimer. | 10 | * notice, this list of conditions and the following disclaimer. | |
11 | * 2. Redistributions in binary form must reproduce the above copyright | 11 | * 2. Redistributions in binary form must reproduce the above copyright | |
12 | * notice, this list of conditions and the following disclaimer in the | 12 | * notice, this list of conditions and the following disclaimer in the | |
13 | * documentation and/or other materials provided with the distribution. | 13 | * documentation and/or other materials provided with the distribution. | |
14 | * | 14 | * | |
@@ -18,27 +18,27 @@ | @@ -18,27 +18,27 @@ | |||
18 | * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, | 18 | * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, | |
19 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 19 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | |
20 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | 20 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | |
21 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | 21 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
22 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | 22 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | |
23 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN | 23 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN | |
24 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | 24 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | |
25 | * POSSIBILITY OF SUCH DAMAGE. | 25 | * POSSIBILITY OF SUCH DAMAGE. | |
26 | */ | 26 | */ | |
27 | /* | 27 | /* | |
28 | * Machine-dependent routines for ACPICA. | 28 | * Machine-dependent routines for ACPICA. | |
29 | */ | 29 | */ | |
30 | #include <sys/cdefs.h> | 30 | #include <sys/cdefs.h> | |
31 | __KERNEL_RCSID(0, "$NetBSD: acpi_machdep.c,v 1.5 2011/06/12 11:31:30 jruoho Exp $"); | 31 | __KERNEL_RCSID(0, "$NetBSD: acpi_machdep.c,v 1.6 2012/09/23 00:31:05 chs Exp $"); | |
32 | 32 | |||
33 | #include <sys/param.h> | 33 | #include <sys/param.h> | |
34 | 34 | |||
35 | #include <uvm/uvm_extern.h> | 35 | #include <uvm/uvm_extern.h> | |
36 | 36 | |||
37 | #include <machine/bus.h> | 37 | #include <machine/bus.h> | |
38 | #include <machine/efi.h> | 38 | #include <machine/efi.h> | |
39 | #include <machine/intrdefs.h> | 39 | #include <machine/intrdefs.h> | |
40 | 40 | |||
41 | #include <dev/acpi/acpica.h> | 41 | #include <dev/acpi/acpica.h> | |
42 | #include <dev/acpi/acpivar.h> | 42 | #include <dev/acpi/acpivar.h> | |
43 | 43 | |||
44 | #include <machine/acpi_machdep.h> | 44 | #include <machine/acpi_machdep.h> | |
@@ -179,24 +179,24 @@ acpi_md_OsDisableInterrupt(void) | @@ -179,24 +179,24 @@ acpi_md_OsDisableInterrupt(void) | |||
179 | uint32_t | 179 | uint32_t | |
180 | acpi_md_pdc(void) | 180 | acpi_md_pdc(void) | |
181 | { | 181 | { | |
182 | return 0; | 182 | return 0; | |
183 | } | 183 | } | |
184 | 184 | |||
185 | uint32_t | 185 | uint32_t | |
186 | acpi_md_ncpus(void) | 186 | acpi_md_ncpus(void) | |
187 | { | 187 | { | |
188 | return 0; /* XXX. */ | 188 | return 0; /* XXX. */ | |
189 | } | 189 | } | |
190 | 190 | |||
191 | void | 191 | void | |
192 | acpi_md_callback(void) | 192 | acpi_md_callback(struct acpi_softc *sc) | |
193 | { | 193 | { | |
194 | /* Nothing. */ | 194 | /* Nothing. */ | |
195 | } | 195 | } | |
196 | 196 | |||
197 | int | 197 | int | |
198 | acpi_md_sleep(int state) | 198 | acpi_md_sleep(int state) | |
199 | { | 199 | { | |
200 | printf("%s: not yet...\n", __func__); | 200 | printf("%s: not yet...\n", __func__); | |
201 | return 0; | 201 | return 0; | |
202 | } | 202 | } |
--- src/sys/arch/ia64/include/acpi_machdep.h 2011/06/12 11:31:30 1.5
+++ src/sys/arch/ia64/include/acpi_machdep.h 2012/09/23 00:31:05 1.6
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: acpi_machdep.h,v 1.5 2011/06/12 11:31:30 jruoho Exp $ */ | 1 | /* $NetBSD: acpi_machdep.h,v 1.6 2012/09/23 00:31:05 chs Exp $ */ | |
2 | 2 | |||
3 | ACPI_STATUS acpi_md_OsInitialize(void); | 3 | ACPI_STATUS acpi_md_OsInitialize(void); | |
4 | ACPI_PHYSICAL_ADDRESS acpi_md_OsGetRootPointer(void); | 4 | ACPI_PHYSICAL_ADDRESS acpi_md_OsGetRootPointer(void); | |
5 | 5 | |||
6 | #define acpi_md_OsIn8(x) inb((x)) | 6 | #define acpi_md_OsIn8(x) inb((x)) | |
7 | #define acpi_md_OsIn16(x) inw((x)) | 7 | #define acpi_md_OsIn16(x) inw((x)) | |
8 | #define acpi_md_OsIn32(x) inl((x)) | 8 | #define acpi_md_OsIn32(x) inl((x)) | |
9 | 9 | |||
10 | #define acpi_md_OsOut8(x, v) outb((x), (v)) | 10 | #define acpi_md_OsOut8(x, v) outb((x), (v)) | |
11 | #define acpi_md_OsOut16(x, v) outw((x), (v)) | 11 | #define acpi_md_OsOut16(x, v) outw((x), (v)) | |
12 | #define acpi_md_OsOut32(x, v) outl((x), (v)) | 12 | #define acpi_md_OsOut32(x, v) outl((x), (v)) | |
13 | 13 | |||
14 | ACPI_STATUS acpi_md_OsInstallInterruptHandler(UINT32, ACPI_OSD_HANDLER, | 14 | ACPI_STATUS acpi_md_OsInstallInterruptHandler(UINT32, ACPI_OSD_HANDLER, | |
@@ -18,14 +18,15 @@ void acpi_md_OsRemoveInterruptHandler(vo | @@ -18,14 +18,15 @@ void acpi_md_OsRemoveInterruptHandler(vo | |||
18 | ACPI_STATUS acpi_md_OsMapMemory(ACPI_PHYSICAL_ADDRESS, UINT32, void **); | 18 | ACPI_STATUS acpi_md_OsMapMemory(ACPI_PHYSICAL_ADDRESS, UINT32, void **); | |
19 | void acpi_md_OsUnmapMemory(void *, UINT32); | 19 | void acpi_md_OsUnmapMemory(void *, UINT32); | |
20 | ACPI_STATUS acpi_md_OsGetPhysicalAddress(void *LogicalAddress, | 20 | ACPI_STATUS acpi_md_OsGetPhysicalAddress(void *LogicalAddress, | |
21 | ACPI_PHYSICAL_ADDRESS *PhysicalAddress); | 21 | ACPI_PHYSICAL_ADDRESS *PhysicalAddress); | |
22 | 22 | |||
23 | BOOLEAN acpi_md_OsReadable(void *, UINT32); | 23 | BOOLEAN acpi_md_OsReadable(void *, UINT32); | |
24 | BOOLEAN acpi_md_OsWritable(void *, UINT32); | 24 | BOOLEAN acpi_md_OsWritable(void *, UINT32); | |
25 | void acpi_md_OsEnableInterrupt(void); | 25 | void acpi_md_OsEnableInterrupt(void); | |
26 | void acpi_md_OsDisableInterrupt(void); | 26 | void acpi_md_OsDisableInterrupt(void); | |
27 | 27 | |||
28 | int acpi_md_sleep(int); | 28 | int acpi_md_sleep(int); | |
29 | uint32_t acpi_md_pdc(void); | 29 | uint32_t acpi_md_pdc(void); | |
30 | uint32_t acpi_md_ncpus(void); | 30 | uint32_t acpi_md_ncpus(void); | |
31 | void acpi_md_callback(void); | 31 | struct acpi_softc; | |
32 | void acpi_md_callback(struct acpi_softc *); |
--- src/sys/arch/x86/acpi/acpi_machdep.c 2012/01/30 21:47:24 1.3
+++ src/sys/arch/x86/acpi/acpi_machdep.c 2012/09/23 00:31:05 1.4
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: acpi_machdep.c,v 1.3 2012/01/30 21:47:24 rmind Exp $ */ | 1 | /* $NetBSD: acpi_machdep.c,v 1.4 2012/09/23 00:31:05 chs Exp $ */ | |
2 | 2 | |||
3 | /* | 3 | /* | |
4 | * Copyright 2001 Wasabi Systems, Inc. | 4 | * Copyright 2001 Wasabi Systems, Inc. | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * Written by Jason R. Thorpe for Wasabi Systems, Inc. | 7 | * Written by Jason R. Thorpe 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 | |
@@ -30,27 +30,27 @@ | @@ -30,27 +30,27 @@ | |||
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 | /* | 38 | /* | |
39 | * Machine-dependent routines for ACPICA. | 39 | * Machine-dependent routines for ACPICA. | |
40 | */ | 40 | */ | |
41 | 41 | |||
42 | #include <sys/cdefs.h> | 42 | #include <sys/cdefs.h> | |
43 | __KERNEL_RCSID(0, "$NetBSD: acpi_machdep.c,v 1.3 2012/01/30 21:47:24 rmind Exp $"); | 43 | __KERNEL_RCSID(0, "$NetBSD: acpi_machdep.c,v 1.4 2012/09/23 00:31:05 chs Exp $"); | |
44 | 44 | |||
45 | #include <sys/param.h> | 45 | #include <sys/param.h> | |
46 | #include <sys/systm.h> | 46 | #include <sys/systm.h> | |
47 | #include <sys/bus.h> | 47 | #include <sys/bus.h> | |
48 | #include <sys/cpu.h> | 48 | #include <sys/cpu.h> | |
49 | #include <sys/device.h> | 49 | #include <sys/device.h> | |
50 | 50 | |||
51 | #include <uvm/uvm_extern.h> | 51 | #include <uvm/uvm_extern.h> | |
52 | 52 | |||
53 | #include <machine/cpufunc.h> | 53 | #include <machine/cpufunc.h> | |
54 | 54 | |||
55 | #include <dev/acpi/acpica.h> | 55 | #include <dev/acpi/acpica.h> | |
56 | #include <dev/acpi/acpivar.h> | 56 | #include <dev/acpi/acpivar.h> | |
@@ -273,24 +273,24 @@ acpi_md_OsDisableInterrupt(void) | @@ -273,24 +273,24 @@ acpi_md_OsDisableInterrupt(void) | |||
273 | void | 273 | void | |
274 | acpi_md_OsEnableInterrupt(void) | 274 | acpi_md_OsEnableInterrupt(void) | |
275 | { | 275 | { | |
276 | x86_enable_intr(); | 276 | x86_enable_intr(); | |
277 | } | 277 | } | |
278 | 278 | |||
279 | uint32_t | 279 | uint32_t | |
280 | acpi_md_ncpus(void) | 280 | acpi_md_ncpus(void) | |
281 | { | 281 | { | |
282 | return kcpuset_countset(kcpuset_attached); | 282 | return kcpuset_countset(kcpuset_attached); | |
283 | } | 283 | } | |
284 | 284 | |||
285 | void | 285 | void | |
286 | acpi_md_callback(void) | 286 | acpi_md_callback(struct acpi_softc *sc) | |
287 | { | 287 | { | |
288 | #ifdef MPBIOS | 288 | #ifdef MPBIOS | |
289 | if (!mpbios_scanned) | 289 | if (!mpbios_scanned) | |
290 | #endif | 290 | #endif | |
291 | mpacpi_find_interrupts(acpi_softc); | 291 | mpacpi_find_interrupts(sc); | |
292 | 292 | |||
293 | #ifndef XEN | 293 | #ifndef XEN | |
294 | acpi_md_sleep_init(); | 294 | acpi_md_sleep_init(); | |
295 | #endif | 295 | #endif | |
296 | } | 296 | } |
--- src/sys/arch/x86/include/acpi_machdep.h 2011/06/12 11:31:31 1.10
+++ src/sys/arch/x86/include/acpi_machdep.h 2012/09/23 00:31:05 1.11
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: acpi_machdep.h,v 1.10 2011/06/12 11:31:31 jruoho Exp $ */ | 1 | /* $NetBSD: acpi_machdep.h,v 1.11 2012/09/23 00:31:05 chs Exp $ */ | |
2 | 2 | |||
3 | /* | 3 | /* | |
4 | * Copyright 2001 Wasabi Systems, Inc. | 4 | * Copyright 2001 Wasabi Systems, Inc. | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * Written by Jason R. Thorpe for Wasabi Systems, Inc. | 7 | * Written by Jason R. Thorpe 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 | |
@@ -65,16 +65,17 @@ void acpi_md_OsUnmapMemory(void *, UINT | @@ -65,16 +65,17 @@ void acpi_md_OsUnmapMemory(void *, UINT | |||
65 | ACPI_STATUS acpi_md_OsGetPhysicalAddress(void *LogicalAddress, | 65 | ACPI_STATUS acpi_md_OsGetPhysicalAddress(void *LogicalAddress, | |
66 | ACPI_PHYSICAL_ADDRESS *PhysicalAddress); | 66 | ACPI_PHYSICAL_ADDRESS *PhysicalAddress); | |
67 | 67 | |||
68 | BOOLEAN acpi_md_OsReadable(void *, UINT32); | 68 | BOOLEAN acpi_md_OsReadable(void *, UINT32); | |
69 | BOOLEAN acpi_md_OsWritable(void *, UINT32); | 69 | BOOLEAN acpi_md_OsWritable(void *, UINT32); | |
70 | void acpi_md_OsDisableInterrupt(void); | 70 | void acpi_md_OsDisableInterrupt(void); | |
71 | void acpi_md_OsEnableInterrupt(void); | 71 | void acpi_md_OsEnableInterrupt(void); | |
72 | 72 | |||
73 | int acpi_md_sleep(int); | 73 | int acpi_md_sleep(int); | |
74 | void acpi_md_sleep_init(void); | 74 | void acpi_md_sleep_init(void); | |
75 | 75 | |||
76 | uint32_t acpi_md_pdc(void); | 76 | uint32_t acpi_md_pdc(void); | |
77 | uint32_t acpi_md_ncpus(void); | 77 | uint32_t acpi_md_ncpus(void); | |
78 | void acpi_md_callback(void); | 78 | struct acpi_softc; | |
79 | void acpi_md_callback(struct acpi_softc *); | |||
79 | 80 | |||
80 | #endif /* !_X86_ACPI_MACHDEP_H_ */ | 81 | #endif /* !_X86_ACPI_MACHDEP_H_ */ |
--- src/sys/arch/x86/x86/mpacpi.c 2012/04/27 04:32:27 1.94
+++ src/sys/arch/x86/x86/mpacpi.c 2012/09/23 00:31:05 1.95
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: mpacpi.c,v 1.94 2012/04/27 04:32:27 jruoho Exp $ */ | 1 | /* $NetBSD: mpacpi.c,v 1.95 2012/09/23 00:31:05 chs Exp $ */ | |
2 | 2 | |||
3 | /* | 3 | /* | |
4 | * Copyright (c) 2003 Wasabi Systems, Inc. | 4 | * Copyright (c) 2003 Wasabi Systems, Inc. | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * Written by Frank van der Linden for Wasabi Systems, Inc. | 7 | * Written by Frank van der Linden 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: mpacpi.c,v 1.94 2012/04/27 04:32:27 jruoho Exp $"); | 39 | __KERNEL_RCSID(0, "$NetBSD: mpacpi.c,v 1.95 2012/09/23 00:31:05 chs Exp $"); | |
40 | 40 | |||
41 | #include "acpica.h" | 41 | #include "acpica.h" | |
42 | #include "opt_acpi.h" | 42 | #include "opt_acpi.h" | |
43 | #include "opt_mpbios.h" | 43 | #include "opt_mpbios.h" | |
44 | #include "opt_multiprocessor.h" | 44 | #include "opt_multiprocessor.h" | |
45 | #include "pchb.h" | 45 | #include "pchb.h" | |
46 | 46 | |||
47 | #include <sys/param.h> | 47 | #include <sys/param.h> | |
48 | #include <sys/systm.h> | 48 | #include <sys/systm.h> | |
49 | #include <sys/kernel.h> | 49 | #include <sys/kernel.h> | |
50 | #include <sys/device.h> | 50 | #include <sys/device.h> | |
51 | #include <sys/kmem.h> | 51 | #include <sys/kmem.h> | |
52 | #include <sys/queue.h> | 52 | #include <sys/queue.h> | |
@@ -81,47 +81,44 @@ ACPI_MODULE_NAME ("mpacpi") | @@ -81,47 +81,44 @@ ACPI_MODULE_NAME ("mpacpi") | |||
81 | #include "ioapic.h" | 81 | #include "ioapic.h" | |
82 | #include "lapic.h" | 82 | #include "lapic.h" | |
83 | 83 | |||
84 | #include "locators.h" | 84 | #include "locators.h" | |
85 | 85 | |||
86 | /* XXX room for PCI-to-PCI bus */ | 86 | /* XXX room for PCI-to-PCI bus */ | |
87 | #define BUS_BUFFER (16) | 87 | #define BUS_BUFFER (16) | |
88 | 88 | |||
89 | #if NPCI > 0 | 89 | #if NPCI > 0 | |
90 | struct mpacpi_pcibus { | 90 | struct mpacpi_pcibus { | |
91 | TAILQ_ENTRY(mpacpi_pcibus) mpr_list; | 91 | TAILQ_ENTRY(mpacpi_pcibus) mpr_list; | |
92 | ACPI_HANDLE mpr_handle; /* Same thing really, but.. */ | 92 | ACPI_HANDLE mpr_handle; /* Same thing really, but.. */ | |
93 | ACPI_BUFFER mpr_buf; /* preserve _PRT */ | 93 | ACPI_BUFFER mpr_buf; /* preserve _PRT */ | |
94 | int mpr_seg; /* PCI segment number */ | |||
94 | int mpr_bus; /* PCI bus number */ | 95 | int mpr_bus; /* PCI bus number */ | |
95 | }; | 96 | }; | |
96 | 97 | |||
97 | static TAILQ_HEAD(, mpacpi_pcibus) mpacpi_pcibusses; | 98 | static TAILQ_HEAD(, mpacpi_pcibus) mpacpi_pcibusses; | |
98 | 99 | |||
99 | #endif | 100 | #endif | |
100 | 101 | |||
101 | static int mpacpi_cpuprint(void *, const char *); | 102 | static int mpacpi_cpuprint(void *, const char *); | |
102 | static int mpacpi_ioapicprint(void *, const char *); | 103 | static int mpacpi_ioapicprint(void *, const char *); | |
103 | 104 | |||
104 | /* acpi_madt_walk callbacks */ | 105 | /* acpi_madt_walk callbacks */ | |
105 | static ACPI_STATUS mpacpi_count(ACPI_SUBTABLE_HEADER *, void *); | 106 | static ACPI_STATUS mpacpi_count(ACPI_SUBTABLE_HEADER *, void *); | |
106 | static ACPI_STATUS mpacpi_config_cpu(ACPI_SUBTABLE_HEADER *, void *); | 107 | static ACPI_STATUS mpacpi_config_cpu(ACPI_SUBTABLE_HEADER *, void *); | |
107 | static ACPI_STATUS mpacpi_config_ioapic(ACPI_SUBTABLE_HEADER *, void *); | 108 | static ACPI_STATUS mpacpi_config_ioapic(ACPI_SUBTABLE_HEADER *, void *); | |
108 | static ACPI_STATUS mpacpi_nonpci_intr(ACPI_SUBTABLE_HEADER *, void *); | 109 | static ACPI_STATUS mpacpi_nonpci_intr(ACPI_SUBTABLE_HEADER *, void *); | |
109 | 110 | |||
110 | #if NPCI > 0 | 111 | #if NPCI > 0 | |
111 | /* Callbacks for the ACPI namespace walk */ | |||
112 | static ACPI_STATUS mpacpi_pcibus_cb(ACPI_HANDLE, uint32_t, void *, void **); | |||
113 | static int mpacpi_derive_bus(ACPI_HANDLE, struct acpi_softc *); | |||
114 | ||||
115 | static int mpacpi_pcircount(struct mpacpi_pcibus *); | 112 | static int mpacpi_pcircount(struct mpacpi_pcibus *); | |
116 | static int mpacpi_pciroute(struct mpacpi_pcibus *); | 113 | static int mpacpi_pciroute(struct mpacpi_pcibus *); | |
117 | static int mpacpi_find_pcibusses(struct acpi_softc *); | 114 | static int mpacpi_find_pcibusses(struct acpi_softc *); | |
118 | 115 | |||
119 | static void mpacpi_print_pci_intr(int); | 116 | static void mpacpi_print_pci_intr(int); | |
120 | #endif | 117 | #endif | |
121 | 118 | |||
122 | static void mpacpi_config_irouting(struct acpi_softc *); | 119 | static void mpacpi_config_irouting(struct acpi_softc *); | |
123 | 120 | |||
124 | static void mpacpi_print_intr(struct mp_intr_map *); | 121 | static void mpacpi_print_intr(struct mp_intr_map *); | |
125 | static void mpacpi_print_isa_intr(int); | 122 | static void mpacpi_print_isa_intr(int); | |
126 | 123 | |||
127 | static void mpacpi_user_continue(const char *fmt, ...); | 124 | static void mpacpi_user_continue(const char *fmt, ...); | |
@@ -474,306 +471,94 @@ mpacpi_scan_apics(device_t self, int *nc | @@ -474,306 +471,94 @@ mpacpi_scan_apics(device_t self, int *nc | |||
474 | if (!mpacpi_force && | 471 | if (!mpacpi_force && | |
475 | (acpi_find_quirks() & (ACPI_QUIRK_BADPCI)) != 0) | 472 | (acpi_find_quirks() & (ACPI_QUIRK_BADPCI)) != 0) | |
476 | goto done; | 473 | goto done; | |
477 | #endif | 474 | #endif | |
478 | rv = 1; | 475 | rv = 1; | |
479 | done: | 476 | done: | |
480 | *ncpup = mpacpi_ncpu; | 477 | *ncpup = mpacpi_ncpu; | |
481 | acpi_madt_unmap(); | 478 | acpi_madt_unmap(); | |
482 | return rv; | 479 | return rv; | |
483 | } | 480 | } | |
484 | 481 | |||
485 | #if NPCI > 0 | 482 | #if NPCI > 0 | |
486 | 483 | |||
487 | /* | 484 | static void | |
488 | * Find all PCI busses from ACPI namespace and construct mpacpi_pcibusses list. | 485 | mpacpi_pci_foundbus(struct acpi_devnode *ad) | |
489 | * | |||
490 | * Note: | |||
491 | * We cannot find all PCI busses in the system from ACPI namespace. | |||
492 | * For example, a PCI-to-PCI bridge on an add-on PCI card is not | |||
493 | * described in the ACPI namespace. | |||
494 | * We search valid devices which have _PRT (PCI interrupt routing table) | |||
495 | * method. | |||
496 | * Such devices are either one of PCI root bridge or PCI-to-PCI bridge. | |||
497 | */ | |||
498 | static int | |||
499 | mpacpi_find_pcibusses(struct acpi_softc *acpi) | |||
500 | { | |||
501 | ACPI_HANDLE sbhandle; | |||
502 | ||||
503 | if (AcpiGetHandle(ACPI_ROOT_OBJECT, "\\_SB_", &sbhandle) != AE_OK) | |||
504 | return ENOENT; | |||
505 | TAILQ_INIT(&mpacpi_pcibusses); | |||
506 | AcpiWalkNamespace(ACPI_TYPE_DEVICE, sbhandle, 100, | |||
507 | mpacpi_pcibus_cb, NULL, acpi, NULL); | |||
508 | return 0; | |||
509 | } | |||
510 | ||||
511 | static const char * const pciroot_hid[] = { | |||
512 | "PNP0A03", /* PCI root bridge */ | |||
513 | "PNP0A08", /* PCI-X root bridge */ | |||
514 | NULL | |||
515 | }; | |||
516 | ||||
517 | /* | |||
518 | * mpacpi_get_bbn: | |||
519 | * | |||
520 | * Get or guess the Base Bus Number and sanity check it. | |||
521 | */ | |||
522 | static ACPI_STATUS | |||
523 | mpacpi_get_bbn(struct acpi_softc *acpi, ACPI_HANDLE handle, int *bus) | |||
524 | { | |||
525 | ACPI_STATUS rv; | |||
526 | ACPI_INTEGER val; | |||
527 | #if NPCHB > 0 | |||
528 | pcireg_t class, dvid; | |||
529 | pcitag_t tag; | |||
530 | #endif | |||
531 | ||||
532 | rv = acpi_eval_integer(handle, METHOD_NAME__BBN, &val); | |||
533 | if (ACPI_SUCCESS(rv)) | |||
534 | *bus = ACPI_LOWORD(val); | |||
535 | else | |||
536 | *bus = 0; | |||
537 | ||||
538 | /* If the _BBN is not 0, assume it is valid. */ | |||
539 | if (*bus != 0) | |||
540 | return AE_OK; | |||
541 | ||||
542 | rv = acpi_eval_integer(handle, METHOD_NAME__ADR, &val); | |||
543 | if (ACPI_FAILURE(rv) || val == 0xffffffff) | |||
544 | return AE_ERROR; | |||
545 | ||||
546 | /* If the _ADR is also 0, assume the _BBN is valid. */ | |||
547 | if (val == 0) | |||
548 | return AE_OK; | |||
549 | ||||
550 | #if NPCHB > 0 | |||
551 | tag = pci_make_tag(acpi->sc_pc, 0, | |||
552 | ACPI_HIWORD(val), ACPI_LOWORD(val)); | |||
553 | ||||
554 | dvid = pci_conf_read(acpi->sc_pc, tag, PCI_ID_REG); | |||
555 | if (PCI_VENDOR(dvid) == PCI_VENDOR_INVALID || PCI_VENDOR(dvid) == 0) | |||
556 | return AE_ERROR; | |||
557 | ||||
558 | /* Check if this is a host bridge device. */ | |||
559 | class = pci_conf_read(acpi->sc_pc, tag, PCI_CLASS_REG); | |||
560 | if (PCI_CLASS(class) != PCI_CLASS_BRIDGE || | |||
561 | PCI_SUBCLASS(class) != PCI_SUBCLASS_BRIDGE_HOST) | |||
562 | return AE_ERROR; | |||
563 | ||||
564 | *bus = pchb_get_bus_number(acpi->sc_pc, tag); | |||
565 | return *bus != -1 ? AE_OK : AE_ERROR; | |||
566 | #else | |||
567 | return AE_ERROR; | |||
568 | #endif | |||
569 | } | |||
570 | ||||
571 | /* | |||
572 | * mpacpi_derive_bus: | |||
573 | * | |||
574 | * Derive PCI bus number for the ACPI handle. | |||
575 | * | |||
576 | * If a device is not a PCI root bridge, it doesn't have _BBN method | |||
577 | * and we have no direct method to know the bus number. | |||
578 | * We have to walk up to search its root bridge and then walk down | |||
579 | * to resolve the bus number. | |||
580 | */ | |||
581 | static int | |||
582 | mpacpi_derive_bus(ACPI_HANDLE handle, struct acpi_softc *acpi) | |||
583 | { | 486 | { | |
584 | ACPI_HANDLE parent, current; | 487 | struct mpacpi_pcibus *mpr; | |
585 | ACPI_STATUS rv; | 488 | ACPI_BUFFER buf; | |
586 | ACPI_INTEGER val; | 489 | int rv; | |
587 | ACPI_DEVICE_INFO *devinfo; | |||
588 | struct ac_dev { | |||
589 | TAILQ_ENTRY(ac_dev) list; | |||
590 | ACPI_HANDLE handle; | |||
591 | }; | |||
592 | TAILQ_HEAD(, ac_dev) dev_list; | |||
593 | struct ac_dev *dev; | |||
594 | pcireg_t binf, class, dvid; | |||
595 | pcitag_t tag; | |||
596 | int bus; | |||
597 | ||||
598 | TAILQ_INIT(&dev_list); | |||
599 | ||||
600 | /* first, search parent root bus */ | |||
601 | for (current = handle;; current = parent) { | |||
602 | rv = AcpiGetObjectInfo(current, &devinfo); | |||
603 | if (ACPI_FAILURE(rv)) | |||
604 | goto out; | |||
605 | ||||
606 | /* add this device to the list only if it's active */ | |||
607 | if ((devinfo->Valid & ACPI_VALID_STA) == 0 || | |||
608 | (devinfo->CurrentStatus & ACPI_STA_OK) == ACPI_STA_OK) { | |||
609 | ACPI_FREE(devinfo); | |||
610 | dev = kmem_zalloc(sizeof(struct ac_dev), KM_SLEEP); | |||
611 | if (dev == NULL) { | |||
612 | rv = AE_NO_MEMORY; | |||
613 | goto out; | |||
614 | } | |||
615 | dev->handle = current; | |||
616 | TAILQ_INSERT_HEAD(&dev_list, dev, list); | |||
617 | } else | |||
618 | ACPI_FREE(devinfo); | |||
619 | ||||
620 | rv = AcpiGetParent(current, &parent); | |||
621 | if (ACPI_FAILURE(rv)) | |||
622 | goto out; | |||
623 | ||||
624 | rv = AcpiGetObjectInfo(parent, &devinfo); | |||
625 | if (ACPI_FAILURE(rv)) | |||
626 | goto out; | |||
627 | ||||
628 | if (acpi_match_hid(devinfo, pciroot_hid)) { | |||
629 | rv = mpacpi_get_bbn(acpi, parent, &bus); | |||
630 | if (ACPI_FAILURE(rv)) | |||
631 | bus = 0; | |||
632 | ACPI_FREE(devinfo); | |||
633 | break; | |||
634 | } | |||
635 | ||||
636 | ACPI_FREE(devinfo); | |||
637 | } | |||
638 | 490 | |||
639 | /* | 491 | /* | |
640 | * second, we walk down from the root to the target | 492 | * set mpr_buf from _PRT (if it exists). | |
641 | * resolving the bus number | 493 | * set mpr_seg and mpr_bus from previously cached info. | |
642 | */ | 494 | */ | |
643 | TAILQ_FOREACH(dev, &dev_list, list) { | |||
644 | rv = acpi_eval_integer(dev->handle, METHOD_NAME__ADR, &val); | |||
645 | if (ACPI_FAILURE(rv) || val == 0xffffffff) { | |||
646 | rv = AE_ERROR; | |||
647 | goto out; | |||
648 | } | |||
649 | ||||
650 | tag = pci_make_tag(acpi->sc_pc, bus, | |||
651 | ACPI_HIWORD(val), ACPI_LOWORD(val)); | |||
652 | ||||
653 | /* check if this device exists */ | |||
654 | dvid = pci_conf_read(acpi->sc_pc, tag, PCI_ID_REG); | |||
655 | if (PCI_VENDOR(dvid) == PCI_VENDOR_INVALID || | |||
656 | PCI_VENDOR(dvid) == 0) { | |||
657 | rv = AE_NOT_EXIST; | |||
658 | goto out; | |||
659 | } | |||
660 | ||||
661 | /* check if this is a bridge device */ | |||
662 | class = pci_conf_read(acpi->sc_pc, tag, PCI_CLASS_REG); | |||
663 | if (PCI_CLASS(class) != PCI_CLASS_BRIDGE || | |||
664 | PCI_SUBCLASS(class) != PCI_SUBCLASS_BRIDGE_PCI) { | |||
665 | rv = AE_TYPE; | |||
666 | goto out; | |||
667 | } | |||
668 | ||||
669 | /* if this is a bridge, get secondary bus */ | |||
670 | binf = pci_conf_read(acpi->sc_pc, tag, PPB_REG_BUSINFO); | |||
671 | bus = PPB_BUSINFO_SECONDARY(binf); | |||
672 | } | |||
673 | ||||
674 | out: | |||
675 | /* cleanup */ | |||
676 | while (!TAILQ_EMPTY(&dev_list)) { | |||
677 | dev = TAILQ_FIRST(&dev_list); | |||
678 | TAILQ_REMOVE(&dev_list, dev, list); | |||
679 | kmem_free(dev, sizeof(struct ac_dev)); | |||
680 | } | |||
681 | ||||
682 | if (ACPI_FAILURE(rv)) | |||
683 | bus = -1; | |||
684 | ||||
685 | return bus; | |||
686 | } | |||
687 | ||||
688 | /* | |||
689 | * Callback function for a namespace walk through ACPI space, finding all | |||
690 | * PCI root and subordinate busses. | |||
691 | */ | |||
692 | static ACPI_STATUS | |||
693 | mpacpi_pcibus_cb(ACPI_HANDLE handle, uint32_t level, void *p, | |||
694 | void **status) | |||
695 | { | |||
696 | ACPI_STATUS rv; | |||
697 | ACPI_DEVICE_INFO *devinfo; | |||
698 | struct mpacpi_pcibus *mpr; | |||
699 | struct acpi_softc *acpi = p; | |||
700 | ||||
701 | /* get _HID, _CID and _STA */ | |||
702 | rv = AcpiGetObjectInfo(handle, &devinfo); | |||
703 | if (ACPI_FAILURE(rv)) | |||
704 | return AE_OK; | |||
705 | ||||
706 | /* if this device is not active, ignore it */ | |||
707 | if ((devinfo->Valid & ACPI_VALID_STA) && | |||
708 | (devinfo->CurrentStatus & ACPI_STA_OK) != ACPI_STA_OK) | |||
709 | goto out; | |||
710 | 495 | |||
711 | mpr = kmem_zalloc(sizeof(struct mpacpi_pcibus), KM_SLEEP); | 496 | rv = acpi_get(ad->ad_handle, &buf, AcpiGetIrqRoutingTable); | |
712 | if (mpr == NULL) { | |||
713 | ACPI_FREE(devinfo); | |||
714 | return AE_NO_MEMORY; | |||
715 | } | |||
716 | ||||
717 | /* try get _PRT. if this fails, we're not interested in it */ | |||
718 | rv = acpi_get(handle, &mpr->mpr_buf, AcpiGetIrqRoutingTable); | |||
719 | if (ACPI_FAILURE(rv)) { | 497 | if (ACPI_FAILURE(rv)) { | |
720 | kmem_free(mpr, sizeof(struct mpacpi_pcibus)); | 498 | buf.Length = 0; | |
721 | goto out; | 499 | buf.Pointer = NULL; | |
722 | } | 500 | } | |
723 | 501 | |||
724 | /* check whether this is PCI root bridge or not */ | 502 | mpr = kmem_zalloc(sizeof(struct mpacpi_pcibus), KM_SLEEP); | |
725 | if (acpi_match_hid(devinfo, pciroot_hid)) { | 503 | if ((ad->ad_devinfo->Flags & ACPI_PCI_ROOT_BRIDGE) != 0) { | |
726 | /* this is PCI root bridge */ | |||
727 | rv = mpacpi_get_bbn(acpi, handle, &mpr->mpr_bus); | |||
728 | if (ACPI_FAILURE(rv)) { | |||
729 | if (mpacpi_npciroots) | |||
730 | panic("mpacpi: PCI root bridge with broken _BBN"); | |||
731 | /* For the first bus we find, assume the BBN is 0. */ | |||
732 | mpr->mpr_bus = 0; | |||
733 | } | |||
734 | ||||
735 | if (mp_verbose) | 504 | if (mp_verbose) | |
736 | printf("mpacpi: found root PCI bus %d at level %u\n", | 505 | printf("mpacpi: found root PCI bus %d\n", | |
737 | mpr->mpr_bus, level); | 506 | mpr->mpr_bus); | |
738 | mpacpi_npciroots++; | 507 | mpacpi_npciroots++; | |
739 | } else { | 508 | } else { | |
740 | /* this is subordinate PCI bus (behind PCI-to-PCI bridge) */ | |||
741 | ||||
742 | /* we have no direct method to get the bus number... */ | |||
743 | mpr->mpr_bus = mpacpi_derive_bus(handle, acpi); | |||
744 | ||||
745 | if (mpr->mpr_bus < 0) { | |||
746 | if (mp_verbose) | |||
747 | printf("mpacpi: failed to derive bus number, ignoring\n"); | |||
748 | kmem_free(mpr, sizeof(struct mpacpi_pcibus)); | |||
749 | goto out; | |||
750 | } | |||
751 | if (mp_verbose) | 509 | if (mp_verbose) | |
752 | printf("mpacpi: found subordinate bus %d at level %u\n", | 510 | printf("mpacpi: found subordinate bus %d\n", | |
753 | mpr->mpr_bus, level); | 511 | mpr->mpr_bus); | |
754 | } | 512 | } | |
755 | 513 | |||
756 | mpr->mpr_handle = handle; | 514 | mpr->mpr_handle = ad->ad_handle; | |
515 | mpr->mpr_buf = buf; | |||
516 | mpr->mpr_seg = ad->ad_pciinfo->ap_segment; | |||
517 | mpr->mpr_bus = ad->ad_pciinfo->ap_downbus; | |||
757 | TAILQ_INSERT_TAIL(&mpacpi_pcibusses, mpr, mpr_list); | 518 | TAILQ_INSERT_TAIL(&mpacpi_pcibusses, mpr, mpr_list); | |
758 | 519 | |||
520 | /* | |||
521 | * XXX this wrongly assumes that bus numbers are unique | |||
522 | * even between segments. | |||
523 | */ | |||
759 | if (mpr->mpr_bus > mpacpi_maxpci) | 524 | if (mpr->mpr_bus > mpacpi_maxpci) | |
760 | mpacpi_maxpci = mpr->mpr_bus; | 525 | mpacpi_maxpci = mpr->mpr_bus; | |
761 | 526 | |||
762 | mpacpi_npci++; | 527 | mpacpi_npci++; | |
528 | } | |||
763 | 529 | |||
764 | out: | 530 | ||
765 | ACPI_FREE(devinfo); | 531 | static void | |
766 | return AE_OK; | 532 | mpacpi_pci_walk(struct acpi_devnode *ad) | |
533 | { | |||
534 | struct acpi_devnode *child; | |||
535 | ||||
536 | if (ad->ad_pciinfo && | |||
537 | (ad->ad_pciinfo->ap_flags & ACPI_PCI_INFO_BRIDGE) != 0) { | |||
538 | mpacpi_pci_foundbus(ad); | |||
539 | } | |||
540 | SIMPLEQ_FOREACH(child, &ad->ad_child_head, ad_child_list) { | |||
541 | mpacpi_pci_walk(child); | |||
542 | } | |||
543 | } | |||
544 | ||||
545 | static int | |||
546 | mpacpi_find_pcibusses(struct acpi_softc *sc) | |||
547 | { | |||
548 | ||||
549 | TAILQ_INIT(&mpacpi_pcibusses); | |||
550 | mpacpi_pci_walk(sc->sc_root); | |||
551 | return 0; | |||
767 | } | 552 | } | |
768 | 553 | |||
769 | /* | 554 | /* | |
770 | * Find all static PRT entries for a PCI bus. | 555 | * Find all static PRT entries for a PCI bus. | |
771 | */ | 556 | */ | |
772 | static int | 557 | static int | |
773 | mpacpi_pciroute(struct mpacpi_pcibus *mpr) | 558 | mpacpi_pciroute(struct mpacpi_pcibus *mpr) | |
774 | { | 559 | { | |
775 | ACPI_PCI_ROUTING_TABLE *ptrp; | 560 | ACPI_PCI_ROUTING_TABLE *ptrp; | |
776 | ACPI_HANDLE linkdev; | 561 | ACPI_HANDLE linkdev; | |
777 | char *p; | 562 | char *p; | |
778 | struct mp_intr_map *mpi, *iter; | 563 | struct mp_intr_map *mpi, *iter; | |
779 | struct mp_bus *mpb; | 564 | struct mp_bus *mpb; | |
@@ -788,26 +573,30 @@ mpacpi_pciroute(struct mpacpi_pcibus *mp | @@ -788,26 +573,30 @@ mpacpi_pciroute(struct mpacpi_pcibus *mp | |||
788 | mpb = &mp_busses[mpr->mpr_bus]; | 573 | mpb = &mp_busses[mpr->mpr_bus]; | |
789 | 574 | |||
790 | if (mpb->mb_name != NULL) | 575 | if (mpb->mb_name != NULL) | |
791 | printf("mpacpi: PCI bus %d int routing already done!\n", | 576 | printf("mpacpi: PCI bus %d int routing already done!\n", | |
792 | mpr->mpr_bus); | 577 | mpr->mpr_bus); | |
793 | 578 | |||
794 | mpb->mb_intrs = NULL; | 579 | mpb->mb_intrs = NULL; | |
795 | mpb->mb_name = "pci"; | 580 | mpb->mb_name = "pci"; | |
796 | mpb->mb_idx = mpr->mpr_bus; | 581 | mpb->mb_idx = mpr->mpr_bus; | |
797 | mpb->mb_intr_print = mpacpi_print_pci_intr; | 582 | mpb->mb_intr_print = mpacpi_print_pci_intr; | |
798 | mpb->mb_intr_cfg = NULL; | 583 | mpb->mb_intr_cfg = NULL; | |
799 | mpb->mb_data = 0; | 584 | mpb->mb_data = 0; | |
800 | 585 | |||
586 | if (mpr->mpr_buf.Length == 0) { | |||
587 | goto out; | |||
588 | } | |||
589 | ||||
801 | for (p = mpr->mpr_buf.Pointer; ; p += ptrp->Length) { | 590 | for (p = mpr->mpr_buf.Pointer; ; p += ptrp->Length) { | |
802 | ptrp = (ACPI_PCI_ROUTING_TABLE *)p; | 591 | ptrp = (ACPI_PCI_ROUTING_TABLE *)p; | |
803 | if (ptrp->Length == 0) | 592 | if (ptrp->Length == 0) | |
804 | break; | 593 | break; | |
805 | dev = ACPI_HIWORD(ptrp->Address); | 594 | dev = ACPI_HIWORD(ptrp->Address); | |
806 | 595 | |||
807 | if (ptrp->Source[0] == 0 && | 596 | if (ptrp->Source[0] == 0 && | |
808 | (ptrp->SourceIndex == 14 || ptrp->SourceIndex == 15)) { | 597 | (ptrp->SourceIndex == 14 || ptrp->SourceIndex == 15)) { | |
809 | printf("Skipping PCI routing entry for PCI IDE compat IRQ"); | 598 | printf("Skipping PCI routing entry for PCI IDE compat IRQ"); | |
810 | continue; | 599 | continue; | |
811 | } | 600 | } | |
812 | 601 | |||
813 | mpi = &mp_intrs[mpacpi_intr_index]; | 602 | mpi = &mp_intrs[mpacpi_intr_index]; | |
@@ -883,42 +672,47 @@ mpacpi_pciroute(struct mpacpi_pcibus *mp | @@ -883,42 +672,47 @@ mpacpi_pciroute(struct mpacpi_pcibus *mp | |||
883 | if (mp_verbose > 1) | 672 | if (mp_verbose > 1) | |
884 | printf("pciroute: done adding entry\n"); | 673 | printf("pciroute: done adding entry\n"); | |
885 | } | 674 | } | |
886 | 675 | |||
887 | mpi->cpu_id = 0; | 676 | mpi->cpu_id = 0; | |
888 | 677 | |||
889 | mpi->next = mpb->mb_intrs; | 678 | mpi->next = mpb->mb_intrs; | |
890 | mpb->mb_intrs = mpi; | 679 | mpb->mb_intrs = mpi; | |
891 | } | 680 | } | |
892 | 681 | |||
893 | ACPI_FREE(mpr->mpr_buf.Pointer); | 682 | ACPI_FREE(mpr->mpr_buf.Pointer); | |
894 | mpr->mpr_buf.Pointer = NULL; /* be preventive to bugs */ | 683 | mpr->mpr_buf.Pointer = NULL; /* be preventive to bugs */ | |
895 | 684 | |||
685 | out: | |||
896 | if (mp_verbose > 1) | 686 | if (mp_verbose > 1) | |
897 | printf("pciroute: done\n"); | 687 | printf("pciroute: done\n"); | |
898 | 688 | |||
899 | return 0; | 689 | return 0; | |
900 | } | 690 | } | |
901 | 691 | |||
902 | /* | 692 | /* | |
903 | * Count number of elements in _PRT | 693 | * Count number of elements in _PRT | |
904 | */ | 694 | */ | |
905 | static int | 695 | static int | |
906 | mpacpi_pcircount(struct mpacpi_pcibus *mpr) | 696 | mpacpi_pcircount(struct mpacpi_pcibus *mpr) | |
907 | { | 697 | { | |
908 | int count = 0; | 698 | int count = 0; | |
909 | ACPI_PCI_ROUTING_TABLE *PrtElement; | 699 | ACPI_PCI_ROUTING_TABLE *PrtElement; | |
910 | uint8_t *Buffer; | 700 | uint8_t *Buffer; | |
911 | 701 | |||
702 | if (mpr->mpr_buf.Length == 0) { | |||
703 | return 0; | |||
704 | } | |||
705 | ||||
912 | for (Buffer = mpr->mpr_buf.Pointer;; Buffer += PrtElement->Length) { | 706 | for (Buffer = mpr->mpr_buf.Pointer;; Buffer += PrtElement->Length) { | |
913 | PrtElement = (ACPI_PCI_ROUTING_TABLE *)Buffer; | 707 | PrtElement = (ACPI_PCI_ROUTING_TABLE *)Buffer; | |
914 | if (PrtElement->Length == 0) | 708 | if (PrtElement->Length == 0) | |
915 | break; | 709 | break; | |
916 | count++; | 710 | count++; | |
917 | } | 711 | } | |
918 | 712 | |||
919 | return count; | 713 | return count; | |
920 | } | 714 | } | |
921 | #endif | 715 | #endif | |
922 | 716 | |||
923 | /* | 717 | /* | |
924 | * Set up the interrupt config lists, in the same format as the mpbios does. | 718 | * Set up the interrupt config lists, in the same format as the mpbios does. |
--- src/sys/dev/acpi/acpi.c 2012/08/14 14:38:02 1.254
+++ src/sys/dev/acpi/acpi.c 2012/09/23 00:31:06 1.255
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: acpi.c,v 1.254 2012/08/14 14:38:02 jruoho Exp $ */ | 1 | /* $NetBSD: acpi.c,v 1.255 2012/09/23 00:31:06 chs Exp $ */ | |
2 | 2 | |||
3 | /*- | 3 | /*- | |
4 | * Copyright (c) 2003, 2007 The NetBSD Foundation, Inc. | 4 | * Copyright (c) 2003, 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 Charles M. Hannum of By Noon Software, Inc. | 8 | * by Charles M. Hannum of By Noon Software, Inc. | |
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. | |
@@ -90,27 +90,27 @@ | @@ -90,27 +90,27 @@ | |||
90 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED | 90 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED | |
91 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | 91 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | |
92 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL WASABI SYSTEMS, INC | 92 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL WASABI SYSTEMS, INC | |
93 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | 93 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | |
94 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | 94 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | |
95 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | 95 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | |
96 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | 96 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | |
97 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | 97 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
98 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | 98 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | |
99 | * POSSIBILITY OF SUCH DAMAGE. | 99 | * POSSIBILITY OF SUCH DAMAGE. | |
100 | */ | 100 | */ | |
101 | 101 | |||
102 | #include <sys/cdefs.h> | 102 | #include <sys/cdefs.h> | |
103 | __KERNEL_RCSID(0, "$NetBSD: acpi.c,v 1.254 2012/08/14 14:38:02 jruoho Exp $"); | 103 | __KERNEL_RCSID(0, "$NetBSD: acpi.c,v 1.255 2012/09/23 00:31:06 chs Exp $"); | |
104 | 104 | |||
105 | #include "opt_acpi.h" | 105 | #include "opt_acpi.h" | |
106 | #include "opt_pcifixup.h" | 106 | #include "opt_pcifixup.h" | |
107 | 107 | |||
108 | #include <sys/param.h> | 108 | #include <sys/param.h> | |
109 | #include <sys/device.h> | 109 | #include <sys/device.h> | |
110 | #include <sys/kernel.h> | 110 | #include <sys/kernel.h> | |
111 | #include <sys/kmem.h> | 111 | #include <sys/kmem.h> | |
112 | #include <sys/malloc.h> | 112 | #include <sys/malloc.h> | |
113 | #include <sys/module.h> | 113 | #include <sys/module.h> | |
114 | #include <sys/mutex.h> | 114 | #include <sys/mutex.h> | |
115 | #include <sys/sysctl.h> | 115 | #include <sys/sysctl.h> | |
116 | #include <sys/systm.h> | 116 | #include <sys/systm.h> | |
@@ -180,26 +180,27 @@ static const char * const acpi_early_ids | @@ -180,26 +180,27 @@ static const char * const acpi_early_ids | |||
180 | "PNP0C09", /* acpiec(4) */ | 180 | "PNP0C09", /* acpiec(4) */ | |
181 | NULL | 181 | NULL | |
182 | }; | 182 | }; | |
183 | 183 | |||
184 | static int acpi_match(device_t, cfdata_t, void *); | 184 | static int acpi_match(device_t, cfdata_t, void *); | |
185 | static int acpi_submatch(device_t, cfdata_t, const int *, void *); | 185 | static int acpi_submatch(device_t, cfdata_t, const int *, void *); | |
186 | static void acpi_attach(device_t, device_t, void *); | 186 | static void acpi_attach(device_t, device_t, void *); | |
187 | static int acpi_detach(device_t, int); | 187 | static int acpi_detach(device_t, int); | |
188 | static void acpi_childdet(device_t, device_t); | 188 | static void acpi_childdet(device_t, device_t); | |
189 | static bool acpi_suspend(device_t, const pmf_qual_t *); | 189 | static bool acpi_suspend(device_t, const pmf_qual_t *); | |
190 | static bool acpi_resume(device_t, const pmf_qual_t *); | 190 | static bool acpi_resume(device_t, const pmf_qual_t *); | |
191 | 191 | |||
192 | static void acpi_build_tree(struct acpi_softc *); | 192 | static void acpi_build_tree(struct acpi_softc *); | |
193 | static void acpi_config_tree(struct acpi_softc *); | |||
193 | static ACPI_STATUS acpi_make_devnode(ACPI_HANDLE, uint32_t, | 194 | static ACPI_STATUS acpi_make_devnode(ACPI_HANDLE, uint32_t, | |
194 | void *, void **); | 195 | void *, void **); | |
195 | static ACPI_STATUS acpi_make_devnode_post(ACPI_HANDLE, uint32_t, | 196 | static ACPI_STATUS acpi_make_devnode_post(ACPI_HANDLE, uint32_t, | |
196 | void *, void **); | 197 | void *, void **); | |
197 | static void acpi_make_name(struct acpi_devnode *, uint32_t); | 198 | static void acpi_make_name(struct acpi_devnode *, uint32_t); | |
198 | 199 | |||
199 | static int acpi_rescan(device_t, const char *, const int *); | 200 | static int acpi_rescan(device_t, const char *, const int *); | |
200 | static void acpi_rescan_early(struct acpi_softc *); | 201 | static void acpi_rescan_early(struct acpi_softc *); | |
201 | static void acpi_rescan_nodes(struct acpi_softc *); | 202 | static void acpi_rescan_nodes(struct acpi_softc *); | |
202 | static void acpi_rescan_capabilities(device_t); | 203 | static void acpi_rescan_capabilities(device_t); | |
203 | static int acpi_print(void *aux, const char *); | 204 | static int acpi_print(void *aux, const char *); | |
204 | 205 | |||
205 | static void acpi_notify_handler(ACPI_HANDLE, uint32_t, void *); | 206 | static void acpi_notify_handler(ACPI_HANDLE, uint32_t, void *); | |
@@ -452,55 +453,50 @@ acpi_attach(device_t parent, device_t se | @@ -452,55 +453,50 @@ acpi_attach(device_t parent, device_t se | |||
452 | sc->sc_pciflags = aa->aa_pciflags; | 453 | sc->sc_pciflags = aa->aa_pciflags; | |
453 | sc->sc_ic = aa->aa_ic; | 454 | sc->sc_ic = aa->aa_ic; | |
454 | 455 | |||
455 | SIMPLEQ_INIT(&sc->ad_head); | 456 | SIMPLEQ_INIT(&sc->ad_head); | |
456 | 457 | |||
457 | acpi_softc = sc; | 458 | acpi_softc = sc; | |
458 | 459 | |||
459 | if (pmf_device_register(self, acpi_suspend, acpi_resume) != true) | 460 | if (pmf_device_register(self, acpi_suspend, acpi_resume) != true) | |
460 | aprint_error_dev(self, "couldn't establish power handler\n"); | 461 | aprint_error_dev(self, "couldn't establish power handler\n"); | |
461 | 462 | |||
462 | /* | 463 | /* | |
463 | * Bring ACPICA on-line. | 464 | * Bring ACPICA on-line. | |
464 | */ | 465 | */ | |
465 | #define ACPI_ENABLE_PHASE1 \ | |||
466 | (ACPI_NO_HANDLER_INIT | ACPI_NO_EVENT_INIT) | |||
467 | #define ACPI_ENABLE_PHASE2 \ | |||
468 | (ACPI_NO_HARDWARE_INIT | ACPI_NO_ACPI_ENABLE | \ | |||
469 | ACPI_NO_ADDRESS_SPACE_INIT) | |||
470 | 466 | |||
471 | rv = AcpiEnableSubsystem(ACPI_ENABLE_PHASE1); | 467 | rv = AcpiEnableSubsystem(ACPI_FULL_INITIALIZATION); | |
472 | ||||
473 | if (ACPI_FAILURE(rv)) | |||
474 | goto fail; | |||
475 | ||||
476 | acpi_md_callback(); | |||
477 | ||||
478 | rv = AcpiEnableSubsystem(ACPI_ENABLE_PHASE2); | |||
479 | 468 | |||
480 | if (ACPI_FAILURE(rv)) | 469 | if (ACPI_FAILURE(rv)) | |
481 | goto fail; | 470 | goto fail; | |
482 | 471 | |||
483 | /* | 472 | /* | |
484 | * Early initialization of acpiec(4) via ECDT. | 473 | * Early initialization of acpiec(4) via ECDT. | |
485 | */ | 474 | */ | |
486 | (void)config_found_ia(self, "acpiecdtbus", aa, NULL); | 475 | (void)config_found_ia(self, "acpiecdtbus", aa, NULL); | |
487 | 476 | |||
488 | rv = AcpiInitializeObjects(ACPI_FULL_INITIALIZATION); | 477 | rv = AcpiInitializeObjects(ACPI_FULL_INITIALIZATION); | |
489 | 478 | |||
490 | if (ACPI_FAILURE(rv)) | 479 | if (ACPI_FAILURE(rv)) | |
491 | goto fail; | 480 | goto fail; | |
492 | 481 | |||
493 | /* | 482 | /* | |
483 | * Scan the namespace and build our device tree. | |||
484 | */ | |||
485 | acpi_build_tree(sc); | |||
486 | ||||
487 | acpi_md_callback(sc); | |||
488 | ||||
489 | /* | |||
494 | * Early initialization of the _PDC control method | 490 | * Early initialization of the _PDC control method | |
495 | * that may load additional SSDT tables dynamically. | 491 | * that may load additional SSDT tables dynamically. | |
496 | */ | 492 | */ | |
497 | (void)acpi_md_pdc(); | 493 | (void)acpi_md_pdc(); | |
498 | 494 | |||
499 | /* | 495 | /* | |
500 | * Install global notify handlers. | 496 | * Install global notify handlers. | |
501 | */ | 497 | */ | |
502 | rv = AcpiInstallNotifyHandler(ACPI_ROOT_OBJECT, | 498 | rv = AcpiInstallNotifyHandler(ACPI_ROOT_OBJECT, | |
503 | ACPI_SYSTEM_NOTIFY, acpi_notify_handler, NULL); | 499 | ACPI_SYSTEM_NOTIFY, acpi_notify_handler, NULL); | |
504 | 500 | |||
505 | if (ACPI_FAILURE(rv)) | 501 | if (ACPI_FAILURE(rv)) | |
506 | goto fail; | 502 | goto fail; | |
@@ -514,31 +510,27 @@ acpi_attach(device_t parent, device_t se | @@ -514,31 +510,27 @@ acpi_attach(device_t parent, device_t se | |||
514 | acpi_active = 1; | 510 | acpi_active = 1; | |
515 | 511 | |||
516 | /* Show SCI interrupt. */ | 512 | /* Show SCI interrupt. */ | |
517 | aprint_verbose_dev(self, "SCI interrupting at int %u\n", | 513 | aprint_verbose_dev(self, "SCI interrupting at int %u\n", | |
518 | AcpiGbl_FADT.SciInterrupt); | 514 | AcpiGbl_FADT.SciInterrupt); | |
519 | 515 | |||
520 | /* | 516 | /* | |
521 | * Install fixed-event handlers. | 517 | * Install fixed-event handlers. | |
522 | */ | 518 | */ | |
523 | acpi_register_fixed_button(sc, ACPI_EVENT_POWER_BUTTON); | 519 | acpi_register_fixed_button(sc, ACPI_EVENT_POWER_BUTTON); | |
524 | acpi_register_fixed_button(sc, ACPI_EVENT_SLEEP_BUTTON); | 520 | acpi_register_fixed_button(sc, ACPI_EVENT_SLEEP_BUTTON); | |
525 | 521 | |||
526 | acpitimer_init(sc); | 522 | acpitimer_init(sc); | |
527 | 523 | acpi_config_tree(sc); | ||
528 | /* | |||
529 | * Scan the namespace and build our device tree. | |||
530 | */ | |||
531 | acpi_build_tree(sc); | |||
532 | acpi_sleep_init(sc); | 524 | acpi_sleep_init(sc); | |
533 | 525 | |||
534 | #ifdef ACPI_DEBUG | 526 | #ifdef ACPI_DEBUG | |
535 | acpi_debug_init(); | 527 | acpi_debug_init(); | |
536 | #endif | 528 | #endif | |
537 | 529 | |||
538 | /* | 530 | /* | |
539 | * Print debug information. | 531 | * Print debug information. | |
540 | */ | 532 | */ | |
541 | acpi_print_verbose(sc); | 533 | acpi_print_verbose(sc); | |
542 | 534 | |||
543 | return; | 535 | return; | |
544 | 536 | |||
@@ -656,26 +648,35 @@ acpi_build_tree(struct acpi_softc *sc) | @@ -656,26 +648,35 @@ acpi_build_tree(struct acpi_softc *sc) | |||
656 | 648 | |||
657 | sc->sc_root = awc.aw_parent; | 649 | sc->sc_root = awc.aw_parent; | |
658 | 650 | |||
659 | /* | 651 | /* | |
660 | * Build the internal namespace. | 652 | * Build the internal namespace. | |
661 | */ | 653 | */ | |
662 | (void)AcpiWalkNamespace(ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, UINT32_MAX, | 654 | (void)AcpiWalkNamespace(ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, UINT32_MAX, | |
663 | acpi_make_devnode, acpi_make_devnode_post, &awc, NULL); | 655 | acpi_make_devnode, acpi_make_devnode_post, &awc, NULL); | |
664 | 656 | |||
665 | /* | 657 | /* | |
666 | * Scan the internal namespace. | 658 | * Scan the internal namespace. | |
667 | */ | 659 | */ | |
668 | (void)acpi_pcidev_scan(sc->sc_root); | 660 | (void)acpi_pcidev_scan(sc->sc_root); | |
661 | } | |||
662 | ||||
663 | static void | |||
664 | acpi_config_tree(struct acpi_softc *sc) | |||
665 | { | |||
666 | ||||
667 | /* | |||
668 | * Configure all everything found "at acpi?". | |||
669 | */ | |||
669 | (void)acpi_rescan(sc->sc_dev, NULL, NULL); | 670 | (void)acpi_rescan(sc->sc_dev, NULL, NULL); | |
670 | 671 | |||
671 | /* | 672 | /* | |
672 | * Update GPE information. | 673 | * Update GPE information. | |
673 | * | 674 | * | |
674 | * Note that this must be called after | 675 | * Note that this must be called after | |
675 | * all GPE handlers have been installed. | 676 | * all GPE handlers have been installed. | |
676 | */ | 677 | */ | |
677 | (void)AcpiUpdateAllGpes(); | 678 | (void)AcpiUpdateAllGpes(); | |
678 | 679 | |||
679 | /* | 680 | /* | |
680 | * Defer rest of the configuration. | 681 | * Defer rest of the configuration. | |
681 | */ | 682 | */ |