blob: c5f359372bc8b2acd2c714d9335413c781bc9ee4 [file] [log] [blame]
Deepak Kodihalli76794492017-02-16 23:48:18 -06001#pragma once
2
SunnySrivastava1984f6d541e2020-02-04 12:50:40 -06003#include "const.hpp"
Alpana Kumarif05effd2021-04-07 07:32:53 -05004#include "store.hpp"
Deepak Kodihalli76794492017-02-16 23:48:18 -06005#include "types.hpp"
6
Alpana Kumari735dee92022-03-25 01:24:40 -05007#include <nlohmann/json.hpp>
Patrick Williamsc78d8872023-05-10 07:50:56 -05008
9#include <iostream>
Santosh Puranik53b38ed2022-04-10 23:15:22 +053010#include <optional>
GiridhariKrishnan63639102023-03-02 05:55:47 -060011#include <variant>
SunnySrivastava1984d076da82020-03-05 05:33:35 -060012
Deepak Kodihalli76794492017-02-16 23:48:18 -060013namespace openpower
14{
15namespace vpd
16{
SunnySrivastava1984945a02d2020-05-06 01:55:41 -050017
Priyanga Ramasamy952d6c52022-11-07 07:20:24 -060018// Map which holds system vpd keywords which can be restored at standby and via
19// vpd-tool and also can be used to reset keywords to its defaults at
20// manufacturing. The list of keywords for VSYS record is as per the S0 system.
21// Should be updated for another type of systems For those keywords whose
22// default value is system specific, the default value field is left empty.
23// Record : {Keyword, Default value, Is PEL required on restore failure, Is MFG
Kantesh Nagaradder38ee9c82023-04-07 00:58:12 -050024// reset required, backupVpdRecName, backupVpdKwName}
Priyanga Ramasamy952d6c52022-11-07 07:20:24 -060025static const inventory::SystemKeywordsMap svpdKwdMap{
26 {"VSYS",
Kantesh Nagaradder38ee9c82023-04-07 00:58:12 -050027 {inventory::SystemKeywordInfo("BR", Binary(2, 0x20), true, true, "VSBK",
28 "BR"),
29 inventory::SystemKeywordInfo("TM", Binary(8, 0x20), true, true, "VSBK",
30 "TM"),
31 inventory::SystemKeywordInfo("SE", Binary(7, 0x20), true, true, "VSBK",
32 "SE"),
33 inventory::SystemKeywordInfo("SU", Binary(6, 0x20), true, true, "VSBK",
34 "SU"),
35 inventory::SystemKeywordInfo("RB", Binary(4, 0x20), true, true, "VSBK",
36 "RB"),
37 inventory::SystemKeywordInfo("WN", Binary(12, 0x20), true, true, "VSBK",
38 "WN"),
39 inventory::SystemKeywordInfo("RG", Binary(4, 0x20), true, true, "VSBK",
40 "RG"),
41 inventory::SystemKeywordInfo("FV", Binary(32, 0x20), false, true, "VSBK",
42 "FV")}},
Priyanga Ramasamy952d6c52022-11-07 07:20:24 -060043 {"VCEN",
Kantesh Nagaradder38ee9c82023-04-07 00:58:12 -050044 {inventory::SystemKeywordInfo("FC", Binary(), true, false, "VSBK", "FC"),
45 inventory::SystemKeywordInfo("SE", Binary(7, 0x20), true, true, "VSBK",
46 "ES")}},
47 {"LXR0",
48 {inventory::SystemKeywordInfo("LX", Binary(), true, false, "VSBK", "LX")}},
Priyanga Ramasamy952d6c52022-11-07 07:20:24 -060049 {"UTIL",
Kantesh Nagaradder38ee9c82023-04-07 00:58:12 -050050 {inventory::SystemKeywordInfo("D0", Binary(1, 0x00), true, true, "VSBK",
51 "D0"),
52 inventory::SystemKeywordInfo("F5", Binary(16, 0x00), false, true, "VSBK",
53 "F5"),
54 inventory::SystemKeywordInfo("F6", Binary(16, 0x00), false, true, "VSBK",
55 "F6")}}};
Santosh Puranik6b2b5372022-06-02 20:49:02 +053056
Santosh Puranikbd011b22020-01-23 04:05:25 -060057/** @brief Return the hex representation of the incoming byte
58 *
59 * @param [in] c - The input byte
60 * @returns The hex representation of the byte as a character.
61 */
62constexpr auto toHex(size_t c)
63{
64 constexpr auto map = "0123456789abcdef";
65 return map[c];
66}
Deepak Kodihalli76794492017-02-16 23:48:18 -060067
68namespace inventory
69{
PriyangaRamasamyc2fe40f2021-03-02 06:27:33 -060070/** @brief API to obtain a dictionary of path -> services
SunnySrivastava19849094d4f2020-08-05 09:32:29 -050071 * where path is in subtree and services is of the type
72 * returned by the GetObject method.
73 *
74 * @param [in] root - Root path for object subtree
75 * @param [in] depth - Maximum subtree depth required
76 * @param [in] interfaces - Array to interfaces for which
77 * result is required.
78 * @return A dictionary of Path -> services
79 */
80MapperResponse
81 getObjectSubtreeForInterfaces(const std::string& root, const int32_t depth,
82 const std::vector<std::string>& interfaces);
83
Deepak Kodihalli76794492017-02-16 23:48:18 -060084} // namespace inventory
85
SunnySrivastava1984f6d541e2020-02-04 12:50:40 -060086/**@brief This API reads 2 Bytes of data and swap the read data
87 * @param[in] iterator- Pointer pointing to the data to be read
88 * @return returns 2 Byte data read at the given pointer
89 */
90openpower::vpd::constants::LE2ByteData
91 readUInt16LE(Binary::const_iterator iterator);
92
SunnySrivastava1984d076da82020-03-05 05:33:35 -060093/** @brief Encodes a keyword for D-Bus.
94 * @param[in] kw - kwd data in string format
95 * @param[in] encoding - required for kwd data
96 */
Priyanga Ramasamye0084322022-09-27 06:28:33 -050097std::string encodeKeyword(const std::string& kw, const std::string& encoding);
SunnySrivastava198443306542020-04-01 02:50:20 -050098
99/** @brief Reads a property from the inventory manager given object path,
100 * intreface and property.
101 * @param[in] obj - object path
102 * @param[in] inf - interface
103 * @param[in] prop - property whose value is fetched
104 * @return [out] - value of the property
105 */
Priyanga Ramasamye0084322022-09-27 06:28:33 -0500106std::string readBusProperty(const std::string& obj, const std::string& inf,
107 const std::string& prop);
SunnySrivastava1984a20be8e2020-08-26 02:00:50 -0500108
Priyanga Ramasamyf1449cd2022-07-13 04:28:30 -0500109/** @brief A templated function to read D-Bus properties.
110 *
111 * @param[in] service - Service path
112 * @param[in] object - object path
113 * @param[in] inf - interface
114 * @param[in] prop - property whose value is fetched
115 * @return The property value of its own type.
116 */
117template <typename T>
Priyanga Ramasamye0084322022-09-27 06:28:33 -0500118T readDBusProperty(const std::string& service, const std::string& object,
119 const std::string& inf, const std::string& prop)
Priyanga Ramasamyf1449cd2022-07-13 04:28:30 -0500120{
121 T retVal{};
122 try
123 {
124 auto bus = sdbusplus::bus::new_default();
Patrick Williamsc78d8872023-05-10 07:50:56 -0500125 auto properties = bus.new_method_call(service.c_str(), object.c_str(),
126 "org.freedesktop.DBus.Properties",
127 "Get");
Priyanga Ramasamyf1449cd2022-07-13 04:28:30 -0500128 properties.append(inf);
129 properties.append(prop);
130 auto result = bus.call(properties);
131 result.read(retVal);
132 }
133 catch (const sdbusplus::exception::SdBusError& e)
134 {
135 std::cerr << e.what();
136 }
137 return retVal;
138}
139
Priyanga Ramasamy43ffcf72022-06-08 14:10:11 -0500140/** @brief A templated method to get all D-Bus properties
141 *
142 * @param[in] service - Service path
143 * @param[in] object - Object path
144 * @param[in] inf - Interface
145 *
146 * @return All properties under the given interface.
147 */
148template <typename T>
149T getAllDBusProperty(const std::string& service, const std::string& object,
150 const std::string& inf)
151{
152 T retVal{};
153 try
154 {
155 auto bus = sdbusplus::bus::new_default();
156 auto allProperties =
157 bus.new_method_call(service.c_str(), object.c_str(),
158 "org.freedesktop.DBus.Properties", "GetAll");
159 allProperties.append(inf);
160
161 auto result = bus.call(allProperties);
162 result.read(retVal);
163 }
164 catch (const sdbusplus::exception::SdBusError& e)
165 {
166 std::cerr << e.what();
167 }
168 return retVal;
169}
170
SunnySrivastava1984a20be8e2020-08-26 02:00:50 -0500171/**
172 * @brief API to create PEL entry
Sunny Srivastavaa2ddc962022-06-29 08:53:16 -0500173 * The api makes synchronous call to phosphor-logging create api.
Sunny Srivastava0746eee2021-03-22 13:36:54 -0500174 * @param[in] additionalData - Map holding the additional data
175 * @param[in] sev - Severity
176 * @param[in] errIntf - error interface
SunnySrivastava1984a20be8e2020-08-26 02:00:50 -0500177 */
Sunny Srivastavaa2ddc962022-06-29 08:53:16 -0500178void createSyncPEL(const std::map<std::string, std::string>& additionalData,
179 const constants::PelSeverity& sev,
180 const std::string& errIntf);
181
182/**
183 * @brief Api to create PEL.
184 * A wrapper api through which sync/async call to phosphor-logging create api
185 * can be made as and when required.
186 * sdBus as nullptr will result in sync call else async call will be made with
187 * just "DESCRIPTION" key/value pair in additional data.
188 * To make asyn call with more fields in additional data call
189 * "sd_bus_call_method_async" in place.
190 *
191 * @param[in] additionalData - Map of additional data.
192 * @param[in] sev - severity of the PEL.
193 * @param[in] errIntf - Error interface to be used in PEL.
194 * @param[in] sdBus - Pointer to Sd-Bus
195 */
SunnySrivastava1984a20be8e2020-08-26 02:00:50 -0500196void createPEL(const std::map<std::string, std::string>& additionalData,
Sunny Srivastavaa2ddc962022-06-29 08:53:16 -0500197 const constants::PelSeverity& sev, const std::string& errIntf,
198 sd_bus* sdBus);
SunnySrivastava19849094d4f2020-08-05 09:32:29 -0500199
PriyangaRamasamyc0a534f2020-08-24 21:29:18 +0530200/**
201 * @brief getVpdFilePath
202 * Get vpd file path corresponding to the given object path.
203 * @param[in] - json file path
204 * @param[in] - Object path
205 * @return - Vpd file path
206 */
Priyanga Ramasamye0084322022-09-27 06:28:33 -0500207inventory::VPDfilepath getVpdFilePath(const std::string& jsonFile,
PriyangaRamasamyc0a534f2020-08-24 21:29:18 +0530208 const std::string& ObjPath);
209
210/**
211 * @brief isPathInJson
212 * API which checks for the presence of the given eeprom path in the given json.
213 * @param[in] - eepromPath
214 * @return - true if the eeprom is present in the json; false otherwise
215 */
216bool isPathInJson(const std::string& eepromPath);
217
218/**
219 * @brief isRecKwInDbusJson
220 * API which checks whether the given keyword under the given record is to be
221 * published on dbus or not. Checks against the keywords present in
222 * dbus_property.json.
223 * @param[in] - record name
224 * @param[in] - keyword name
225 * @return - true if the record-keyword pair is present in dbus_property.json;
226 * false otherwise.
227 */
228bool isRecKwInDbusJson(const std::string& record, const std::string& keyword);
229
Sunny Srivastava6c71c9d2021-04-15 04:43:54 -0500230/**
231 * @brief Check the type of VPD.
232 *
233 * Checks the type of vpd based on the start tag.
234 * @param[in] vector - Vpd data in vector format
235 *
236 * @return enum of type vpdType
237 */
238constants::vpdType vpdTypeCheck(const Binary& vector);
239
SunnySrivastava19849a195542020-09-07 06:04:50 -0500240/*
241 * @brief This method does nothing. Just an empty function to return null
242 * at the end of variadic template args
243 */
Priyanga Ramasamye0084322022-09-27 06:28:33 -0500244inline std::string getCommand()
SunnySrivastava19849a195542020-09-07 06:04:50 -0500245{
246 return "";
247}
248
249/**
250 * @brief This function to arrange all arguments to make commandy
251 * @param[in] arguments to create the command
252 * @return cmd - command string
253 */
254template <typename T, typename... Types>
Priyanga Ramasamye0084322022-09-27 06:28:33 -0500255inline std::string getCommand(T arg1, Types... args)
SunnySrivastava19849a195542020-09-07 06:04:50 -0500256{
Priyanga Ramasamye0084322022-09-27 06:28:33 -0500257 std::string cmd = " " + arg1 + getCommand(args...);
SunnySrivastava19849a195542020-09-07 06:04:50 -0500258
259 return cmd;
260}
261
262/**
263 * @brief This API takes arguments, creates a shell command line and executes
264 * them.
265 * @param[in] arguments for command
266 * @returns output of that command
267 */
268template <typename T, typename... Types>
Priyanga Ramasamye0084322022-09-27 06:28:33 -0500269inline std::vector<std::string> executeCmd(T&& path, Types... args)
SunnySrivastava19849a195542020-09-07 06:04:50 -0500270{
Priyanga Ramasamye0084322022-09-27 06:28:33 -0500271 std::vector<std::string> stdOutput;
272 std::array<char, 128> buffer;
SunnySrivastava19849a195542020-09-07 06:04:50 -0500273
Priyanga Ramasamye0084322022-09-27 06:28:33 -0500274 std::string cmd = path + getCommand(args...);
SunnySrivastava19849a195542020-09-07 06:04:50 -0500275
Priyanga Ramasamye0084322022-09-27 06:28:33 -0500276 std::unique_ptr<FILE, decltype(&pclose)> pipe(popen(cmd.c_str(), "r"),
277 pclose);
SunnySrivastava19849a195542020-09-07 06:04:50 -0500278 if (!pipe)
279 {
Priyanga Ramasamye0084322022-09-27 06:28:33 -0500280 throw std::runtime_error("popen() failed!");
SunnySrivastava19849a195542020-09-07 06:04:50 -0500281 }
282 while (fgets(buffer.data(), buffer.size(), pipe.get()) != nullptr)
283 {
284 stdOutput.emplace_back(buffer.data());
285 }
286
287 return stdOutput;
288}
289
Alpana Kumarif05effd2021-04-07 07:32:53 -0500290/** @brief This API checks for IM and HW keywords, and based
291 * on these values decides which system json to be used.
292 * @param[in] vpdMap - parsed vpd
293 * @returns System json path
294 */
Priyanga Ramasamye0084322022-09-27 06:28:33 -0500295std::string getSystemsJson(const Parsed& vpdMap);
Alpana Kumarif05effd2021-04-07 07:32:53 -0500296
297/** @brief Reads HW Keyword from the vpd
298 * @param[in] vpdMap - parsed vpd
299 * @returns value of HW Keyword
300 */
Priyanga Ramasamye0084322022-09-27 06:28:33 -0500301const std::string getHW(const Parsed& vpdMap);
Alpana Kumarif05effd2021-04-07 07:32:53 -0500302
303/** @brief Reads IM Keyword from the vpd
304 * @param[in] vpdMap - parsed vpd
305 * @returns value of IM Keyword
306 */
Priyanga Ramasamye0084322022-09-27 06:28:33 -0500307const std::string getIM(const Parsed& vpdMap);
Alpana Kumarif05effd2021-04-07 07:32:53 -0500308
PriyangaRamasamy647868e2020-09-08 17:03:19 +0530309/** @brief Translate udev event generated path to a generic /sys/bus eeprom path
310 * @param[io] file - path generated from udev event.
jinuthomasf457a3e2023-04-13 12:22:48 -0500311 * @param[in] driver - kernel driver used by the device.
PriyangaRamasamy647868e2020-09-08 17:03:19 +0530312 */
jinuthomasf457a3e2023-04-13 12:22:48 -0500313void udevToGenericPath(std::string& file, const std::string& driver);
PriyangaRamasamyc2fe40f2021-03-02 06:27:33 -0600314
315/**
316 * @brief API to generate a vpd name in some pattern.
317 * This vpd-name denotes name of the bad vpd file.
318 * For i2c eeproms - the pattern of the vpd-name will be
319 * i2c-<bus-number>-<eeprom-address>. For spi eeproms - the pattern of the
320 * vpd-name will be spi-<spi-number>.
321 *
322 * @param[in] file - file path of the vpd
323 * @return the vpd-name.
324 */
Priyanga Ramasamye0084322022-09-27 06:28:33 -0500325std::string getBadVpdName(const std::string& file);
PriyangaRamasamyc2fe40f2021-03-02 06:27:33 -0600326
327/**
328 * @brief API which dumps the broken/bad vpd in a directory
329 * When the vpd is bad, this api places the bad vpd file inside
330 * "/tmp/bad-vpd" in BMC, in order to collect bad VPD data as a part of user
331 * initiated BMC dump.
332 *
333 * @param[in] file - bad vpd file path
334 * @param[in] vpdVector - bad vpd vector
335 */
336void dumpBadVpd(const std::string& file, const Binary& vpdVector);
alpana077ce68722021-07-25 13:23:59 -0500337
338/*
339 * @brief This function fetches the value for given keyword in the given record
340 * from vpd data and returns this value.
341 *
342 * @param[in] vpdMap - vpd to find out the data
343 * @param[in] rec - Record under which desired keyword exists
344 * @param[in] kwd - keyword to read the data from
345 *
346 * @returns keyword value if record/keyword combination found
347 * empty string if record or keyword is not found.
348 */
Priyanga Ramasamye0084322022-09-27 06:28:33 -0500349const std::string getKwVal(const Parsed& vpdMap, const std::string& rec,
350 const std::string& kwd);
alpana077ce68722021-07-25 13:23:59 -0500351
Alpana Kumarib17dd3b2020-10-01 00:18:10 -0500352/** @brief This creates a complete command using all it's input parameters,
353 * to bind or unbind the driver.
354 * @param[in] devNameAddr - device address on that bus
355 * @param[in] busType - i2c, spi
356 * @param[in] driverType - type of driver like at24
357 * @param[in] bindOrUnbind - either bind or unbind
358 * @returns Command to bind or unbind the driver.
359 */
Priyanga Ramasamye0084322022-09-27 06:28:33 -0500360inline std::string createBindUnbindDriverCmnd(const std::string& devNameAddr,
361 const std::string& busType,
362 const std::string& driverType,
363 const std::string& bindOrUnbind)
Alpana Kumarib17dd3b2020-10-01 00:18:10 -0500364{
365 return ("echo " + devNameAddr + " > /sys/bus/" + busType + "/drivers/" +
366 driverType + "/" + bindOrUnbind);
367}
368
Priyanga Ramasamy02434932021-10-07 16:26:05 -0500369/**
370 * @brief Get Printable Value
371 *
GiridhariKrishnan63639102023-03-02 05:55:47 -0600372 * Checks if the value has non printable characters.
Priyanga Ramasamy02434932021-10-07 16:26:05 -0500373 * Returns hex value if non printable char is found else
374 * returns ascii value.
375 *
GiridhariKrishnan63639102023-03-02 05:55:47 -0600376 * @param[in] kwVal - Reference of the input data, Keyword value
Priyanga Ramasamy02434932021-10-07 16:26:05 -0500377 * @return printable value - either in hex or in ascii.
378 */
GiridhariKrishnan63639102023-03-02 05:55:47 -0600379std::string getPrintableValue(const std::variant<Binary, std::string>& kwVal);
Priyanga Ramasamyc9ecf8e2021-10-08 02:28:52 -0500380
381/**
GiridhariKrishnan63639102023-03-02 05:55:47 -0600382 * @brief Convert array to hex string.
383 * @param[in] kwVal - input data, Keyword value
Priyanga Ramasamyc9ecf8e2021-10-08 02:28:52 -0500384 * @return hexadecimal string of bytes.
385 */
GiridhariKrishnan63639102023-03-02 05:55:47 -0600386std::string hexString(const std::variant<Binary, std::string>& kwVal);
Priyanga Ramasamy02434932021-10-07 16:26:05 -0500387
Priyanga Ramasamyaa8a8932022-01-27 09:12:41 -0600388/**
Santosh Puranik53b38ed2022-04-10 23:15:22 +0530389 * @brief Return presence of the FRU.
390 *
391 * This API returns the presence information of the FRU corresponding to the
392 * given EEPROM. If the JSON contains no information about presence detect, this
393 * will return an empty optional. Else it will get the presence GPIO information
394 * from the JSON and return the appropriate present status.
395 * In case of GPIO find/read errors, it will return false.
396 *
397 * @param[in] json - The VPD JSON
398 * @param[in] file - EEPROM file path
399 * @return Empty optional if there is no presence info. Else returns presence
400 * based on the GPIO read.
401 */
Priyanga Ramasamye0084322022-09-27 06:28:33 -0500402std::optional<bool> isPresent(const nlohmann::json& json,
403 const std::string& file);
Santosh Puranik53b38ed2022-04-10 23:15:22 +0530404
405/**
406 * @brief Performs any pre-action needed to get the FRU setup for
407 * collection.
Alpana Kumari735dee92022-03-25 01:24:40 -0500408 *
409 * @param[in] json - json object
410 * @param[in] file - eeprom file path
411 * @return - success or failure
412 */
Priyanga Ramasamye0084322022-09-27 06:28:33 -0500413bool executePreAction(const nlohmann::json& json, const std::string& file);
Alpana Kumari735dee92022-03-25 01:24:40 -0500414
415/**
416 * @brief This API will be called at the end of VPD collection to perform any
417 * post actions.
418 *
419 * @param[in] json - json object
420 * @param[in] file - eeprom file path
421 */
Priyanga Ramasamye0084322022-09-27 06:28:33 -0500422void executePostFailAction(const nlohmann::json& json, const std::string& file);
Alpana Kumari735dee92022-03-25 01:24:40 -0500423
424/**
Priyanga Ramasamyaa8a8932022-01-27 09:12:41 -0600425 * @brief Helper function to insert or merge in map.
426 *
427 * This method checks in the given inventory::InterfaceMap if the given
428 * interface key is existing or not. If the interface key already exists, given
429 * property map is inserted into it. If the key does'nt exist then given
430 * interface and property map pair is newly created. If the property present in
431 * propertymap already exist in the InterfaceMap, then the new property value is
432 * ignored.
433 *
434 * @param[in,out] map - map object of type inventory::InterfaceMap only.
435 * @param[in] interface - Interface name.
436 * @param[in] property - new property map that needs to be emplaced.
437 */
438void insertOrMerge(inventory::InterfaceMap& map,
439 const inventory::Interface& interface,
440 inventory::PropertyMap&& property);
441
Santosh Puranikf2d3b532022-04-19 06:44:07 -0500442/**
443 * @brief Utility API to set a D-Bus property
444 *
445 * This calls org.freedesktop.DBus.Properties;Set method with the supplied
446 * arguments
447 *
448 * @tparam T Template type of the D-Bus property
449 * @param service[in] - The D-Bus service name.
450 * @param object[in] - The D-Bus object on which the property is to be set.
451 * @param interface[in] - The D-Bus interface to which the property belongs.
452 * @param propertyName[in] - The name of the property to set.
453 * @param propertyValue[in] - The value of the property.
454 */
455template <typename T>
456void setBusProperty(const std::string& service, const std::string& object,
457 const std::string& interface,
458 const std::string& propertyName,
459 const std::variant<T>& propertyValue)
460{
461 try
462 {
463 auto bus = sdbusplus::bus::new_default();
Patrick Williamsc78d8872023-05-10 07:50:56 -0500464 auto method = bus.new_method_call(service.c_str(), object.c_str(),
465 "org.freedesktop.DBus.Properties",
466 "Set");
Santosh Puranikf2d3b532022-04-19 06:44:07 -0500467 method.append(interface);
468 method.append(propertyName);
469 method.append(propertyValue);
470
471 bus.call(method);
472 }
473 catch (const sdbusplus::exception::SdBusError& e)
474 {
475 std::cerr << e.what() << std::endl;
476 }
477}
478
479/**
480 * @brief Reads BIOS Attribute by name.
481 *
482 * @param attrName[in] - The BIOS attribute name.
483 * @return std::variant<int64_t, std::string> - The BIOS attribute value.
484 */
485std::variant<int64_t, std::string>
486 readBIOSAttribute(const std::string& attrName);
Priyanga Ramasamy335873f2022-05-18 01:31:54 -0500487
488/**
489 * @brief Returns the power state for chassis0
490 * @return The chassis power state.
491 */
492std::string getPowerState();
Santosh Puranik6b2b5372022-06-02 20:49:02 +0530493
494/**
495 * @brief Reads VPD from the supplied EEPROM
496 *
497 * This function reads the given VPD EEPROM file and returns its contents as a
498 * byte array. It handles any offsets into the file that need to be taken care
499 * of by looking up the VPD JSON for a possible offset key.
500 *
501 * @param js[in] - The VPD JSON Object
502 * @param file[in] - The path to the EEPROM to read
503 * @return A byte array containing the raw VPD.
504 */
505Binary getVpdDataInVector(const nlohmann::json& js, const std::string& file);
Priyanga Ramasamy5629fbc2023-03-01 08:17:19 -0600506
507/**
508 * @brief Get D-bus name for the keyword
509 * Some of the VPD keywords has different name in PIM when compared with its
510 * name from hardware. This method returns the D-bus name for the given keyword.
511 *
512 * @param[in] keyword - Keyword name
513 * @return D-bus name for the keyword
514 */
515std::string getDbusNameForThisKw(const std::string& keyword);
516
Patrick Venturec83c4dc2018-11-01 16:29:18 -0700517} // namespace vpd
Patrick Williamsc78d8872023-05-10 07:50:56 -0500518} // namespace openpower