blob: e431cd3910d4e6661528ca3b66bbd1b7bfc0eac5 [file] [log] [blame]
SunnySrivastava1984e12b1812020-05-26 02:23:11 -05001#pragma once
2
3#include "const.hpp"
4#include "parser_interface.hpp"
5#include "store.hpp"
6#include "types.hpp"
7
8#include <vector>
9
10namespace openpower
11{
12namespace vpd
13{
14namespace ipz
15{
16namespace parser
17{
18
19using ParserInterface = openpower::vpd::parser::interface::ParserInterface;
20using kwdVpdMap = openpower::vpd::inventory::KeywordVpdMap;
21
22class IpzVpdParser : public ParserInterface
23{
24 public:
25 IpzVpdParser() = delete;
26 IpzVpdParser(const IpzVpdParser&) = delete;
27 IpzVpdParser& operator=(const IpzVpdParser&) = delete;
28 IpzVpdParser(IpzVpdParser&&) = delete;
29 IpzVpdParser& operator=(IpzVpdParser&&) = delete;
30 ~IpzVpdParser() = default;
31
32 /**
33 * @brief Constructor
girik18bb9852022-11-16 05:48:13 -060034 * @param[in] - VpdVector - vpd buffer
35 * @param[in] - path - Inventory Path
36 * @param[in] - vpdFilePath - VPD H/w path
37 * @param[in] - vpdStartOffset - VPD starting offset
SunnySrivastava1984e12b1812020-05-26 02:23:11 -050038 */
girik18bb9852022-11-16 05:48:13 -060039 IpzVpdParser(const Binary& VpdVector, const std::string& path,
40 const std::string& vpdFilePath, uint32_t vpdStartOffset) :
41 vpd(VpdVector),
42 inventoryPath(path), vpdFilePath(vpdFilePath),
43 vpdStartOffset(vpdStartOffset)
SunnySrivastava1984e12b1812020-05-26 02:23:11 -050044 {
45 }
46
47 /**
48 * @brief Parse the memory VPD binary data.
49 * Collects and emplace the keyword-value pairs in map.
50 *
51 * @return map of keyword:value
52 */
53 std::variant<kwdVpdMap, Store> parse();
54
55 /**
56 * @brief An api to return interface name with respect to
57 * the parser selected.
58 *
59 * @return - Interface name for that vpd type.
60 */
61 std::string getInterfaceName() const;
62
63 /** @brief API to check vpd header
64 * @param [in] vpd - VPDheader in binary format
65 */
66 void processHeader();
67
68 private:
PriyangaRamasamy33c61c22021-04-06 11:15:57 -050069 const Binary& vpd;
Sunny Srivastavaf31a91b2022-06-09 08:11:29 -050070
71 /*Inventory path of the FRU */
72 const std::string inventoryPath;
girik18bb9852022-11-16 05:48:13 -060073
74 /* VPD Path */
75 const std::string vpdFilePath;
76
77 /* Offset */
78 uint32_t vpdStartOffset;
79
SunnySrivastava1984e12b1812020-05-26 02:23:11 -050080}; // class IpzVpdParser
81
82} // namespace parser
83} // namespace ipz
84} // namespace vpd
85} // namespace openpower