blob: 5c2a251eb9f494df0de60e494298efdca77228ea [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",
Sunny Srivastavaf9162682023-08-28 01:42:45 -050044 {inventory::SystemKeywordInfo("FC", Binary(8, 0x20), true, false, "VSBK",
45 "FC"),
Kantesh Nagaradder38ee9c82023-04-07 00:58:12 -050046 inventory::SystemKeywordInfo("SE", Binary(7, 0x20), true, true, "VSBK",
47 "ES")}},
48 {"LXR0",
Sunny Srivastavaf9162682023-08-28 01:42:45 -050049 {inventory::SystemKeywordInfo("LX", Binary(8, 0x00), true, false, "VSBK",
50 "LX")}},
Priyanga Ramasamy952d6c52022-11-07 07:20:24 -060051 {"UTIL",
Kantesh Nagaradder38ee9c82023-04-07 00:58:12 -050052 {inventory::SystemKeywordInfo("D0", Binary(1, 0x00), true, true, "VSBK",
53 "D0"),
girik964db562023-05-05 03:09:18 -050054 inventory::SystemKeywordInfo("F0", Binary(8, 0x00), false, true, "VSBK",
55 "F0"),
Kantesh Nagaradder38ee9c82023-04-07 00:58:12 -050056 inventory::SystemKeywordInfo("F5", Binary(16, 0x00), false, true, "VSBK",
57 "F5"),
58 inventory::SystemKeywordInfo("F6", Binary(16, 0x00), false, true, "VSBK",
59 "F6")}}};
Santosh Puranik6b2b5372022-06-02 20:49:02 +053060
Santosh Puranikbd011b22020-01-23 04:05:25 -060061/** @brief Return the hex representation of the incoming byte
62 *
63 * @param [in] c - The input byte
64 * @returns The hex representation of the byte as a character.
65 */
66constexpr auto toHex(size_t c)
67{
68 constexpr auto map = "0123456789abcdef";
69 return map[c];
70}
Deepak Kodihalli76794492017-02-16 23:48:18 -060071
72namespace inventory
73{
PriyangaRamasamyc2fe40f2021-03-02 06:27:33 -060074/** @brief API to obtain a dictionary of path -> services
SunnySrivastava19849094d4f2020-08-05 09:32:29 -050075 * where path is in subtree and services is of the type
76 * returned by the GetObject method.
77 *
78 * @param [in] root - Root path for object subtree
79 * @param [in] depth - Maximum subtree depth required
80 * @param [in] interfaces - Array to interfaces for which
81 * result is required.
82 * @return A dictionary of Path -> services
83 */
84MapperResponse
85 getObjectSubtreeForInterfaces(const std::string& root, const int32_t depth,
86 const std::vector<std::string>& interfaces);
87
Deepak Kodihalli76794492017-02-16 23:48:18 -060088} // namespace inventory
89
SunnySrivastava1984f6d541e2020-02-04 12:50:40 -060090/**@brief This API reads 2 Bytes of data and swap the read data
91 * @param[in] iterator- Pointer pointing to the data to be read
92 * @return returns 2 Byte data read at the given pointer
93 */
94openpower::vpd::constants::LE2ByteData
95 readUInt16LE(Binary::const_iterator iterator);
96
SunnySrivastava1984d076da82020-03-05 05:33:35 -060097/** @brief Encodes a keyword for D-Bus.
98 * @param[in] kw - kwd data in string format
99 * @param[in] encoding - required for kwd data
100 */
Priyanga Ramasamye0084322022-09-27 06:28:33 -0500101std::string encodeKeyword(const std::string& kw, const std::string& encoding);
SunnySrivastava198443306542020-04-01 02:50:20 -0500102
103/** @brief Reads a property from the inventory manager given object path,
104 * intreface and property.
105 * @param[in] obj - object path
106 * @param[in] inf - interface
107 * @param[in] prop - property whose value is fetched
108 * @return [out] - value of the property
109 */
Priyanga Ramasamye0084322022-09-27 06:28:33 -0500110std::string readBusProperty(const std::string& obj, const std::string& inf,
111 const std::string& prop);
SunnySrivastava1984a20be8e2020-08-26 02:00:50 -0500112
Priyanga Ramasamyf1449cd2022-07-13 04:28:30 -0500113/** @brief A templated function to read D-Bus properties.
114 *
115 * @param[in] service - Service path
116 * @param[in] object - object path
117 * @param[in] inf - interface
118 * @param[in] prop - property whose value is fetched
119 * @return The property value of its own type.
120 */
121template <typename T>
Priyanga Ramasamye0084322022-09-27 06:28:33 -0500122T readDBusProperty(const std::string& service, const std::string& object,
123 const std::string& inf, const std::string& prop)
Priyanga Ramasamyf1449cd2022-07-13 04:28:30 -0500124{
125 T retVal{};
126 try
127 {
128 auto bus = sdbusplus::bus::new_default();
Patrick Williamsc78d8872023-05-10 07:50:56 -0500129 auto properties = bus.new_method_call(service.c_str(), object.c_str(),
130 "org.freedesktop.DBus.Properties",
131 "Get");
Priyanga Ramasamyf1449cd2022-07-13 04:28:30 -0500132 properties.append(inf);
133 properties.append(prop);
134 auto result = bus.call(properties);
135 result.read(retVal);
136 }
137 catch (const sdbusplus::exception::SdBusError& e)
138 {
139 std::cerr << e.what();
140 }
141 return retVal;
142}
143
Priyanga Ramasamy43ffcf72022-06-08 14:10:11 -0500144/** @brief A templated method to get all D-Bus properties
145 *
146 * @param[in] service - Service path
147 * @param[in] object - Object path
148 * @param[in] inf - Interface
149 *
150 * @return All properties under the given interface.
151 */
152template <typename T>
153T getAllDBusProperty(const std::string& service, const std::string& object,
154 const std::string& inf)
155{
156 T retVal{};
157 try
158 {
159 auto bus = sdbusplus::bus::new_default();
160 auto allProperties =
161 bus.new_method_call(service.c_str(), object.c_str(),
162 "org.freedesktop.DBus.Properties", "GetAll");
163 allProperties.append(inf);
164
165 auto result = bus.call(allProperties);
166 result.read(retVal);
167 }
168 catch (const sdbusplus::exception::SdBusError& e)
169 {
170 std::cerr << e.what();
171 }
172 return retVal;
173}
174
SunnySrivastava1984a20be8e2020-08-26 02:00:50 -0500175/**
176 * @brief API to create PEL entry
Sunny Srivastavaa2ddc962022-06-29 08:53:16 -0500177 * The api makes synchronous call to phosphor-logging create api.
Sunny Srivastava0746eee2021-03-22 13:36:54 -0500178 * @param[in] additionalData - Map holding the additional data
179 * @param[in] sev - Severity
180 * @param[in] errIntf - error interface
SunnySrivastava1984a20be8e2020-08-26 02:00:50 -0500181 */
Sunny Srivastavaa2ddc962022-06-29 08:53:16 -0500182void createSyncPEL(const std::map<std::string, std::string>& additionalData,
183 const constants::PelSeverity& sev,
184 const std::string& errIntf);
185
186/**
187 * @brief Api to create PEL.
188 * A wrapper api through which sync/async call to phosphor-logging create api
189 * can be made as and when required.
190 * sdBus as nullptr will result in sync call else async call will be made with
191 * just "DESCRIPTION" key/value pair in additional data.
192 * To make asyn call with more fields in additional data call
193 * "sd_bus_call_method_async" in place.
194 *
195 * @param[in] additionalData - Map of additional data.
196 * @param[in] sev - severity of the PEL.
197 * @param[in] errIntf - Error interface to be used in PEL.
198 * @param[in] sdBus - Pointer to Sd-Bus
199 */
SunnySrivastava1984a20be8e2020-08-26 02:00:50 -0500200void createPEL(const std::map<std::string, std::string>& additionalData,
Sunny Srivastavaa2ddc962022-06-29 08:53:16 -0500201 const constants::PelSeverity& sev, const std::string& errIntf,
202 sd_bus* sdBus);
SunnySrivastava19849094d4f2020-08-05 09:32:29 -0500203
PriyangaRamasamyc0a534f2020-08-24 21:29:18 +0530204/**
205 * @brief getVpdFilePath
206 * Get vpd file path corresponding to the given object path.
207 * @param[in] - json file path
208 * @param[in] - Object path
209 * @return - Vpd file path
210 */
Priyanga Ramasamye0084322022-09-27 06:28:33 -0500211inventory::VPDfilepath getVpdFilePath(const std::string& jsonFile,
PriyangaRamasamyc0a534f2020-08-24 21:29:18 +0530212 const std::string& ObjPath);
213
214/**
215 * @brief isPathInJson
216 * API which checks for the presence of the given eeprom path in the given json.
217 * @param[in] - eepromPath
218 * @return - true if the eeprom is present in the json; false otherwise
219 */
220bool isPathInJson(const std::string& eepromPath);
221
222/**
223 * @brief isRecKwInDbusJson
224 * API which checks whether the given keyword under the given record is to be
225 * published on dbus or not. Checks against the keywords present in
226 * dbus_property.json.
227 * @param[in] - record name
228 * @param[in] - keyword name
229 * @return - true if the record-keyword pair is present in dbus_property.json;
230 * false otherwise.
231 */
232bool isRecKwInDbusJson(const std::string& record, const std::string& keyword);
233
Sunny Srivastava6c71c9d2021-04-15 04:43:54 -0500234/**
235 * @brief Check the type of VPD.
236 *
237 * Checks the type of vpd based on the start tag.
238 * @param[in] vector - Vpd data in vector format
239 *
240 * @return enum of type vpdType
241 */
242constants::vpdType vpdTypeCheck(const Binary& vector);
243
SunnySrivastava19849a195542020-09-07 06:04:50 -0500244/*
245 * @brief This method does nothing. Just an empty function to return null
246 * at the end of variadic template args
247 */
Priyanga Ramasamye0084322022-09-27 06:28:33 -0500248inline std::string getCommand()
SunnySrivastava19849a195542020-09-07 06:04:50 -0500249{
250 return "";
251}
252
253/**
254 * @brief This function to arrange all arguments to make commandy
255 * @param[in] arguments to create the command
256 * @return cmd - command string
257 */
258template <typename T, typename... Types>
Priyanga Ramasamye0084322022-09-27 06:28:33 -0500259inline std::string getCommand(T arg1, Types... args)
SunnySrivastava19849a195542020-09-07 06:04:50 -0500260{
Priyanga Ramasamye0084322022-09-27 06:28:33 -0500261 std::string cmd = " " + arg1 + getCommand(args...);
SunnySrivastava19849a195542020-09-07 06:04:50 -0500262
263 return cmd;
264}
265
266/**
267 * @brief This API takes arguments, creates a shell command line and executes
268 * them.
269 * @param[in] arguments for command
270 * @returns output of that command
271 */
272template <typename T, typename... Types>
Priyanga Ramasamye0084322022-09-27 06:28:33 -0500273inline std::vector<std::string> executeCmd(T&& path, Types... args)
SunnySrivastava19849a195542020-09-07 06:04:50 -0500274{
Priyanga Ramasamye0084322022-09-27 06:28:33 -0500275 std::vector<std::string> stdOutput;
276 std::array<char, 128> buffer;
SunnySrivastava19849a195542020-09-07 06:04:50 -0500277
Priyanga Ramasamye0084322022-09-27 06:28:33 -0500278 std::string cmd = path + getCommand(args...);
SunnySrivastava19849a195542020-09-07 06:04:50 -0500279
Priyanga Ramasamye0084322022-09-27 06:28:33 -0500280 std::unique_ptr<FILE, decltype(&pclose)> pipe(popen(cmd.c_str(), "r"),
281 pclose);
SunnySrivastava19849a195542020-09-07 06:04:50 -0500282 if (!pipe)
283 {
Priyanga Ramasamye0084322022-09-27 06:28:33 -0500284 throw std::runtime_error("popen() failed!");
SunnySrivastava19849a195542020-09-07 06:04:50 -0500285 }
286 while (fgets(buffer.data(), buffer.size(), pipe.get()) != nullptr)
287 {
288 stdOutput.emplace_back(buffer.data());
289 }
290
291 return stdOutput;
292}
293
Alpana Kumarif05effd2021-04-07 07:32:53 -0500294/** @brief This API checks for IM and HW keywords, and based
295 * on these values decides which system json to be used.
296 * @param[in] vpdMap - parsed vpd
297 * @returns System json path
298 */
Priyanga Ramasamye0084322022-09-27 06:28:33 -0500299std::string getSystemsJson(const Parsed& vpdMap);
Alpana Kumarif05effd2021-04-07 07:32:53 -0500300
301/** @brief Reads HW Keyword from the vpd
302 * @param[in] vpdMap - parsed vpd
303 * @returns value of HW Keyword
304 */
Priyanga Ramasamye0084322022-09-27 06:28:33 -0500305const std::string getHW(const Parsed& vpdMap);
Alpana Kumarif05effd2021-04-07 07:32:53 -0500306
307/** @brief Reads IM Keyword from the vpd
308 * @param[in] vpdMap - parsed vpd
309 * @returns value of IM Keyword
310 */
Priyanga Ramasamye0084322022-09-27 06:28:33 -0500311const std::string getIM(const Parsed& vpdMap);
Alpana Kumarif05effd2021-04-07 07:32:53 -0500312
PriyangaRamasamy647868e2020-09-08 17:03:19 +0530313/** @brief Translate udev event generated path to a generic /sys/bus eeprom path
314 * @param[io] file - path generated from udev event.
jinuthomasf457a3e2023-04-13 12:22:48 -0500315 * @param[in] driver - kernel driver used by the device.
PriyangaRamasamy647868e2020-09-08 17:03:19 +0530316 */
jinuthomasf457a3e2023-04-13 12:22:48 -0500317void udevToGenericPath(std::string& file, const std::string& driver);
PriyangaRamasamyc2fe40f2021-03-02 06:27:33 -0600318
319/**
320 * @brief API to generate a vpd name in some pattern.
321 * This vpd-name denotes name of the bad vpd file.
322 * For i2c eeproms - the pattern of the vpd-name will be
323 * i2c-<bus-number>-<eeprom-address>. For spi eeproms - the pattern of the
324 * vpd-name will be spi-<spi-number>.
325 *
326 * @param[in] file - file path of the vpd
327 * @return the vpd-name.
328 */
Priyanga Ramasamye0084322022-09-27 06:28:33 -0500329std::string getBadVpdName(const std::string& file);
PriyangaRamasamyc2fe40f2021-03-02 06:27:33 -0600330
331/**
332 * @brief API which dumps the broken/bad vpd in a directory
333 * When the vpd is bad, this api places the bad vpd file inside
334 * "/tmp/bad-vpd" in BMC, in order to collect bad VPD data as a part of user
335 * initiated BMC dump.
336 *
337 * @param[in] file - bad vpd file path
338 * @param[in] vpdVector - bad vpd vector
339 */
340void dumpBadVpd(const std::string& file, const Binary& vpdVector);
alpana077ce68722021-07-25 13:23:59 -0500341
342/*
343 * @brief This function fetches the value for given keyword in the given record
344 * from vpd data and returns this value.
345 *
346 * @param[in] vpdMap - vpd to find out the data
347 * @param[in] rec - Record under which desired keyword exists
348 * @param[in] kwd - keyword to read the data from
349 *
350 * @returns keyword value if record/keyword combination found
351 * empty string if record or keyword is not found.
352 */
Priyanga Ramasamye0084322022-09-27 06:28:33 -0500353const std::string getKwVal(const Parsed& vpdMap, const std::string& rec,
354 const std::string& kwd);
alpana077ce68722021-07-25 13:23:59 -0500355
Alpana Kumarib17dd3b2020-10-01 00:18:10 -0500356/** @brief This creates a complete command using all it's input parameters,
357 * to bind or unbind the driver.
358 * @param[in] devNameAddr - device address on that bus
359 * @param[in] busType - i2c, spi
360 * @param[in] driverType - type of driver like at24
361 * @param[in] bindOrUnbind - either bind or unbind
362 * @returns Command to bind or unbind the driver.
363 */
Priyanga Ramasamye0084322022-09-27 06:28:33 -0500364inline std::string createBindUnbindDriverCmnd(const std::string& devNameAddr,
365 const std::string& busType,
366 const std::string& driverType,
367 const std::string& bindOrUnbind)
Alpana Kumarib17dd3b2020-10-01 00:18:10 -0500368{
369 return ("echo " + devNameAddr + " > /sys/bus/" + busType + "/drivers/" +
370 driverType + "/" + bindOrUnbind);
371}
372
Priyanga Ramasamy02434932021-10-07 16:26:05 -0500373/**
374 * @brief Get Printable Value
375 *
GiridhariKrishnan63639102023-03-02 05:55:47 -0600376 * Checks if the value has non printable characters.
Priyanga Ramasamy02434932021-10-07 16:26:05 -0500377 * Returns hex value if non printable char is found else
378 * returns ascii value.
379 *
GiridhariKrishnan63639102023-03-02 05:55:47 -0600380 * @param[in] kwVal - Reference of the input data, Keyword value
Priyanga Ramasamy02434932021-10-07 16:26:05 -0500381 * @return printable value - either in hex or in ascii.
382 */
GiridhariKrishnan63639102023-03-02 05:55:47 -0600383std::string getPrintableValue(const std::variant<Binary, std::string>& kwVal);
Priyanga Ramasamyc9ecf8e2021-10-08 02:28:52 -0500384
385/**
GiridhariKrishnan63639102023-03-02 05:55:47 -0600386 * @brief Convert array to hex string.
387 * @param[in] kwVal - input data, Keyword value
Priyanga Ramasamyc9ecf8e2021-10-08 02:28:52 -0500388 * @return hexadecimal string of bytes.
389 */
GiridhariKrishnan63639102023-03-02 05:55:47 -0600390std::string hexString(const std::variant<Binary, std::string>& kwVal);
Priyanga Ramasamy02434932021-10-07 16:26:05 -0500391
Priyanga Ramasamyaa8a8932022-01-27 09:12:41 -0600392/**
Santosh Puranik53b38ed2022-04-10 23:15:22 +0530393 * @brief Return presence of the FRU.
394 *
395 * This API returns the presence information of the FRU corresponding to the
396 * given EEPROM. If the JSON contains no information about presence detect, this
397 * will return an empty optional. Else it will get the presence GPIO information
398 * from the JSON and return the appropriate present status.
399 * In case of GPIO find/read errors, it will return false.
400 *
401 * @param[in] json - The VPD JSON
402 * @param[in] file - EEPROM file path
403 * @return Empty optional if there is no presence info. Else returns presence
404 * based on the GPIO read.
405 */
Priyanga Ramasamye0084322022-09-27 06:28:33 -0500406std::optional<bool> isPresent(const nlohmann::json& json,
407 const std::string& file);
Santosh Puranik53b38ed2022-04-10 23:15:22 +0530408
409/**
410 * @brief Performs any pre-action needed to get the FRU setup for
411 * collection.
Alpana Kumari735dee92022-03-25 01:24:40 -0500412 *
413 * @param[in] json - json object
414 * @param[in] file - eeprom file path
415 * @return - success or failure
416 */
Priyanga Ramasamye0084322022-09-27 06:28:33 -0500417bool executePreAction(const nlohmann::json& json, const std::string& file);
Alpana Kumari735dee92022-03-25 01:24:40 -0500418
419/**
420 * @brief This API will be called at the end of VPD collection to perform any
421 * post actions.
422 *
423 * @param[in] json - json object
424 * @param[in] file - eeprom file path
425 */
Priyanga Ramasamye0084322022-09-27 06:28:33 -0500426void executePostFailAction(const nlohmann::json& json, const std::string& file);
Alpana Kumari735dee92022-03-25 01:24:40 -0500427
428/**
Priyanga Ramasamyaa8a8932022-01-27 09:12:41 -0600429 * @brief Helper function to insert or merge in map.
430 *
431 * This method checks in the given inventory::InterfaceMap if the given
432 * interface key is existing or not. If the interface key already exists, given
433 * property map is inserted into it. If the key does'nt exist then given
434 * interface and property map pair is newly created. If the property present in
435 * propertymap already exist in the InterfaceMap, then the new property value is
436 * ignored.
437 *
438 * @param[in,out] map - map object of type inventory::InterfaceMap only.
439 * @param[in] interface - Interface name.
440 * @param[in] property - new property map that needs to be emplaced.
441 */
442void insertOrMerge(inventory::InterfaceMap& map,
443 const inventory::Interface& interface,
444 inventory::PropertyMap&& property);
445
Santosh Puranikf2d3b532022-04-19 06:44:07 -0500446/**
447 * @brief Utility API to set a D-Bus property
448 *
449 * This calls org.freedesktop.DBus.Properties;Set method with the supplied
450 * arguments
451 *
452 * @tparam T Template type of the D-Bus property
453 * @param service[in] - The D-Bus service name.
454 * @param object[in] - The D-Bus object on which the property is to be set.
455 * @param interface[in] - The D-Bus interface to which the property belongs.
456 * @param propertyName[in] - The name of the property to set.
457 * @param propertyValue[in] - The value of the property.
458 */
459template <typename T>
460void setBusProperty(const std::string& service, const std::string& object,
461 const std::string& interface,
462 const std::string& propertyName,
463 const std::variant<T>& propertyValue)
464{
465 try
466 {
467 auto bus = sdbusplus::bus::new_default();
Patrick Williamsc78d8872023-05-10 07:50:56 -0500468 auto method = bus.new_method_call(service.c_str(), object.c_str(),
469 "org.freedesktop.DBus.Properties",
470 "Set");
Santosh Puranikf2d3b532022-04-19 06:44:07 -0500471 method.append(interface);
472 method.append(propertyName);
473 method.append(propertyValue);
474
475 bus.call(method);
476 }
477 catch (const sdbusplus::exception::SdBusError& e)
478 {
479 std::cerr << e.what() << std::endl;
480 }
481}
482
483/**
484 * @brief Reads BIOS Attribute by name.
485 *
486 * @param attrName[in] - The BIOS attribute name.
487 * @return std::variant<int64_t, std::string> - The BIOS attribute value.
488 */
489std::variant<int64_t, std::string>
490 readBIOSAttribute(const std::string& attrName);
Priyanga Ramasamy335873f2022-05-18 01:31:54 -0500491
492/**
493 * @brief Returns the power state for chassis0
494 * @return The chassis power state.
495 */
496std::string getPowerState();
Santosh Puranik6b2b5372022-06-02 20:49:02 +0530497
498/**
499 * @brief Reads VPD from the supplied EEPROM
500 *
501 * This function reads the given VPD EEPROM file and returns its contents as a
502 * byte array. It handles any offsets into the file that need to be taken care
503 * of by looking up the VPD JSON for a possible offset key.
504 *
505 * @param js[in] - The VPD JSON Object
506 * @param file[in] - The path to the EEPROM to read
507 * @return A byte array containing the raw VPD.
508 */
509Binary getVpdDataInVector(const nlohmann::json& js, const std::string& file);
Priyanga Ramasamy5629fbc2023-03-01 08:17:19 -0600510
511/**
512 * @brief Get D-bus name for the keyword
513 * Some of the VPD keywords has different name in PIM when compared with its
514 * name from hardware. This method returns the D-bus name for the given keyword.
515 *
516 * @param[in] keyword - Keyword name
517 * @return D-bus name for the keyword
518 */
519std::string getDbusNameForThisKw(const std::string& keyword);
520
Patrick Venturec83c4dc2018-11-01 16:29:18 -0700521} // namespace vpd
Patrick Williamsc78d8872023-05-10 07:50:56 -0500522} // namespace openpower