diff options
Diffstat (limited to 'src/hardware/LMI_PCIDeviceProvider.c')
-rw-r--r-- | src/hardware/LMI_PCIDeviceProvider.c | 96 |
1 files changed, 19 insertions, 77 deletions
diff --git a/src/hardware/LMI_PCIDeviceProvider.c b/src/hardware/LMI_PCIDeviceProvider.c index a88f9cd..cc6adc8 100644 --- a/src/hardware/LMI_PCIDeviceProvider.c +++ b/src/hardware/LMI_PCIDeviceProvider.c @@ -20,16 +20,11 @@ */ #include <konkret/konkret.h> -#include <pci/pci.h> #include "LMI_PCIDevice.h" #include "LMI_Hardware.h" +#include "PCIDev.h" #include "globals.h" -#define NAME_BUF_SIZE 128 - -void get_subid(struct pci_dev *d, u16 *subvp, u16 *subdp); -CMPIUint16 get_capability(const u16 pci_cap); - static const CMPIBroker* _cb = NULL; static void LMI_PCIDeviceInitialize() @@ -78,7 +73,7 @@ static CMPIStatus LMI_PCIDeviceEnumInstances( char instance_id[INSTANCE_ID_LEN]; if (!(acc = pci_alloc())) { - KReturn2(_cb, ERR_FAILED, "Can't access the PCI bus."); + KReturn2(_cb, ERR_FAILED, "Cannot access the PCI bus."); } pci_init(acc); pci_scan_bus(acc); @@ -92,6 +87,12 @@ static CMPIStatus LMI_PCIDeviceEnumInstances( | PCI_FILL_CLASS | PCI_FILL_CAPS); + /* Ignore PCI Bridges */ + /* Throw away the lower 8 bits denoting the subclass */ + if (((dev->device_class) >> 8) == LMI_PCIDevice_ClassCode_Bridge) { + continue; + } + vendor_name = pci_lookup_name(acc, vendor_buf, NAME_BUF_SIZE, PCI_LOOKUP_VENDOR, dev->vendor_id); device_name = pci_lookup_name(acc, device_buf, NAME_BUF_SIZE, @@ -166,15 +167,17 @@ static CMPIStatus LMI_PCIDeviceEnumInstances( /* Throw away the lower 8 bits denoting the subclass */ LMI_PCIDevice_Set_ClassCode(&lmi_dev, ((dev->device_class) >> 8)); - if ((status & PCI_STATUS_DEVSEL_MASK) == PCI_STATUS_DEVSEL_SLOW) { - LMI_PCIDevice_Set_DeviceSelectTiming(&lmi_dev, - LMI_PCIDevice_DeviceSelectTiming_Slow); - } else if ((status & PCI_STATUS_DEVSEL_MASK) == PCI_STATUS_DEVSEL_MEDIUM) { - LMI_PCIDevice_Set_DeviceSelectTiming(&lmi_dev, - LMI_PCIDevice_DeviceSelectTiming_Medium); - } else if ((status & PCI_STATUS_DEVSEL_MASK) == PCI_STATUS_DEVSEL_FAST) { - LMI_PCIDevice_Set_DeviceSelectTiming(&lmi_dev, - LMI_PCIDevice_DeviceSelectTiming_Fast); + if (status) { + if ((status & PCI_STATUS_DEVSEL_MASK) == PCI_STATUS_DEVSEL_SLOW) { + LMI_PCIDevice_Set_DeviceSelectTiming(&lmi_dev, + LMI_PCIDevice_DeviceSelectTiming_Slow); + } else if ((status & PCI_STATUS_DEVSEL_MASK) == PCI_STATUS_DEVSEL_MEDIUM) { + LMI_PCIDevice_Set_DeviceSelectTiming(&lmi_dev, + LMI_PCIDevice_DeviceSelectTiming_Medium); + } else if ((status & PCI_STATUS_DEVSEL_MASK) == PCI_STATUS_DEVSEL_FAST) { + LMI_PCIDevice_Set_DeviceSelectTiming(&lmi_dev, + LMI_PCIDevice_DeviceSelectTiming_Fast); + } } if (dev->rom_base_addr) { @@ -477,67 +480,6 @@ KUint8 LMI_PCIDevice_BISTExecution( return result; } -void get_subid(struct pci_dev *d, u16 *subvp, u16 *subdp) -{ - u8 htype = pci_read_byte(d, PCI_HEADER_TYPE) & 0x7f; - - if (htype == PCI_HEADER_TYPE_NORMAL) { - *subvp = pci_read_word(d, PCI_SUBSYSTEM_VENDOR_ID); - *subdp = pci_read_word(d, PCI_SUBSYSTEM_ID); - } else if (htype == PCI_HEADER_TYPE_CARDBUS) { - *subvp = pci_read_word(d, PCI_CB_SUBSYSTEM_VENDOR_ID); - *subdp = pci_read_word(d, PCI_CB_SUBSYSTEM_ID); - } else { - *subvp = *subdp = 0xffff; - } -} - -/* - * Get pci capability according to the pci lib. - * @param pci_cap from pci lib - * @return CIM id of pci capability - */ -CMPIUint16 get_capability(const u16 pci_cap) -{ - static struct { - CMPIUint16 cim_val; /* CIM value */ - u16 pci_cap; /* pci value */ - } values[] = { - /* - {0, "Unknown"}, - {1, "Other"}, - {2, "Supports 66MHz"}, - {3, "Supports User Definable Features"}, - {4, "Supports Fast Back-to-Back Transactions"}, - */ - {5, PCI_CAP_ID_PCIX}, - {6, PCI_CAP_ID_PM}, - {7, PCI_CAP_ID_MSI}, - /* - {8, "Parity Error Recovery Capable"}, - */ - {9, PCI_CAP_ID_AGP}, - {10, PCI_CAP_ID_VPD}, - {11, PCI_CAP_ID_SLOTID}, - {12, PCI_CAP_ID_HOTPLUG}, - {13, PCI_CAP_ID_EXP}, - /* - {14, "Supports PCIe Gen 2"}, - {15, "Supports PCIe Gen 3"}, - */ - }; - - size_t i, val_length = sizeof(values) / sizeof(values[0]); - - for (i = 0; i < val_length; i++) { - if (pci_cap == values[i].pci_cap) { - return values[i].cim_val; - } - } - - return 1; /* Other */ -} - KONKRET_REGISTRATION( "root/cimv2", "LMI_PCIDevice", |