16f9e7a76SPrithvi Pai #pragma once 26f9e7a76SPrithvi Pai #include "smbios_mdrv2.hpp" 36f9e7a76SPrithvi Pai 46f9e7a76SPrithvi Pai #include <sdbusplus/asio/connection.hpp> 56f9e7a76SPrithvi Pai #include <xyz/openbmc_project/Inventory/Item/server.hpp> 6*ac4cb328SPrithvi Pai #include <xyz/openbmc_project/Software/Asset/server.hpp> 76f9e7a76SPrithvi Pai #include <xyz/openbmc_project/Software/ExtendedVersion/server.hpp> 86f9e7a76SPrithvi Pai #include <xyz/openbmc_project/Software/Version/server.hpp> 96f9e7a76SPrithvi Pai 106f9e7a76SPrithvi Pai #include <vector> 116f9e7a76SPrithvi Pai 126f9e7a76SPrithvi Pai namespace phosphor 136f9e7a76SPrithvi Pai { 146f9e7a76SPrithvi Pai 156f9e7a76SPrithvi Pai namespace smbios 166f9e7a76SPrithvi Pai { 176f9e7a76SPrithvi Pai namespace utils 186f9e7a76SPrithvi Pai { 196f9e7a76SPrithvi Pai std::vector<std::string> getExistingVersionPaths(sdbusplus::bus_t& bus); 206f9e7a76SPrithvi Pai } 216f9e7a76SPrithvi Pai 22*ac4cb328SPrithvi Pai using softwareAsset = sdbusplus::server::xyz::openbmc_project::software::Asset; 236f9e7a76SPrithvi Pai using item = sdbusplus::server::xyz::openbmc_project::inventory::Item; 246f9e7a76SPrithvi Pai using softwareVersion = 256f9e7a76SPrithvi Pai sdbusplus::server::xyz::openbmc_project::software::Version; 266f9e7a76SPrithvi Pai using softwareExtendedVersion = 276f9e7a76SPrithvi Pai sdbusplus::server::xyz::openbmc_project::software::ExtendedVersion; 286f9e7a76SPrithvi Pai 296f9e7a76SPrithvi Pai class FirmwareInventory : 30*ac4cb328SPrithvi Pai sdbusplus::server::object_t<softwareAsset, item, softwareVersion, 316f9e7a76SPrithvi Pai softwareExtendedVersion> 326f9e7a76SPrithvi Pai { 336f9e7a76SPrithvi Pai public: 346f9e7a76SPrithvi Pai FirmwareInventory() = delete; 356f9e7a76SPrithvi Pai ~FirmwareInventory() = default; 366f9e7a76SPrithvi Pai FirmwareInventory(const FirmwareInventory&) = delete; 376f9e7a76SPrithvi Pai FirmwareInventory& operator=(const FirmwareInventory&) = delete; 386f9e7a76SPrithvi Pai FirmwareInventory(FirmwareInventory&&) = default; 396f9e7a76SPrithvi Pai FirmwareInventory& operator=(FirmwareInventory&&) = default; 406f9e7a76SPrithvi Pai 416f9e7a76SPrithvi Pai FirmwareInventory(sdbusplus::bus_t& bus, const std::string& objPath, 426f9e7a76SPrithvi Pai const uint8_t index, uint8_t* smbiosTableStorage) : 43*ac4cb328SPrithvi Pai sdbusplus::server::object_t<softwareAsset, item, softwareVersion, 446f9e7a76SPrithvi Pai softwareExtendedVersion>(bus, FirmwareInventory(sdbusplus::bus_t & bus,const std::string & objPath,const uint8_t index,uint8_t * smbiosTableStorage)456f9e7a76SPrithvi Pai objPath.c_str()), 466f9e7a76SPrithvi Pai firmwareInventoryIndex(index), storage(smbiosTableStorage) 476f9e7a76SPrithvi Pai { 486f9e7a76SPrithvi Pai firmwareInfoUpdate(smbiosTableStorage); 496f9e7a76SPrithvi Pai } 506f9e7a76SPrithvi Pai 516f9e7a76SPrithvi Pai void firmwareInfoUpdate(uint8_t* smbiosTableStorage); 526f9e7a76SPrithvi Pai 536f9e7a76SPrithvi Pai static std::string checkAndCreateFirmwarePath( 546f9e7a76SPrithvi Pai uint8_t* dataIn, int index, 556f9e7a76SPrithvi Pai std::vector<std::string>& existingVersionPaths); 566f9e7a76SPrithvi Pai 576f9e7a76SPrithvi Pai private: 586f9e7a76SPrithvi Pai int firmwareInventoryIndex; 596f9e7a76SPrithvi Pai 606f9e7a76SPrithvi Pai uint8_t* storage; 616f9e7a76SPrithvi Pai 626f9e7a76SPrithvi Pai struct FirmwareInfo 636f9e7a76SPrithvi Pai { 646f9e7a76SPrithvi Pai uint8_t type; 656f9e7a76SPrithvi Pai uint8_t length; 666f9e7a76SPrithvi Pai uint16_t handle; 676f9e7a76SPrithvi Pai uint8_t componentName; 686f9e7a76SPrithvi Pai uint8_t version; 696f9e7a76SPrithvi Pai uint8_t versionFormat; 706f9e7a76SPrithvi Pai uint8_t id; 716f9e7a76SPrithvi Pai uint8_t idFormat; 726f9e7a76SPrithvi Pai uint8_t releaseDate; 736f9e7a76SPrithvi Pai uint8_t manufacturer; 746f9e7a76SPrithvi Pai uint8_t lowestSupportedVersion; 756f9e7a76SPrithvi Pai uint64_t imageSize; 766f9e7a76SPrithvi Pai uint16_t characteristics; 776f9e7a76SPrithvi Pai uint8_t state; 786f9e7a76SPrithvi Pai uint8_t numOfAssociatedComponents; 796f9e7a76SPrithvi Pai uint16_t associatedComponentHandles[1]; 806f9e7a76SPrithvi Pai } __attribute__((packed)); 816f9e7a76SPrithvi Pai 826f9e7a76SPrithvi Pai void firmwareId(const uint8_t positionNum, const uint8_t structLen, 836f9e7a76SPrithvi Pai uint8_t* dataIn); 846f9e7a76SPrithvi Pai void firmwareVersion(const uint8_t positionNum, const uint8_t structLen, 856f9e7a76SPrithvi Pai uint8_t* dataIn); 866f9e7a76SPrithvi Pai void firmwareReleaseDate(const uint8_t positionNum, const uint8_t structLen, 876f9e7a76SPrithvi Pai uint8_t* dataIn); 886f9e7a76SPrithvi Pai void firmwareManufacturer(const uint8_t positionNum, 896f9e7a76SPrithvi Pai const uint8_t structLen, uint8_t* dataIn); 906f9e7a76SPrithvi Pai void firmwareComponentName(const uint8_t positionNum, 916f9e7a76SPrithvi Pai const uint8_t structLen, uint8_t* dataIn); 926f9e7a76SPrithvi Pai static bool getFirmwareInventoryData(uint8_t*& dataIn, int inventoryIndex); 936f9e7a76SPrithvi Pai }; 946f9e7a76SPrithvi Pai } // namespace smbios 956f9e7a76SPrithvi Pai } // namespace phosphor 96