16555e7efSjinuthomas #pragma once
26555e7efSjinuthomas 
36555e7efSjinuthomas #include "impl.hpp"
46555e7efSjinuthomas #include "parser_interface.hpp"
56555e7efSjinuthomas #include "types.hpp"
66555e7efSjinuthomas 
76555e7efSjinuthomas namespace openpower
86555e7efSjinuthomas {
96555e7efSjinuthomas namespace vpd
106555e7efSjinuthomas {
11*5700b3c8Sjinuthomas namespace isdimm
126555e7efSjinuthomas {
136555e7efSjinuthomas namespace parser
146555e7efSjinuthomas {
156555e7efSjinuthomas using ParserInterface = openpower::vpd::parser::interface::ParserInterface;
166555e7efSjinuthomas using kwdVpdMap = inventory::KeywordVpdMap;
176555e7efSjinuthomas 
186555e7efSjinuthomas class isdimmVpdParser : public ParserInterface
196555e7efSjinuthomas {
206555e7efSjinuthomas   public:
216555e7efSjinuthomas     isdimmVpdParser() = delete;
226555e7efSjinuthomas     isdimmVpdParser(const isdimmVpdParser&) = delete;
236555e7efSjinuthomas     isdimmVpdParser& operator=(const isdimmVpdParser&) = delete;
246555e7efSjinuthomas     isdimmVpdParser(isdimmVpdParser&&) = delete;
256555e7efSjinuthomas     isdimmVpdParser& operator=(isdimmVpdParser&&) = delete;
266555e7efSjinuthomas     ~isdimmVpdParser() = default;
276555e7efSjinuthomas 
286555e7efSjinuthomas     /**
296555e7efSjinuthomas      * @brief Constructor
306555e7efSjinuthomas      *
316555e7efSjinuthomas      * Move memVpdVector to parser object's memVpdVector
326555e7efSjinuthomas      */
336555e7efSjinuthomas     isdimmVpdParser(const Binary& VpdVector) : memVpd(VpdVector)
346555e7efSjinuthomas     {
356555e7efSjinuthomas     }
366555e7efSjinuthomas 
376555e7efSjinuthomas     /**
386555e7efSjinuthomas      * @brief Parse the memory SPD binary data.
396555e7efSjinuthomas      * Collects and emplace the keyword-value pairs in map.
406555e7efSjinuthomas      *
416555e7efSjinuthomas      * @return map of keyword:value
426555e7efSjinuthomas      */
436555e7efSjinuthomas     std::variant<kwdVpdMap, Store> parse();
446555e7efSjinuthomas 
456555e7efSjinuthomas     /**
466555e7efSjinuthomas      * @brief An api to return interface name with respect to
476555e7efSjinuthomas      * published data on cache
486555e7efSjinuthomas      *
496555e7efSjinuthomas      * @return - Interface name for that vpd type.
506555e7efSjinuthomas      */
516555e7efSjinuthomas     std::string getInterfaceName() const;
526555e7efSjinuthomas 
536555e7efSjinuthomas   private:
546555e7efSjinuthomas     /**
556555e7efSjinuthomas      * @brief An api to read keywords.
566555e7efSjinuthomas      *
576555e7efSjinuthomas      * @return- map of kwd:value
586555e7efSjinuthomas      */
596555e7efSjinuthomas     kwdVpdMap readKeywords(Binary::const_iterator& iterator);
606555e7efSjinuthomas 
616555e7efSjinuthomas     /**
626555e7efSjinuthomas      * @brief This function calculates DIMM size from SPD
636555e7efSjinuthomas      *
646555e7efSjinuthomas      * @param[in] iterator - iterator to buffer containing SPD
656555e7efSjinuthomas      * @return calculated data or 0 in case of any error.
666555e7efSjinuthomas      */
676555e7efSjinuthomas     auto getDDR4DimmCapacity(Binary::const_iterator& iterator);
686555e7efSjinuthomas 
696555e7efSjinuthomas     /**
706555e7efSjinuthomas      * @brief This function calculates part number from SPD
716555e7efSjinuthomas      *
726555e7efSjinuthomas      * @param[in] iterator - iterator to buffer containing SPD
736555e7efSjinuthomas      * @return calculated part number.
746555e7efSjinuthomas      */
756555e7efSjinuthomas     auto getDDR4PartNumber(Binary::const_iterator& iterator);
766555e7efSjinuthomas 
776555e7efSjinuthomas     /**
786555e7efSjinuthomas      * @brief This function calculates serial number from SPD
796555e7efSjinuthomas      *
806555e7efSjinuthomas      * @param[in] iterator - iterator to buffer containing SPD
816555e7efSjinuthomas      * @return calculated serial number.
826555e7efSjinuthomas      */
836555e7efSjinuthomas     auto getDDR4SerialNumber(Binary::const_iterator& iterator);
846555e7efSjinuthomas 
856555e7efSjinuthomas     /**
866555e7efSjinuthomas      * @brief This function allocates FRU number based on part number
876555e7efSjinuthomas      *
886555e7efSjinuthomas      * @param[in] partNumber - part number of the DIMM
896555e7efSjinuthomas      * @return allocated FRU number.
906555e7efSjinuthomas      */
916555e7efSjinuthomas     auto getDDR4FruNumber(const std::string& partNumber);
926555e7efSjinuthomas 
936555e7efSjinuthomas     /**
946555e7efSjinuthomas      * @brief This function allocates CCIN based on part number
956555e7efSjinuthomas      *
966555e7efSjinuthomas      * @param[in] partNumber - part number of the DIMM
976555e7efSjinuthomas      * @return allocated CCIN.
986555e7efSjinuthomas      */
996555e7efSjinuthomas     auto getDDR4CCIN(const std::string& partNumber);
1006555e7efSjinuthomas 
1016555e7efSjinuthomas     /**
1026555e7efSjinuthomas      * @brief This function calculates DIMM size from SPD
1036555e7efSjinuthomas      *
1046555e7efSjinuthomas      * @param[in] iterator - iterator to buffer containing SPD
1056555e7efSjinuthomas      * @return calculated data or 0 in case of any error.
1066555e7efSjinuthomas      */
1076555e7efSjinuthomas     auto getDDR5DimmCapacity(Binary::const_iterator& iterator);
1086555e7efSjinuthomas 
1096555e7efSjinuthomas     /**
1106555e7efSjinuthomas      * @brief This function calculates part number from SPD
1116555e7efSjinuthomas      *
1126555e7efSjinuthomas      * @param[in] iterator - iterator to buffer containing SPD
1136555e7efSjinuthomas      * @return calculated part number.
1146555e7efSjinuthomas      */
1156555e7efSjinuthomas     auto getDDR5PartNumber(Binary::const_iterator& iterator);
1166555e7efSjinuthomas 
1176555e7efSjinuthomas     /**
1186555e7efSjinuthomas      * @brief This function calculates serial number from SPD
1196555e7efSjinuthomas      *
1206555e7efSjinuthomas      * @param[in] iterator - iterator to buffer containing SPD
1216555e7efSjinuthomas      * @return calculated serial number.
1226555e7efSjinuthomas      */
1236555e7efSjinuthomas     auto getDDR5SerialNumber(Binary::const_iterator& iterator);
1246555e7efSjinuthomas 
1256555e7efSjinuthomas     /**
1266555e7efSjinuthomas      * @brief This function allocates FRU number based on part number
1276555e7efSjinuthomas      *
1286555e7efSjinuthomas      * @param[in] partNumber - part number of the DIMM
1296555e7efSjinuthomas      * @return allocated FRU number.
1306555e7efSjinuthomas      */
1316555e7efSjinuthomas     auto getDDR5FruNumber(const std::string& partNumber);
1326555e7efSjinuthomas 
1336555e7efSjinuthomas     /**
1346555e7efSjinuthomas      * @brief This function allocates CCIN based on part number
1356555e7efSjinuthomas      *
1366555e7efSjinuthomas      * @param[in] partNumber - part number of the DIMM
1376555e7efSjinuthomas      * @return allocated CCIN.
1386555e7efSjinuthomas      */
1396555e7efSjinuthomas     auto getDDR5CCIN(const std::string& partNumber);
1406555e7efSjinuthomas 
1416555e7efSjinuthomas     // vdp file to be parsed
1426555e7efSjinuthomas     const Binary& memVpd;
1436555e7efSjinuthomas };
1446555e7efSjinuthomas 
1456555e7efSjinuthomas inline std::string isdimmVpdParser::getInterfaceName() const
1466555e7efSjinuthomas {
1476555e7efSjinuthomas     return constants::memVpdInf;
1486555e7efSjinuthomas }
1496555e7efSjinuthomas 
1506555e7efSjinuthomas } // namespace parser
151*5700b3c8Sjinuthomas } // namespace isdimm
1526555e7efSjinuthomas } // namespace vpd
1536555e7efSjinuthomas } // namespace openpower
154