blob: 3793ae07779d8ce071e0fa70e9dbdae2d0638c47 [file] [log] [blame]
Alpana Kumaria00936f2020-04-14 07:15:46 -05001#include "memory_vpd_parser.hpp"
2
3#include <iostream>
4#include <numeric>
5#include <string>
6
7namespace openpower
8{
9namespace vpd
10{
11namespace memory
12{
13namespace parser
14{
15using namespace inventory;
Alpana Kumaria00936f2020-04-14 07:15:46 -050016using namespace constants;
17using namespace std;
SunnySrivastava1984e12b1812020-05-26 02:23:11 -050018using namespace openpower::vpd::parser;
Alpana Kumaria00936f2020-04-14 07:15:46 -050019
SunnySrivastava1984e12b1812020-05-26 02:23:11 -050020kwdVpdMap memoryVpdParser::readKeywords(Binary::const_iterator iterator)
Alpana Kumaria00936f2020-04-14 07:15:46 -050021{
22 KeywordVpdMap map{};
23
Alpana Kumari80f15342020-06-09 07:41:02 -050024 Binary partNumber(iterator, iterator + PART_NUM_LEN);
Alpana Kumaria00936f2020-04-14 07:15:46 -050025
26 advance(iterator, PART_NUM_LEN);
Alpana Kumari80f15342020-06-09 07:41:02 -050027 Binary serialNumber(iterator, iterator + SERIAL_NUM_LEN);
Alpana Kumaria00936f2020-04-14 07:15:46 -050028
29 advance(iterator, SERIAL_NUM_LEN);
Alpana Kumari80f15342020-06-09 07:41:02 -050030 Binary ccin(iterator, iterator + CCIN_LEN);
Alpana Kumaria00936f2020-04-14 07:15:46 -050031
32 map.emplace("PN", move(partNumber));
33 map.emplace("SN", move(serialNumber));
34 map.emplace("CC", move(ccin));
35
36 return map;
37}
38
SunnySrivastava1984e12b1812020-05-26 02:23:11 -050039variant<kwdVpdMap, Store> memoryVpdParser::parse()
Alpana Kumaria00936f2020-04-14 07:15:46 -050040{
Alpana Kumaria00936f2020-04-14 07:15:46 -050041 // 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
SunnySrivastava1984e12b1812020-05-26 02:23:11 -050051std::string memoryVpdParser::getInterfaceName() const
52{
53 return memVpdInf;
54}
55
Alpana Kumaria00936f2020-04-14 07:15:46 -050056} // namespace parser
57} // namespace memory
58} // namespace vpd
59} // namespace openpower