blob: de0d82f0d4de9b3c33fd00c66fa1fafcc28f6944 [file] [log] [blame]
Tom Josephbe5eaa12017-07-12 19:54:44 +05301#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.
9enum ipmi_netfn_sen_cmds
10{
11 // Get capability bits
12 IPMI_CMD_DCMI_GET_POWER = 0x03,
Tom Joseph6f6dd4d2017-07-12 20:07:11 +053013 IPMI_CMD_DCMI_GET_ASSET_TAG = 0x06,
Tom Joseph545dd232017-07-12 20:20:49 +053014 IPMI_CMD_DCMI_SET_ASSET_TAG = 0x08,
Tom Josephbe5eaa12017-07-12 19:54:44 +053015};
16
17namespace dcmi
18{
19
20static constexpr auto propIntf = "org.freedesktop.DBus.Properties";
21static constexpr auto assetTagIntf =
22 "xyz.openbmc_project.Inventory.Decorator.AssetTag";
23static constexpr auto assetTagProp = "AssetTag";
24
25namespace 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 Joseph6f6dd4d2017-07-12 20:07:11 +053035static constexpr auto groupExtId = 0xDC;
36
37static constexpr auto assetTagMaxOffset = 62;
38static constexpr auto assetTagMaxSize = 63;
39static constexpr auto maxBytes = 16;
40
41/** @struct GetAssetTagRequest
42 *
43 * DCMI payload for Get Asset Tag command request.
44 */
45struct 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 */
56struct GetAssetTagResponse
57{
58 uint8_t groupID; //!< Group extension identification.
59 uint8_t tagLength; //!< Total asset tag length.
60} __attribute__((packed));
61
Tom Joseph545dd232017-07-12 20:20:49 +053062/** @struct SetAssetTagRequest
63 *
64 * DCMI payload for Set Asset Tag command request.
65 */
66struct 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 */
77struct SetAssetTagResponse
78{
79 uint8_t groupID; //!< Group extension identification.
80 uint8_t tagLength; //!< Total asset tag length.
81} __attribute__((packed));
82
Tom Josephbe5eaa12017-07-12 19:54:44 +053083/** @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 */
91void 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 */
97std::string readAssetTag();
98
Tom Josephbe5b9892017-07-15 00:55:23 +053099/** @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 */
103void writeAssetTag(const std::string& assetTag);
104
Tom Josephbe5eaa12017-07-12 19:54:44 +0530105} // namespace dcmi
106
107#endif