diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/hardware/LMI_BatterySystemDeviceProvider.c | 268 | ||||
-rw-r--r-- | src/hardware/LMI_ChassisComputerSystemPackageProvider.c | 266 | ||||
-rw-r--r-- | src/hardware/LMI_Hardware.h | 3 | ||||
-rw-r--r-- | src/hardware/LMI_MemorySystemDeviceProvider.c | 254 | ||||
-rw-r--r-- | src/hardware/LMI_PCIDeviceProvider.c | 1 | ||||
-rw-r--r-- | src/hardware/LMI_PCIDeviceSystemDeviceProvider.c | 272 | ||||
-rw-r--r-- | src/hardware/LMI_ProcessorSystemDeviceProvider.c | 268 |
7 files changed, 1331 insertions, 1 deletions
diff --git a/src/hardware/LMI_BatterySystemDeviceProvider.c b/src/hardware/LMI_BatterySystemDeviceProvider.c new file mode 100644 index 0000000..58d59dc --- /dev/null +++ b/src/hardware/LMI_BatterySystemDeviceProvider.c @@ -0,0 +1,268 @@ +/* + * 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_BatterySystemDevice.h" +#include "LMI_Hardware.h" +#include "globals.h" +#include "dmidecode.h" + +static const CMPIBroker* _cb; + +static void LMI_BatterySystemDeviceInitialize() +{ +} + +static CMPIStatus LMI_BatterySystemDeviceCleanup( + CMPIInstanceMI* mi, + const CMPIContext* cc, + CMPIBoolean term) +{ + CMReturn(CMPI_RC_OK); +} + +static CMPIStatus LMI_BatterySystemDeviceEnumInstanceNames( + CMPIInstanceMI* mi, + const CMPIContext* cc, + const CMPIResult* cr, + const CMPIObjectPath* cop) +{ + return KDefaultEnumerateInstanceNames( + _cb, mi, cc, cr, cop); +} + +static CMPIStatus LMI_BatterySystemDeviceEnumInstances( + CMPIInstanceMI* mi, + const CMPIContext* cc, + const CMPIResult* cr, + const CMPIObjectPath* cop, + const char** properties) +{ + LMI_BatterySystemDevice lmi_batt_sys_device; + CIM_ComputerSystemRef cim_cs; + LMI_BatteryRef lmi_batt; + CMPIObjectPath *o; + CMPIStatus st; + const char *ns = KNameSpace(cop); + unsigned i; + DmiBattery *dmi_batt = NULL; + unsigned dmi_batt_nb = 0; + + if (dmi_get_batteries(&dmi_batt, &dmi_batt_nb) != 0 || dmi_batt_nb < 1) { + goto done; + } + + 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()); + + for (i = 0; i < dmi_batt_nb; i++) { + LMI_BatterySystemDevice_Init(&lmi_batt_sys_device, _cb, ns); + + LMI_BatteryRef_Init(&lmi_batt, _cb, ns); + LMI_BatteryRef_Set_SystemCreationClassName(&lmi_batt, + get_system_creation_class_name()); + LMI_BatteryRef_Set_SystemName(&lmi_batt, get_system_name()); + LMI_BatteryRef_Set_CreationClassName(&lmi_batt, + ORGID "_" BATTERY_CLASS_NAME); + LMI_BatteryRef_Set_DeviceID(&lmi_batt, dmi_batt[i].name); + + LMI_BatterySystemDevice_SetObjectPath_GroupComponent( + &lmi_batt_sys_device, o); + LMI_BatterySystemDevice_Set_PartComponent(&lmi_batt_sys_device, + &lmi_batt); + + KReturnInstance(cr, lmi_batt_sys_device); + } + +done: + dmi_free_batteries(&dmi_batt, &dmi_batt_nb); + + CMReturn(CMPI_RC_OK); +} + +static CMPIStatus LMI_BatterySystemDeviceGetInstance( + 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_BatterySystemDeviceCreateInstance( + CMPIInstanceMI* mi, + const CMPIContext* cc, + const CMPIResult* cr, + const CMPIObjectPath* cop, + const CMPIInstance* ci) +{ + CMReturn(CMPI_RC_ERR_NOT_SUPPORTED); +} + +static CMPIStatus LMI_BatterySystemDeviceModifyInstance( + 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_BatterySystemDeviceDeleteInstance( + CMPIInstanceMI* mi, + const CMPIContext* cc, + const CMPIResult* cr, + const CMPIObjectPath* cop) +{ + CMReturn(CMPI_RC_ERR_NOT_SUPPORTED); +} + +static CMPIStatus LMI_BatterySystemDeviceExecQuery( + 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_BatterySystemDeviceAssociationCleanup( + CMPIAssociationMI* mi, + const CMPIContext* cc, + CMPIBoolean term) +{ + CMReturn(CMPI_RC_OK); +} + +static CMPIStatus LMI_BatterySystemDeviceAssociators( + 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_BatterySystemDevice_ClassName, + assocClass, + resultClass, + role, + resultRole, + properties); +} + +static CMPIStatus LMI_BatterySystemDeviceAssociatorNames( + 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_BatterySystemDevice_ClassName, + assocClass, + resultClass, + role, + resultRole); +} + +static CMPIStatus LMI_BatterySystemDeviceReferences( + 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_BatterySystemDevice_ClassName, + assocClass, + role, + properties); +} + +static CMPIStatus LMI_BatterySystemDeviceReferenceNames( + 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_BatterySystemDevice_ClassName, + assocClass, + role); +} + +CMInstanceMIStub( + LMI_BatterySystemDevice, + LMI_BatterySystemDevice, + _cb, + LMI_BatterySystemDeviceInitialize()) + +CMAssociationMIStub( + LMI_BatterySystemDevice, + LMI_BatterySystemDevice, + _cb, + LMI_BatterySystemDeviceInitialize()) + +KONKRET_REGISTRATION( + "root/cimv2", + "LMI_BatterySystemDevice", + "LMI_BatterySystemDevice", + "instance association") diff --git a/src/hardware/LMI_ChassisComputerSystemPackageProvider.c b/src/hardware/LMI_ChassisComputerSystemPackageProvider.c new file mode 100644 index 0000000..d0fc004 --- /dev/null +++ b/src/hardware/LMI_ChassisComputerSystemPackageProvider.c @@ -0,0 +1,266 @@ +/* + * 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_ChassisComputerSystemPackage.h" +#include "LMI_Hardware.h" +#include "globals.h" +#include "dmidecode.h" + +static const CMPIBroker* _cb; + +static void LMI_ChassisComputerSystemPackageInitialize() +{ +} + +static CMPIStatus LMI_ChassisComputerSystemPackageCleanup( + CMPIInstanceMI* mi, + const CMPIContext* cc, + CMPIBoolean term) +{ + CMReturn(CMPI_RC_OK); +} + +static CMPIStatus LMI_ChassisComputerSystemPackageEnumInstanceNames( + CMPIInstanceMI* mi, + const CMPIContext* cc, + const CMPIResult* cr, + const CMPIObjectPath* cop) +{ + return KDefaultEnumerateInstanceNames( + _cb, mi, cc, cr, cop); +} + +static CMPIStatus LMI_ChassisComputerSystemPackageEnumInstances( + CMPIInstanceMI* mi, + const CMPIContext* cc, + const CMPIResult* cr, + const CMPIObjectPath* cop, + const char** properties) +{ + LMI_ChassisComputerSystemPackage lmi_chassis_cs_pkg; + CIM_ComputerSystemRef cim_cs; + LMI_ChassisRef lmi_chassis; + CMPIObjectPath *o; + CMPIStatus st; + const char *ns = KNameSpace(cop); + DmiChassis dmi_chassis; + + if (dmi_get_chassis(&dmi_chassis) != 0) { + goto done; + } + + 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()); + + LMI_ChassisComputerSystemPackage_Init(&lmi_chassis_cs_pkg, _cb, ns); + + LMI_ChassisRef_Init(&lmi_chassis, _cb, ns); + LMI_ChassisRef_Set_CreationClassName(&lmi_chassis, + ORGID "_" CHASSIS_CLASS_NAME); + if (strcmp(dmi_chassis.serial_number, "Not Specified") == 0) { + LMI_ChassisRef_Set_Tag(&lmi_chassis, "0"); + } else { + LMI_ChassisRef_Set_Tag(&lmi_chassis, dmi_chassis.serial_number); + } + + LMI_ChassisComputerSystemPackage_SetObjectPath_Dependent( + &lmi_chassis_cs_pkg, o); + LMI_ChassisComputerSystemPackage_Set_Antecedent(&lmi_chassis_cs_pkg, + &lmi_chassis); + LMI_ChassisComputerSystemPackage_Set_PlatformGUID(&lmi_chassis_cs_pkg, "0"); + + KReturnInstance(cr, lmi_chassis_cs_pkg); + +done: + dmi_free_chassis(&dmi_chassis); + + CMReturn(CMPI_RC_OK); +} + +static CMPIStatus LMI_ChassisComputerSystemPackageGetInstance( + 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_ChassisComputerSystemPackageCreateInstance( + CMPIInstanceMI* mi, + const CMPIContext* cc, + const CMPIResult* cr, + const CMPIObjectPath* cop, + const CMPIInstance* ci) +{ + CMReturn(CMPI_RC_ERR_NOT_SUPPORTED); +} + +static CMPIStatus LMI_ChassisComputerSystemPackageModifyInstance( + 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_ChassisComputerSystemPackageDeleteInstance( + CMPIInstanceMI* mi, + const CMPIContext* cc, + const CMPIResult* cr, + const CMPIObjectPath* cop) +{ + CMReturn(CMPI_RC_ERR_NOT_SUPPORTED); +} + +static CMPIStatus LMI_ChassisComputerSystemPackageExecQuery( + 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_ChassisComputerSystemPackageAssociationCleanup( + CMPIAssociationMI* mi, + const CMPIContext* cc, + CMPIBoolean term) +{ + CMReturn(CMPI_RC_OK); +} + +static CMPIStatus LMI_ChassisComputerSystemPackageAssociators( + 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_ChassisComputerSystemPackage_ClassName, + assocClass, + resultClass, + role, + resultRole, + properties); +} + +static CMPIStatus LMI_ChassisComputerSystemPackageAssociatorNames( + 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_ChassisComputerSystemPackage_ClassName, + assocClass, + resultClass, + role, + resultRole); +} + +static CMPIStatus LMI_ChassisComputerSystemPackageReferences( + 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_ChassisComputerSystemPackage_ClassName, + assocClass, + role, + properties); +} + +static CMPIStatus LMI_ChassisComputerSystemPackageReferenceNames( + 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_ChassisComputerSystemPackage_ClassName, + assocClass, + role); +} + +CMInstanceMIStub( + LMI_ChassisComputerSystemPackage, + LMI_ChassisComputerSystemPackage, + _cb, + LMI_ChassisComputerSystemPackageInitialize()) + +CMAssociationMIStub( + LMI_ChassisComputerSystemPackage, + LMI_ChassisComputerSystemPackage, + _cb, + LMI_ChassisComputerSystemPackageInitialize()) + +KONKRET_REGISTRATION( + "root/cimv2", + "LMI_ChassisComputerSystemPackage", + "LMI_ChassisComputerSystemPackage", + "instance association") diff --git a/src/hardware/LMI_Hardware.h b/src/hardware/LMI_Hardware.h index 1361dd4..e72536a 100644 --- a/src/hardware/LMI_Hardware.h +++ b/src/hardware/LMI_Hardware.h @@ -41,4 +41,7 @@ #define BATTERY_PHYS_PKG_CLASS_NAME "BatteryPhysicalPackage" #define PCI_DEVICE_CLASS_NAME "PCIDevice" +/* PCIDevices */ +#define PCI_DEVID_STR_SIZE 55 + #endif /* LMI_HARDWARE_H_ */ diff --git a/src/hardware/LMI_MemorySystemDeviceProvider.c b/src/hardware/LMI_MemorySystemDeviceProvider.c new file mode 100644 index 0000000..d4d310a --- /dev/null +++ b/src/hardware/LMI_MemorySystemDeviceProvider.c @@ -0,0 +1,254 @@ +/* + * 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_MemorySystemDevice.h" +#include "LMI_Hardware.h" +#include "globals.h" + +static const CMPIBroker* _cb; + +static void LMI_MemorySystemDeviceInitialize() +{ +} + +static CMPIStatus LMI_MemorySystemDeviceCleanup( + CMPIInstanceMI* mi, + const CMPIContext* cc, + CMPIBoolean term) +{ + CMReturn(CMPI_RC_OK); +} + +static CMPIStatus LMI_MemorySystemDeviceEnumInstanceNames( + CMPIInstanceMI* mi, + const CMPIContext* cc, + const CMPIResult* cr, + const CMPIObjectPath* cop) +{ + return KDefaultEnumerateInstanceNames( + _cb, mi, cc, cr, cop); +} + +static CMPIStatus LMI_MemorySystemDeviceEnumInstances( + CMPIInstanceMI* mi, + const CMPIContext* cc, + const CMPIResult* cr, + const CMPIObjectPath* cop, + const char** properties) +{ + LMI_MemorySystemDevice lmi_mem_sys_device; + CIM_ComputerSystemRef cim_cs; + LMI_MemoryRef lmi_mem; + CMPIObjectPath *o; + CMPIStatus st; + const char *ns = KNameSpace(cop); + + 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()); + + LMI_MemorySystemDevice_Init(&lmi_mem_sys_device, _cb, ns); + + LMI_MemoryRef_Init(&lmi_mem, _cb, ns); + LMI_MemoryRef_Set_SystemCreationClassName(&lmi_mem, + get_system_creation_class_name()); + LMI_MemoryRef_Set_SystemName(&lmi_mem, get_system_name()); + LMI_MemoryRef_Set_CreationClassName(&lmi_mem, ORGID "_" MEM_CLASS_NAME); + LMI_MemoryRef_Set_DeviceID(&lmi_mem, "0"); + + LMI_MemorySystemDevice_SetObjectPath_GroupComponent( + &lmi_mem_sys_device, o); + LMI_MemorySystemDevice_Set_PartComponent(&lmi_mem_sys_device, + &lmi_mem); + + KReturnInstance(cr, lmi_mem_sys_device); + + CMReturn(CMPI_RC_OK); +} + +static CMPIStatus LMI_MemorySystemDeviceGetInstance( + 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_MemorySystemDeviceCreateInstance( + CMPIInstanceMI* mi, + const CMPIContext* cc, + const CMPIResult* cr, + const CMPIObjectPath* cop, + const CMPIInstance* ci) +{ + CMReturn(CMPI_RC_ERR_NOT_SUPPORTED); +} + +static CMPIStatus LMI_MemorySystemDeviceModifyInstance( + 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_MemorySystemDeviceDeleteInstance( + CMPIInstanceMI* mi, + const CMPIContext* cc, + const CMPIResult* cr, + const CMPIObjectPath* cop) +{ + CMReturn(CMPI_RC_ERR_NOT_SUPPORTED); +} + +static CMPIStatus LMI_MemorySystemDeviceExecQuery( + 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_MemorySystemDeviceAssociationCleanup( + CMPIAssociationMI* mi, + const CMPIContext* cc, + CMPIBoolean term) +{ + CMReturn(CMPI_RC_OK); +} + +static CMPIStatus LMI_MemorySystemDeviceAssociators( + 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_MemorySystemDevice_ClassName, + assocClass, + resultClass, + role, + resultRole, + properties); +} + +static CMPIStatus LMI_MemorySystemDeviceAssociatorNames( + 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_MemorySystemDevice_ClassName, + assocClass, + resultClass, + role, + resultRole); +} + +static CMPIStatus LMI_MemorySystemDeviceReferences( + 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_MemorySystemDevice_ClassName, + assocClass, + role, + properties); +} + +static CMPIStatus LMI_MemorySystemDeviceReferenceNames( + 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_MemorySystemDevice_ClassName, + assocClass, + role); +} + +CMInstanceMIStub( + LMI_MemorySystemDevice, + LMI_MemorySystemDevice, + _cb, + LMI_MemorySystemDeviceInitialize()) + +CMAssociationMIStub( + LMI_MemorySystemDevice, + LMI_MemorySystemDevice, + _cb, + LMI_MemorySystemDeviceInitialize()) + +KONKRET_REGISTRATION( + "root/cimv2", + "LMI_MemorySystemDevice", + "LMI_MemorySystemDevice", + "instance association") diff --git a/src/hardware/LMI_PCIDeviceProvider.c b/src/hardware/LMI_PCIDeviceProvider.c index 2daf0a6..a88f9cd 100644 --- a/src/hardware/LMI_PCIDeviceProvider.c +++ b/src/hardware/LMI_PCIDeviceProvider.c @@ -26,7 +26,6 @@ #include "globals.h" #define NAME_BUF_SIZE 128 -#define PCI_DEVID_STR_SIZE 55 void get_subid(struct pci_dev *d, u16 *subvp, u16 *subdp); CMPIUint16 get_capability(const u16 pci_cap); diff --git a/src/hardware/LMI_PCIDeviceSystemDeviceProvider.c b/src/hardware/LMI_PCIDeviceSystemDeviceProvider.c new file mode 100644 index 0000000..e473ddf --- /dev/null +++ b/src/hardware/LMI_PCIDeviceSystemDeviceProvider.c @@ -0,0 +1,272 @@ +/* + * 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 <pci/pci.h> +#include "LMI_PCIDeviceSystemDevice.h" +#include "LMI_Hardware.h" +#include "globals.h" + +static const CMPIBroker* _cb; + +static void LMI_PCIDeviceSystemDeviceInitialize() +{ +} + +static CMPIStatus LMI_PCIDeviceSystemDeviceCleanup( + CMPIInstanceMI* mi, + const CMPIContext* cc, + CMPIBoolean term) +{ + CMReturn(CMPI_RC_OK); +} + +static CMPIStatus LMI_PCIDeviceSystemDeviceEnumInstanceNames( + CMPIInstanceMI* mi, + const CMPIContext* cc, + const CMPIResult* cr, + const CMPIObjectPath* cop) +{ + return KDefaultEnumerateInstanceNames( + _cb, mi, cc, cr, cop); +} + +static CMPIStatus LMI_PCIDeviceSystemDeviceEnumInstances( + CMPIInstanceMI* mi, + const CMPIContext* cc, + const CMPIResult* cr, + const CMPIObjectPath* cop, + const char** properties) +{ + LMI_PCIDeviceSystemDevice lmi_pci_sys_device; + CIM_ComputerSystemRef cim_cs; + LMI_PCIDeviceRef 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) { + LMI_PCIDeviceSystemDevice_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_PCIDeviceRef_Init(&lmi_dev, _cb, ns); + LMI_PCIDeviceRef_Set_SystemCreationClassName(&lmi_dev, + get_system_creation_class_name()); + LMI_PCIDeviceRef_Set_SystemName(&lmi_dev, get_system_name()); + LMI_PCIDeviceRef_Set_CreationClassName(&lmi_dev, + ORGID "_" PCI_DEVICE_CLASS_NAME); + LMI_PCIDeviceRef_Set_DeviceID(&lmi_dev, device_id_str); + + LMI_PCIDeviceSystemDevice_SetObjectPath_GroupComponent( + &lmi_pci_sys_device, o); + LMI_PCIDeviceSystemDevice_Set_PartComponent(&lmi_pci_sys_device, + &lmi_dev); + + KReturnInstance(cr, lmi_pci_sys_device); + } + + pci_cleanup(acc); + + CMReturn(CMPI_RC_OK); +} + +static CMPIStatus LMI_PCIDeviceSystemDeviceGetInstance( + 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_PCIDeviceSystemDeviceCreateInstance( + CMPIInstanceMI* mi, + const CMPIContext* cc, + const CMPIResult* cr, + const CMPIObjectPath* cop, + const CMPIInstance* ci) +{ + CMReturn(CMPI_RC_ERR_NOT_SUPPORTED); +} + +static CMPIStatus LMI_PCIDeviceSystemDeviceModifyInstance( + 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_PCIDeviceSystemDeviceDeleteInstance( + CMPIInstanceMI* mi, + const CMPIContext* cc, + const CMPIResult* cr, + const CMPIObjectPath* cop) +{ + CMReturn(CMPI_RC_ERR_NOT_SUPPORTED); +} + +static CMPIStatus LMI_PCIDeviceSystemDeviceExecQuery( + 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_PCIDeviceSystemDeviceAssociationCleanup( + CMPIAssociationMI* mi, + const CMPIContext* cc, + CMPIBoolean term) +{ + CMReturn(CMPI_RC_OK); +} + +static CMPIStatus LMI_PCIDeviceSystemDeviceAssociators( + 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_PCIDeviceSystemDevice_ClassName, + assocClass, + resultClass, + role, + resultRole, + properties); +} + +static CMPIStatus LMI_PCIDeviceSystemDeviceAssociatorNames( + 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_PCIDeviceSystemDevice_ClassName, + assocClass, + resultClass, + role, + resultRole); +} + +static CMPIStatus LMI_PCIDeviceSystemDeviceReferences( + 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_PCIDeviceSystemDevice_ClassName, + assocClass, + role, + properties); +} + +static CMPIStatus LMI_PCIDeviceSystemDeviceReferenceNames( + 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_PCIDeviceSystemDevice_ClassName, + assocClass, + role); +} + +CMInstanceMIStub( + LMI_PCIDeviceSystemDevice, + LMI_PCIDeviceSystemDevice, + _cb, + LMI_PCIDeviceSystemDeviceInitialize()) + +CMAssociationMIStub( + LMI_PCIDeviceSystemDevice, + LMI_PCIDeviceSystemDevice, + _cb, + LMI_PCIDeviceSystemDeviceInitialize()) + +KONKRET_REGISTRATION( + "root/cimv2", + "LMI_PCIDeviceSystemDevice", + "LMI_PCIDeviceSystemDevice", + "instance association") diff --git a/src/hardware/LMI_ProcessorSystemDeviceProvider.c b/src/hardware/LMI_ProcessorSystemDeviceProvider.c new file mode 100644 index 0000000..327f711 --- /dev/null +++ b/src/hardware/LMI_ProcessorSystemDeviceProvider.c @@ -0,0 +1,268 @@ +/* + * 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_ProcessorSystemDevice.h" +#include "LMI_Hardware.h" +#include "globals.h" +#include "dmidecode.h" + +static const CMPIBroker* _cb; + +static void LMI_ProcessorSystemDeviceInitialize() +{ +} + +static CMPIStatus LMI_ProcessorSystemDeviceCleanup( + CMPIInstanceMI* mi, + const CMPIContext* cc, + CMPIBoolean term) +{ + CMReturn(CMPI_RC_OK); +} + +static CMPIStatus LMI_ProcessorSystemDeviceEnumInstanceNames( + CMPIInstanceMI* mi, + const CMPIContext* cc, + const CMPIResult* cr, + const CMPIObjectPath* cop) +{ + return KDefaultEnumerateInstanceNames( + _cb, mi, cc, cr, cop); +} + +static CMPIStatus LMI_ProcessorSystemDeviceEnumInstances( + CMPIInstanceMI* mi, + const CMPIContext* cc, + const CMPIResult* cr, + const CMPIObjectPath* cop, + const char** properties) +{ + LMI_ProcessorSystemDevice lmi_cpu_sys_device; + CIM_ComputerSystemRef cim_cs; + LMI_ProcessorRef lmi_cpu; + CMPIObjectPath *o; + CMPIStatus st; + const char *ns = KNameSpace(cop); + unsigned i; + DmiProcessor *dmi_cpus = NULL; + unsigned dmi_cpus_nb = 0; + + if (dmi_get_processors(&dmi_cpus, &dmi_cpus_nb) != 0 || dmi_cpus_nb < 1) { + goto done; + } + + 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()); + + for (i = 0; i < dmi_cpus_nb; i++) { + LMI_ProcessorSystemDevice_Init(&lmi_cpu_sys_device, _cb, ns); + + LMI_ProcessorRef_Init(&lmi_cpu, _cb, ns); + LMI_ProcessorRef_Set_SystemCreationClassName(&lmi_cpu, + get_system_creation_class_name()); + LMI_ProcessorRef_Set_SystemName(&lmi_cpu, get_system_name()); + LMI_ProcessorRef_Set_CreationClassName(&lmi_cpu, + ORGID "_" CPU_CLASS_NAME); + LMI_ProcessorRef_Set_DeviceID(&lmi_cpu, dmi_cpus[i].id); + + LMI_ProcessorSystemDevice_SetObjectPath_GroupComponent( + &lmi_cpu_sys_device, o); + LMI_ProcessorSystemDevice_Set_PartComponent(&lmi_cpu_sys_device, + &lmi_cpu); + + KReturnInstance(cr, lmi_cpu_sys_device); + } + +done: + dmi_free_processors(&dmi_cpus, &dmi_cpus_nb); + + CMReturn(CMPI_RC_OK); +} + +static CMPIStatus LMI_ProcessorSystemDeviceGetInstance( + 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_ProcessorSystemDeviceCreateInstance( + CMPIInstanceMI* mi, + const CMPIContext* cc, + const CMPIResult* cr, + const CMPIObjectPath* cop, + const CMPIInstance* ci) +{ + CMReturn(CMPI_RC_ERR_NOT_SUPPORTED); +} + +static CMPIStatus LMI_ProcessorSystemDeviceModifyInstance( + 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_ProcessorSystemDeviceDeleteInstance( + CMPIInstanceMI* mi, + const CMPIContext* cc, + const CMPIResult* cr, + const CMPIObjectPath* cop) +{ + CMReturn(CMPI_RC_ERR_NOT_SUPPORTED); +} + +static CMPIStatus LMI_ProcessorSystemDeviceExecQuery( + 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_ProcessorSystemDeviceAssociationCleanup( + CMPIAssociationMI* mi, + const CMPIContext* cc, + CMPIBoolean term) +{ + CMReturn(CMPI_RC_OK); +} + +static CMPIStatus LMI_ProcessorSystemDeviceAssociators( + 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_ProcessorSystemDevice_ClassName, + assocClass, + resultClass, + role, + resultRole, + properties); +} + +static CMPIStatus LMI_ProcessorSystemDeviceAssociatorNames( + 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_ProcessorSystemDevice_ClassName, + assocClass, + resultClass, + role, + resultRole); +} + +static CMPIStatus LMI_ProcessorSystemDeviceReferences( + 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_ProcessorSystemDevice_ClassName, + assocClass, + role, + properties); +} + +static CMPIStatus LMI_ProcessorSystemDeviceReferenceNames( + 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_ProcessorSystemDevice_ClassName, + assocClass, + role); +} + +CMInstanceMIStub( + LMI_ProcessorSystemDevice, + LMI_ProcessorSystemDevice, + _cb, + LMI_ProcessorSystemDeviceInitialize()) + +CMAssociationMIStub( + LMI_ProcessorSystemDevice, + LMI_ProcessorSystemDevice, + _cb, + LMI_ProcessorSystemDeviceInitialize()) + +KONKRET_REGISTRATION( + "root/cimv2", + "LMI_ProcessorSystemDevice", + "LMI_ProcessorSystemDevice", + "instance association") |