blob: e21f13d6f32629173f12251652bbe5d798dcc228 [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;
SunnySrivastava19849094d4f2020-08-05 09:32:29 -05009
Deepak Kodihalli76794492017-02-16 23:48:18 -060010namespace openpower
11{
12namespace vpd
13{
SunnySrivastava1984945a02d2020-05-06 01:55:41 -050014
Santosh Puranikbd011b22020-01-23 04:05:25 -060015/** @brief Return the hex representation of the incoming byte
16 *
17 * @param [in] c - The input byte
18 * @returns The hex representation of the byte as a character.
19 */
20constexpr auto toHex(size_t c)
21{
22 constexpr auto map = "0123456789abcdef";
23 return map[c];
24}
Deepak Kodihalli76794492017-02-16 23:48:18 -060025
26namespace inventory
27{
SunnySrivastava19849094d4f2020-08-05 09:32:29 -050028/** @brief Api to obtain a dictionary of path -> services
29 * where path is in subtree and services is of the type
30 * returned by the GetObject method.
31 *
32 * @param [in] root - Root path for object subtree
33 * @param [in] depth - Maximum subtree depth required
34 * @param [in] interfaces - Array to interfaces for which
35 * result is required.
36 * @return A dictionary of Path -> services
37 */
38MapperResponse
39 getObjectSubtreeForInterfaces(const std::string& root, const int32_t depth,
40 const std::vector<std::string>& interfaces);
41
Deepak Kodihalli76794492017-02-16 23:48:18 -060042} // namespace inventory
43
SunnySrivastava1984f6d541e2020-02-04 12:50:40 -060044/**@brief This API reads 2 Bytes of data and swap the read data
45 * @param[in] iterator- Pointer pointing to the data to be read
46 * @return returns 2 Byte data read at the given pointer
47 */
48openpower::vpd::constants::LE2ByteData
49 readUInt16LE(Binary::const_iterator iterator);
50
SunnySrivastava1984d076da82020-03-05 05:33:35 -060051/** @brief Encodes a keyword for D-Bus.
52 * @param[in] kw - kwd data in string format
53 * @param[in] encoding - required for kwd data
54 */
55string encodeKeyword(const string& kw, const string& encoding);
SunnySrivastava198443306542020-04-01 02:50:20 -050056
57/** @brief Reads a property from the inventory manager given object path,
58 * intreface and property.
59 * @param[in] obj - object path
60 * @param[in] inf - interface
61 * @param[in] prop - property whose value is fetched
62 * @return [out] - value of the property
63 */
64string readBusProperty(const string& obj, const string& inf,
65 const string& prop);
SunnySrivastava1984a20be8e2020-08-26 02:00:50 -050066
67/**
68 * @brief API to create PEL entry
69 * @param[in] Map holding the additional data
70 * @param[in] error interface
71 */
72void createPEL(const std::map<std::string, std::string>& additionalData,
73 const std::string& errIntf);
SunnySrivastava19849094d4f2020-08-05 09:32:29 -050074
PriyangaRamasamyc0a534f2020-08-24 21:29:18 +053075/**
76 * @brief getVpdFilePath
77 * Get vpd file path corresponding to the given object path.
78 * @param[in] - json file path
79 * @param[in] - Object path
80 * @return - Vpd file path
81 */
82inventory::VPDfilepath getVpdFilePath(const string& jsonFile,
83 const std::string& ObjPath);
84
85/**
86 * @brief isPathInJson
87 * API which checks for the presence of the given eeprom path in the given json.
88 * @param[in] - eepromPath
89 * @return - true if the eeprom is present in the json; false otherwise
90 */
91bool isPathInJson(const std::string& eepromPath);
92
93/**
94 * @brief isRecKwInDbusJson
95 * API which checks whether the given keyword under the given record is to be
96 * published on dbus or not. Checks against the keywords present in
97 * dbus_property.json.
98 * @param[in] - record name
99 * @param[in] - keyword name
100 * @return - true if the record-keyword pair is present in dbus_property.json;
101 * false otherwise.
102 */
103bool isRecKwInDbusJson(const std::string& record, const std::string& keyword);
104
Sunny Srivastava6c71c9d2021-04-15 04:43:54 -0500105/**
106 * @brief Check the type of VPD.
107 *
108 * Checks the type of vpd based on the start tag.
109 * @param[in] vector - Vpd data in vector format
110 *
111 * @return enum of type vpdType
112 */
113constants::vpdType vpdTypeCheck(const Binary& vector);
114
Patrick Venturec83c4dc2018-11-01 16:29:18 -0700115} // namespace vpd
116} // namespace openpower