blob: 2c748ee94cada93cdd946494ded3b465184d1716 [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/**
15 * @brief Types of VPD
16 */
17enum vpdType
18{
19 IPZ_VPD, /**< IPZ VPD type */
20 KEYWORD_VPD, /**< Keyword VPD type */
21 MEMORY_VPD, /**< Memory VPD type */
22 INVALID_VPD_FORMAT /**< Invalid VPD type */
23};
24
25/**
26 * @brief Check the type of VPD.
27 *
28 * Checks the type of vpd based on the start tag.
29 * @param[in] vector - Vpd data in vector format
30 *
31 * @return enum of type vpdType
32 */
33vpdType vpdTypeCheck(const Binary& vector);
34
Santosh Puranikbd011b22020-01-23 04:05:25 -060035/** @brief Return the hex representation of the incoming byte
36 *
37 * @param [in] c - The input byte
38 * @returns The hex representation of the byte as a character.
39 */
40constexpr auto toHex(size_t c)
41{
42 constexpr auto map = "0123456789abcdef";
43 return map[c];
44}
Deepak Kodihalli76794492017-02-16 23:48:18 -060045
46namespace inventory
47{
48
SunnySrivastava19849094d4f2020-08-05 09:32:29 -050049/** @brief Api to Get d-bus service for given interface
50 * @param[in] - Bus object
51 * @param[in] - object path of the service
52 * @param[in] - interface under the object path
53 * @return service name
Deepak Kodihalli76794492017-02-16 23:48:18 -060054 */
SunnySrivastava19849094d4f2020-08-05 09:32:29 -050055std::string getService(sdbusplus::bus::bus& bus, const std::string& path,
56 const std::string& interface);
Deepak Kodihalli76794492017-02-16 23:48:18 -060057
58/** @brief Call inventory-manager to add objects
59 *
60 * @param [in] objects - Map of inventory object paths
61 */
62void callPIM(ObjectMap&& objects);
63
SunnySrivastava19849094d4f2020-08-05 09:32:29 -050064/** @brief Api to obtain a dictionary of path -> services
65 * where path is in subtree and services is of the type
66 * returned by the GetObject method.
67 *
68 * @param [in] root - Root path for object subtree
69 * @param [in] depth - Maximum subtree depth required
70 * @param [in] interfaces - Array to interfaces for which
71 * result is required.
72 * @return A dictionary of Path -> services
73 */
74MapperResponse
75 getObjectSubtreeForInterfaces(const std::string& root, const int32_t depth,
76 const std::vector<std::string>& interfaces);
77
Deepak Kodihalli76794492017-02-16 23:48:18 -060078} // namespace inventory
79
SunnySrivastava1984f6d541e2020-02-04 12:50:40 -060080/**@brief This API reads 2 Bytes of data and swap the read data
81 * @param[in] iterator- Pointer pointing to the data to be read
82 * @return returns 2 Byte data read at the given pointer
83 */
84openpower::vpd::constants::LE2ByteData
85 readUInt16LE(Binary::const_iterator iterator);
86
SunnySrivastava1984d076da82020-03-05 05:33:35 -060087/** @brief Encodes a keyword for D-Bus.
88 * @param[in] kw - kwd data in string format
89 * @param[in] encoding - required for kwd data
90 */
91string encodeKeyword(const string& kw, const string& encoding);
SunnySrivastava198443306542020-04-01 02:50:20 -050092
93/** @brief Reads a property from the inventory manager given object path,
94 * intreface and property.
95 * @param[in] obj - object path
96 * @param[in] inf - interface
97 * @param[in] prop - property whose value is fetched
98 * @return [out] - value of the property
99 */
100string readBusProperty(const string& obj, const string& inf,
101 const string& prop);
SunnySrivastava1984a20be8e2020-08-26 02:00:50 -0500102
103/**
104 * @brief API to create PEL entry
105 * @param[in] Map holding the additional data
106 * @param[in] error interface
107 */
108void createPEL(const std::map<std::string, std::string>& additionalData,
109 const std::string& errIntf);
SunnySrivastava19849094d4f2020-08-05 09:32:29 -0500110
Patrick Venturec83c4dc2018-11-01 16:29:18 -0700111} // namespace vpd
112} // namespace openpower