Tom Joseph | be5eaa1 | 2017-07-12 19:54:44 +0530 | [diff] [blame] | 1 | #ifndef __HOST_IPMI_DCMI_HANDLER_H__ |
| 2 | #define __HOST_IPMI_DCMI_HANDLER_H__ |
| 3 | |
| 4 | #include <map> |
| 5 | #include <string> |
| 6 | #include <vector> |
| 7 | |
| 8 | // IPMI commands for net functions. |
| 9 | enum ipmi_netfn_sen_cmds |
| 10 | { |
| 11 | // Get capability bits |
| 12 | IPMI_CMD_DCMI_GET_POWER = 0x03, |
Tom Joseph | 6f6dd4d | 2017-07-12 20:07:11 +0530 | [diff] [blame] | 13 | IPMI_CMD_DCMI_GET_ASSET_TAG = 0x06, |
Tom Joseph | 545dd23 | 2017-07-12 20:20:49 +0530 | [diff] [blame] | 14 | IPMI_CMD_DCMI_SET_ASSET_TAG = 0x08, |
Tom Joseph | be5eaa1 | 2017-07-12 19:54:44 +0530 | [diff] [blame] | 15 | }; |
| 16 | |
| 17 | namespace dcmi |
| 18 | { |
| 19 | |
| 20 | static constexpr auto propIntf = "org.freedesktop.DBus.Properties"; |
| 21 | static constexpr auto assetTagIntf = |
| 22 | "xyz.openbmc_project.Inventory.Decorator.AssetTag"; |
| 23 | static constexpr auto assetTagProp = "AssetTag"; |
| 24 | |
| 25 | namespace assettag |
| 26 | { |
| 27 | |
| 28 | using ObjectPath = std::string; |
| 29 | using Service = std::string; |
| 30 | using Interfaces = std::vector<std::string>; |
| 31 | using ObjectTree = std::map<ObjectPath, std::map<Service, Interfaces>>; |
| 32 | |
| 33 | } //namespace assettag |
| 34 | |
Tom Joseph | 6f6dd4d | 2017-07-12 20:07:11 +0530 | [diff] [blame] | 35 | static constexpr auto groupExtId = 0xDC; |
| 36 | |
| 37 | static constexpr auto assetTagMaxOffset = 62; |
| 38 | static constexpr auto assetTagMaxSize = 63; |
| 39 | static constexpr auto maxBytes = 16; |
| 40 | |
| 41 | /** @struct GetAssetTagRequest |
| 42 | * |
| 43 | * DCMI payload for Get Asset Tag command request. |
| 44 | */ |
| 45 | struct GetAssetTagRequest |
| 46 | { |
| 47 | uint8_t groupID; //!< Group extension identification. |
| 48 | uint8_t offset; //!< Offset to read. |
| 49 | uint8_t bytes; //!< Number of bytes to read. |
| 50 | } __attribute__((packed)); |
| 51 | |
| 52 | /** @struct GetAssetTagResponse |
| 53 | * |
| 54 | * DCMI payload for Get Asset Tag command response. |
| 55 | */ |
| 56 | struct GetAssetTagResponse |
| 57 | { |
| 58 | uint8_t groupID; //!< Group extension identification. |
| 59 | uint8_t tagLength; //!< Total asset tag length. |
| 60 | } __attribute__((packed)); |
| 61 | |
Tom Joseph | 545dd23 | 2017-07-12 20:20:49 +0530 | [diff] [blame] | 62 | /** @struct SetAssetTagRequest |
| 63 | * |
| 64 | * DCMI payload for Set Asset Tag command request. |
| 65 | */ |
| 66 | struct SetAssetTagRequest |
| 67 | { |
| 68 | uint8_t groupID; //!< Group extension identification. |
| 69 | uint8_t offset; //!< Offset to write. |
| 70 | uint8_t bytes; //!< Number of bytes to write. |
| 71 | } __attribute__((packed)); |
| 72 | |
| 73 | /** @struct SetAssetTagResponse |
| 74 | * |
| 75 | * DCMI payload for Set Asset Tag command response. |
| 76 | */ |
| 77 | struct SetAssetTagResponse |
| 78 | { |
| 79 | uint8_t groupID; //!< Group extension identification. |
| 80 | uint8_t tagLength; //!< Total asset tag length. |
| 81 | } __attribute__((packed)); |
| 82 | |
Tom Joseph | be5eaa1 | 2017-07-12 19:54:44 +0530 | [diff] [blame] | 83 | /** @brief Read the object tree to fetch the object path that implemented the |
| 84 | * Asset tag interface. |
| 85 | * |
| 86 | * @param[in,out] objectTree - object tree |
| 87 | * |
| 88 | * @return On success return the object tree with the object path that |
| 89 | * implemented the AssetTag interface. |
| 90 | */ |
| 91 | void readAssetTagObjectTree(dcmi::assettag::ObjectTree& objectTree); |
| 92 | |
| 93 | /** @brief Read the asset tag of the server |
| 94 | * |
| 95 | * @return On success return the asset tag. |
| 96 | */ |
| 97 | std::string readAssetTag(); |
| 98 | |
Tom Joseph | be5b989 | 2017-07-15 00:55:23 +0530 | [diff] [blame] | 99 | /** @brief Write the asset tag to the asset tag DBUS property |
| 100 | * |
| 101 | * @param[in] assetTag - Asset Tag to be written to the property. |
| 102 | */ |
| 103 | void writeAssetTag(const std::string& assetTag); |
| 104 | |
Tom Joseph | be5eaa1 | 2017-07-12 19:54:44 +0530 | [diff] [blame] | 105 | } // namespace dcmi |
| 106 | |
| 107 | #endif |