blob: 21a45b9f945091b2431f5d9aa2aa8b78a037773c [file] [log] [blame]
SunnySrivastava1984e12b1812020-05-26 02:23:11 -05001#pragma once
2
3#include "impl.hpp"
4#include "parser_interface.hpp"
5#include "types.hpp"
6
7namespace openpower
8{
9namespace vpd
10{
11namespace memory
12{
13namespace parser
14{
15using ParserInterface = openpower::vpd::parser::interface::ParserInterface;
16using kwdVpdMap = openpower::vpd::inventory::KeywordVpdMap;
17
18class 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 Kumari80f15342020-06-09 07:41:02 -050031 * Move memVpdVector to parser object's memVpdVector
SunnySrivastava1984e12b1812020-05-26 02:23:11 -050032 */
Patrick Williamsc78d8872023-05-10 07:50:56 -050033 memoryVpdParser(const Binary& VpdVector) : memVpd(VpdVector) {}
SunnySrivastava1984e12b1812020-05-26 02:23:11 -050034
35 /**
36 * @brief Parse the memory VPD binary data.
37 * Collects and emplace the keyword-value pairs in map.
38 *
39 * @return map of keyword:value
40 */
41 std::variant<kwdVpdMap, Store> parse();
42
43 /**
44 * @brief An api to return interface name with respect to
45 * publish data on cache
46 *
47 * @return - Interface name for that vpd type.
48 */
49 std::string getInterfaceName() const;
50
51 private:
52 /**
53 * @brief An api to read keywords.
54 *
55 * @return- map of kwd:value
56 */
57 kwdVpdMap readKeywords(Binary::const_iterator iterator);
58
Alpana Kumari3ab26a72021-04-05 19:09:19 +000059 /**
60 * @brief This function calculates dimm size from DIMM VPD
61 *
62 * @param[in] iterator - iterator to buffer containing VPD
63 * @return calculated data or 0 in case of any error.
64 */
65 auto getDimmSize(Binary::const_iterator iterator);
66
SunnySrivastava1984e12b1812020-05-26 02:23:11 -050067 // vdp file to be parsed
PriyangaRamasamy33c61c22021-04-06 11:15:57 -050068 const Binary& memVpd;
SunnySrivastava1984e12b1812020-05-26 02:23:11 -050069};
70} // namespace parser
71} // namespace memory
72} // namespace vpd
Patrick Williamsc78d8872023-05-10 07:50:56 -050073} // namespace openpower