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; |
SunnySrivastava1984 | 9094d4f | 2020-08-05 09:32:29 -0500 | [diff] [blame] | 9 | |
Deepak Kodihalli | 7679449 | 2017-02-16 23:48:18 -0600 | [diff] [blame] | 10 | namespace openpower |
| 11 | { |
| 12 | namespace vpd |
| 13 | { |
SunnySrivastava1984 | 945a02d | 2020-05-06 01:55:41 -0500 | [diff] [blame] | 14 | /** |
| 15 | * @brief Types of VPD |
| 16 | */ |
| 17 | enum 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 | */ |
| 33 | vpdType vpdTypeCheck(const Binary& vector); |
| 34 | |
Santosh Puranik | bd011b2 | 2020-01-23 04:05:25 -0600 | [diff] [blame] | 35 | /** @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 | */ |
| 40 | constexpr auto toHex(size_t c) |
| 41 | { |
| 42 | constexpr auto map = "0123456789abcdef"; |
| 43 | return map[c]; |
| 44 | } |
Deepak Kodihalli | 7679449 | 2017-02-16 23:48:18 -0600 | [diff] [blame] | 45 | |
| 46 | namespace inventory |
| 47 | { |
| 48 | |
SunnySrivastava1984 | 9094d4f | 2020-08-05 09:32:29 -0500 | [diff] [blame] | 49 | /** @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 Kodihalli | 7679449 | 2017-02-16 23:48:18 -0600 | [diff] [blame] | 54 | */ |
SunnySrivastava1984 | 9094d4f | 2020-08-05 09:32:29 -0500 | [diff] [blame] | 55 | std::string getService(sdbusplus::bus::bus& bus, const std::string& path, |
| 56 | const std::string& interface); |
Deepak Kodihalli | 7679449 | 2017-02-16 23:48:18 -0600 | [diff] [blame] | 57 | |
| 58 | /** @brief Call inventory-manager to add objects |
| 59 | * |
| 60 | * @param [in] objects - Map of inventory object paths |
| 61 | */ |
| 62 | void callPIM(ObjectMap&& objects); |
| 63 | |
SunnySrivastava1984 | 9094d4f | 2020-08-05 09:32:29 -0500 | [diff] [blame] | 64 | /** @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 | */ |
| 74 | MapperResponse |
| 75 | getObjectSubtreeForInterfaces(const std::string& root, const int32_t depth, |
| 76 | const std::vector<std::string>& interfaces); |
| 77 | |
Deepak Kodihalli | 7679449 | 2017-02-16 23:48:18 -0600 | [diff] [blame] | 78 | } // namespace inventory |
| 79 | |
SunnySrivastava1984 | f6d541e | 2020-02-04 12:50:40 -0600 | [diff] [blame] | 80 | /**@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 | */ |
| 84 | openpower::vpd::constants::LE2ByteData |
| 85 | readUInt16LE(Binary::const_iterator iterator); |
| 86 | |
SunnySrivastava1984 | d076da8 | 2020-03-05 05:33:35 -0600 | [diff] [blame] | 87 | /** @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 | */ |
| 91 | string encodeKeyword(const string& kw, const string& encoding); |
SunnySrivastava1984 | 4330654 | 2020-04-01 02:50:20 -0500 | [diff] [blame] | 92 | |
| 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 | */ |
| 100 | string readBusProperty(const string& obj, const string& inf, |
| 101 | const string& prop); |
SunnySrivastava1984 | a20be8e | 2020-08-26 02:00:50 -0500 | [diff] [blame] | 102 | |
| 103 | /** |
| 104 | * @brief API to create PEL entry |
| 105 | * @param[in] Map holding the additional data |
| 106 | * @param[in] error interface |
| 107 | */ |
| 108 | void createPEL(const std::map<std::string, std::string>& additionalData, |
| 109 | const std::string& errIntf); |
SunnySrivastava1984 | 9094d4f | 2020-08-05 09:32:29 -0500 | [diff] [blame] | 110 | |
Patrick Venture | c83c4dc | 2018-11-01 16:29:18 -0700 | [diff] [blame] | 111 | } // namespace vpd |
| 112 | } // namespace openpower |