Sat Aug 7 21:59:11 2010 UTC ()
acpi_madt.h is gone


(cegger)
diff -r1.11 -r1.12 src/sys/arch/xen/x86/mainbus.c

cvs diff -r1.11 -r1.12 src/sys/arch/xen/x86/Attic/mainbus.c (switch to unified diff)

--- src/sys/arch/xen/x86/Attic/mainbus.c 2010/04/28 19:17:04 1.11
+++ src/sys/arch/xen/x86/Attic/mainbus.c 2010/08/07 21:59:11 1.12
@@ -1,224 +1,223 @@ @@ -1,224 +1,223 @@
1/* $NetBSD: mainbus.c,v 1.11 2010/04/28 19:17:04 dyoung Exp $ */ 1/* $NetBSD: mainbus.c,v 1.12 2010/08/07 21:59:11 cegger Exp $ */
2/* NetBSD: mainbus.c,v 1.53 2003/10/27 14:11:47 junyoung Exp */ 2/* NetBSD: mainbus.c,v 1.53 2003/10/27 14:11:47 junyoung Exp */
3 3
4/* 4/*
5 * Copyright (c) 1996 Christopher G. Demetriou. All rights reserved. 5 * Copyright (c) 1996 Christopher G. Demetriou. All rights reserved.
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions 8 * modification, are permitted provided that the following conditions
9 * are met: 9 * are met:
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer. 11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright 12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the 13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution. 14 * documentation and/or other materials provided with the distribution.
15 * 3. All advertising materials mentioning features or use of this software 15 * 3. All advertising materials mentioning features or use of this software
16 * must display the following acknowledgement: 16 * must display the following acknowledgement:
17 * This product includes software developed by Christopher G. Demetriou 17 * This product includes software developed by Christopher G. Demetriou
18 * for the NetBSD Project. 18 * for the NetBSD Project.
19 * 4. The name of the author may not be used to endorse or promote products 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 20 * derived from this software without specific prior written permission
21 * 21 *
22 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 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 23 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
24 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 24 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
25 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 25 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
26 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 26 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
27 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 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 28 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 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 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. 31 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 */ 32 */
33 33
34#include <sys/cdefs.h> 34#include <sys/cdefs.h>
35__KERNEL_RCSID(0, "$NetBSD: mainbus.c,v 1.11 2010/04/28 19:17:04 dyoung Exp $"); 35__KERNEL_RCSID(0, "$NetBSD: mainbus.c,v 1.12 2010/08/07 21:59:11 cegger Exp $");
36 36
37#include <sys/param.h> 37#include <sys/param.h>
38#include <sys/systm.h> 38#include <sys/systm.h>
39#include <sys/device.h> 39#include <sys/device.h>
40 40
41#include <machine/bus.h> 41#include <machine/bus.h>
42 42
43#include "hypervisor.h" 43#include "hypervisor.h"
44#include "pci.h" 44#include "pci.h"
45 45
46#include "opt_xen.h" 46#include "opt_xen.h"
47#include "opt_mpbios.h" 47#include "opt_mpbios.h"
48#include "opt_pcifixup.h" 48#include "opt_pcifixup.h"
49 49
50#include "acpica.h" 50#include "acpica.h"
51#include "ioapic.h" 51#include "ioapic.h"
52 52
53#include "ipmi.h" 53#include "ipmi.h"
54 54
55#include <machine/cpuvar.h> 55#include <machine/cpuvar.h>
56#include <machine/i82093var.h> 56#include <machine/i82093var.h>
57 57
58#include <xen/xen.h> 58#include <xen/xen.h>
59#include <xen/hypervisor.h> 59#include <xen/hypervisor.h>
60 60
61#if NIPMI > 0 61#if NIPMI > 0
62#include <x86/ipmivar.h> 62#include <x86/ipmivar.h>
63#endif 63#endif
64 64
65#if NPCI > 0 65#if NPCI > 0
66#include <dev/pci/pcivar.h> 66#include <dev/pci/pcivar.h>
67#if NACPICA > 0 67#if NACPICA > 0
68#include <dev/acpi/acpivar.h> 68#include <dev/acpi/acpivar.h>
69#include <dev/acpi/acpi_madt.h>  
70#include <xen/mpacpi.h>  69#include <xen/mpacpi.h>
71#endif /* NACPICA > 0 */ 70#endif /* NACPICA > 0 */
72#ifdef MPBIOS 71#ifdef MPBIOS
73#include <machine/mpbiosvar.h>  72#include <machine/mpbiosvar.h>
74#endif /* MPBIOS */ 73#endif /* MPBIOS */
75#ifdef PCI_BUS_FIXUP 74#ifdef PCI_BUS_FIXUP
76#include <arch/x86/pci/pci_bus_fixup.h> 75#include <arch/x86/pci/pci_bus_fixup.h>
77#ifdef PCI_ADDR_FIXUP 76#ifdef PCI_ADDR_FIXUP
78#include <arch/x86/pci/pci_addr_fixup.h> 77#include <arch/x86/pci/pci_addr_fixup.h>
79#endif  78#endif
80#endif 79#endif
81 80
82#if defined(MPBIOS) || NACPICA > 0 81#if defined(MPBIOS) || NACPICA > 0
83struct mp_bus *mp_busses; 82struct mp_bus *mp_busses;
84int mp_nbus; 83int mp_nbus;
85struct mp_intr_map *mp_intrs; 84struct mp_intr_map *mp_intrs;
86int mp_nintr; 85int mp_nintr;
87  86
88int mp_isa_bus = -1; /* XXX */ 87int mp_isa_bus = -1; /* XXX */
89int mp_eisa_bus = -1; /* XXX */ 88int mp_eisa_bus = -1; /* XXX */
90 89
91int acpi_present = 0; 90int acpi_present = 0;
92int mpacpi_active = 0; 91int mpacpi_active = 0;
93#ifdef MPVERBOSE 92#ifdef MPVERBOSE
94int mp_verbose = 1; 93int mp_verbose = 1;
95#else /* MPVERBOSE */ 94#else /* MPVERBOSE */
96int mp_verbose = 0; 95int mp_verbose = 0;
97#endif /* MPVERBOSE */ 96#endif /* MPVERBOSE */
98#endif /* defined(MPBIOS) || NACPICA > 0 */ 97#endif /* defined(MPBIOS) || NACPICA > 0 */
99#endif /* NPCI > 0 */ 98#endif /* NPCI > 0 */
100 99
101 100
102int mainbus_match(device_t, cfdata_t, void *); 101int mainbus_match(device_t, cfdata_t, void *);
103void mainbus_attach(device_t, device_t, void *); 102void mainbus_attach(device_t, device_t, void *);
104 103
105CFATTACH_DECL_NEW(mainbus, 0, 104CFATTACH_DECL_NEW(mainbus, 0,
106 mainbus_match, mainbus_attach, NULL, NULL); 105 mainbus_match, mainbus_attach, NULL, NULL);
107 106
108int mainbus_print(void *, const char *); 107int mainbus_print(void *, const char *);
109 108
110union mainbus_attach_args { 109union mainbus_attach_args {
111 const char *mba_busname; /* first elem of all */ 110 const char *mba_busname; /* first elem of all */
112 struct cpu_attach_args mba_caa; 111 struct cpu_attach_args mba_caa;
113#if NHYPERVISOR > 0 112#if NHYPERVISOR > 0
114 struct hypervisor_attach_args mba_haa; 113 struct hypervisor_attach_args mba_haa;
115#endif 114#endif
116#if NIPMI > 0 115#if NIPMI > 0
117 struct ipmi_attach_args mba_ipmi; 116 struct ipmi_attach_args mba_ipmi;
118#endif 117#endif
119}; 118};
120 119
121/* 120/*
122 * Probe for the mainbus; always succeeds. 121 * Probe for the mainbus; always succeeds.
123 */ 122 */
124int 123int
125mainbus_match(device_t parent, cfdata_t match, void *aux) 124mainbus_match(device_t parent, cfdata_t match, void *aux)
126{ 125{
127 126
128 return 1; 127 return 1;
129} 128}
130 129
131/* 130/*
132 * Attach the mainbus. 131 * Attach the mainbus.
133 */ 132 */
134void 133void
135mainbus_attach(device_t parent, device_t self, void *aux) 134mainbus_attach(device_t parent, device_t self, void *aux)
136{ 135{
137#if NPCI > 0 136#if NPCI > 0
138 int mode; 137 int mode;
139#endif 138#endif
140 union mainbus_attach_args mba; 139 union mainbus_attach_args mba;
141#if defined(DOM0OPS) 140#if defined(DOM0OPS)
142 int numcpus = 0; 141 int numcpus = 0;
143#ifdef MPBIOS 142#ifdef MPBIOS
144 int mpbios_present = 0; 143 int mpbios_present = 0;
145#endif 144#endif
146#ifdef PCI_BUS_FIXUP 145#ifdef PCI_BUS_FIXUP
147 int pci_maxbus = 0; 146 int pci_maxbus = 0;
148#endif 147#endif
149#endif /* defined(DOM0OPS) */ 148#endif /* defined(DOM0OPS) */
150 149
151 aprint_naive("\n"); 150 aprint_naive("\n");
152 aprint_normal("\n"); 151 aprint_normal("\n");
153 152
154#ifdef DOM0OPS 153#ifdef DOM0OPS
155 if (xendomain_is_dom0()) { 154 if (xendomain_is_dom0()) {
156#ifdef MPBIOS 155#ifdef MPBIOS
157 mpbios_present = mpbios_probe(self); 156 mpbios_present = mpbios_probe(self);
158#endif 157#endif
159#if NPCI > 0 158#if NPCI > 0
160 /* ACPI needs to be able to access PCI configuration space. */ 159 /* ACPI needs to be able to access PCI configuration space. */
161 mode = pci_mode_detect(); 160 mode = pci_mode_detect();
162#ifdef PCI_BUS_FIXUP 161#ifdef PCI_BUS_FIXUP
163 if (mode != 0) { 162 if (mode != 0) {
164 pci_maxbus = pci_bus_fixup(NULL, 0); 163 pci_maxbus = pci_bus_fixup(NULL, 0);
165 aprint_debug_dev(self, "PCI bus max, after " 164 aprint_debug_dev(self, "PCI bus max, after "
166 "pci_bus_fixup: %i\n", pci_maxbus); 165 "pci_bus_fixup: %i\n", pci_maxbus);
167#ifdef PCI_ADDR_FIXUP 166#ifdef PCI_ADDR_FIXUP
168 pciaddr.extent_port = NULL; 167 pciaddr.extent_port = NULL;
169 pciaddr.extent_mem = NULL; 168 pciaddr.extent_mem = NULL;
170 pci_addr_fixup(NULL, pci_maxbus); 169 pci_addr_fixup(NULL, pci_maxbus);
171#endif /* PCI_ADDR_FIXUP */ 170#endif /* PCI_ADDR_FIXUP */
172 } 171 }
173#endif /* PCI_BUS_FIXUP */ 172#endif /* PCI_BUS_FIXUP */
174#if NACPICA > 0 173#if NACPICA > 0
175 acpi_present = acpi_probe(); 174 acpi_present = acpi_probe();
176 if (acpi_present) 175 if (acpi_present)
177 mpacpi_active = mpacpi_scan_apics(self, &numcpus); 176 mpacpi_active = mpacpi_scan_apics(self, &numcpus);
178 if (!mpacpi_active) 177 if (!mpacpi_active)
179#endif 178#endif
180 { 179 {
181#ifdef MPBIOS 180#ifdef MPBIOS
182 if (mpbios_present) 181 if (mpbios_present)
183 mpbios_scan(self, &numcpus);  182 mpbios_scan(self, &numcpus);
184 else 183 else
185#endif 184#endif
186 if (numcpus == 0) { 185 if (numcpus == 0) {
187 memset(&mba.mba_caa, 0, sizeof(mba.mba_caa)); 186 memset(&mba.mba_caa, 0, sizeof(mba.mba_caa));
188 mba.mba_caa.cpu_number = 0; 187 mba.mba_caa.cpu_number = 0;
189 mba.mba_caa.cpu_role = CPU_ROLE_SP; 188 mba.mba_caa.cpu_role = CPU_ROLE_SP;
190 mba.mba_caa.cpu_func = 0; 189 mba.mba_caa.cpu_func = 0;
191 config_found_ia(self, "cpubus", 190 config_found_ia(self, "cpubus",
192 &mba.mba_caa, mainbus_print); 191 &mba.mba_caa, mainbus_print);
193 } 192 }
194 } 193 }
195#if NIOAPIC > 0 194#if NIOAPIC > 0
196 ioapic_enable(); 195 ioapic_enable();
197#endif 196#endif
198#endif /* NPCI */ 197#endif /* NPCI */
199 } 198 }
200#endif /* DOM0OPS */ 199#endif /* DOM0OPS */
201 200
202#if NIPMI > 0 201#if NIPMI > 0
203 memset(&mba.mba_ipmi, 0, sizeof(mba.mba_ipmi)); 202 memset(&mba.mba_ipmi, 0, sizeof(mba.mba_ipmi));
204 mba.mba_ipmi.iaa_iot = x86_bus_space_io; 203 mba.mba_ipmi.iaa_iot = x86_bus_space_io;
205 mba.mba_ipmi.iaa_memt = x86_bus_space_mem; 204 mba.mba_ipmi.iaa_memt = x86_bus_space_mem;
206 if (ipmi_probe(&mba.mba_ipmi)) 205 if (ipmi_probe(&mba.mba_ipmi))
207 config_found_ia(self, "ipmibus", &mba.mba_ipmi, 0); 206 config_found_ia(self, "ipmibus", &mba.mba_ipmi, 0);
208#endif 207#endif
209 208
210#if NHYPERVISOR > 0 209#if NHYPERVISOR > 0
211 mba.mba_haa.haa_busname = "hypervisor"; 210 mba.mba_haa.haa_busname = "hypervisor";
212 config_found_ia(self, "hypervisorbus", &mba.mba_haa, mainbus_print); 211 config_found_ia(self, "hypervisorbus", &mba.mba_haa, mainbus_print);
213#endif 212#endif
214} 213}
215 214
216int 215int
217mainbus_print(void *aux, const char *pnp) 216mainbus_print(void *aux, const char *pnp)
218{ 217{
219 union mainbus_attach_args *mba = aux; 218 union mainbus_attach_args *mba = aux;
220 219
221 if (pnp) 220 if (pnp)
222 aprint_normal("%s at %s", mba->mba_busname, pnp); 221 aprint_normal("%s at %s", mba->mba_busname, pnp);
223 return (UNCONF); 222 return (UNCONF);
224} 223}