Prithvi Pai | 6f9e7a7 | 2025-03-14 13:05:02 +0530 | [diff] [blame^] | 1 | #pragma once |
| 2 | #include "smbios_mdrv2.hpp" |
| 3 | |
| 4 | #include <sdbusplus/asio/connection.hpp> |
| 5 | #include <xyz/openbmc_project/Association/Definitions/server.hpp> |
| 6 | #include <xyz/openbmc_project/Inventory/Decorator/Asset/server.hpp> |
| 7 | #include <xyz/openbmc_project/Inventory/Item/server.hpp> |
| 8 | #include <xyz/openbmc_project/Software/ExtendedVersion/server.hpp> |
| 9 | #include <xyz/openbmc_project/Software/Version/server.hpp> |
| 10 | |
| 11 | #include <vector> |
| 12 | |
| 13 | namespace phosphor |
| 14 | { |
| 15 | |
| 16 | namespace smbios |
| 17 | { |
| 18 | namespace utils |
| 19 | { |
| 20 | std::vector<std::string> getExistingVersionPaths(sdbusplus::bus_t& bus); |
| 21 | } |
| 22 | |
| 23 | using association = |
| 24 | sdbusplus::server::xyz::openbmc_project::association::Definitions; |
| 25 | using asset = |
| 26 | sdbusplus::server::xyz::openbmc_project::inventory::decorator::Asset; |
| 27 | using item = sdbusplus::server::xyz::openbmc_project::inventory::Item; |
| 28 | using softwareVersion = |
| 29 | sdbusplus::server::xyz::openbmc_project::software::Version; |
| 30 | using softwareExtendedVersion = |
| 31 | sdbusplus::server::xyz::openbmc_project::software::ExtendedVersion; |
| 32 | |
| 33 | class FirmwareInventory : |
| 34 | sdbusplus::server::object_t<asset, item, association, softwareVersion, |
| 35 | softwareExtendedVersion> |
| 36 | { |
| 37 | public: |
| 38 | FirmwareInventory() = delete; |
| 39 | ~FirmwareInventory() = default; |
| 40 | FirmwareInventory(const FirmwareInventory&) = delete; |
| 41 | FirmwareInventory& operator=(const FirmwareInventory&) = delete; |
| 42 | FirmwareInventory(FirmwareInventory&&) = default; |
| 43 | FirmwareInventory& operator=(FirmwareInventory&&) = default; |
| 44 | |
| 45 | FirmwareInventory(sdbusplus::bus_t& bus, const std::string& objPath, |
| 46 | const uint8_t index, uint8_t* smbiosTableStorage) : |
| 47 | sdbusplus::server::object_t<asset, item, association, softwareVersion, |
| 48 | softwareExtendedVersion>(bus, |
| 49 | objPath.c_str()), |
| 50 | firmwareInventoryIndex(index), storage(smbiosTableStorage) |
| 51 | { |
| 52 | firmwareInfoUpdate(smbiosTableStorage); |
| 53 | } |
| 54 | |
| 55 | void firmwareInfoUpdate(uint8_t* smbiosTableStorage); |
| 56 | |
| 57 | static std::string checkAndCreateFirmwarePath( |
| 58 | uint8_t* dataIn, int index, |
| 59 | std::vector<std::string>& existingVersionPaths); |
| 60 | |
| 61 | private: |
| 62 | int firmwareInventoryIndex; |
| 63 | |
| 64 | uint8_t* storage; |
| 65 | |
| 66 | struct FirmwareInfo |
| 67 | { |
| 68 | uint8_t type; |
| 69 | uint8_t length; |
| 70 | uint16_t handle; |
| 71 | uint8_t componentName; |
| 72 | uint8_t version; |
| 73 | uint8_t versionFormat; |
| 74 | uint8_t id; |
| 75 | uint8_t idFormat; |
| 76 | uint8_t releaseDate; |
| 77 | uint8_t manufacturer; |
| 78 | uint8_t lowestSupportedVersion; |
| 79 | uint64_t imageSize; |
| 80 | uint16_t characteristics; |
| 81 | uint8_t state; |
| 82 | uint8_t numOfAssociatedComponents; |
| 83 | uint16_t associatedComponentHandles[1]; |
| 84 | } __attribute__((packed)); |
| 85 | |
| 86 | void firmwareId(const uint8_t positionNum, const uint8_t structLen, |
| 87 | uint8_t* dataIn); |
| 88 | void firmwareVersion(const uint8_t positionNum, const uint8_t structLen, |
| 89 | uint8_t* dataIn); |
| 90 | void firmwareReleaseDate(const uint8_t positionNum, const uint8_t structLen, |
| 91 | uint8_t* dataIn); |
| 92 | void firmwareManufacturer(const uint8_t positionNum, |
| 93 | const uint8_t structLen, uint8_t* dataIn); |
| 94 | void firmwareComponentName(const uint8_t positionNum, |
| 95 | const uint8_t structLen, uint8_t* dataIn); |
| 96 | static bool getFirmwareInventoryData(uint8_t*& dataIn, int inventoryIndex); |
| 97 | }; |
| 98 | } // namespace smbios |
| 99 | } // namespace phosphor |