1*fa5e4d32SSunny Srivastava #include "isdimm_parser.hpp"
2*fa5e4d32SSunny Srivastava
3*fa5e4d32SSunny Srivastava #include "constants.hpp"
4*fa5e4d32SSunny Srivastava #include "logger.hpp"
5*fa5e4d32SSunny Srivastava
6*fa5e4d32SSunny Srivastava #include <algorithm>
7*fa5e4d32SSunny Srivastava #include <iostream>
8*fa5e4d32SSunny Srivastava #include <numeric>
9*fa5e4d32SSunny Srivastava #include <optional>
10*fa5e4d32SSunny Srivastava #include <string>
11*fa5e4d32SSunny Srivastava #include <unordered_map>
12*fa5e4d32SSunny Srivastava
13*fa5e4d32SSunny Srivastava namespace vpd
14*fa5e4d32SSunny Srivastava {
15*fa5e4d32SSunny Srivastava
16*fa5e4d32SSunny Srivastava // Constants
17*fa5e4d32SSunny Srivastava constexpr auto SPD_JEDEC_DDR4_SDRAM_CAP_MASK = 0x0F;
18*fa5e4d32SSunny Srivastava constexpr auto SPD_JEDEC_DDR4_PRI_BUS_WIDTH_MASK = 0x07;
19*fa5e4d32SSunny Srivastava constexpr auto SPD_JEDEC_DDR4_SDRAM_WIDTH_MASK = 0x07;
20*fa5e4d32SSunny Srivastava constexpr auto SPD_JEDEC_DDR4_NUM_RANKS_MASK = 0x38;
21*fa5e4d32SSunny Srivastava constexpr auto SPD_JEDEC_DDR4_DIE_COUNT_MASK = 0x70;
22*fa5e4d32SSunny Srivastava constexpr auto SPD_JEDEC_DDR4_SINGLE_LOAD_STACK = 0x02;
23*fa5e4d32SSunny Srivastava constexpr auto SPD_JEDEC_DDR4_SIGNAL_LOADING_MASK = 0x03;
24*fa5e4d32SSunny Srivastava
25*fa5e4d32SSunny Srivastava constexpr auto SPD_JEDEC_DDR4_SDRAMCAP_MULTIPLIER = 256;
26*fa5e4d32SSunny Srivastava constexpr auto SPD_JEDEC_DDR4_PRI_BUS_WIDTH_MULTIPLIER = 8;
27*fa5e4d32SSunny Srivastava constexpr auto SPD_JEDEC_DDR4_SDRAM_WIDTH_MULTIPLIER = 4;
28*fa5e4d32SSunny Srivastava constexpr auto SPD_JEDEC_DDR4_SDRAMCAP_RESERVED = 8;
29*fa5e4d32SSunny Srivastava constexpr auto SPD_JEDEC_DDR4_4_RESERVED_BITS = 4;
30*fa5e4d32SSunny Srivastava constexpr auto SPD_JEDEC_DDR4_3_RESERVED_BITS = 3;
31*fa5e4d32SSunny Srivastava constexpr auto SPD_JEDEC_DDR4_DIE_COUNT_RIGHT_SHIFT = 4;
32*fa5e4d32SSunny Srivastava
33*fa5e4d32SSunny Srivastava constexpr auto SPD_JEDEC_DDR4_MFG_ID_MSB_OFFSET = 321;
34*fa5e4d32SSunny Srivastava constexpr auto SPD_JEDEC_DDR4_MFG_ID_LSB_OFFSET = 320;
35*fa5e4d32SSunny Srivastava constexpr auto SPD_JEDEC_DDR4_SN_BYTE0_OFFSET = 325;
36*fa5e4d32SSunny Srivastava constexpr auto SPD_JEDEC_DDR4_SN_BYTE1_OFFSET = 326;
37*fa5e4d32SSunny Srivastava constexpr auto SPD_JEDEC_DDR4_SN_BYTE2_OFFSET = 327;
38*fa5e4d32SSunny Srivastava constexpr auto SPD_JEDEC_DDR4_SN_BYTE3_OFFSET = 328;
39*fa5e4d32SSunny Srivastava constexpr auto SPD_JEDEC_DDR4_SDRAM_DENSITY_BANK_OFFSET = 4;
40*fa5e4d32SSunny Srivastava constexpr auto SPD_JEDEC_DDR4_SDRAM_ADDR_OFFSET = 5;
41*fa5e4d32SSunny Srivastava constexpr auto SPD_JEDEC_DDR4_DRAM_PRI_PACKAGE_OFFSET = 6;
42*fa5e4d32SSunny Srivastava constexpr auto SPD_JEDEC_DDR4_DRAM_MODULE_ORG_OFFSET = 12;
43*fa5e4d32SSunny Srivastava
44*fa5e4d32SSunny Srivastava // Lookup tables
45*fa5e4d32SSunny Srivastava const std::map<std::tuple<std::string, uint8_t>, std::string> pnFreqFnMap = {
46*fa5e4d32SSunny Srivastava {std::make_tuple("8421000", 6), "78P4191"},
47*fa5e4d32SSunny Srivastava {std::make_tuple("8421008", 6), "78P4192"},
48*fa5e4d32SSunny Srivastava {std::make_tuple("8529000", 6), "78P4197"},
49*fa5e4d32SSunny Srivastava {std::make_tuple("8529008", 6), "78P4198"},
50*fa5e4d32SSunny Srivastava {std::make_tuple("8529928", 6), "78P4199"},
51*fa5e4d32SSunny Srivastava {std::make_tuple("8529B28", 6), "78P4200"},
52*fa5e4d32SSunny Srivastava {std::make_tuple("8631928", 6), "78P6925"},
53*fa5e4d32SSunny Srivastava {std::make_tuple("8529000", 5), "78P7317"},
54*fa5e4d32SSunny Srivastava {std::make_tuple("8529008", 5), "78P7318"},
55*fa5e4d32SSunny Srivastava {std::make_tuple("8631008", 5), "78P6815"}};
56*fa5e4d32SSunny Srivastava
57*fa5e4d32SSunny Srivastava const std::unordered_map<std::string, std::string> pnCCINMap = {
58*fa5e4d32SSunny Srivastava {"78P4191", "324D"}, {"78P4192", "324E"}, {"78P4197", "324E"},
59*fa5e4d32SSunny Srivastava {"78P4198", "324F"}, {"78P4199", "325A"}, {"78P4200", "324C"},
60*fa5e4d32SSunny Srivastava {"78P6925", "32BC"}, {"78P7317", "331A"}, {"78P7318", "331F"},
61*fa5e4d32SSunny Srivastava {"78P6815", "32BB"}};
62*fa5e4d32SSunny Srivastava
getDDR4DimmCapacity(types::BinaryVector::const_iterator & i_iterator)63*fa5e4d32SSunny Srivastava auto JedecSpdParser::getDDR4DimmCapacity(
64*fa5e4d32SSunny Srivastava types::BinaryVector::const_iterator& i_iterator)
65*fa5e4d32SSunny Srivastava {
66*fa5e4d32SSunny Srivastava size_t l_tmp = 0, l_dimmSize = 0;
67*fa5e4d32SSunny Srivastava
68*fa5e4d32SSunny Srivastava size_t l_sdramCap = 1, l_priBusWid = 1, l_sdramWid = 1,
69*fa5e4d32SSunny Srivastava l_logicalRanksPerDimm = 1;
70*fa5e4d32SSunny Srivastava size_t l_dieCount = 1;
71*fa5e4d32SSunny Srivastava
72*fa5e4d32SSunny Srivastava // NOTE: This calculation is Only for DDR4
73*fa5e4d32SSunny Srivastava
74*fa5e4d32SSunny Srivastava // Calculate SDRAM capacity
75*fa5e4d32SSunny Srivastava l_tmp = i_iterator[constants::SPD_BYTE_4] & SPD_JEDEC_DDR4_SDRAM_CAP_MASK;
76*fa5e4d32SSunny Srivastava
77*fa5e4d32SSunny Srivastava /* Make sure the bits are not Reserved */
78*fa5e4d32SSunny Srivastava if (l_tmp >= SPD_JEDEC_DDR4_SDRAMCAP_RESERVED)
79*fa5e4d32SSunny Srivastava {
80*fa5e4d32SSunny Srivastava logging::logMessage(
81*fa5e4d32SSunny Srivastava "Bad data in spd byte 4. Can't calculate SDRAM capacity "
82*fa5e4d32SSunny Srivastava "and so dimm size.\n ");
83*fa5e4d32SSunny Srivastava return l_dimmSize;
84*fa5e4d32SSunny Srivastava }
85*fa5e4d32SSunny Srivastava l_sdramCap = (l_sdramCap << l_tmp) * SPD_JEDEC_DDR4_SDRAMCAP_MULTIPLIER;
86*fa5e4d32SSunny Srivastava
87*fa5e4d32SSunny Srivastava /* Calculate Primary bus width */
88*fa5e4d32SSunny Srivastava l_tmp = i_iterator[constants::SPD_BYTE_13] &
89*fa5e4d32SSunny Srivastava SPD_JEDEC_DDR4_PRI_BUS_WIDTH_MASK;
90*fa5e4d32SSunny Srivastava if (l_tmp >= SPD_JEDEC_DDR4_4_RESERVED_BITS)
91*fa5e4d32SSunny Srivastava {
92*fa5e4d32SSunny Srivastava logging::logMessage(
93*fa5e4d32SSunny Srivastava "Bad data in spd byte 13. Can't calculate primary bus "
94*fa5e4d32SSunny Srivastava "width and so dimm size.\n ");
95*fa5e4d32SSunny Srivastava return l_dimmSize;
96*fa5e4d32SSunny Srivastava }
97*fa5e4d32SSunny Srivastava l_priBusWid = (l_priBusWid << l_tmp) *
98*fa5e4d32SSunny Srivastava SPD_JEDEC_DDR4_PRI_BUS_WIDTH_MULTIPLIER;
99*fa5e4d32SSunny Srivastava
100*fa5e4d32SSunny Srivastava /* Calculate SDRAM width */
101*fa5e4d32SSunny Srivastava l_tmp = i_iterator[constants::SPD_BYTE_12] &
102*fa5e4d32SSunny Srivastava SPD_JEDEC_DDR4_SDRAM_WIDTH_MASK;
103*fa5e4d32SSunny Srivastava if (l_tmp >= SPD_JEDEC_DDR4_4_RESERVED_BITS)
104*fa5e4d32SSunny Srivastava {
105*fa5e4d32SSunny Srivastava logging::logMessage(
106*fa5e4d32SSunny Srivastava "Bad data in spd byte 12. Can't calculate SDRAM width and "
107*fa5e4d32SSunny Srivastava "so dimm size.\n ");
108*fa5e4d32SSunny Srivastava return l_dimmSize;
109*fa5e4d32SSunny Srivastava }
110*fa5e4d32SSunny Srivastava l_sdramWid = (l_sdramWid << l_tmp) * SPD_JEDEC_DDR4_SDRAM_WIDTH_MULTIPLIER;
111*fa5e4d32SSunny Srivastava
112*fa5e4d32SSunny Srivastava l_tmp = i_iterator[constants::SPD_BYTE_6] &
113*fa5e4d32SSunny Srivastava SPD_JEDEC_DDR4_SIGNAL_LOADING_MASK;
114*fa5e4d32SSunny Srivastava if (l_tmp == SPD_JEDEC_DDR4_SINGLE_LOAD_STACK)
115*fa5e4d32SSunny Srivastava {
116*fa5e4d32SSunny Srivastava // Fetch die count
117*fa5e4d32SSunny Srivastava l_tmp = i_iterator[constants::SPD_BYTE_6] &
118*fa5e4d32SSunny Srivastava SPD_JEDEC_DDR4_DIE_COUNT_MASK;
119*fa5e4d32SSunny Srivastava l_tmp >>= SPD_JEDEC_DDR4_DIE_COUNT_RIGHT_SHIFT;
120*fa5e4d32SSunny Srivastava l_dieCount = l_tmp + 1;
121*fa5e4d32SSunny Srivastava }
122*fa5e4d32SSunny Srivastava
123*fa5e4d32SSunny Srivastava /* Calculate Number of ranks */
124*fa5e4d32SSunny Srivastava l_tmp = i_iterator[constants::SPD_BYTE_12] & SPD_JEDEC_DDR4_NUM_RANKS_MASK;
125*fa5e4d32SSunny Srivastava l_tmp >>= SPD_JEDEC_DDR4_3_RESERVED_BITS;
126*fa5e4d32SSunny Srivastava
127*fa5e4d32SSunny Srivastava if (l_tmp >= SPD_JEDEC_DDR4_4_RESERVED_BITS)
128*fa5e4d32SSunny Srivastava {
129*fa5e4d32SSunny Srivastava logging::logMessage(
130*fa5e4d32SSunny Srivastava "Can't calculate number of ranks. Invalid data found.\n ");
131*fa5e4d32SSunny Srivastava return l_dimmSize;
132*fa5e4d32SSunny Srivastava }
133*fa5e4d32SSunny Srivastava l_logicalRanksPerDimm = (l_tmp + 1) * l_dieCount;
134*fa5e4d32SSunny Srivastava
135*fa5e4d32SSunny Srivastava l_dimmSize = (l_sdramCap / SPD_JEDEC_DDR4_PRI_BUS_WIDTH_MULTIPLIER) *
136*fa5e4d32SSunny Srivastava (l_priBusWid / l_sdramWid) * l_logicalRanksPerDimm;
137*fa5e4d32SSunny Srivastava
138*fa5e4d32SSunny Srivastava return l_dimmSize;
139*fa5e4d32SSunny Srivastava }
140*fa5e4d32SSunny Srivastava
getDDR4PartNumber(types::BinaryVector::const_iterator & i_iterator)141*fa5e4d32SSunny Srivastava std::string_view JedecSpdParser::getDDR4PartNumber(
142*fa5e4d32SSunny Srivastava types::BinaryVector::const_iterator& i_iterator)
143*fa5e4d32SSunny Srivastava {
144*fa5e4d32SSunny Srivastava char l_tmpPN[constants::PART_NUM_LEN + 1] = {'\0'};
145*fa5e4d32SSunny Srivastava sprintf(l_tmpPN, "%02X%02X%02X%X",
146*fa5e4d32SSunny Srivastava i_iterator[SPD_JEDEC_DDR4_SDRAM_DENSITY_BANK_OFFSET],
147*fa5e4d32SSunny Srivastava i_iterator[SPD_JEDEC_DDR4_SDRAM_ADDR_OFFSET],
148*fa5e4d32SSunny Srivastava i_iterator[SPD_JEDEC_DDR4_DRAM_PRI_PACKAGE_OFFSET],
149*fa5e4d32SSunny Srivastava i_iterator[SPD_JEDEC_DDR4_DRAM_MODULE_ORG_OFFSET] & 0x0F);
150*fa5e4d32SSunny Srivastava std::string l_partNumber(l_tmpPN, sizeof(l_tmpPN) - 1);
151*fa5e4d32SSunny Srivastava return l_partNumber;
152*fa5e4d32SSunny Srivastava }
153*fa5e4d32SSunny Srivastava
getDDR4SerialNumber(types::BinaryVector::const_iterator & i_iterator)154*fa5e4d32SSunny Srivastava std::string JedecSpdParser::getDDR4SerialNumber(
155*fa5e4d32SSunny Srivastava types::BinaryVector::const_iterator& i_iterator)
156*fa5e4d32SSunny Srivastava {
157*fa5e4d32SSunny Srivastava char l_tmpSN[constants::SERIAL_NUM_LEN + 1] = {'\0'};
158*fa5e4d32SSunny Srivastava sprintf(l_tmpSN, "%02X%02X%02X%02X%02X%02X",
159*fa5e4d32SSunny Srivastava i_iterator[SPD_JEDEC_DDR4_MFG_ID_MSB_OFFSET],
160*fa5e4d32SSunny Srivastava i_iterator[SPD_JEDEC_DDR4_MFG_ID_LSB_OFFSET],
161*fa5e4d32SSunny Srivastava i_iterator[SPD_JEDEC_DDR4_SN_BYTE0_OFFSET],
162*fa5e4d32SSunny Srivastava i_iterator[SPD_JEDEC_DDR4_SN_BYTE1_OFFSET],
163*fa5e4d32SSunny Srivastava i_iterator[SPD_JEDEC_DDR4_SN_BYTE2_OFFSET],
164*fa5e4d32SSunny Srivastava i_iterator[SPD_JEDEC_DDR4_SN_BYTE3_OFFSET]);
165*fa5e4d32SSunny Srivastava std::string l_serialNumber(l_tmpSN, sizeof(l_tmpSN) - 1);
166*fa5e4d32SSunny Srivastava return l_serialNumber;
167*fa5e4d32SSunny Srivastava }
168*fa5e4d32SSunny Srivastava
getDDR4FruNumber(const std::string & i_partNumber,types::BinaryVector::const_iterator & i_iterator)169*fa5e4d32SSunny Srivastava std::string_view JedecSpdParser::getDDR4FruNumber(
170*fa5e4d32SSunny Srivastava const std::string& i_partNumber,
171*fa5e4d32SSunny Srivastava types::BinaryVector::const_iterator& i_iterator)
172*fa5e4d32SSunny Srivastava {
173*fa5e4d32SSunny Srivastava // check for 128GB ISRDIMM not implemented
174*fa5e4d32SSunny Srivastava //(128GB 2RX4(8GX72) IS RDIMM 36*(16GBIT, 2H),1.2V 288PIN,1.2" ROHS) - NA
175*fa5e4d32SSunny Srivastava
176*fa5e4d32SSunny Srivastava // MTB Units is used in deciding the frequency of the DIMM
177*fa5e4d32SSunny Srivastava // This is applicable only for DDR4 specification
178*fa5e4d32SSunny Srivastava // 10 - DDR4-1600
179*fa5e4d32SSunny Srivastava // 9 - DDR4-1866
180*fa5e4d32SSunny Srivastava // 8 - DDR4-2133
181*fa5e4d32SSunny Srivastava // 7 - DDR4-2400
182*fa5e4d32SSunny Srivastava // 6 - DDR4-2666
183*fa5e4d32SSunny Srivastava // 5 - DDR4-3200
184*fa5e4d32SSunny Srivastava // pnFreqFnMap < tuple <partNumber, MTBUnits>, fruNumber>
185*fa5e4d32SSunny Srivastava uint8_t l_mtbUnits = i_iterator[constants::SPD_BYTE_18] &
186*fa5e4d32SSunny Srivastava constants::SPD_BYTE_MASK;
187*fa5e4d32SSunny Srivastava std::string l_fruNumber = "FFFFFFF";
188*fa5e4d32SSunny Srivastava auto it = pnFreqFnMap.find({i_partNumber, l_mtbUnits});
189*fa5e4d32SSunny Srivastava if (it != pnFreqFnMap.end())
190*fa5e4d32SSunny Srivastava {
191*fa5e4d32SSunny Srivastava l_fruNumber = it->second;
192*fa5e4d32SSunny Srivastava }
193*fa5e4d32SSunny Srivastava
194*fa5e4d32SSunny Srivastava return l_fruNumber;
195*fa5e4d32SSunny Srivastava }
196*fa5e4d32SSunny Srivastava
getDDR4CCIN(const std::string & i_fruNumber)197*fa5e4d32SSunny Srivastava std::string_view JedecSpdParser::getDDR4CCIN(const std::string& i_fruNumber)
198*fa5e4d32SSunny Srivastava {
199*fa5e4d32SSunny Srivastava auto it = pnCCINMap.find(i_fruNumber);
200*fa5e4d32SSunny Srivastava if (it != pnCCINMap.end())
201*fa5e4d32SSunny Srivastava {
202*fa5e4d32SSunny Srivastava return it->second;
203*fa5e4d32SSunny Srivastava }
204*fa5e4d32SSunny Srivastava return "XXXX"; // Return default value as XXXX
205*fa5e4d32SSunny Srivastava }
206*fa5e4d32SSunny Srivastava
getDDR5DimmCapacity(types::BinaryVector::const_iterator & i_iterator)207*fa5e4d32SSunny Srivastava auto JedecSpdParser::getDDR5DimmCapacity(
208*fa5e4d32SSunny Srivastava types::BinaryVector::const_iterator& i_iterator)
209*fa5e4d32SSunny Srivastava {
210*fa5e4d32SSunny Srivastava // dummy implementation to be updated when required
211*fa5e4d32SSunny Srivastava size_t dimmSize = 0;
212*fa5e4d32SSunny Srivastava (void)i_iterator;
213*fa5e4d32SSunny Srivastava return dimmSize;
214*fa5e4d32SSunny Srivastava }
215*fa5e4d32SSunny Srivastava
getDDR5PartNumber(types::BinaryVector::const_iterator & i_iterator)216*fa5e4d32SSunny Srivastava auto JedecSpdParser::getDDR5PartNumber(
217*fa5e4d32SSunny Srivastava types::BinaryVector::const_iterator& i_iterator)
218*fa5e4d32SSunny Srivastava {
219*fa5e4d32SSunny Srivastava // dummy implementation to be updated when required
220*fa5e4d32SSunny Srivastava std::string l_partNumber;
221*fa5e4d32SSunny Srivastava (void)i_iterator;
222*fa5e4d32SSunny Srivastava l_partNumber = "0123456";
223*fa5e4d32SSunny Srivastava return l_partNumber;
224*fa5e4d32SSunny Srivastava }
225*fa5e4d32SSunny Srivastava
getDDR5SerialNumber(types::BinaryVector::const_iterator & i_iterator)226*fa5e4d32SSunny Srivastava auto JedecSpdParser::getDDR5SerialNumber(
227*fa5e4d32SSunny Srivastava types::BinaryVector::const_iterator& i_iterator)
228*fa5e4d32SSunny Srivastava {
229*fa5e4d32SSunny Srivastava // dummy implementation to be updated when required
230*fa5e4d32SSunny Srivastava std::string l_serialNumber;
231*fa5e4d32SSunny Srivastava (void)i_iterator;
232*fa5e4d32SSunny Srivastava l_serialNumber = "444444444444";
233*fa5e4d32SSunny Srivastava return l_serialNumber;
234*fa5e4d32SSunny Srivastava }
235*fa5e4d32SSunny Srivastava
getDDR5FruNumber(const std::string & i_partNumber)236*fa5e4d32SSunny Srivastava auto JedecSpdParser::getDDR5FruNumber(const std::string& i_partNumber)
237*fa5e4d32SSunny Srivastava {
238*fa5e4d32SSunny Srivastava // dummy implementation to be updated when required
239*fa5e4d32SSunny Srivastava static std::unordered_map<std::string, std::string> pnFruMap = {
240*fa5e4d32SSunny Srivastava {"1234567", "XXXXXXX"}};
241*fa5e4d32SSunny Srivastava
242*fa5e4d32SSunny Srivastava std::string l_fruNumber;
243*fa5e4d32SSunny Srivastava auto itr = pnFruMap.find(i_partNumber);
244*fa5e4d32SSunny Srivastava if (itr != pnFruMap.end())
245*fa5e4d32SSunny Srivastava {
246*fa5e4d32SSunny Srivastava l_fruNumber = itr->second;
247*fa5e4d32SSunny Srivastava }
248*fa5e4d32SSunny Srivastava else
249*fa5e4d32SSunny Srivastava {
250*fa5e4d32SSunny Srivastava l_fruNumber = "FFFFFFF";
251*fa5e4d32SSunny Srivastava }
252*fa5e4d32SSunny Srivastava return l_fruNumber;
253*fa5e4d32SSunny Srivastava }
254*fa5e4d32SSunny Srivastava
getDDR5CCIN(const std::string & i_partNumber)255*fa5e4d32SSunny Srivastava auto JedecSpdParser::getDDR5CCIN(const std::string& i_partNumber)
256*fa5e4d32SSunny Srivastava {
257*fa5e4d32SSunny Srivastava // dummy implementation to be updated when required
258*fa5e4d32SSunny Srivastava static std::unordered_map<std::string, std::string> pnCCINMap = {
259*fa5e4d32SSunny Srivastava {"1234567", "XXXX"}};
260*fa5e4d32SSunny Srivastava
261*fa5e4d32SSunny Srivastava std::string ccin = "XXXX";
262*fa5e4d32SSunny Srivastava auto itr = pnCCINMap.find(i_partNumber);
263*fa5e4d32SSunny Srivastava if (itr != pnCCINMap.end())
264*fa5e4d32SSunny Srivastava {
265*fa5e4d32SSunny Srivastava ccin = itr->second;
266*fa5e4d32SSunny Srivastava }
267*fa5e4d32SSunny Srivastava return ccin;
268*fa5e4d32SSunny Srivastava }
269*fa5e4d32SSunny Srivastava
readKeywords(types::BinaryVector::const_iterator & i_iterator)270*fa5e4d32SSunny Srivastava types::JedecSpdMap JedecSpdParser::readKeywords(
271*fa5e4d32SSunny Srivastava types::BinaryVector::const_iterator& i_iterator)
272*fa5e4d32SSunny Srivastava {
273*fa5e4d32SSunny Srivastava types::JedecSpdMap l_keywordValueMap{};
274*fa5e4d32SSunny Srivastava size_t dimmSize = getDDR4DimmCapacity(i_iterator);
275*fa5e4d32SSunny Srivastava if (!dimmSize)
276*fa5e4d32SSunny Srivastava {
277*fa5e4d32SSunny Srivastava logging::logMessage("Error: Calculated dimm size is 0.");
278*fa5e4d32SSunny Srivastava }
279*fa5e4d32SSunny Srivastava else
280*fa5e4d32SSunny Srivastava {
281*fa5e4d32SSunny Srivastava l_keywordValueMap.emplace("MemorySizeInKB",
282*fa5e4d32SSunny Srivastava dimmSize * constants::CONVERT_MB_TO_KB);
283*fa5e4d32SSunny Srivastava }
284*fa5e4d32SSunny Srivastava
285*fa5e4d32SSunny Srivastava auto l_partNumber = getDDR4PartNumber(i_iterator);
286*fa5e4d32SSunny Srivastava auto l_fruNumber = getDDR4FruNumber(
287*fa5e4d32SSunny Srivastava std::string(l_partNumber.begin(), l_partNumber.end()), i_iterator);
288*fa5e4d32SSunny Srivastava auto l_serialNumber = getDDR4SerialNumber(i_iterator);
289*fa5e4d32SSunny Srivastava auto ccin =
290*fa5e4d32SSunny Srivastava getDDR4CCIN(std::string(l_fruNumber.begin(), l_fruNumber.end()));
291*fa5e4d32SSunny Srivastava // PN value is made same as FN value
292*fa5e4d32SSunny Srivastava auto l_displayPartNumber = l_fruNumber;
293*fa5e4d32SSunny Srivastava l_keywordValueMap.emplace("PN",
294*fa5e4d32SSunny Srivastava move(std::string(l_displayPartNumber.begin(),
295*fa5e4d32SSunny Srivastava l_displayPartNumber.end())));
296*fa5e4d32SSunny Srivastava l_keywordValueMap.emplace(
297*fa5e4d32SSunny Srivastava "FN", move(std::string(l_fruNumber.begin(), l_fruNumber.end())));
298*fa5e4d32SSunny Srivastava l_keywordValueMap.emplace("SN", move(l_serialNumber));
299*fa5e4d32SSunny Srivastava l_keywordValueMap.emplace("CC",
300*fa5e4d32SSunny Srivastava move(std::string(ccin.begin(), ccin.end())));
301*fa5e4d32SSunny Srivastava
302*fa5e4d32SSunny Srivastava return l_keywordValueMap;
303*fa5e4d32SSunny Srivastava }
304*fa5e4d32SSunny Srivastava
parse()305*fa5e4d32SSunny Srivastava types::VPDMapVariant JedecSpdParser::parse()
306*fa5e4d32SSunny Srivastava {
307*fa5e4d32SSunny Srivastava // Read the data and return the map
308*fa5e4d32SSunny Srivastava auto l_iterator = m_memSpd.cbegin();
309*fa5e4d32SSunny Srivastava auto l_spdDataMap = readKeywords(l_iterator);
310*fa5e4d32SSunny Srivastava return l_spdDataMap;
311*fa5e4d32SSunny Srivastava }
312*fa5e4d32SSunny Srivastava
313*fa5e4d32SSunny Srivastava } // namespace vpd
314