summaryrefslogtreecommitdiffstats
path: root/src/hardware/LMI_PCIDeviceProvider.c
diff options
context:
space:
mode:
authorPeter Schiffer <pschiffe@redhat.com>2013-09-09 20:05:06 +0200
committerPeter Schiffer <pschiffe@redhat.com>2013-09-09 20:05:06 +0200
commit6c65d5564cfbb7b0d0b53a2375cb59a2428f8c49 (patch)
treecce771bb5524f484d0917b4e64c76b530f34988d /src/hardware/LMI_PCIDeviceProvider.c
parent49f626f598c0fe173f48b3bb9094c89747faa9d5 (diff)
downloadopenlmi-providers-6c65d5564cfbb7b0d0b53a2375cb59a2428f8c49.tar.gz
openlmi-providers-6c65d5564cfbb7b0d0b53a2375cb59a2428f8c49.tar.xz
openlmi-providers-6c65d5564cfbb7b0d0b53a2375cb59a2428f8c49.zip
Hardware: Added PCI_Bridge provider
Separated PCI_Bridges from PCI_Devices and provided multiple additional information related to PCI_Bridges. New providers: * LMI_PCIBridgeProvider * LMI_PCIBridgeSystemDeviceProvider
Diffstat (limited to 'src/hardware/LMI_PCIDeviceProvider.c')
-rw-r--r--src/hardware/LMI_PCIDeviceProvider.c96
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",