Deepak Kodihalli | 7679449 | 2017-02-16 23:48:18 -0600 | [diff] [blame] | 1 | #pragma once |
| 2 | |
SunnySrivastava1984 | f6d541e | 2020-02-04 12:50:40 -0600 | [diff] [blame] | 3 | #include "const.hpp" |
Deepak Kodihalli | 7679449 | 2017-02-16 23:48:18 -0600 | [diff] [blame] | 4 | #include "types.hpp" |
| 5 | |
SunnySrivastava1984 | d076da8 | 2020-03-05 05:33:35 -0600 | [diff] [blame] | 6 | #include <iostream> |
| 7 | |
| 8 | using namespace std; |
Deepak Kodihalli | 7679449 | 2017-02-16 23:48:18 -0600 | [diff] [blame] | 9 | namespace openpower |
| 10 | { |
| 11 | namespace vpd |
| 12 | { |
SunnySrivastava1984 | 945a02d | 2020-05-06 01:55:41 -0500 | [diff] [blame] | 13 | /** |
| 14 | * @brief Types of VPD |
| 15 | */ |
| 16 | enum 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 | */ |
| 32 | vpdType vpdTypeCheck(const Binary& vector); |
| 33 | |
Santosh Puranik | bd011b2 | 2020-01-23 04:05:25 -0600 | [diff] [blame] | 34 | /** @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 | */ |
| 39 | constexpr auto toHex(size_t c) |
| 40 | { |
| 41 | constexpr auto map = "0123456789abcdef"; |
| 42 | return map[c]; |
| 43 | } |
Deepak Kodihalli | 7679449 | 2017-02-16 23:48:18 -0600 | [diff] [blame] | 44 | |
| 45 | namespace inventory |
| 46 | { |
| 47 | |
| 48 | /** @brief Get inventory-manager's d-bus service |
| 49 | */ |
| 50 | auto getPIMService(); |
| 51 | |
| 52 | /** @brief Call inventory-manager to add objects |
| 53 | * |
| 54 | * @param [in] objects - Map of inventory object paths |
| 55 | */ |
| 56 | void callPIM(ObjectMap&& objects); |
| 57 | |
| 58 | } // namespace inventory |
| 59 | |
SunnySrivastava1984 | f6d541e | 2020-02-04 12:50:40 -0600 | [diff] [blame] | 60 | /**@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 | */ |
| 64 | openpower::vpd::constants::LE2ByteData |
| 65 | readUInt16LE(Binary::const_iterator iterator); |
| 66 | |
SunnySrivastava1984 | d076da8 | 2020-03-05 05:33:35 -0600 | [diff] [blame] | 67 | /** @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 | */ |
| 71 | string encodeKeyword(const string& kw, const string& encoding); |
SunnySrivastava1984 | 4330654 | 2020-04-01 02:50:20 -0500 | [diff] [blame] | 72 | |
| 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 | */ |
| 80 | string readBusProperty(const string& obj, const string& inf, |
| 81 | const string& prop); |
Patrick Venture | c83c4dc | 2018-11-01 16:29:18 -0700 | [diff] [blame] | 82 | } // namespace vpd |
| 83 | } // namespace openpower |