Annotation of sys/arch/i386/i386/mainbus.c, Revision 1.1.1.1
1.1 nbrk 1: /* $OpenBSD: mainbus.c,v 1.38 2007/05/29 21:01:56 tedu Exp $ */
2: /* $NetBSD: mainbus.c,v 1.21 1997/06/06 23:14:20 thorpej Exp $ */
3:
4: /*
5: * Copyright (c) 1996 Christopher G. Demetriou. All rights reserved.
6: *
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
21: *
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.
32: */
33:
34: #include <sys/param.h>
35: #include <sys/systm.h>
36: #include <sys/device.h>
37:
38: #include <machine/bus.h>
39:
40: #include <dev/isa/isavar.h>
41: #include <dev/eisa/eisavar.h>
42: #include <dev/pci/pcivar.h>
43:
44: #include <dev/isa/isareg.h> /* for ISA_HOLE_VADDR */
45: #include <i386/isa/isa_machdep.h>
46:
47: #include "pci.h"
48: #include "eisa.h"
49: #include "isa.h"
50: #include "apm.h"
51: #include "bios.h"
52: #include "mpbios.h"
53: #include "acpi.h"
54: #include "ipmi.h"
55: #include "esm.h"
56: #include "vesabios.h"
57:
58: #include <machine/cpuvar.h>
59: #include <machine/i82093var.h>
60: #include <machine/mpbiosvar.h>
61:
62: #if NBIOS > 0
63: #include <machine/biosvar.h>
64: #endif
65:
66: #if NACPI > 0
67: #include <dev/acpi/acpireg.h>
68: #include <dev/acpi/acpivar.h>
69: #endif
70:
71: #if NIPMI > 0
72: #include <dev/ipmivar.h>
73: #endif
74:
75: #if NESM > 0
76: #include <arch/i386/i386/esmvar.h>
77: #endif
78:
79: #if NVESABIOS > 0
80: #include <dev/vesa/vesabiosvar.h>
81: #endif
82:
83: #if 0
84: #ifdef SMP /* XXX MULTIPROCESSOR */
85: #include <machine/mp.h>
86: #endif
87: #endif
88:
89: int mainbus_match(struct device *, void *, void *);
90: void mainbus_attach(struct device *, struct device *, void *);
91:
92: struct cfattach mainbus_ca = {
93: sizeof(struct device), mainbus_match, mainbus_attach
94: };
95:
96: struct cfdriver mainbus_cd = {
97: NULL, "mainbus", DV_DULL
98: };
99:
100: int mainbus_print(void *, const char *);
101:
102: union mainbus_attach_args {
103: const char *mba_busname; /* first elem of all */
104: struct pcibus_attach_args mba_pba;
105: struct eisabus_attach_args mba_eba;
106: struct isabus_attach_args mba_iba;
107: #if NBIOS > 0
108: struct bios_attach_args mba_bios;
109: #endif
110: struct cpu_attach_args mba_caa;
111: struct apic_attach_args aaa_caa;
112: #if NACPI > 0
113: struct acpi_attach_args mba_aaa;
114: #endif
115: #if NIPMI > 0
116: struct ipmi_attach_args mba_iaa;
117: #endif
118: #if NESM > 0
119: struct esm_attach_args mba_eaa;
120: #endif
121: };
122:
123: /*
124: * This is set when the ISA bus is attached. If it's not set by the
125: * time it's checked below, then mainbus attempts to attach an ISA.
126: */
127: int isa_has_been_seen;
128:
129: /*
130: * Probe for the mainbus; always succeeds.
131: */
132: int
133: mainbus_match(struct device *parent, void *match, void *aux)
134: {
135: return (1);
136: }
137:
138: /*
139: * Attach the mainbus.
140: */
141: void
142: mainbus_attach(struct device *parent, struct device *self, void *aux)
143: {
144: union mainbus_attach_args mba;
145: extern void (*setperf_setup)(struct cpu_info *);
146: extern void (*cpusensors_setup)(struct cpu_info *);
147:
148: printf("\n");
149:
150: #if NBIOS > 0
151: {
152: mba.mba_bios.bios_dev = "bios";
153: mba.mba_bios.bios_iot = I386_BUS_SPACE_IO;
154: mba.mba_bios.bios_memt = I386_BUS_SPACE_MEM;
155: config_found(self, &mba.mba_bios, mainbus_print);
156: }
157: #endif
158: #if NACPI > 0
159: #if NPCI > 0
160: if (pci_mode_detect() != 0)
161: #endif
162: {
163: memset(&mba.mba_aaa, 0, sizeof(mba.mba_aaa));
164: mba.mba_aaa.aaa_name = "acpi";
165: mba.mba_aaa.aaa_iot = I386_BUS_SPACE_IO;
166: mba.mba_aaa.aaa_memt = I386_BUS_SPACE_MEM;
167:
168: if (acpi_probe(self, aux, &mba.mba_aaa))
169: config_found(self, &mba.mba_aaa, mainbus_print);
170: }
171: #endif
172:
173: #if NIPMI > 0
174: {
175: memset(&mba.mba_iaa, 0, sizeof(mba.mba_iaa));
176: mba.mba_iaa.iaa_name = "ipmi";
177: mba.mba_iaa.iaa_iot = I386_BUS_SPACE_IO;
178: mba.mba_iaa.iaa_memt = I386_BUS_SPACE_MEM;
179: if (ipmi_probe(&mba.mba_iaa))
180: config_found(self, &mba.mba_iaa, mainbus_print);
181: }
182: #endif
183:
184: #if NMPBIOS > 0
185: if (mpbios_probe(self))
186: mpbios_scan(self);
187: #endif
188:
189: if ((cpu_info_primary.ci_flags & CPUF_PRESENT) == 0) {
190: struct cpu_attach_args caa;
191:
192: memset(&caa, 0, sizeof(caa));
193: caa.caa_name = "cpu";
194: caa.cpu_number = 0;
195: caa.cpu_role = CPU_ROLE_SP;
196: caa.cpu_func = 0;
197: caa.cpu_signature = cpu_id;
198: caa.feature_flags = cpu_feature;
199:
200: config_found(self, &caa, mainbus_print);
201: }
202:
203: #if NACPI > 0
204: if (!acpi_hasprocfvs)
205: #endif
206: {
207: if (setperf_setup != NULL)
208: setperf_setup(&cpu_info_primary);
209: }
210:
211: #ifdef MULTIPROCESSOR
212: mp_setperf_init();
213: #endif
214:
215: if (cpusensors_setup != NULL)
216: cpusensors_setup(&cpu_info_primary);
217:
218: #if NVESABIOS > 0
219: if (vbeprobe()) {
220: mba.mba_busname = "vesabios";
221: config_found(self, &mba.mba_busname, NULL);
222: }
223: #endif
224:
225: #if 0
226: #ifdef SMP
227: if (bios_smpinfo != NULL) {
228: struct mp_float *mp = bios_smpinfo;
229:
230: printf("%s: MP 1.%d configuration %d\n", self->dv_xname,
231: mp->revision, mp->feature1);
232: }
233: #ifdef CPU_DEBUG
234: else
235: printf ("%s: No MP configuration found.", self->dv_xname);
236: #endif
237: #endif
238: #endif
239:
240: #if NESM > 0
241: {
242: memset(&mba.mba_eaa, 0, sizeof(mba.mba_eaa));
243: mba.mba_eaa.eaa_name = "esm";
244: mba.mba_eaa.eaa_iot = I386_BUS_SPACE_IO;
245: mba.mba_eaa.eaa_memt = I386_BUS_SPACE_MEM;
246: if (esm_probe(&mba.mba_eaa))
247: config_found(self, &mba.mba_eaa, mainbus_print);
248: }
249: #endif
250:
251: /*
252: * XXX Note also that the presence of a PCI bus should
253: * XXX _always_ be checked, and if present the bus should be
254: * XXX 'found'. However, because of the structure of the code,
255: * XXX that's not currently possible.
256: */
257: #if NPCI > 0
258: if (pci_mode_detect() != 0) {
259: mba.mba_pba.pba_busname = "pci";
260: mba.mba_pba.pba_iot = I386_BUS_SPACE_IO;
261: mba.mba_pba.pba_memt = I386_BUS_SPACE_MEM;
262: mba.mba_pba.pba_dmat = &pci_bus_dma_tag;
263: mba.mba_pba.pba_domain = pci_ndomains++;
264: mba.mba_pba.pba_bus = 0;
265: mba.mba_pba.pba_bridgetag = NULL;
266: config_found(self, &mba.mba_pba, mainbus_print);
267: }
268: #endif
269:
270: if (!bcmp(ISA_HOLE_VADDR(EISA_ID_PADDR), EISA_ID, EISA_ID_LEN)) {
271: mba.mba_eba.eba_busname = "eisa";
272: mba.mba_eba.eba_iot = I386_BUS_SPACE_IO;
273: mba.mba_eba.eba_memt = I386_BUS_SPACE_MEM;
274: #if NEISA > 0
275: mba.mba_eba.eba_dmat = &eisa_bus_dma_tag;
276: #endif
277: config_found(self, &mba.mba_eba, mainbus_print);
278: }
279:
280: if (isa_has_been_seen == 0) {
281: mba.mba_iba.iba_busname = "isa";
282: mba.mba_iba.iba_iot = I386_BUS_SPACE_IO;
283: mba.mba_iba.iba_memt = I386_BUS_SPACE_MEM;
284: #if NISADMA > 0
285: mba.mba_iba.iba_dmat = &isa_bus_dma_tag;
286: #endif
287: config_found(self, &mba.mba_iba, mainbus_print);
288: }
289: }
290:
291: int
292: mainbus_print(void *aux, const char *pnp)
293: {
294: union mainbus_attach_args *mba = aux;
295:
296: if (pnp)
297: printf("%s at %s", mba->mba_busname, pnp);
298: if (!strcmp(mba->mba_busname, "pci"))
299: printf(" bus %d", mba->mba_pba.pba_bus);
300:
301: return (UNCONF);
302: }
CVSweb