Alpana Kumari | a00936f | 2020-04-14 07:15:46 -0500 | [diff] [blame] | 1 | #include "memory_vpd_parser.hpp" |
| 2 | |
| 3 | #include <iostream> |
| 4 | #include <numeric> |
| 5 | #include <string> |
| 6 | |
| 7 | namespace openpower |
| 8 | { |
| 9 | namespace vpd |
| 10 | { |
| 11 | namespace memory |
| 12 | { |
| 13 | namespace parser |
| 14 | { |
| 15 | using namespace inventory; |
Alpana Kumari | a00936f | 2020-04-14 07:15:46 -0500 | [diff] [blame] | 16 | using namespace constants; |
| 17 | using namespace std; |
SunnySrivastava1984 | e12b181 | 2020-05-26 02:23:11 -0500 | [diff] [blame] | 18 | using namespace openpower::vpd::parser; |
Alpana Kumari | a00936f | 2020-04-14 07:15:46 -0500 | [diff] [blame] | 19 | |
SunnySrivastava1984 | e12b181 | 2020-05-26 02:23:11 -0500 | [diff] [blame] | 20 | kwdVpdMap memoryVpdParser::readKeywords(Binary::const_iterator iterator) |
Alpana Kumari | a00936f | 2020-04-14 07:15:46 -0500 | [diff] [blame] | 21 | { |
| 22 | KeywordVpdMap map{}; |
| 23 | |
Alpana Kumari | 80f1534 | 2020-06-09 07:41:02 -0500 | [diff] [blame] | 24 | Binary partNumber(iterator, iterator + PART_NUM_LEN); |
Alpana Kumari | a00936f | 2020-04-14 07:15:46 -0500 | [diff] [blame] | 25 | |
| 26 | advance(iterator, PART_NUM_LEN); |
Alpana Kumari | 80f1534 | 2020-06-09 07:41:02 -0500 | [diff] [blame] | 27 | Binary serialNumber(iterator, iterator + SERIAL_NUM_LEN); |
Alpana Kumari | a00936f | 2020-04-14 07:15:46 -0500 | [diff] [blame] | 28 | |
| 29 | advance(iterator, SERIAL_NUM_LEN); |
Alpana Kumari | 80f1534 | 2020-06-09 07:41:02 -0500 | [diff] [blame] | 30 | Binary ccin(iterator, iterator + CCIN_LEN); |
Alpana Kumari | a00936f | 2020-04-14 07:15:46 -0500 | [diff] [blame] | 31 | |
| 32 | map.emplace("PN", move(partNumber)); |
| 33 | map.emplace("SN", move(serialNumber)); |
| 34 | map.emplace("CC", move(ccin)); |
| 35 | |
| 36 | return map; |
| 37 | } |
| 38 | |
SunnySrivastava1984 | e12b181 | 2020-05-26 02:23:11 -0500 | [diff] [blame] | 39 | variant<kwdVpdMap, Store> memoryVpdParser::parse() |
Alpana Kumari | a00936f | 2020-04-14 07:15:46 -0500 | [diff] [blame] | 40 | { |
Alpana Kumari | a00936f | 2020-04-14 07:15:46 -0500 | [diff] [blame] | 41 | // Read the data and return the map |
| 42 | auto iterator = memVpd.cbegin(); |
| 43 | // point the iterator to DIMM data and skip "11S" |
| 44 | advance(iterator, MEMORY_VPD_DATA_START + 3); |
| 45 | |
| 46 | auto vpdDataMap = readKeywords(iterator); |
| 47 | |
| 48 | return vpdDataMap; |
| 49 | } |
| 50 | |
SunnySrivastava1984 | e12b181 | 2020-05-26 02:23:11 -0500 | [diff] [blame] | 51 | std::string memoryVpdParser::getInterfaceName() const |
| 52 | { |
| 53 | return memVpdInf; |
| 54 | } |
| 55 | |
Alpana Kumari | a00936f | 2020-04-14 07:15:46 -0500 | [diff] [blame] | 56 | } // namespace parser |
| 57 | } // namespace memory |
| 58 | } // namespace vpd |
| 59 | } // namespace openpower |