| @@ -1,456 +1,455 @@ | | | @@ -1,456 +1,455 @@ |
1 | /* $NetBSD: mainbus.c,v 1.92 2011/10/21 21:35:28 dyoung Exp $ */ | | 1 | /* $NetBSD: mainbus.c,v 1.93 2012/01/18 21:34:38 drochner Exp $ */ |
2 | | | 2 | |
3 | /* | | 3 | /* |
4 | * Copyright (c) 1996 Christopher G. Demetriou. All rights reserved. | | 4 | * Copyright (c) 1996 Christopher G. Demetriou. 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 | * 3. All advertising materials mentioning features or use of this software | | 14 | * 3. All advertising materials mentioning features or use of this software |
15 | * must display the following acknowledgement: | | 15 | * must display the following acknowledgement: |
16 | * This product includes software developed by Christopher G. Demetriou | | 16 | * This product includes software developed by Christopher G. Demetriou |
17 | * for the NetBSD Project. | | 17 | * for the NetBSD Project. |
18 | * 4. The name of the author may not be used to endorse or promote products | | 18 | * 4. The name of the author may not be used to endorse or promote products |
19 | * derived from this software without specific prior written permission | | 19 | * derived from this software without specific prior written permission |
20 | * | | 20 | * |
21 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR | | 21 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
22 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | | 22 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
23 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. | | 23 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
24 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, | | 24 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
25 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | | 25 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
26 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | | 26 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
27 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | | 27 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
28 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | | 28 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
29 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | | 29 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
30 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | | 30 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
31 | */ | | 31 | */ |
32 | | | 32 | |
33 | #include <sys/cdefs.h> | | 33 | #include <sys/cdefs.h> |
34 | __KERNEL_RCSID(0, "$NetBSD: mainbus.c,v 1.92 2011/10/21 21:35:28 dyoung Exp $"); | | 34 | __KERNEL_RCSID(0, "$NetBSD: mainbus.c,v 1.93 2012/01/18 21:34:38 drochner Exp $"); |
35 | | | 35 | |
36 | #include <sys/param.h> | | 36 | #include <sys/param.h> |
37 | #include <sys/systm.h> | | 37 | #include <sys/systm.h> |
38 | #include <sys/device.h> | | 38 | #include <sys/device.h> |
39 | #include <sys/reboot.h> | | 39 | #include <sys/reboot.h> |
40 | #include <sys/bus.h> | | 40 | #include <sys/bus.h> |
41 | | | 41 | |
42 | #include <dev/isa/isavar.h> | | 42 | #include <dev/isa/isavar.h> |
43 | #include <dev/eisa/eisavar.h> | | 43 | #include <dev/eisa/eisavar.h> |
44 | #include <dev/pci/pcivar.h> | | 44 | #include <dev/pci/pcivar.h> |
45 | | | 45 | |
46 | #include <dev/isa/isareg.h> /* for ISA_HOLE_VADDR */ | | 46 | #include <dev/isa/isareg.h> /* for ISA_HOLE_VADDR */ |
47 | | | 47 | |
48 | #include "pci.h" | | 48 | #include "pci.h" |
49 | #include "eisa.h" | | 49 | #include "eisa.h" |
50 | #include "isa.h" | | 50 | #include "isa.h" |
51 | #include "isadma.h" | | 51 | #include "isadma.h" |
52 | #include "mca.h" | | 52 | #include "mca.h" |
53 | #include "apmbios.h" | | 53 | #include "apmbios.h" |
54 | #include "pnpbios.h" | | 54 | #include "pnpbios.h" |
55 | #include "acpica.h" | | 55 | #include "acpica.h" |
56 | #include "ipmi.h" | | 56 | #include "ipmi.h" |
57 | | | 57 | |
58 | #include "opt_acpi.h" | | 58 | #include "opt_acpi.h" |
59 | #include "opt_mpbios.h" | | 59 | #include "opt_mpbios.h" |
60 | #include "opt_pcifixup.h" | | 60 | #include "opt_pcifixup.h" |
61 | | | 61 | |
62 | #include <machine/cpuvar.h> | | 62 | #include <machine/cpuvar.h> |
63 | #include <machine/i82093var.h> | | 63 | #include <machine/i82093var.h> |
64 | #include <machine/mpbiosvar.h> | | 64 | #include <machine/mpbiosvar.h> |
65 | #include <machine/mpacpi.h> | | 65 | #include <machine/mpacpi.h> |
66 | | | 66 | |
67 | #if NAPMBIOS > 0 | | 67 | #if NAPMBIOS > 0 |
68 | #include <machine/bioscall.h> | | 68 | #include <machine/bioscall.h> |
69 | #include <machine/apmvar.h> | | 69 | #include <machine/apmvar.h> |
70 | #endif | | 70 | #endif |
71 | | | 71 | |
72 | #if NPNPBIOS > 0 | | 72 | #if NPNPBIOS > 0 |
73 | #include <arch/i386/pnpbios/pnpbiosvar.h> | | 73 | #include <arch/i386/pnpbios/pnpbiosvar.h> |
74 | #endif | | 74 | #endif |
75 | | | 75 | |
76 | #if NACPICA > 0 | | 76 | #if NACPICA > 0 |
77 | #include <dev/acpi/acpivar.h> | | 77 | #include <dev/acpi/acpivar.h> |
78 | #endif | | 78 | #endif |
79 | | | 79 | |
80 | #if NMCA > 0 | | 80 | #if NMCA > 0 |
81 | #include <dev/mca/mcavar.h> | | 81 | #include <dev/mca/mcavar.h> |
82 | #endif | | 82 | #endif |
83 | | | 83 | |
84 | #if NIPMI > 0 | | 84 | #if NIPMI > 0 |
85 | #include <x86/ipmivar.h> | | 85 | #include <x86/ipmivar.h> |
86 | #endif | | 86 | #endif |
87 | | | 87 | |
88 | #if NPCI > 0 | | 88 | #if NPCI > 0 |
89 | #if defined(PCI_BUS_FIXUP) | | 89 | #if defined(PCI_BUS_FIXUP) |
90 | #include <arch/x86/pci/pci_bus_fixup.h> | | 90 | #include <arch/x86/pci/pci_bus_fixup.h> |
91 | #if defined(PCI_ADDR_FIXUP) | | 91 | #if defined(PCI_ADDR_FIXUP) |
92 | #include <arch/x86/pci/pci_addr_fixup.h> | | 92 | #include <arch/x86/pci/pci_addr_fixup.h> |
93 | #endif | | 93 | #endif |
94 | #endif | | 94 | #endif |
95 | #endif | | 95 | #endif |
96 | | | 96 | |
97 | void mainbus_childdetached(device_t, device_t); | | 97 | void mainbus_childdetached(device_t, device_t); |
98 | int mainbus_match(device_t, cfdata_t, void *); | | 98 | int mainbus_match(device_t, cfdata_t, void *); |
99 | void mainbus_attach(device_t, device_t, void *); | | 99 | void mainbus_attach(device_t, device_t, void *); |
100 | | | 100 | |
101 | static int mainbus_rescan(device_t, const char *, const int *); | | 101 | static int mainbus_rescan(device_t, const char *, const int *); |
102 | | | 102 | |
103 | struct mainbus_softc { | | 103 | struct mainbus_softc { |
104 | device_t sc_acpi; | | 104 | device_t sc_acpi; |
105 | device_t sc_dev; | | 105 | device_t sc_dev; |
106 | device_t sc_ipmi; | | 106 | device_t sc_ipmi; |
107 | device_t sc_pci; | | 107 | device_t sc_pci; |
108 | device_t sc_mca; | | 108 | device_t sc_mca; |
109 | device_t sc_pnpbios; | | 109 | device_t sc_pnpbios; |
110 | bool sc_acpi_present; | | 110 | bool sc_acpi_present; |
111 | bool sc_mpacpi_active; | | 111 | bool sc_mpacpi_active; |
112 | }; | | 112 | }; |
113 | | | 113 | |
114 | CFATTACH_DECL2_NEW(mainbus, sizeof(struct mainbus_softc), | | 114 | CFATTACH_DECL2_NEW(mainbus, sizeof(struct mainbus_softc), |
115 | mainbus_match, mainbus_attach, NULL, NULL, mainbus_rescan, | | 115 | mainbus_match, mainbus_attach, NULL, NULL, mainbus_rescan, |
116 | mainbus_childdetached); | | 116 | mainbus_childdetached); |
117 | | | 117 | |
118 | int mainbus_print(void *, const char *); | | 118 | int mainbus_print(void *, const char *); |
119 | | | 119 | |
120 | union mainbus_attach_args { | | 120 | union mainbus_attach_args { |
121 | const char *mba_busname; /* first elem of all */ | | 121 | const char *mba_busname; /* first elem of all */ |
122 | struct pcibus_attach_args mba_pba; | | 122 | struct pcibus_attach_args mba_pba; |
123 | struct eisabus_attach_args mba_eba; | | 123 | struct eisabus_attach_args mba_eba; |
124 | struct isabus_attach_args mba_iba; | | 124 | struct isabus_attach_args mba_iba; |
125 | #if NMCA > 0 | | 125 | #if NMCA > 0 |
126 | struct mcabus_attach_args mba_mba; | | 126 | struct mcabus_attach_args mba_mba; |
127 | #endif | | 127 | #endif |
128 | #if NPNPBIOS > 0 | | 128 | #if NPNPBIOS > 0 |
129 | struct pnpbios_attach_args mba_paa; | | 129 | struct pnpbios_attach_args mba_paa; |
130 | #endif | | 130 | #endif |
131 | struct cpu_attach_args mba_caa; | | 131 | struct cpu_attach_args mba_caa; |
132 | struct apic_attach_args aaa_caa; | | 132 | struct apic_attach_args aaa_caa; |
133 | #if NACPICA > 0 | | 133 | #if NACPICA > 0 |
134 | struct acpibus_attach_args mba_acpi; | | 134 | struct acpibus_attach_args mba_acpi; |
135 | #endif | | 135 | #endif |
136 | #if NIPMI > 0 | | 136 | #if NIPMI > 0 |
137 | struct ipmi_attach_args mba_ipmi; | | 137 | struct ipmi_attach_args mba_ipmi; |
138 | #endif | | 138 | #endif |
139 | }; | | 139 | }; |
140 | | | 140 | |
141 | /* | | 141 | /* |
142 | * This is set when the ISA bus is attached. If it's not set by the | | 142 | * This is set when the ISA bus is attached. If it's not set by the |
143 | * time it's checked below, then mainbus attempts to attach an ISA. | | 143 | * time it's checked below, then mainbus attempts to attach an ISA. |
144 | */ | | 144 | */ |
145 | int isa_has_been_seen; | | 145 | int isa_has_been_seen; |
146 | struct x86_isa_chipset x86_isa_chipset; | | 146 | struct x86_isa_chipset x86_isa_chipset; |
147 | #if NISA > 0 | | 147 | #if NISA > 0 |
148 | static const struct isabus_attach_args mba_iba = { | | 148 | static const struct isabus_attach_args mba_iba = { |
149 | ._iba_busname = "isa", | | 149 | ._iba_busname = "isa", |
150 | .iba_dmat = &isa_bus_dma_tag, | | 150 | .iba_dmat = &isa_bus_dma_tag, |
151 | .iba_ic = &x86_isa_chipset | | 151 | .iba_ic = &x86_isa_chipset |
152 | }; | | 152 | }; |
153 | #endif | | 153 | #endif |
154 | | | 154 | |
155 | /* | | 155 | /* |
156 | * Same as above, but for EISA. | | 156 | * Same as above, but for EISA. |
157 | */ | | 157 | */ |
158 | int eisa_has_been_seen; | | 158 | int eisa_has_been_seen; |
159 | | | 159 | |
160 | #if defined(MPBIOS) || NACPICA > 0 | | 160 | #if defined(MPBIOS) || NACPICA > 0 |
161 | struct mp_bus *mp_busses; | | 161 | struct mp_bus *mp_busses; |
162 | int mp_nbus; | | 162 | int mp_nbus; |
163 | struct mp_intr_map *mp_intrs; | | 163 | struct mp_intr_map *mp_intrs; |
164 | int mp_nintr; | | 164 | int mp_nintr; |
165 | | | 165 | |
166 | int mp_isa_bus = -1; /* XXX */ | | 166 | int mp_isa_bus = -1; /* XXX */ |
167 | int mp_eisa_bus = -1; /* XXX */ | | 167 | int mp_eisa_bus = -1; /* XXX */ |
168 | | | 168 | |
169 | #ifdef MPVERBOSE | | 169 | #ifdef MPVERBOSE |
170 | int mp_verbose = 1; | | 170 | int mp_verbose = 1; |
171 | #else | | 171 | #else |
172 | int mp_verbose = 0; | | 172 | int mp_verbose = 0; |
173 | #endif | | 173 | #endif |
174 | #endif | | 174 | #endif |
175 | | | 175 | |
176 | void | | 176 | void |
177 | mainbus_childdetached(device_t self, device_t child) | | 177 | mainbus_childdetached(device_t self, device_t child) |
178 | { | | 178 | { |
179 | struct mainbus_softc *sc = device_private(self); | | 179 | struct mainbus_softc *sc = device_private(self); |
180 | | | 180 | |
181 | if (sc->sc_acpi == child) | | 181 | if (sc->sc_acpi == child) |
182 | sc->sc_acpi = NULL; | | 182 | sc->sc_acpi = NULL; |
183 | if (sc->sc_ipmi == child) | | 183 | if (sc->sc_ipmi == child) |
184 | sc->sc_ipmi = NULL; | | 184 | sc->sc_ipmi = NULL; |
185 | if (sc->sc_mca == child) | | 185 | if (sc->sc_mca == child) |
186 | sc->sc_mca = NULL; | | 186 | sc->sc_mca = NULL; |
187 | if (sc->sc_pnpbios == child) | | 187 | if (sc->sc_pnpbios == child) |
188 | sc->sc_pnpbios = NULL; | | 188 | sc->sc_pnpbios = NULL; |
189 | if (sc->sc_pci == child) | | 189 | if (sc->sc_pci == child) |
190 | sc->sc_pci = NULL; | | 190 | sc->sc_pci = NULL; |
191 | | | 191 | |
192 | #if NPCI > 0 | | 192 | #if NPCI > 0 |
193 | mp_pci_childdetached(self, child); | | 193 | mp_pci_childdetached(self, child); |
194 | #endif | | 194 | #endif |
195 | } | | 195 | } |
196 | | | 196 | |
197 | /* | | 197 | /* |
198 | * Probe for the mainbus; always succeeds. | | 198 | * Probe for the mainbus; always succeeds. |
199 | */ | | 199 | */ |
200 | int | | 200 | int |
201 | mainbus_match(device_t parent, cfdata_t match, void *aux) | | 201 | mainbus_match(device_t parent, cfdata_t match, void *aux) |
202 | { | | 202 | { |
203 | | | 203 | |
204 | return 1; | | 204 | return 1; |
205 | } | | 205 | } |
206 | | | 206 | |
207 | /* | | 207 | /* |
208 | * Attach the mainbus. | | 208 | * Attach the mainbus. |
209 | */ | | 209 | */ |
210 | void | | 210 | void |
211 | mainbus_attach(device_t parent, device_t self, void *aux) | | 211 | mainbus_attach(device_t parent, device_t self, void *aux) |
212 | { | | 212 | { |
213 | #if NPCI > 0 | | 213 | #if NPCI > 0 |
214 | int mode; | | 214 | int mode; |
215 | #endif | | 215 | #endif |
216 | struct mainbus_softc *sc = device_private(self); | | 216 | struct mainbus_softc *sc = device_private(self); |
217 | union mainbus_attach_args mba; | | 217 | union mainbus_attach_args mba; |
218 | #ifdef MPBIOS | | 218 | #ifdef MPBIOS |
219 | int mpbios_present = 0; | | 219 | int mpbios_present = 0; |
220 | #endif | | 220 | #endif |
221 | #if defined(PCI_BUS_FIXUP) | | 221 | #if defined(PCI_BUS_FIXUP) |
222 | int pci_maxbus = 0; | | 222 | int pci_maxbus = 0; |
223 | #endif | | 223 | #endif |
224 | int numcpus = 0; | | 224 | int numcpus = 0; |
225 | | | 225 | |
226 | sc->sc_dev = self; | | 226 | sc->sc_dev = self; |
227 | | | 227 | |
228 | aprint_naive("\n"); | | 228 | aprint_naive("\n"); |
229 | aprint_normal("\n"); | | 229 | aprint_normal("\n"); |
230 | | | 230 | |
231 | #ifdef MPBIOS | | 231 | #ifdef MPBIOS |
232 | mpbios_present = mpbios_probe(self); | | 232 | mpbios_present = mpbios_probe(self); |
233 | #endif | | 233 | #endif |
234 | | | 234 | |
235 | #if NPCI > 0 | | 235 | #if NPCI > 0 |
236 | /* | | 236 | /* |
237 | * ACPI needs to be able to access PCI configuration space. | | 237 | * ACPI needs to be able to access PCI configuration space. |
238 | */ | | 238 | */ |
239 | mode = pci_mode_detect(); | | 239 | mode = pci_mode_detect(); |
240 | #if defined(PCI_BUS_FIXUP) | | 240 | #if defined(PCI_BUS_FIXUP) |
241 | if (mode != 0) { | | 241 | if (mode != 0) { |
242 | pci_maxbus = pci_bus_fixup(NULL, 0); | | 242 | pci_maxbus = pci_bus_fixup(NULL, 0); |
243 | aprint_debug("PCI bus max, after pci_bus_fixup: %i\n", | | 243 | aprint_debug("PCI bus max, after pci_bus_fixup: %i\n", |
244 | pci_maxbus); | | 244 | pci_maxbus); |
245 | #if defined(PCI_ADDR_FIXUP) | | 245 | #if defined(PCI_ADDR_FIXUP) |
246 | pciaddr.extent_port = NULL; | | 246 | pciaddr.extent_port = NULL; |
247 | pciaddr.extent_mem = NULL; | | 247 | pciaddr.extent_mem = NULL; |
248 | pci_addr_fixup(NULL, pci_maxbus); | | 248 | pci_addr_fixup(NULL, pci_maxbus); |
249 | #endif | | 249 | #endif |
250 | } | | 250 | } |
251 | #endif | | 251 | #endif |
252 | #endif | | 252 | #endif |
253 | | | 253 | |
254 | #if NACPICA > 0 | | 254 | #if NACPICA > 0 |
255 | if ((boothowto & RB_MD2) == 0 && acpi_check(self, "acpibus")) | | 255 | if ((boothowto & RB_MD2) == 0 && acpi_check(self, "acpibus")) |
256 | sc->sc_acpi_present = acpi_probe() != 0; | | 256 | sc->sc_acpi_present = acpi_probe() != 0; |
257 | /* | | 257 | /* |
258 | * First, see if the MADT contains CPUs, and possibly I/O APICs. | | 258 | * First, see if the MADT contains CPUs, and possibly I/O APICs. |
259 | * Building the interrupt routing structures can only | | 259 | * Building the interrupt routing structures can only |
260 | * be done later (via a callback). | | 260 | * be done later (via a callback). |
261 | */ | | 261 | */ |
262 | if (sc->sc_acpi_present) | | 262 | if (sc->sc_acpi_present) |
263 | sc->sc_mpacpi_active = mpacpi_scan_apics(self, &numcpus) != 0; | | 263 | sc->sc_mpacpi_active = mpacpi_scan_apics(self, &numcpus) != 0; |
264 | #endif | | 264 | #endif |
265 | | | 265 | |
266 | if (!sc->sc_mpacpi_active) { | | 266 | if (!sc->sc_mpacpi_active) { |
267 | #ifdef MPBIOS | | 267 | #ifdef MPBIOS |
268 | if (mpbios_present) | | 268 | if (mpbios_present) |
269 | mpbios_scan(self, &numcpus); | | 269 | mpbios_scan(self, &numcpus); |
270 | else | | 270 | else |
271 | #endif | | 271 | #endif |
272 | if (numcpus == 0) { | | 272 | if (numcpus == 0) { |
273 | struct cpu_attach_args caa; | | 273 | struct cpu_attach_args caa; |
274 | | | 274 | |
275 | memset(&caa, 0, sizeof(caa)); | | 275 | memset(&caa, 0, sizeof(caa)); |
276 | caa.cpu_number = 0; | | 276 | caa.cpu_number = 0; |
277 | caa.cpu_role = CPU_ROLE_SP; | | 277 | caa.cpu_role = CPU_ROLE_SP; |
278 | caa.cpu_func = 0; | | 278 | caa.cpu_func = 0; |
279 | | | 279 | |
280 | config_found_ia(self, "cpubus", &caa, mainbus_print); | | 280 | config_found_ia(self, "cpubus", &caa, mainbus_print); |
281 | } | | 281 | } |
282 | } | | 282 | } |
283 | | | 283 | |
284 | #if NISADMA > 0 && (NACPICA > 0 || NPNPBIOS > 0) | | 284 | #if NISADMA > 0 && (NACPICA > 0 || NPNPBIOS > 0) |
285 | /* | | 285 | /* |
286 | * ACPI and PNPBIOS need ISA DMA initialized before they start probing. | | 286 | * ACPI and PNPBIOS need ISA DMA initialized before they start probing. |
287 | */ | | 287 | */ |
288 | isa_dmainit(&x86_isa_chipset, x86_bus_space_io, &isa_bus_dma_tag, | | 288 | isa_dmainit(&x86_isa_chipset, x86_bus_space_io, &isa_bus_dma_tag, |
289 | self); | | 289 | self); |
290 | #endif | | 290 | #endif |
291 | | | 291 | |
292 | mainbus_rescan(self, "acpibus", NULL); | | 292 | mainbus_rescan(self, "acpibus", NULL); |
293 | | | 293 | |
294 | mainbus_rescan(self, "pnpbiosbus", NULL); | | 294 | mainbus_rescan(self, "pnpbiosbus", NULL); |
295 | | | 295 | |
296 | mainbus_rescan(self, "ipmibus", NULL); | | 296 | mainbus_rescan(self, "ipmibus", NULL); |
297 | | | 297 | |
298 | mainbus_rescan(self, "pcibus", NULL); | | 298 | mainbus_rescan(self, "pcibus", NULL); |
299 | | | 299 | |
300 | mainbus_rescan(self, "mcabus", NULL); | | 300 | mainbus_rescan(self, "mcabus", NULL); |
301 | | | 301 | |
302 | if (memcmp(ISA_HOLE_VADDR(EISA_ID_PADDR), EISA_ID, EISA_ID_LEN) == 0 && | | 302 | if (memcmp(ISA_HOLE_VADDR(EISA_ID_PADDR), EISA_ID, EISA_ID_LEN) == 0 && |
303 | eisa_has_been_seen == 0) { | | 303 | eisa_has_been_seen == 0) { |
304 | mba.mba_eba.eba_iot = x86_bus_space_io; | | 304 | mba.mba_eba.eba_iot = x86_bus_space_io; |
305 | mba.mba_eba.eba_memt = x86_bus_space_mem; | | 305 | mba.mba_eba.eba_memt = x86_bus_space_mem; |
306 | #if NEISA > 0 | | 306 | #if NEISA > 0 |
307 | mba.mba_eba.eba_dmat = &eisa_bus_dma_tag; | | 307 | mba.mba_eba.eba_dmat = &eisa_bus_dma_tag; |
308 | #endif | | 308 | #endif |
309 | config_found_ia(self, "eisabus", &mba.mba_eba, eisabusprint); | | 309 | config_found_ia(self, "eisabus", &mba.mba_eba, eisabusprint); |
310 | } | | 310 | } |
311 | | | 311 | |
312 | #if NISA > 0 | | 312 | #if NISA > 0 |
313 | if (isa_has_been_seen == 0) { | | 313 | if (isa_has_been_seen == 0) { |
314 | mba.mba_iba = mba_iba; | | 314 | mba.mba_iba = mba_iba; |
315 | mba.mba_iba.iba_iot = x86_bus_space_io; | | 315 | mba.mba_iba.iba_iot = x86_bus_space_io; |
316 | mba.mba_iba.iba_memt = x86_bus_space_mem; | | 316 | mba.mba_iba.iba_memt = x86_bus_space_mem; |
317 | config_found_ia(self, "isabus", &mba.mba_iba, isabusprint); | | 317 | config_found_ia(self, "isabus", &mba.mba_iba, isabusprint); |
318 | } | | 318 | } |
319 | #endif | | 319 | #endif |
320 | | | 320 | |
321 | #if NAPMBIOS > 0 | | 321 | #if NAPMBIOS > 0 |
322 | #if NACPICA > 0 | | 322 | #if NACPICA > 0 |
323 | if (acpi_active == 0) | | 323 | if (acpi_active == 0) |
324 | #endif | | 324 | #endif |
325 | if (apm_busprobe()) | | 325 | if (apm_busprobe()) |
326 | config_found_ia(self, "apmbus", 0, 0); | | 326 | config_found_ia(self, "apmbus", 0, 0); |
327 | #endif | | 327 | #endif |
328 | | | 328 | |
329 | if (!pmf_device_register(self, NULL, NULL)) | | 329 | if (!pmf_device_register(self, NULL, NULL)) |
330 | aprint_error_dev(self, "couldn't establish power handler\n"); | | 330 | aprint_error_dev(self, "couldn't establish power handler\n"); |
331 | } | | 331 | } |
332 | | | 332 | |
333 | /* scan for new children */ | | 333 | /* scan for new children */ |
334 | static int | | 334 | static int |
335 | mainbus_rescan(device_t self, const char *ifattr, const int *locators) | | 335 | mainbus_rescan(device_t self, const char *ifattr, const int *locators) |
336 | { | | 336 | { |
337 | struct mainbus_softc *sc = device_private(self); | | 337 | struct mainbus_softc *sc = device_private(self); |
338 | #if NACPICA > 0 || NIPMI > 0 || NMCA > 0 || NPCI > 0 || NPNPBIOS > 0 | | 338 | #if NACPICA > 0 || NIPMI > 0 || NMCA > 0 || NPCI > 0 || NPNPBIOS > 0 |
339 | union mainbus_attach_args mba; | | 339 | union mainbus_attach_args mba; |
340 | #endif | | 340 | #endif |
341 | | | 341 | |
342 | if (ifattr_match(ifattr, "acpibus") && sc->sc_acpi == NULL && | | 342 | if (ifattr_match(ifattr, "acpibus") && sc->sc_acpi == NULL && |
343 | sc->sc_acpi_present) { | | 343 | sc->sc_acpi_present) { |
344 | #if NACPICA > 0 | | 344 | #if NACPICA > 0 |
345 | mba.mba_acpi.aa_iot = x86_bus_space_io; | | 345 | mba.mba_acpi.aa_iot = x86_bus_space_io; |
346 | mba.mba_acpi.aa_memt = x86_bus_space_mem; | | 346 | mba.mba_acpi.aa_memt = x86_bus_space_mem; |
347 | mba.mba_acpi.aa_pc = NULL; | | 347 | mba.mba_acpi.aa_pc = NULL; |
348 | mba.mba_acpi.aa_pciflags = | | 348 | mba.mba_acpi.aa_pciflags = |
349 | PCI_FLAGS_IO_OKAY | PCI_FLAGS_MEM_OKAY | | | 349 | PCI_FLAGS_IO_OKAY | PCI_FLAGS_MEM_OKAY | |
350 | PCI_FLAGS_MRL_OKAY | PCI_FLAGS_MRM_OKAY | | | 350 | PCI_FLAGS_MRL_OKAY | PCI_FLAGS_MRM_OKAY | |
351 | PCI_FLAGS_MWI_OKAY; | | 351 | PCI_FLAGS_MWI_OKAY; |
352 | mba.mba_acpi.aa_ic = &x86_isa_chipset; | | 352 | mba.mba_acpi.aa_ic = &x86_isa_chipset; |
353 | sc->sc_acpi = | | 353 | sc->sc_acpi = |
354 | config_found_ia(self, "acpibus", &mba.mba_acpi, 0); | | 354 | config_found_ia(self, "acpibus", &mba.mba_acpi, 0); |
355 | #if 0 /* XXXJRT not yet */ | | 355 | #if 0 /* XXXJRT not yet */ |
356 | if (acpi_active) { | | 356 | if (acpi_active) { |
357 | /* | | 357 | /* |
358 | * ACPI already did all the work for us, there | | 358 | * ACPI already did all the work for us, there |
359 | * is nothing more for us to do. | | 359 | * is nothing more for us to do. |
360 | */ | | 360 | */ |
361 | return; | | 361 | return; |
362 | } | | 362 | } |
363 | #endif | | 363 | #endif |
364 | #endif | | 364 | #endif |
365 | } | | 365 | } |
366 | | | 366 | |
367 | if (ifattr_match(ifattr, "pnpbiosbus") && sc->sc_pnpbios == NULL) { | | 367 | if (ifattr_match(ifattr, "pnpbiosbus") && sc->sc_pnpbios == NULL) { |
368 | #if NPNPBIOS > 0 | | 368 | #if NPNPBIOS > 0 |
369 | #if NACPICA > 0 | | 369 | #if NACPICA > 0 |
370 | if (acpi_active == 0) | | 370 | if (acpi_active == 0) |
371 | #endif | | 371 | #endif |
372 | if (pnpbios_probe()) { | | 372 | if (pnpbios_probe()) { |
373 | mba.mba_paa.paa_ic = &x86_isa_chipset; | | 373 | mba.mba_paa.paa_ic = &x86_isa_chipset; |
374 | sc->sc_pnpbios = config_found_ia(self, "pnpbiosbus", | | 374 | sc->sc_pnpbios = config_found_ia(self, "pnpbiosbus", |
375 | &mba.mba_paa, 0); | | 375 | &mba.mba_paa, 0); |
376 | } | | 376 | } |
377 | #endif | | 377 | #endif |
378 | } | | 378 | } |
379 | | | 379 | |
380 | if (ifattr_match(ifattr, "ipmibus") && sc->sc_ipmi == NULL) { | | 380 | if (ifattr_match(ifattr, "ipmibus") && sc->sc_ipmi == NULL) { |
381 | #if NIPMI > 0 | | 381 | #if NIPMI > 0 |
382 | memset(&mba.mba_ipmi, 0, sizeof(mba.mba_ipmi)); | | 382 | memset(&mba.mba_ipmi, 0, sizeof(mba.mba_ipmi)); |
383 | mba.mba_ipmi.iaa_iot = x86_bus_space_io; | | 383 | mba.mba_ipmi.iaa_iot = x86_bus_space_io; |
384 | mba.mba_ipmi.iaa_memt = x86_bus_space_mem; | | 384 | mba.mba_ipmi.iaa_memt = x86_bus_space_mem; |
385 | if (ipmi_probe(&mba.mba_ipmi)) { | | 385 | if (ipmi_probe(&mba.mba_ipmi)) { |
386 | sc->sc_ipmi = | | 386 | sc->sc_ipmi = |
387 | config_found_ia(self, "ipmibus", &mba.mba_ipmi, 0); | | 387 | config_found_ia(self, "ipmibus", &mba.mba_ipmi, 0); |
388 | } | | 388 | } |
389 | #endif | | 389 | #endif |
390 | } | | 390 | } |
391 | | | 391 | |
392 | /* | | 392 | /* |
393 | * XXX Note also that the presence of a PCI bus should | | 393 | * XXX Note also that the presence of a PCI bus should |
394 | * XXX _always_ be checked, and if present the bus should be | | 394 | * XXX _always_ be checked, and if present the bus should be |
395 | * XXX 'found'. However, because of the structure of the code, | | 395 | * XXX 'found'. However, because of the structure of the code, |
396 | * XXX that's not currently possible. | | 396 | * XXX that's not currently possible. |
397 | */ | | 397 | */ |
398 | #if NPCI > 0 | | 398 | #if NPCI > 0 |
399 | if (pci_mode_detect() != 0 && ifattr_match(ifattr, "pcibus")) { | | 399 | if (pci_mode_detect() != 0 && ifattr_match(ifattr, "pcibus")) { |
400 | int npcibus = 0; | | 400 | int npcibus = 0; |
401 | | | 401 | |
402 | mba.mba_pba.pba_iot = x86_bus_space_io; | | 402 | mba.mba_pba.pba_iot = x86_bus_space_io; |
403 | mba.mba_pba.pba_memt = x86_bus_space_mem; | | 403 | mba.mba_pba.pba_memt = x86_bus_space_mem; |
404 | mba.mba_pba.pba_dmat = &pci_bus_dma_tag; | | 404 | mba.mba_pba.pba_dmat = &pci_bus_dma_tag; |
405 | mba.mba_pba.pba_dmat64 = NULL; | | 405 | mba.mba_pba.pba_dmat64 = NULL; |
406 | mba.mba_pba.pba_pc = NULL; | | 406 | mba.mba_pba.pba_pc = NULL; |
407 | mba.mba_pba.pba_flags = pci_bus_flags(); | | 407 | mba.mba_pba.pba_flags = pci_bus_flags(); |
408 | mba.mba_pba.pba_bus = 0; | | 408 | mba.mba_pba.pba_bus = 0; |
409 | mba.mba_pba.pba_sub = 255; | | | |
410 | mba.mba_pba.pba_bridgetag = NULL; | | 409 | mba.mba_pba.pba_bridgetag = NULL; |
411 | #if NACPICA > 0 && defined(ACPI_SCANPCI) | | 410 | #if NACPICA > 0 && defined(ACPI_SCANPCI) |
412 | if (npcibus == 0 && sc->sc_mpacpi_active) | | 411 | if (npcibus == 0 && sc->sc_mpacpi_active) |
413 | npcibus = mp_pci_scan(self, &mba.mba_pba, pcibusprint); | | 412 | npcibus = mp_pci_scan(self, &mba.mba_pba, pcibusprint); |
414 | #endif | | 413 | #endif |
415 | #if defined(MPBIOS) && defined(MPBIOS_SCANPCI) | | 414 | #if defined(MPBIOS) && defined(MPBIOS_SCANPCI) |
416 | if (npcibus == 0 && mpbios_scanned != 0) | | 415 | if (npcibus == 0 && mpbios_scanned != 0) |
417 | npcibus = mp_pci_scan(self, &mba.mba_pba, pcibusprint); | | 416 | npcibus = mp_pci_scan(self, &mba.mba_pba, pcibusprint); |
418 | #endif | | 417 | #endif |
419 | if (npcibus == 0 && sc->sc_pci == NULL) { | | 418 | if (npcibus == 0 && sc->sc_pci == NULL) { |
420 | sc->sc_pci = config_found_ia(self, "pcibus", | | 419 | sc->sc_pci = config_found_ia(self, "pcibus", |
421 | &mba.mba_pba, pcibusprint); | | 420 | &mba.mba_pba, pcibusprint); |
422 | } | | 421 | } |
423 | #if NACPICA > 0 | | 422 | #if NACPICA > 0 |
424 | if (mp_verbose) | | 423 | if (mp_verbose) |
425 | acpi_pci_link_state(); | | 424 | acpi_pci_link_state(); |
426 | #endif | | 425 | #endif |
427 | } | | 426 | } |
428 | #endif | | 427 | #endif |
429 | | | 428 | |
430 | | | 429 | |
431 | if (ifattr_match(ifattr, "mcabus") && sc->sc_mca == NULL) { | | 430 | if (ifattr_match(ifattr, "mcabus") && sc->sc_mca == NULL) { |
432 | #if NMCA > 0 | | 431 | #if NMCA > 0 |
433 | /* Note: MCA bus probe is done in i386/machdep.c */ | | 432 | /* Note: MCA bus probe is done in i386/machdep.c */ |
434 | if (MCA_system) { | | 433 | if (MCA_system) { |
435 | mba.mba_mba.mba_iot = x86_bus_space_io; | | 434 | mba.mba_mba.mba_iot = x86_bus_space_io; |
436 | mba.mba_mba.mba_memt = x86_bus_space_mem; | | 435 | mba.mba_mba.mba_memt = x86_bus_space_mem; |
437 | mba.mba_mba.mba_dmat = &mca_bus_dma_tag; | | 436 | mba.mba_mba.mba_dmat = &mca_bus_dma_tag; |
438 | mba.mba_mba.mba_mc = NULL; | | 437 | mba.mba_mba.mba_mc = NULL; |
439 | mba.mba_mba.mba_bus = 0; | | 438 | mba.mba_mba.mba_bus = 0; |
440 | sc->sc_mca = config_found_ia(self, "mcabus", | | 439 | sc->sc_mca = config_found_ia(self, "mcabus", |
441 | &mba.mba_mba, mcabusprint); | | 440 | &mba.mba_mba, mcabusprint); |
442 | } | | 441 | } |
443 | #endif | | 442 | #endif |
444 | } | | 443 | } |
445 | return 0; | | 444 | return 0; |
446 | } | | 445 | } |
447 | | | 446 | |
448 | int | | 447 | int |
449 | mainbus_print(void *aux, const char *pnp) | | 448 | mainbus_print(void *aux, const char *pnp) |
450 | { | | 449 | { |
451 | union mainbus_attach_args *mba = aux; | | 450 | union mainbus_attach_args *mba = aux; |
452 | | | 451 | |
453 | if (pnp) | | 452 | if (pnp) |
454 | aprint_normal("%s at %s", mba->mba_busname, pnp); | | 453 | aprint_normal("%s at %s", mba->mba_busname, pnp); |
455 | return (UNCONF); | | 454 | return (UNCONF); |
456 | } | | 455 | } |