split single-subdevice lookup & attachment into a subroutine
(pci_attach_subdev()). remove pciattach() function and the pcicd cfdriver struct, the former because thre are a lot of attachment actions which really are machine-dependent (perhaps even "most"), and the latter because now that both pcimatch() and pciattach() are machine-dependent it's bad style to declare them here and it gains nothing.
This commit is contained in:
parent
7e68171a95
commit
bad826164e
|
@ -1,4 +1,4 @@
|
||||||
/* $NetBSD: pci.c,v 1.7 1995/01/27 05:44:32 cgd Exp $ */
|
/* $NetBSD: pci.c,v 1.8 1995/05/23 03:43:06 cgd Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 1994 Charles Hannum. All rights reserved.
|
* Copyright (c) 1994 Charles Hannum. All rights reserved.
|
||||||
|
@ -31,6 +31,7 @@
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* PCI autoconfiguration support
|
* PCI autoconfiguration support
|
||||||
|
* XXX probably should be moved to pci_subr.c?
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
@ -40,13 +41,6 @@
|
||||||
#include <dev/pci/pcivar.h>
|
#include <dev/pci/pcivar.h>
|
||||||
#include <dev/pci/pcireg.h>
|
#include <dev/pci/pcireg.h>
|
||||||
|
|
||||||
int pcimatch __P((struct device *, void *, void *));
|
|
||||||
void pciattach __P((struct device *, struct device *, void *));
|
|
||||||
|
|
||||||
struct cfdriver pcicd = {
|
|
||||||
NULL, "pci", pcimatch, pciattach, DV_DULL, sizeof(struct device)
|
|
||||||
};
|
|
||||||
|
|
||||||
int
|
int
|
||||||
pciprint(aux, pci)
|
pciprint(aux, pci)
|
||||||
void *aux;
|
void *aux;
|
||||||
|
@ -73,58 +67,40 @@ pcisubmatch(parent, match, aux)
|
||||||
return ((*cf->cf_driver->cd_match)(parent, match, aux));
|
return ((*cf->cf_driver->cd_match)(parent, match, aux));
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
/*
|
||||||
pciattach(parent, self, aux)
|
* Try to find and attach the PCI device at the give bus and device number.
|
||||||
struct device *parent, *self;
|
* Return 1 if successful, 0 if unsuccessful.
|
||||||
void *aux;
|
*/
|
||||||
|
int
|
||||||
|
pci_attach_subdev(pcidev, bus, device)
|
||||||
|
struct device *pcidev;
|
||||||
|
int bus, device;
|
||||||
{
|
{
|
||||||
int bus, device;
|
pcitag_t tag;
|
||||||
|
pcireg_t id, class;
|
||||||
|
struct pci_attach_args pa;
|
||||||
|
struct cfdata *cf;
|
||||||
|
|
||||||
#ifdef i386
|
tag = pci_make_tag(bus, device, 0);
|
||||||
printf(": configuration mode %d\n", pci_mode);
|
id = pci_conf_read(tag, PCI_ID_REG);
|
||||||
#else
|
if (id == 0 || id == 0xffffffff)
|
||||||
printf("\n");
|
return (0);
|
||||||
#endif
|
class = pci_conf_read(tag, PCI_CLASS_REG);
|
||||||
|
|
||||||
#if 0
|
pa.pa_bus = bus;
|
||||||
for (bus = 0; bus <= 255; bus++) {
|
pa.pa_device = device;
|
||||||
#else
|
pa.pa_tag = tag;
|
||||||
/*
|
pa.pa_id = id;
|
||||||
* XXX
|
pa.pa_class = class;
|
||||||
* Some current chipsets do wacky things with bus numbers > 0.
|
|
||||||
* This seems like a violation of protocol, but the PCI BIOS does
|
|
||||||
* allow one to query the maximum bus number, and eventually we
|
|
||||||
* should do so.
|
|
||||||
*/
|
|
||||||
for (bus = 0; bus <= 0; bus++) {
|
|
||||||
#endif
|
|
||||||
#ifdef i386
|
|
||||||
for (device = 0; device <= (pci_mode == 2 ? 15 : 31);
|
|
||||||
device++) {
|
|
||||||
#else
|
|
||||||
for (device = 0; device <= 31; device++) {
|
|
||||||
#endif
|
|
||||||
pcitag_t tag = pci_make_tag(bus, device, 0);
|
|
||||||
pcireg_t id = pci_conf_read(tag, PCI_ID_REG),
|
|
||||||
class = pci_conf_read(tag, PCI_CLASS_REG);
|
|
||||||
struct pci_attach_args pa;
|
|
||||||
struct cfdata *cf;
|
|
||||||
|
|
||||||
if (id == 0 || id == 0xffffffff)
|
if ((cf = config_search(pcisubmatch, pcidev, &pa)) != NULL)
|
||||||
continue;
|
config_attach(pcidev, cf, &pa, pciprint);
|
||||||
|
else {
|
||||||
pa.pa_bus = bus;
|
printf("%s bus %d device %d: identifier %08x class %08x%s",
|
||||||
pa.pa_device = device;
|
pcidev->dv_xname, bus, device, id, class,
|
||||||
pa.pa_tag = tag;
|
" not configured\n");
|
||||||
pa.pa_id = id;
|
return (0);
|
||||||
pa.pa_class = class;
|
|
||||||
|
|
||||||
if ((cf = config_search(pcisubmatch, self, &pa)) != NULL)
|
|
||||||
config_attach(self, cf, &pa, pciprint);
|
|
||||||
else
|
|
||||||
printf("%s bus %d device %d: identifier %08x class %08x%s",
|
|
||||||
self->dv_xname, bus, device, id, class,
|
|
||||||
" not configured\n");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return (1);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $NetBSD: pci_subr.c,v 1.7 1995/01/27 05:44:32 cgd Exp $ */
|
/* $NetBSD: pci_subr.c,v 1.8 1995/05/23 03:43:06 cgd Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 1994 Charles Hannum. All rights reserved.
|
* Copyright (c) 1994 Charles Hannum. All rights reserved.
|
||||||
|
@ -31,6 +31,7 @@
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* PCI autoconfiguration support
|
* PCI autoconfiguration support
|
||||||
|
* XXX probably should be moved to pci_subr.c?
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
@ -40,13 +41,6 @@
|
||||||
#include <dev/pci/pcivar.h>
|
#include <dev/pci/pcivar.h>
|
||||||
#include <dev/pci/pcireg.h>
|
#include <dev/pci/pcireg.h>
|
||||||
|
|
||||||
int pcimatch __P((struct device *, void *, void *));
|
|
||||||
void pciattach __P((struct device *, struct device *, void *));
|
|
||||||
|
|
||||||
struct cfdriver pcicd = {
|
|
||||||
NULL, "pci", pcimatch, pciattach, DV_DULL, sizeof(struct device)
|
|
||||||
};
|
|
||||||
|
|
||||||
int
|
int
|
||||||
pciprint(aux, pci)
|
pciprint(aux, pci)
|
||||||
void *aux;
|
void *aux;
|
||||||
|
@ -73,58 +67,40 @@ pcisubmatch(parent, match, aux)
|
||||||
return ((*cf->cf_driver->cd_match)(parent, match, aux));
|
return ((*cf->cf_driver->cd_match)(parent, match, aux));
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
/*
|
||||||
pciattach(parent, self, aux)
|
* Try to find and attach the PCI device at the give bus and device number.
|
||||||
struct device *parent, *self;
|
* Return 1 if successful, 0 if unsuccessful.
|
||||||
void *aux;
|
*/
|
||||||
|
int
|
||||||
|
pci_attach_subdev(pcidev, bus, device)
|
||||||
|
struct device *pcidev;
|
||||||
|
int bus, device;
|
||||||
{
|
{
|
||||||
int bus, device;
|
pcitag_t tag;
|
||||||
|
pcireg_t id, class;
|
||||||
|
struct pci_attach_args pa;
|
||||||
|
struct cfdata *cf;
|
||||||
|
|
||||||
#ifdef i386
|
tag = pci_make_tag(bus, device, 0);
|
||||||
printf(": configuration mode %d\n", pci_mode);
|
id = pci_conf_read(tag, PCI_ID_REG);
|
||||||
#else
|
if (id == 0 || id == 0xffffffff)
|
||||||
printf("\n");
|
return (0);
|
||||||
#endif
|
class = pci_conf_read(tag, PCI_CLASS_REG);
|
||||||
|
|
||||||
#if 0
|
pa.pa_bus = bus;
|
||||||
for (bus = 0; bus <= 255; bus++) {
|
pa.pa_device = device;
|
||||||
#else
|
pa.pa_tag = tag;
|
||||||
/*
|
pa.pa_id = id;
|
||||||
* XXX
|
pa.pa_class = class;
|
||||||
* Some current chipsets do wacky things with bus numbers > 0.
|
|
||||||
* This seems like a violation of protocol, but the PCI BIOS does
|
|
||||||
* allow one to query the maximum bus number, and eventually we
|
|
||||||
* should do so.
|
|
||||||
*/
|
|
||||||
for (bus = 0; bus <= 0; bus++) {
|
|
||||||
#endif
|
|
||||||
#ifdef i386
|
|
||||||
for (device = 0; device <= (pci_mode == 2 ? 15 : 31);
|
|
||||||
device++) {
|
|
||||||
#else
|
|
||||||
for (device = 0; device <= 31; device++) {
|
|
||||||
#endif
|
|
||||||
pcitag_t tag = pci_make_tag(bus, device, 0);
|
|
||||||
pcireg_t id = pci_conf_read(tag, PCI_ID_REG),
|
|
||||||
class = pci_conf_read(tag, PCI_CLASS_REG);
|
|
||||||
struct pci_attach_args pa;
|
|
||||||
struct cfdata *cf;
|
|
||||||
|
|
||||||
if (id == 0 || id == 0xffffffff)
|
if ((cf = config_search(pcisubmatch, pcidev, &pa)) != NULL)
|
||||||
continue;
|
config_attach(pcidev, cf, &pa, pciprint);
|
||||||
|
else {
|
||||||
pa.pa_bus = bus;
|
printf("%s bus %d device %d: identifier %08x class %08x%s",
|
||||||
pa.pa_device = device;
|
pcidev->dv_xname, bus, device, id, class,
|
||||||
pa.pa_tag = tag;
|
" not configured\n");
|
||||||
pa.pa_id = id;
|
return (0);
|
||||||
pa.pa_class = class;
|
|
||||||
|
|
||||||
if ((cf = config_search(pcisubmatch, self, &pa)) != NULL)
|
|
||||||
config_attach(self, cf, &pa, pciprint);
|
|
||||||
else
|
|
||||||
printf("%s bus %d device %d: identifier %08x class %08x%s",
|
|
||||||
self->dv_xname, bus, device, id, class,
|
|
||||||
" not configured\n");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return (1);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $NetBSD: pcivar.h,v 1.5 1995/04/17 12:09:47 cgd Exp $ */
|
/* $NetBSD: pcivar.h,v 1.6 1995/05/23 03:43:08 cgd Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 1994 Charles Hannum. All rights reserved.
|
* Copyright (c) 1994 Charles Hannum. All rights reserved.
|
||||||
|
@ -63,6 +63,8 @@ struct pci_attach_args {
|
||||||
|
|
||||||
pcitag_t pci_make_tag __P((int, int, int));
|
pcitag_t pci_make_tag __P((int, int, int));
|
||||||
pcireg_t pci_conf_read __P((pcitag_t, int));
|
pcireg_t pci_conf_read __P((pcitag_t, int));
|
||||||
void pci_conf_write __P((pcitag_t, int, pcireg_t));
|
void pci_conf_write __P((pcitag_t, int, pcireg_t));
|
||||||
int pci_map_mem __P((pcitag_t, int, vm_offset_t *, vm_offset_t *));
|
int pci_map_mem __P((pcitag_t, int, vm_offset_t *, vm_offset_t *));
|
||||||
void *pci_map_int __P((pcitag_t, pci_intrlevel, int (*)(void *), void *));
|
void *pci_map_int __P((pcitag_t, pci_intrlevel, int (*)(void *), void *));
|
||||||
|
|
||||||
|
int pci_attach_subdev __P((struct device *, int, int));
|
||||||
|
|
Loading…
Reference in New Issue