SunnySrivastava1984 | e12b181 | 2020-05-26 02:23:11 -0500 | [diff] [blame] | 1 | #pragma once |
| 2 | |
| 3 | #include "impl.hpp" |
| 4 | #include "parser_interface.hpp" |
| 5 | #include "types.hpp" |
| 6 | |
| 7 | namespace openpower |
| 8 | { |
| 9 | namespace vpd |
| 10 | { |
| 11 | namespace memory |
| 12 | { |
| 13 | namespace parser |
| 14 | { |
| 15 | using ParserInterface = openpower::vpd::parser::interface::ParserInterface; |
| 16 | using kwdVpdMap = openpower::vpd::inventory::KeywordVpdMap; |
| 17 | |
| 18 | class memoryVpdParser : public ParserInterface |
| 19 | { |
| 20 | public: |
| 21 | memoryVpdParser() = delete; |
| 22 | memoryVpdParser(const memoryVpdParser&) = delete; |
| 23 | memoryVpdParser& operator=(const memoryVpdParser&) = delete; |
| 24 | memoryVpdParser(memoryVpdParser&&) = delete; |
| 25 | memoryVpdParser& operator=(memoryVpdParser&&) = delete; |
| 26 | ~memoryVpdParser() = default; |
| 27 | |
| 28 | /** |
| 29 | * @brief Constructor |
| 30 | * |
Alpana Kumari | 80f1534 | 2020-06-09 07:41:02 -0500 | [diff] [blame] | 31 | * Move memVpdVector to parser object's memVpdVector |
SunnySrivastava1984 | e12b181 | 2020-05-26 02:23:11 -0500 | [diff] [blame] | 32 | */ |
PriyangaRamasamy | 33c61c2 | 2021-04-06 11:15:57 -0500 | [diff] [blame] | 33 | memoryVpdParser(const Binary& VpdVector) : memVpd(VpdVector) |
SunnySrivastava1984 | e12b181 | 2020-05-26 02:23:11 -0500 | [diff] [blame] | 34 | { |
| 35 | } |
| 36 | |
| 37 | /** |
| 38 | * @brief Parse the memory VPD binary data. |
| 39 | * Collects and emplace the keyword-value pairs in map. |
| 40 | * |
| 41 | * @return map of keyword:value |
| 42 | */ |
| 43 | std::variant<kwdVpdMap, Store> parse(); |
| 44 | |
| 45 | /** |
| 46 | * @brief An api to return interface name with respect to |
| 47 | * publish data on cache |
| 48 | * |
| 49 | * @return - Interface name for that vpd type. |
| 50 | */ |
| 51 | std::string getInterfaceName() const; |
| 52 | |
| 53 | private: |
| 54 | /** |
| 55 | * @brief An api to read keywords. |
| 56 | * |
| 57 | * @return- map of kwd:value |
| 58 | */ |
| 59 | kwdVpdMap readKeywords(Binary::const_iterator iterator); |
| 60 | |
Alpana Kumari | 3ab26a7 | 2021-04-05 19:09:19 +0000 | [diff] [blame] | 61 | /** |
| 62 | * @brief This function calculates dimm size from DIMM VPD |
| 63 | * |
| 64 | * @param[in] iterator - iterator to buffer containing VPD |
| 65 | * @return calculated data or 0 in case of any error. |
| 66 | */ |
| 67 | auto getDimmSize(Binary::const_iterator iterator); |
| 68 | |
SunnySrivastava1984 | e12b181 | 2020-05-26 02:23:11 -0500 | [diff] [blame] | 69 | // vdp file to be parsed |
PriyangaRamasamy | 33c61c2 | 2021-04-06 11:15:57 -0500 | [diff] [blame] | 70 | const Binary& memVpd; |
SunnySrivastava1984 | e12b181 | 2020-05-26 02:23:11 -0500 | [diff] [blame] | 71 | }; |
| 72 | } // namespace parser |
| 73 | } // namespace memory |
| 74 | } // namespace vpd |
| 75 | } // namespace openpower |