Sync usage with man page.
[netbsd-mini2440.git] / sys / arch / xen / x86 / mainbus.c
blob78c427c6bd8eb90e24c18ab657dc733a0ac9d238
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 */
4 /*
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
9 * are met:
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"
44 #include "pci.h"
46 #include "opt_xen.h"
47 #include "opt_mpbios.h"
48 #include "opt_pcifixup.h"
50 #include "acpica.h"
51 #include "ioapic.h"
53 #include "ipmi.h"
55 #include <machine/cpuvar.h>
56 #include <machine/i82093var.h>
58 #include <xen/xen.h>
59 #include <xen/hypervisor.h>
61 #if NIPMI > 0
62 #include <x86/ipmivar.h>
63 #endif
65 #if NPCI > 0
66 #include <dev/pci/pcivar.h>
67 #if NACPICA > 0
68 #include <dev/acpi/acpivar.h>
69 #include <dev/acpi/acpi_madt.h>
70 #include <xen/mpacpi.h>
71 #endif /* NACPICA > 0 */
72 #ifdef MPBIOS
73 #include <machine/mpbiosvar.h>
74 #endif /* MPBIOS */
75 #ifdef PCI_BUS_FIXUP
76 #include <arch/x86/pci/pci_bus_fixup.h>
77 #ifdef PCI_ADDR_FIXUP
78 #include <arch/x86/pci/pci_addr_fixup.h>
79 #endif
80 #endif
82 #if defined(MPBIOS) || NACPICA > 0
83 struct mp_bus *mp_busses;
84 int mp_nbus;
85 struct mp_intr_map *mp_intrs;
86 int mp_nintr;
88 int mp_isa_bus = -1; /* XXX */
89 int mp_eisa_bus = -1; /* XXX */
91 int acpi_present = 0;
92 int mpacpi_active = 0;
93 #ifdef MPVERBOSE
94 int mp_verbose = 1;
95 #else /* MPVERBOSE */
96 int mp_verbose = 0;
97 #endif /* MPVERBOSE */
98 #endif /* defined(MPBIOS) || NACPICA > 0 */
99 #endif /* NPCI > 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;
113 #if NHYPERVISOR > 0
114 struct hypervisor_attach_args mba_haa;
115 #endif
116 #if NIPMI > 0
117 struct ipmi_attach_args mba_ipmi;
118 #endif
122 * Probe for the mainbus; always succeeds.
125 mainbus_match(device_t parent, cfdata_t match, void *aux)
128 return 1;
132 * Attach the mainbus.
134 void
135 mainbus_attach(device_t parent, device_t self, void *aux)
137 union mainbus_attach_args mba;
138 #if defined(DOM0OPS)
139 int numcpus = 0;
140 #ifdef MPBIOS
141 int mpbios_present = 0;
142 #endif
143 #ifdef PCI_BUS_FIXUP
144 int pci_maxbus = 0;
145 #endif
146 #endif /* defined(DOM0OPS) */
148 aprint_naive("\n");
149 aprint_normal("\n");
151 #ifdef DOM0OPS
152 if (xendomain_is_dom0()) {
153 #ifdef MPBIOS
154 mpbios_present = mpbios_probe(self);
155 #endif
156 #if NPCI > 0
157 /* ACPI needs to be able to access PCI configuration space. */
158 pci_mode = pci_mode_detect();
159 #ifdef PCI_BUS_FIXUP
160 if (pci_mode != 0) {
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 */
171 #if NACPICA > 0
172 acpi_present = acpi_probe();
173 if (acpi_present)
174 mpacpi_active = mpacpi_scan_apics(self, &numcpus);
175 if (!mpacpi_active)
176 #endif
178 #ifdef MPBIOS
179 if (mpbios_present)
180 mpbios_scan(self, &numcpus);
181 else
182 #endif
183 if (numcpus == 0) {
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);
192 #if NIOAPIC > 0
193 ioapic_enable();
194 #endif
195 #endif /* NPCI */
197 #endif /* DOM0OPS */
199 #if NIPMI > 0
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);
205 #endif
207 #if NHYPERVISOR > 0
208 mba.mba_haa.haa_busname = "hypervisor";
209 config_found_ia(self, "hypervisorbus", &mba.mba_haa, mainbus_print);
210 #endif
214 mainbus_print(void *aux, const char *pnp)
216 union mainbus_attach_args *mba = aux;
218 if (pnp)
219 aprint_normal("%s at %s", mba->mba_busname, pnp);
220 return (UNCONF);