aboutsummaryrefslogtreecommitdiff
path: root/src/pci.c
diff options
context:
space:
mode:
authorKevin O'Connor <kevin@koconnor.net>2008-08-31 11:06:27 -0400
committerKevin O'Connor <kevin@koconnor.net>2008-08-31 11:06:27 -0400
commit5fdaa0346cb9d864ffff0e6fd2c2139c4a6b612f (patch)
treeccd6c13405c18a2397b191d187f820780bb0634d /src/pci.c
parent15b3165711bc3c94b4941e17bc9036cd151f997e (diff)
downloadseabios-hppa-5fdaa0346cb9d864ffff0e6fd2c2139c4a6b612f.zip
seabios-hppa-5fdaa0346cb9d864ffff0e6fd2c2139c4a6b612f.tar.gz
seabios-hppa-5fdaa0346cb9d864ffff0e6fd2c2139c4a6b612f.tar.bz2
Rename pci_find_class() to pci_find_classprog(), and add new functions.
New pci_find_class() searches by just class, not class and prog-if. Add some new pci config space definitions. Add inline functions for converting to/from bus/dev/fn to bdf to PCIDevice.
Diffstat (limited to 'src/pci.c')
-rw-r--r--src/pci.c30
1 files changed, 27 insertions, 3 deletions
diff --git a/src/pci.c b/src/pci.c
index 7ed8300..1f11ee3 100644
--- a/src/pci.c
+++ b/src/pci.c
@@ -60,7 +60,7 @@ pci_find_device(u16 vendid, u16 devid, int index, PCIDevice *dev)
for (bus=0; bus < CONFIG_PCI_BUS_COUNT; bus++) {
for (devfn=0; devfn<0x100; devfn++) {
PCIDevice d = pci_bd(bus, devfn);
- u32 v = pci_config_readl(d, 0x00);
+ u32 v = pci_config_readl(d, PCI_VENDOR_ID);
if (v != id)
continue;
if (index) {
@@ -75,15 +75,39 @@ pci_find_device(u16 vendid, u16 devid, int index, PCIDevice *dev)
return -1;
}
+// Search for a device with the specified class id and prog-if.
int
-pci_find_class(u32 classid, int index, PCIDevice *dev)
+pci_find_classprog(u32 classprog, int index, PCIDevice *dev)
{
int devfn, bus;
for (bus=0; bus < CONFIG_PCI_BUS_COUNT; bus++) {
for (devfn=0; devfn<0x100; devfn++) {
PCIDevice d = pci_bd(bus, devfn);
u32 v = pci_config_readl(d, 0x08);
- if ((v>>8) != classid)
+ if ((v>>8) != classprog)
+ continue;
+ if (index) {
+ index--;
+ continue;
+ }
+ // Found it.
+ *dev = d;
+ return 0;
+ }
+ }
+ return -1;
+}
+
+// Search for a device with the specified class id.
+int
+pci_find_class(u16 classid, int index, PCIDevice *dev)
+{
+ int devfn, bus;
+ for (bus=0; bus < CONFIG_PCI_BUS_COUNT; bus++) {
+ for (devfn=0; devfn<0x100; devfn++) {
+ PCIDevice d = pci_bd(bus, devfn);
+ u16 v = pci_config_readw(d, PCI_CLASS_DEVICE);
+ if (v != classid)
continue;
if (index) {
index--;