AMD64 - Fix trapframe, intrframe, and user mode cpu accounting.
[dragonfly.git] / sys / bus / pci / i386 / pcibus.c
1 /*
2  * Copyright (c) 1997, Stefan Esser <se@freebsd.org>
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  * 1. Redistributions of source code must retain the above copyright
9  *    notice unmodified, this list of conditions, and the following
10  *    disclaimer.
11  * 2. Redistributions in binary form must reproduce the above copyright
12  *    notice, this list of conditions and the following disclaimer in the
13  *    documentation and/or other materials provided with the distribution.
14  *
15  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
16  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
17  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
18  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
19  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
20  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25  *
26  * $FreeBSD: src/sys/i386/isa/pcibus.c,v 1.57.2.12 2003/08/07 06:19:26 imp Exp $
27  * $DragonFly: src/sys/bus/pci/i386/pcibus.c,v 1.21 2008/09/05 10:39:36 hasso Exp $
28  *
29  */
30
31 #include "opt_pci.h"
32
33 #include <sys/param.h>
34 #include <sys/systm.h>
35 #include <sys/bus.h>
36 #include <sys/kernel.h>
37 #include <sys/malloc.h>
38 #include <sys/sysctl.h>
39
40 #include <bus/pci/pcivar.h>
41 #include <bus/pci/pcireg.h>
42 #include "pcibus.h"
43 #include <bus/isa/isavar.h>
44 #include "pci_cfgreg.h"
45 #include <machine/md_var.h>
46 #include <machine/nexusvar.h>
47
48 #include "pcib_if.h"
49
50 static u_int32_t nexus_pcib_read_config(device_t, int, int, int, int, int);
51
52 /*
53  * Figure out if a PCI entity is a host bridge, return its name or NULL.
54  */
55 static const char *
56 nexus_legacypci_is_host_bridge(int bus, int slot, int func,
57                           u_int32_t id, u_int8_t class, u_int8_t subclass,
58                           u_int8_t *busnum)
59 {
60         const char *s = NULL;
61         static u_int8_t pxb[4]; /* hack for 450nx */
62
63         *busnum = 0;
64
65         switch (id) {
66         case 0x12258086:
67                 s = "Intel 824?? host to PCI bridge";
68                 /* XXX This is a guess */
69                 /* *busnum = nexus_pcib_read_config(0, bus, slot, func, 0x41, 1); */
70                 *busnum = bus;
71                 break;
72         case 0x71208086:
73                 s = "Intel 82810 (i810 GMCH) Host To Hub bridge";
74                 break;
75         case 0x71228086:
76                 s = "Intel 82810-DC100 (i810-DC100 GMCH) Host To Hub bridge";
77                 break;
78         case 0x71248086:
79                 s = "Intel 82810E (i810E GMCH) Host To Hub bridge";
80                 break;
81         case 0x71808086:
82                 s = "Intel 82443LX (440 LX) host to PCI bridge";
83                 break;
84         case 0x71908086:
85                 s = "Intel 82443BX (440 BX) host to PCI bridge";
86                 break;
87         case 0x71928086:
88                 s = "Intel 82443BX host to PCI bridge (AGP disabled)";
89                 break;
90         case 0x71948086:
91                 s = "Intel 82443MX host to PCI bridge";
92                 break;
93         case 0x71a08086:
94                 s = "Intel 82443GX host to PCI bridge";
95                 break;
96         case 0x71a18086:
97                 s = "Intel 82443GX host to AGP bridge";
98                 break;
99         case 0x71a28086:
100                 s = "Intel 82443GX host to PCI bridge (AGP disabled)";
101                 break;
102         case 0x84c48086:
103                 s = "Intel 82454KX/GX (Orion) host to PCI bridge";
104                 *busnum = nexus_pcib_read_config(0, bus, slot, func, 0x4a, 1);
105                 break;
106         case 0x84ca8086:
107                 /*
108                  * For the 450nx chipset, there is a whole bundle of
109                  * things pretending to be host bridges. The MIOC will 
110                  * be seen first and isn't really a pci bridge (the
111                  * actual busses are attached to the PXB's). We need to 
112                  * read the registers of the MIOC to figure out the
113                  * bus numbers for the PXB channels.
114                  *
115                  * Since the MIOC doesn't have a pci bus attached, we
116                  * pretend it wasn't there.
117                  */
118                 pxb[0] = nexus_pcib_read_config(0, bus, slot, func,
119                                                 0xd0, 1); /* BUSNO[0] */
120                 pxb[1] = nexus_pcib_read_config(0, bus, slot, func,
121                                                 0xd1, 1) + 1;   /* SUBA[0]+1 */
122                 pxb[2] = nexus_pcib_read_config(0, bus, slot, func,
123                                                 0xd3, 1); /* BUSNO[1] */
124                 pxb[3] = nexus_pcib_read_config(0, bus, slot, func,
125                                                 0xd4, 1) + 1;   /* SUBA[1]+1 */
126                 return NULL;
127         case 0x84cb8086:
128                 switch (slot) {
129                 case 0x12:
130                         s = "Intel 82454NX PXB#0, Bus#A";
131                         *busnum = pxb[0];
132                         break;
133                 case 0x13:
134                         s = "Intel 82454NX PXB#0, Bus#B";
135                         *busnum = pxb[1];
136                         break;
137                 case 0x14:
138                         s = "Intel 82454NX PXB#1, Bus#A";
139                         *busnum = pxb[2];
140                         break;
141                 case 0x15:
142                         s = "Intel 82454NX PXB#1, Bus#B";
143                         *busnum = pxb[3];
144                         break;
145                 }
146                 break;
147         case 0x1A308086:
148                 s = "Intel 82845 Host to PCI bridge";
149                 break;
150
151                 /* AMD -- vendor 0x1022 */
152         case 0x30001022:
153                 s = "AMD Elan SC520 host to PCI bridge";
154 #ifdef CPU_ELAN
155                 init_AMD_Elan_sc520();
156 #else
157                 kprintf("*** WARNING: kernel option CPU_ELAN missing");
158                 kprintf("-- timekeeping may be wrong\n");
159 #endif
160                 break;
161         case 0x70061022:
162                 s = "AMD-751 host to PCI bridge";
163                 break;
164         case 0x700e1022:
165                 s = "AMD-761 host to PCI bridge";
166                 break;
167
168                 /* SiS -- vendor 0x1039 */
169         case 0x04961039:
170                 s = "SiS 85c496";
171                 break;
172         case 0x04061039:
173                 s = "SiS 85c501";
174                 break;
175         case 0x06011039:
176                 s = "SiS 85c601";
177                 break;
178         case 0x55911039:
179                 s = "SiS 5591 host to PCI bridge";
180                 break;
181         case 0x00011039:
182                 s = "SiS 5591 host to AGP bridge";
183                 break;
184
185                 /* VLSI -- vendor 0x1004 */
186         case 0x00051004:
187                 s = "VLSI 82C592 Host to PCI bridge";
188                 break;
189
190                 /* XXX Here is MVP3, I got the datasheet but NO M/B to test it  */
191                 /* totally. Please let me know if anything wrong.            -F */
192                 /* XXX need info on the MVP3 -- any takers? */
193         case 0x05981106:
194                 s = "VIA 82C598MVP (Apollo MVP3) host bridge";
195                 break;
196
197                 /* AcerLabs -- vendor 0x10b9 */
198                 /* Funny : The datasheet told me vendor id is "10b8",sub-vendor */
199                 /* id is '10b9" but the register always shows "10b9". -Foxfair  */
200         case 0x154110b9:
201                 s = "AcerLabs M1541 (Aladdin-V) PCI host bridge";
202                 break;
203
204                 /* OPTi -- vendor 0x1045 */
205         case 0xc7011045:
206                 s = "OPTi 82C700 host to PCI bridge";
207                 break;
208         case 0xc8221045:
209                 s = "OPTi 82C822 host to PCI Bridge";
210                 break;
211
212                 /* ServerWorks -- vendor 0x1166 */
213         case 0x00051166:
214                 s = "ServerWorks NB6536 2.0HE host to PCI bridge";
215                 *busnum = nexus_pcib_read_config(0, bus, slot, func, 0x44, 1);
216                 break;
217         
218         case 0x00061166:
219                 /* FALLTHROUGH */
220         case 0x00081166:
221                 /* FALLTHROUGH */
222         case 0x02011166:
223                 /* FALLTHROUGH */
224         case 0x010f1014: /* IBM re-badged ServerWorks chipset */
225                 /* FALLTHROUGH */
226                 s = "ServerWorks host to PCI bridge";
227                 *busnum = nexus_pcib_read_config(0, bus, slot, func, 0x44, 1);
228                 break;
229
230         case 0x00091166:
231                 s = "ServerWorks NB6635 3.0LE host to PCI bridge";
232                 *busnum = nexus_pcib_read_config(0, bus, slot, func, 0x44, 1);
233                 break;
234
235         case 0x00101166:
236                 s = "ServerWorks CIOB30 host to PCI bridge";
237                 *busnum = nexus_pcib_read_config(0, bus, slot, func, 0x44, 1);
238                 break;
239
240         case 0x00111166:
241                 /* FALLTHROUGH */
242         case 0x03021014: /* IBM re-badged ServerWorks chipset */
243                 s = "ServerWorks CMIC-HE host to PCI-X bridge";
244                 *busnum = nexus_pcib_read_config(0, bus, slot, func, 0x44, 1);
245                 break;
246
247                 /* XXX unknown chipset, but working */
248         case 0x00171166:
249                 /* FALLTHROUGH */
250         case 0x01011166:
251                 s = "ServerWorks host to PCI bridge(unknown chipset)";
252                 *busnum = nexus_pcib_read_config(0, bus, slot, func, 0x44, 1);
253                 break;
254
255                 /* Integrated Micro Solutions -- vendor 0x10e0 */
256         case 0x884910e0:
257                 s = "Integrated Micro Solutions VL Bridge";
258                 break;
259
260         default:
261                 if (class == PCIC_BRIDGE && subclass == PCIS_BRIDGE_HOST)
262                         s = "Host to PCI bridge";
263                 break;
264         }
265
266         return s;
267 }
268
269 /*
270  * Identify the existance of the first pci bus and install a child to
271  * nexus if we find it.  Use an order of 1 so it gets probed after
272  * any ACPI device installed under nexus.  To avoid boot-time confusion,
273  * we do not install any 'pcib' devices at this time.
274  *
275  * The identify method coupled with the driver spec of the same name
276  * automatically installs it under the nexus.
277  */
278 static int
279 nexus_legacypci_identify(driver_t *driver, device_t parent)
280 {
281         /*
282          * Basically a static device, there's no point reinstalling it
283          * on rescan.
284          */
285         if (device_get_state(parent) == DS_ATTACHED)
286                 return (0);
287         if (device_get_state(parent) == DS_INPROGRESS)
288                 return (0);
289
290         if (pci_cfgregopen() == 0)
291                 return (ENXIO);
292
293         BUS_ADD_CHILD(parent, parent, 100, "legacypci", 0);
294         return (0);
295 }
296
297 /*
298  * Scan the first pci bus for host-pci bridges and add pcib instances
299  * to the nexus for each bridge.
300  */
301 static int
302 nexus_legacypci_probe(device_t dev)
303 {
304         int bus, slot, func;
305         u_int8_t  hdrtype;
306         int found = 0;
307         int pcifunchigh;
308         int found824xx = 0;
309         device_t child;
310
311         /*
312          * Do not install any pci busses ('pcib' devices) if the PCI
313          * subsystem has already been claimed by someone else.
314          */
315         if (pcib_owner != NULL) {
316                 device_printf(dev, "PCI subsystem owned by %s, skipping scan\n",
317                               pcib_owner);
318                 return (ENXIO);
319         }
320         pcib_owner = "legacypci";
321
322         if (pci_cfgregopen() == 0)
323                 return (ENXIO);
324
325         /*
326          * Scan away!
327          */
328         bus = 0;
329  retry:
330         for (slot = 0; slot <= PCI_SLOTMAX; slot++) {
331                 func = 0;
332                 hdrtype = nexus_pcib_read_config(0, bus, slot, func,
333                                                  PCIR_HDRTYPE, 1);
334                 if ((hdrtype & ~PCIM_MFDEV) > 2)
335                         continue;
336                 if (hdrtype & PCIM_MFDEV)
337                         pcifunchigh = 7;
338                 else
339                         pcifunchigh = 0;
340                 for (func = 0; func <= pcifunchigh; func++) {
341                         /*
342                          * Read the IDs and class from the device.
343                          */
344                         u_int32_t id;
345                         u_int8_t class, subclass, busnum;
346                         const char *s;
347                         device_t *devs;
348                         int ndevs, i;
349
350                         id = nexus_pcib_read_config(0, bus, slot, func,
351                                                     PCIR_DEVVENDOR, 4);
352                         if (id == -1)
353                                 continue;
354                         class = nexus_pcib_read_config(0, bus, slot, func,
355                                                        PCIR_CLASS, 1);
356                         subclass = nexus_pcib_read_config(0, bus, slot, func,
357                                                           PCIR_SUBCLASS, 1);
358
359                         s = nexus_legacypci_is_host_bridge(bus, slot, func,
360                                                       id, class, subclass,
361                                                       &busnum);
362                         if (s == NULL)
363                                 continue;
364
365                         /*
366                          * Check to see if the physical bus has already
367                          * been seen. Eg: hybrid 32 and 64 bit host
368                          * bridges to the same logical bus.
369                          */
370                         if (device_get_children(dev, &devs, &ndevs) == 0) {
371                                 for (i = 0; s != NULL && i < ndevs; i++) {
372                                         if (strcmp(device_get_name(devs[i]),
373                                             "pcib") != 0)
374                                                 continue;
375                                         if (nexus_get_pcibus(devs[i]) == busnum)
376                                                 s = NULL;
377                                 }
378                                 kfree(devs, M_TEMP);
379                         }
380
381                         if (s == NULL)
382                                 continue;
383                         /*
384                          * Add at priority 100+busnum to keep the scanning
385                          * order sane in the boot dmesg output.
386                          */
387                         child = BUS_ADD_CHILD(dev, dev, 100 + busnum, 
388                                               "pcib", busnum);
389                         device_set_desc(child, s);
390                         nexus_set_pcibus(child, busnum);
391
392                         found = 1;
393                         if (id == 0x12258086)
394                                 found824xx = 1;
395                 }
396         }
397         if (found824xx && bus == 0) {
398                 bus++;
399                 goto retry;
400         }
401
402 #if 0
403         /*
404          * Now that we have installed the main PCI bridges, go
405          * probe and attach each one.
406          */
407         bus_generic_attach(dev);
408 #endif
409
410         /*
411          * Make sure we add at least one bridge since some old
412          * hardware doesn't actually have a host-pci bridge device.
413          * Note that pci_cfgregopen() thinks we have PCI devices..
414          */
415         if (!found) {
416                 if (bootverbose) {
417                         kprintf("nexus_pcib_identify: no bridge found, "
418                                "adding pcib0 anyway\n");
419                 }
420                 child = BUS_ADD_CHILD(dev, dev, 100, "pcib", 0);
421                 nexus_set_pcibus(child, 0);
422         }
423         return (0);
424 }
425
426 static int
427 nexus_legacypci_attach(device_t dev)
428 {
429         bus_generic_attach(dev);
430         return (0);
431 }
432
433 #ifdef PCI_MAP_FIXUP
434
435 SYSCTL_DECL(_hw_pci);
436
437 static unsigned long legacy_host_mem_start = 0x80000000;
438 /* XXX need TUNABLE_ULONG? */
439 TUNABLE_INT("hw.pci.host_mem_start", (int *)&legacy_host_mem_start);
440 SYSCTL_ULONG(_hw_pci, OID_AUTO, host_mem_start, CTLFLAG_RD,
441              &legacy_host_mem_start, 0x80000000,
442              "Limit the host bridge memory to being above this address.  "
443              "Must be\n"
444              "set at boot via hw.pci.host_mem_start tunable.");
445
446 static struct resource *
447 nexus_legacypci_alloc_resource(device_t dev, device_t child, int type, int *rid,
448                                u_long start, u_long end, u_long count,
449                                u_int flags)
450 {
451         /*
452          * If no memory preference is given, use upper 32MB slot most
453          * bioses use for their memory window.  Typically other bridges
454          * before us get in the way to assert their preferences on memory.
455          * Hardcoding like this sucks, so a more MD/MI way needs to be
456          * found to do it.  This is typically only used on older laptops
457          * that don't have pci busses behind pci bridge, so assuming > 32MB
458          * is likely OK.
459          *
460          * However, this can cause problems for other chipsets, so we make
461          * this tunable by hw.pci.host_mem_start.
462          */
463         if (type == SYS_RES_MEMORY && start == 0UL && end == ~0UL)
464                 start = legacy_host_mem_start;
465         if (type == SYS_RES_IOPORT && start == 0UL && end == ~0UL)
466                 start = 0x1000;
467         return bus_generic_alloc_resource(dev, child, type, rid,
468                                           start, end, count, flags);
469 }
470
471 #endif  /* PCI_MAP_FIXUP */
472
473 static device_method_t legacypci_methods[] = {
474         /* Device interface */
475         DEVMETHOD(device_identify,      nexus_legacypci_identify),
476         DEVMETHOD(device_probe,         nexus_legacypci_probe),
477         DEVMETHOD(device_attach,        nexus_legacypci_attach),
478         DEVMETHOD(device_shutdown,      bus_generic_shutdown),
479         DEVMETHOD(device_suspend,       bus_generic_suspend),
480         DEVMETHOD(device_resume,        bus_generic_resume),
481
482         /*
483          * Bus interface - propogate through to the nexus.  Note that
484          * this means devices under us will have nexus ivars.
485          */
486         DEVMETHOD(bus_add_child,        bus_generic_add_child),
487         DEVMETHOD(bus_print_child,      bus_generic_print_child),
488         DEVMETHOD(bus_read_ivar,        bus_generic_read_ivar),
489         DEVMETHOD(bus_write_ivar,       bus_generic_write_ivar),
490 #ifdef PCI_MAP_FIXUP
491         DEVMETHOD(bus_alloc_resource,   nexus_legacypci_alloc_resource),
492 #else
493         DEVMETHOD(bus_alloc_resource,   bus_generic_alloc_resource),
494 #endif
495         DEVMETHOD(bus_release_resource, bus_generic_release_resource),
496         DEVMETHOD(bus_activate_resource, bus_generic_activate_resource),
497         DEVMETHOD(bus_deactivate_resource, bus_generic_deactivate_resource),
498         DEVMETHOD(bus_setup_intr,       bus_generic_setup_intr),
499         DEVMETHOD(bus_teardown_intr,    bus_generic_teardown_intr),
500         DEVMETHOD(bus_set_resource,     bus_generic_set_resource),
501         DEVMETHOD(bus_get_resource,     bus_generic_get_resource),
502         DEVMETHOD(bus_delete_resource,  bus_generic_delete_resource),
503         { 0, 0 }
504 };
505
506 static driver_t legacypci_driver = {
507         "legacypci",
508         legacypci_methods,
509         1,
510 };
511
512 static devclass_t legacypci_devclass;
513
514 DRIVER_MODULE(legacypci, nexus, legacypci_driver, legacypci_devclass, 0, 0);
515
516 /*
517  * Legacypci Host-Bridge PCI BUS support.  The underlying pcib devices
518  * will only exist if we actually control the PCI bus.  The actual PCI
519  * bus driver is attached in our attach routine.
520  *
521  * There is no identify function because the legacypci placeholder will
522  * have already scanned and added PCIB devices for the host-bridges found.
523  */
524 static int
525 nexus_pcib_maxslots(device_t dev)
526 {
527         return 31;
528 }
529
530 /*
531  * Read configuration space register.
532  */
533 static u_int32_t
534 nexus_pcib_read_config(device_t dev, int bus, int slot, int func,
535                        int reg, int bytes)
536 {
537         return (pci_cfgregread(bus, slot, func, reg, bytes));
538 }
539
540 /*
541  * Write configuration space register.
542  */
543 static void
544 nexus_pcib_write_config(device_t dev, int bus, int slot, int func,
545                         int reg, u_int32_t data, int bytes)
546 {
547         pci_cfgregwrite(bus, slot, func, reg, data, bytes);
548 }
549
550 /*
551  * Stack a pci device on top of the pci bridge bus device.
552  */
553 static int
554 nexus_pcib_probe(device_t dev)
555 {
556         BUS_ADD_CHILD(dev, dev, 0, "pci", device_get_unit(dev));
557         return (0);
558 }
559
560 static int
561 nexus_pcib_attach(device_t dev)
562 {
563         int error;
564
565         error = bus_generic_attach(dev);
566         return (error);
567 }
568
569 /* route interrupt */
570
571 static int
572 nexus_pcib_route_interrupt(device_t pcib, device_t dev, int pin)
573 {
574         return(pci_cfgintr(pci_get_bus(dev), pci_get_slot(dev), pin, 
575                            pci_get_irq(dev)));
576 }
577
578 static device_method_t nexus_pcib_methods[] = {
579         /* Device interface */
580         DEVMETHOD(device_probe,         nexus_pcib_probe),
581         DEVMETHOD(device_attach,        nexus_pcib_attach),
582         DEVMETHOD(device_shutdown,      bus_generic_shutdown),
583         DEVMETHOD(device_suspend,       bus_generic_suspend),
584         DEVMETHOD(device_resume,        bus_generic_resume),
585
586         /*
587          * Bus interface - propogate through to the nexus.  Note
588          * that this means we will get nexus-managed ivars.
589          */
590         DEVMETHOD(bus_add_child,        bus_generic_add_child),
591         DEVMETHOD(bus_print_child,      bus_generic_print_child),
592         DEVMETHOD(bus_read_ivar,        bus_generic_read_ivar),
593         DEVMETHOD(bus_write_ivar,       bus_generic_write_ivar),
594         DEVMETHOD(bus_alloc_resource,   bus_generic_alloc_resource),
595         DEVMETHOD(bus_release_resource, bus_generic_release_resource),
596         DEVMETHOD(bus_activate_resource, bus_generic_activate_resource),
597         DEVMETHOD(bus_deactivate_resource, bus_generic_deactivate_resource),
598         DEVMETHOD(bus_setup_intr,       bus_generic_setup_intr),
599         DEVMETHOD(bus_teardown_intr,    bus_generic_teardown_intr),
600
601         /* pcib interface */
602         DEVMETHOD(pcib_maxslots,        nexus_pcib_maxslots),
603         DEVMETHOD(pcib_read_config,     nexus_pcib_read_config),
604         DEVMETHOD(pcib_write_config,    nexus_pcib_write_config),
605         DEVMETHOD(pcib_route_interrupt, nexus_pcib_route_interrupt),
606
607         { 0, 0 }
608 };
609
610 static driver_t nexus_pcib_driver = {
611         "pcib",
612         nexus_pcib_methods,
613         1,
614 };
615
616 static devclass_t       pcib_devclass;
617
618 DRIVER_MODULE(pcib, legacypci, nexus_pcib_driver, pcib_devclass, 0, 0);
619
620
621 /*
622  * Provide a device to "eat" the host->pci bridges that we dug up above
623  * and stop them showing up twice on the probes.  This also stops them
624  * showing up as 'none' in pciconf -l.
625  *
626  * Return an ultra-low priority so other devices can attach the bus before
627  * our dummy attach.
628  *
629  * XXX may have to disable the registration entirely to support module-loaded
630  * bridges such as agp.ko.
631  */
632 static int
633 pci_hostb_probe(device_t dev)
634 {
635         if (pci_get_class(dev) == PCIC_BRIDGE &&
636             pci_get_subclass(dev) == PCIS_BRIDGE_HOST) {
637                 device_set_desc(dev, "Host to PCI bridge");
638                 device_quiet(dev);
639                 return -10000;
640         }
641         return (ENXIO);
642 }
643
644 static int
645 pci_hostb_attach(device_t dev)
646 {
647         return (0);
648 }
649
650 static device_method_t pci_hostb_methods[] = {
651         /* Device interface */
652         DEVMETHOD(device_probe,         pci_hostb_probe),
653         DEVMETHOD(device_attach,        pci_hostb_attach),
654         DEVMETHOD(device_shutdown,      bus_generic_shutdown),
655         DEVMETHOD(device_suspend,       bus_generic_suspend),
656         DEVMETHOD(device_resume,        bus_generic_resume),
657
658         { 0, 0 }
659 };
660 static driver_t pci_hostb_driver = {
661         "hostb",
662         pci_hostb_methods,
663         1,
664 };
665 static devclass_t pci_hostb_devclass;
666
667 DRIVER_MODULE(hostb, pci, pci_hostb_driver, pci_hostb_devclass, 0, 0);
668
669
670 /*
671  * Install placeholder to claim the resources owned by the
672  * PCI bus interface.  This could be used to extract the 
673  * config space registers in the extreme case where the PnP
674  * ID is available and the PCI BIOS isn't, but for now we just
675  * eat the PnP ID and do nothing else.
676  *
677  * XXX we should silence this probe, as it will generally confuse 
678  * people.
679  */
680 static struct isa_pnp_id pcibus_pnp_ids[] = {
681         { 0x030ad041 /* PNP030A */, "PCI Bus" },
682         { 0 }
683 };
684
685 static int
686 pcibus_pnp_probe(device_t dev)
687 {
688         int result;
689         
690         if ((result = ISA_PNP_PROBE(device_get_parent(dev), dev, pcibus_pnp_ids)) <= 0)
691                 device_quiet(dev);
692         return (result);
693 }
694
695 static int
696 pcibus_pnp_attach(device_t dev)
697 {
698         return(0);
699 }
700
701 static device_method_t pcibus_pnp_methods[] = {
702         /* Device interface */
703         DEVMETHOD(device_probe,         pcibus_pnp_probe),
704         DEVMETHOD(device_attach,        pcibus_pnp_attach),
705         DEVMETHOD(device_detach,        bus_generic_detach),
706         DEVMETHOD(device_shutdown,      bus_generic_shutdown),
707         DEVMETHOD(device_suspend,       bus_generic_suspend),
708         DEVMETHOD(device_resume,        bus_generic_resume),
709         { 0, 0 }
710 };
711
712 static driver_t pcibus_pnp_driver = {
713         "pcibus_pnp",
714         pcibus_pnp_methods,
715         1,              /* no softc */
716 };
717
718 static devclass_t pcibus_pnp_devclass;
719
720 DRIVER_MODULE(pcibus_pnp, isa, pcibus_pnp_driver, pcibus_pnp_devclass, 0, 0);
721