blob: 54e562cddc01c378bd832cdfd5850ac5d9121c4e [file] [log] [blame]
Deepak Kodihalli76794492017-02-16 23:48:18 -06001#pragma once
2
SunnySrivastava1984f6d541e2020-02-04 12:50:40 -06003#include "const.hpp"
Deepak Kodihalli76794492017-02-16 23:48:18 -06004#include "types.hpp"
5
SunnySrivastava1984d076da82020-03-05 05:33:35 -06006#include <iostream>
7
8using namespace std;
Deepak Kodihalli76794492017-02-16 23:48:18 -06009namespace openpower
10{
11namespace vpd
12{
SunnySrivastava1984945a02d2020-05-06 01:55:41 -050013/**
14 * @brief Types of VPD
15 */
16enum vpdType
17{
18 IPZ_VPD, /**< IPZ VPD type */
19 KEYWORD_VPD, /**< Keyword VPD type */
20 MEMORY_VPD, /**< Memory VPD type */
21 INVALID_VPD_FORMAT /**< Invalid VPD type */
22};
23
24/**
25 * @brief Check the type of VPD.
26 *
27 * Checks the type of vpd based on the start tag.
28 * @param[in] vector - Vpd data in vector format
29 *
30 * @return enum of type vpdType
31 */
32vpdType vpdTypeCheck(const Binary& vector);
33
Santosh Puranikbd011b22020-01-23 04:05:25 -060034/** @brief Return the hex representation of the incoming byte
35 *
36 * @param [in] c - The input byte
37 * @returns The hex representation of the byte as a character.
38 */
39constexpr auto toHex(size_t c)
40{
41 constexpr auto map = "0123456789abcdef";
42 return map[c];
43}
Deepak Kodihalli76794492017-02-16 23:48:18 -060044
45namespace inventory
46{
47
48/** @brief Get inventory-manager's d-bus service
49 */
50auto getPIMService();
51
52/** @brief Call inventory-manager to add objects
53 *
54 * @param [in] objects - Map of inventory object paths
55 */
56void callPIM(ObjectMap&& objects);
57
58} // namespace inventory
59
SunnySrivastava1984f6d541e2020-02-04 12:50:40 -060060/**@brief This API reads 2 Bytes of data and swap the read data
61 * @param[in] iterator- Pointer pointing to the data to be read
62 * @return returns 2 Byte data read at the given pointer
63 */
64openpower::vpd::constants::LE2ByteData
65 readUInt16LE(Binary::const_iterator iterator);
66
SunnySrivastava1984d076da82020-03-05 05:33:35 -060067/** @brief Encodes a keyword for D-Bus.
68 * @param[in] kw - kwd data in string format
69 * @param[in] encoding - required for kwd data
70 */
71string encodeKeyword(const string& kw, const string& encoding);
SunnySrivastava198443306542020-04-01 02:50:20 -050072
73/** @brief Reads a property from the inventory manager given object path,
74 * intreface and property.
75 * @param[in] obj - object path
76 * @param[in] inf - interface
77 * @param[in] prop - property whose value is fetched
78 * @return [out] - value of the property
79 */
80string readBusProperty(const string& obj, const string& inf,
81 const string& prop);
Patrick Venturec83c4dc2018-11-01 16:29:18 -070082} // namespace vpd
83} // namespace openpower