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 | */ |
Patrick Williams | c78d887 | 2023-05-10 07:50:56 -0500 | [diff] [blame] | 33 | memoryVpdParser(const Binary& VpdVector) : memVpd(VpdVector) {} |
SunnySrivastava1984 | e12b181 | 2020-05-26 02:23:11 -0500 | [diff] [blame] | 34 | |
| 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 Kumari | 3ab26a7 | 2021-04-05 19:09:19 +0000 | [diff] [blame] | 59 | /** |
Jinu Joy Thomas | db43bcd | 2023-08-17 09:40:16 +0530 | [diff] [blame] | 60 | * @brief This function calculates dimm size from DDIMM VPD |
Alpana Kumari | 3ab26a7 | 2021-04-05 19:09:19 +0000 | [diff] [blame] | 61 | * |
| 62 | * @param[in] iterator - iterator to buffer containing VPD |
| 63 | * @return calculated data or 0 in case of any error. |
| 64 | */ |
Jinu Joy Thomas | db43bcd | 2023-08-17 09:40:16 +0530 | [diff] [blame] | 65 | size_t getDDimmSize(Binary::const_iterator iterator); |
| 66 | |
| 67 | /** |
| 68 | * @brief This function calculates DDR4 based DDIMM's capacity |
| 69 | * |
| 70 | * @param[in] iterator - iterator to buffer containing VPD |
| 71 | * @return calculated data or 0 in case of any error. |
| 72 | */ |
| 73 | auto getDdr4BasedDDimmSize(Binary::const_iterator iterator); |
| 74 | |
| 75 | /** |
| 76 | * @brief This function calculates DDR5 based DDIMM's capacity |
| 77 | * |
| 78 | * @param[in] iterator - iterator to buffer containing VPD |
| 79 | * @return calculated data or 0 in case of any error. |
| 80 | */ |
| 81 | auto getDdr5BasedDDimmSize(Binary::const_iterator iterator); |
| 82 | |
| 83 | /** |
| 84 | * @brief This function calculates DDR5 based die per package |
| 85 | * |
| 86 | * @param[in] l_ByteValue - the bit value for calculation |
| 87 | * @return die per package value. |
| 88 | */ |
| 89 | uint8_t getDDR5DiePerPackage(uint8_t l_ByteValue); |
| 90 | |
| 91 | /** |
| 92 | * @brief This function calculates DDR5 based density per die |
| 93 | * |
| 94 | * @param[in] l_ByteValue - the bit value for calculation |
| 95 | * @return density per die. |
| 96 | */ |
| 97 | uint8_t getDDR5DensityPerDie(uint8_t l_ByteValue); |
| 98 | |
| 99 | /** |
| 100 | * @brief This function checks the validity of the bits |
| 101 | * |
| 102 | * @param[in] l_ByteValue - the byte value with relevant bits |
| 103 | * @param[in] shift - shifter value to selects needed bits |
| 104 | * @param[in] minValue - minimum value it can contain |
| 105 | * @param[in] maxValue - maximum value it can contain |
| 106 | * @return true if valid else false. |
| 107 | */ |
| 108 | bool checkValidValue(uint8_t l_ByteValue, uint8_t shift, uint8_t minValue, |
| 109 | uint8_t maxValue); |
Alpana Kumari | 3ab26a7 | 2021-04-05 19:09:19 +0000 | [diff] [blame] | 110 | |
SunnySrivastava1984 | e12b181 | 2020-05-26 02:23:11 -0500 | [diff] [blame] | 111 | // vdp file to be parsed |
PriyangaRamasamy | 33c61c2 | 2021-04-06 11:15:57 -0500 | [diff] [blame] | 112 | const Binary& memVpd; |
SunnySrivastava1984 | e12b181 | 2020-05-26 02:23:11 -0500 | [diff] [blame] | 113 | }; |
| 114 | } // namespace parser |
| 115 | } // namespace memory |
| 116 | } // namespace vpd |
Patrick Williams | c78d887 | 2023-05-10 07:50:56 -0500 | [diff] [blame] | 117 | } // namespace openpower |