summaryrefslogtreecommitdiffstats
path: root/src/hardware/LMI_PCIBridgeSystemDeviceProvider.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_PCIBridgeSystemDeviceProvider.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_PCIBridgeSystemDeviceProvider.c')
-rw-r--r--src/hardware/LMI_PCIBridgeSystemDeviceProvider.c280
1 files changed, 280 insertions, 0 deletions
diff --git a/src/hardware/LMI_PCIBridgeSystemDeviceProvider.c b/src/hardware/LMI_PCIBridgeSystemDeviceProvider.c
new file mode 100644
index 0000000..2151dd5
--- /dev/null
+++ b/src/hardware/LMI_PCIBridgeSystemDeviceProvider.c
@@ -0,0 +1,280 @@
+/*
+ * Copyright (C) 2013 Red Hat, Inc. All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Authors: Peter Schiffer <pschiffe@redhat.com>
+ */
+
+#include <konkret/konkret.h>
+#include "LMI_PCIBridgeSystemDevice.h"
+#include "LMI_Hardware.h"
+#include "PCIDev.h"
+#include "globals.h"
+
+static const CMPIBroker* _cb;
+
+static void LMI_PCIBridgeSystemDeviceInitialize()
+{
+}
+
+static CMPIStatus LMI_PCIBridgeSystemDeviceCleanup(
+ CMPIInstanceMI* mi,
+ const CMPIContext* cc,
+ CMPIBoolean term)
+{
+ CMReturn(CMPI_RC_OK);
+}
+
+static CMPIStatus LMI_PCIBridgeSystemDeviceEnumInstanceNames(
+ CMPIInstanceMI* mi,
+ const CMPIContext* cc,
+ const CMPIResult* cr,
+ const CMPIObjectPath* cop)
+{
+ return KDefaultEnumerateInstanceNames(
+ _cb, mi, cc, cr, cop);
+}
+
+static CMPIStatus LMI_PCIBridgeSystemDeviceEnumInstances(
+ CMPIInstanceMI* mi,
+ const CMPIContext* cc,
+ const CMPIResult* cr,
+ const CMPIObjectPath* cop,
+ const char** properties)
+{
+ LMI_PCIBridgeSystemDevice lmi_pci_sys_device;
+ CIM_ComputerSystemRef cim_cs;
+ LMI_PCIBridgeRef lmi_dev;
+ CMPIObjectPath *o;
+ CMPIStatus st;
+ const char *ns = KNameSpace(cop);
+ struct pci_access *acc;
+ struct pci_dev *dev;
+ char device_id_str[PCI_DEVID_STR_SIZE];
+
+ CIM_ComputerSystemRef_Init(&cim_cs, _cb, ns);
+ CIM_ComputerSystemRef_Set_Name(&cim_cs, get_system_name());
+ CIM_ComputerSystemRef_Set_CreationClassName(&cim_cs,
+ get_system_creation_class_name());
+ o = CIM_ComputerSystemRef_ToObjectPath(&cim_cs, &st);
+ CMSetClassName(o, get_system_creation_class_name());
+
+ if (!(acc = pci_alloc())) {
+ KReturn2(_cb, ERR_FAILED, "Can't access the PCI bus.");
+ }
+ pci_init(acc);
+ pci_scan_bus(acc);
+
+ for (dev = acc->devices; dev; dev = dev->next) {
+ pci_fill_info(dev, PCI_FILL_CLASS);
+
+ /* Use only PCI Bridges */
+ /* Throw away the lower 8 bits denoting the subclass */
+ if (((dev->device_class) >> 8) != LMI_PCIBridge_ClassCode_Bridge) {
+ continue;
+ }
+
+ LMI_PCIBridgeSystemDevice_Init(&lmi_pci_sys_device, _cb, ns);
+
+ snprintf(device_id_str, PCI_DEVID_STR_SIZE, "%02x:%02x.%u",
+ dev->bus, dev->dev, dev->func);
+
+ LMI_PCIBridgeRef_Init(&lmi_dev, _cb, ns);
+ LMI_PCIBridgeRef_Set_SystemCreationClassName(&lmi_dev,
+ get_system_creation_class_name());
+ LMI_PCIBridgeRef_Set_SystemName(&lmi_dev, get_system_name());
+ LMI_PCIBridgeRef_Set_CreationClassName(&lmi_dev,
+ ORGID "_" PCI_BRIDGE_CLASS_NAME);
+ LMI_PCIBridgeRef_Set_DeviceID(&lmi_dev, device_id_str);
+
+ LMI_PCIBridgeSystemDevice_SetObjectPath_GroupComponent(
+ &lmi_pci_sys_device, o);
+ LMI_PCIBridgeSystemDevice_Set_PartComponent(&lmi_pci_sys_device,
+ &lmi_dev);
+
+ KReturnInstance(cr, lmi_pci_sys_device);
+ }
+
+ pci_cleanup(acc);
+
+ CMReturn(CMPI_RC_OK);
+}
+
+static CMPIStatus LMI_PCIBridgeSystemDeviceGetInstance(
+ CMPIInstanceMI* mi,
+ const CMPIContext* cc,
+ const CMPIResult* cr,
+ const CMPIObjectPath* cop,
+ const char** properties)
+{
+ return KDefaultGetInstance(
+ _cb, mi, cc, cr, cop, properties);
+}
+
+static CMPIStatus LMI_PCIBridgeSystemDeviceCreateInstance(
+ CMPIInstanceMI* mi,
+ const CMPIContext* cc,
+ const CMPIResult* cr,
+ const CMPIObjectPath* cop,
+ const CMPIInstance* ci)
+{
+ CMReturn(CMPI_RC_ERR_NOT_SUPPORTED);
+}
+
+static CMPIStatus LMI_PCIBridgeSystemDeviceModifyInstance(
+ CMPIInstanceMI* mi,
+ const CMPIContext* cc,
+ const CMPIResult* cr,
+ const CMPIObjectPath* cop,
+ const CMPIInstance* ci,
+ const char**properties)
+{
+ CMReturn(CMPI_RC_ERR_NOT_SUPPORTED);
+}
+
+static CMPIStatus LMI_PCIBridgeSystemDeviceDeleteInstance(
+ CMPIInstanceMI* mi,
+ const CMPIContext* cc,
+ const CMPIResult* cr,
+ const CMPIObjectPath* cop)
+{
+ CMReturn(CMPI_RC_ERR_NOT_SUPPORTED);
+}
+
+static CMPIStatus LMI_PCIBridgeSystemDeviceExecQuery(
+ CMPIInstanceMI* mi,
+ const CMPIContext* cc,
+ const CMPIResult* cr,
+ const CMPIObjectPath* cop,
+ const char* lang,
+ const char* query)
+{
+ CMReturn(CMPI_RC_ERR_NOT_SUPPORTED);
+}
+
+static CMPIStatus LMI_PCIBridgeSystemDeviceAssociationCleanup(
+ CMPIAssociationMI* mi,
+ const CMPIContext* cc,
+ CMPIBoolean term)
+{
+ CMReturn(CMPI_RC_OK);
+}
+
+static CMPIStatus LMI_PCIBridgeSystemDeviceAssociators(
+ CMPIAssociationMI* mi,
+ const CMPIContext* cc,
+ const CMPIResult* cr,
+ const CMPIObjectPath* cop,
+ const char* assocClass,
+ const char* resultClass,
+ const char* role,
+ const char* resultRole,
+ const char** properties)
+{
+ return KDefaultAssociators(
+ _cb,
+ mi,
+ cc,
+ cr,
+ cop,
+ LMI_PCIBridgeSystemDevice_ClassName,
+ assocClass,
+ resultClass,
+ role,
+ resultRole,
+ properties);
+}
+
+static CMPIStatus LMI_PCIBridgeSystemDeviceAssociatorNames(
+ CMPIAssociationMI* mi,
+ const CMPIContext* cc,
+ const CMPIResult* cr,
+ const CMPIObjectPath* cop,
+ const char* assocClass,
+ const char* resultClass,
+ const char* role,
+ const char* resultRole)
+{
+ return KDefaultAssociatorNames(
+ _cb,
+ mi,
+ cc,
+ cr,
+ cop,
+ LMI_PCIBridgeSystemDevice_ClassName,
+ assocClass,
+ resultClass,
+ role,
+ resultRole);
+}
+
+static CMPIStatus LMI_PCIBridgeSystemDeviceReferences(
+ CMPIAssociationMI* mi,
+ const CMPIContext* cc,
+ const CMPIResult* cr,
+ const CMPIObjectPath* cop,
+ const char* assocClass,
+ const char* role,
+ const char** properties)
+{
+ return KDefaultReferences(
+ _cb,
+ mi,
+ cc,
+ cr,
+ cop,
+ LMI_PCIBridgeSystemDevice_ClassName,
+ assocClass,
+ role,
+ properties);
+}
+
+static CMPIStatus LMI_PCIBridgeSystemDeviceReferenceNames(
+ CMPIAssociationMI* mi,
+ const CMPIContext* cc,
+ const CMPIResult* cr,
+ const CMPIObjectPath* cop,
+ const char* assocClass,
+ const char* role)
+{
+ return KDefaultReferenceNames(
+ _cb,
+ mi,
+ cc,
+ cr,
+ cop,
+ LMI_PCIBridgeSystemDevice_ClassName,
+ assocClass,
+ role);
+}
+
+CMInstanceMIStub(
+ LMI_PCIBridgeSystemDevice,
+ LMI_PCIBridgeSystemDevice,
+ _cb,
+ LMI_PCIBridgeSystemDeviceInitialize())
+
+CMAssociationMIStub(
+ LMI_PCIBridgeSystemDevice,
+ LMI_PCIBridgeSystemDevice,
+ _cb,
+ LMI_PCIBridgeSystemDeviceInitialize())
+
+KONKRET_REGISTRATION(
+ "root/cimv2",
+ "LMI_PCIBridgeSystemDevice",
+ "LMI_PCIBridgeSystemDevice",
+ "instance association")