1 /* $NetBSD: mainbus.c,v 1.8 2009/07/29 12:02:08 cegger Exp $ */
2 /* NetBSD: mainbus.c,v 1.53 2003/10/27 14:11:47 junyoung Exp */
5 * Copyright (c) 1996 Christopher G. Demetriou. All rights reserved.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * 3. All advertising materials mentioning features or use of this software
16 * must display the following acknowledgement:
17 * This product includes software developed by Christopher G. Demetriou
18 * for the NetBSD Project.
19 * 4. The name of the author may not be used to endorse or promote products
20 * derived from this software without specific prior written permission
22 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
23 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
24 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
25 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
26 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
27 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
31 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34 #include <sys/cdefs.h>
35 __KERNEL_RCSID(0, "$NetBSD: mainbus.c,v 1.8 2009/07/29 12:02:08 cegger Exp $");
37 #include <sys/param.h>
38 #include <sys/systm.h>
39 #include <sys/device.h>
41 #include <machine/bus.h>
43 #include "hypervisor.h"
47 #include "opt_mpbios.h"
48 #include "opt_pcifixup.h"
55 #include <machine/cpuvar.h>
56 #include <machine/i82093var.h>
59 #include <xen/hypervisor.h>
62 #include <x86/ipmivar.h>
66 #include <dev/pci/pcivar.h>
68 #include <dev/acpi/acpivar.h>
69 #include <dev/acpi/acpi_madt.h>
70 #include <xen/mpacpi.h>
71 #endif /* NACPICA > 0 */
73 #include <machine/mpbiosvar.h>
76 #include <arch/x86/pci/pci_bus_fixup.h>
78 #include <arch/x86/pci/pci_addr_fixup.h>
82 #if defined(MPBIOS) || NACPICA > 0
83 struct mp_bus
*mp_busses
;
85 struct mp_intr_map
*mp_intrs
;
88 int mp_isa_bus
= -1; /* XXX */
89 int mp_eisa_bus
= -1; /* XXX */
92 int mpacpi_active
= 0;
97 #endif /* MPVERBOSE */
98 #endif /* defined(MPBIOS) || NACPICA > 0 */
102 int mainbus_match(device_t
, cfdata_t
, void *);
103 void mainbus_attach(device_t
, device_t
, void *);
105 CFATTACH_DECL_NEW(mainbus
, 0,
106 mainbus_match
, mainbus_attach
, NULL
, NULL
);
108 int mainbus_print(void *, const char *);
110 union mainbus_attach_args
{
111 const char *mba_busname
; /* first elem of all */
112 struct cpu_attach_args mba_caa
;
114 struct hypervisor_attach_args mba_haa
;
117 struct ipmi_attach_args mba_ipmi
;
122 * Probe for the mainbus; always succeeds.
125 mainbus_match(device_t parent
, cfdata_t match
, void *aux
)
132 * Attach the mainbus.
135 mainbus_attach(device_t parent
, device_t self
, void *aux
)
137 union mainbus_attach_args mba
;
141 int mpbios_present
= 0;
146 #endif /* defined(DOM0OPS) */
152 if (xendomain_is_dom0()) {
154 mpbios_present
= mpbios_probe(self
);
157 /* ACPI needs to be able to access PCI configuration space. */
158 pci_mode
= pci_mode_detect();
161 pci_maxbus
= pci_bus_fixup(NULL
, 0);
162 aprint_debug_dev(self
, "PCI bus max, after "
163 "pci_bus_fixup: %i\n", pci_maxbus
);
164 #ifdef PCI_ADDR_FIXUP
165 pciaddr
.extent_port
= NULL
;
166 pciaddr
.extent_mem
= NULL
;
167 pci_addr_fixup(NULL
, pci_maxbus
);
168 #endif /* PCI_ADDR_FIXUP */
170 #endif /* PCI_BUS_FIXUP */
172 acpi_present
= acpi_probe();
174 mpacpi_active
= mpacpi_scan_apics(self
, &numcpus
);
180 mpbios_scan(self
, &numcpus
);
184 memset(&mba
.mba_caa
, 0, sizeof(mba
.mba_caa
));
185 mba
.mba_caa
.cpu_number
= 0;
186 mba
.mba_caa
.cpu_role
= CPU_ROLE_SP
;
187 mba
.mba_caa
.cpu_func
= 0;
188 config_found_ia(self
, "cpubus",
189 &mba
.mba_caa
, mainbus_print
);
200 memset(&mba
.mba_ipmi
, 0, sizeof(mba
.mba_ipmi
));
201 mba
.mba_ipmi
.iaa_iot
= X86_BUS_SPACE_IO
;
202 mba
.mba_ipmi
.iaa_memt
= X86_BUS_SPACE_MEM
;
203 if (ipmi_probe(&mba
.mba_ipmi
))
204 config_found_ia(self
, "ipmibus", &mba
.mba_ipmi
, 0);
208 mba
.mba_haa
.haa_busname
= "hypervisor";
209 config_found_ia(self
, "hypervisorbus", &mba
.mba_haa
, mainbus_print
);
214 mainbus_print(void *aux
, const char *pnp
)
216 union mainbus_attach_args
*mba
= aux
;
219 aprint_normal("%s at %s", mba
->mba_busname
, pnp
);