Add logic for supporting the secondary post codes

- The intent behind this commit to fix up the post code manager
  to support the secondary post codes as well.

- This commit needs the PDI Change from:
https://gerrit.openbmc-project.xyz/c/openbmc/phosphor-dbus-interfaces/+/40927
https://gerrit.openbmc-project.xyz/c/openbmc/phosphor-dbus-interfaces/+/40903

Tested By :
===========
1. Patched the library generated by the PDI change.
2. Compile the post code manager with this commit.
3. PATCH it on a live system to check if the post codes stored
   in the file system has both the primary & secondary codes

Signed-off-by: Manojkiran Eda <manojkiran.eda@gmail.com>
Change-Id: I8b36cc3a908bb94467b12a5b41ffb156789795a8
diff --git a/inc/post_code.hpp b/inc/post_code.hpp
index 5e2a7b9..05ce284 100644
--- a/inc/post_code.hpp
+++ b/inc/post_code.hpp
@@ -21,6 +21,7 @@
 #include <cereal/archives/json.hpp>
 #include <cereal/cereal.hpp>
 #include <cereal/types/map.hpp>
+#include <cereal/types/tuple.hpp>
 #include <cereal/types/vector.hpp>
 #include <chrono>
 #include <experimental/filesystem>
@@ -76,6 +77,9 @@
     }
 };
 using EventPtr = std::unique_ptr<sd_event, EventDeleter>;
+using primarycode_t = uint64_t;
+using secondarycode_t = std::vector<uint8_t>;
+using postcode_t = std::tuple<primarycode_t, secondarycode_t>;
 namespace fs = std::experimental::filesystem;
 namespace StateServer = sdbusplus::xyz::openbmc_project::State::server;
 
@@ -102,7 +106,7 @@
                     postcodeDataHolderObj->PropertiesIntf),
             [this](sdbusplus::message::message &msg) {
                 std::string objectName;
-                std::map<std::string, std::variant<uint64_t>> msgData;
+                std::map<std::string, std::variant<postcode_t>> msgData;
                 msg.read(objectName, msgData);
                 // Check if it was the Value property that changed.
                 auto valPropMap = msgData.find("Value");
@@ -110,7 +114,7 @@
                     if (valPropMap != msgData.end())
                     {
                         this->savePostCodes(
-                            std::get<uint64_t>(valPropMap->second));
+                            std::get<postcode_t>(valPropMap->second));
                     }
                 }
             }),
@@ -179,8 +183,8 @@
     {
     }
 
-    std::vector<uint64_t> getPostCodes(uint16_t index) override;
-    std::map<uint64_t, uint64_t>
+    std::vector<postcode_t> getPostCodes(uint16_t index) override;
+    std::map<uint64_t, postcode_t>
         getPostCodesWithTimeStamp(uint16_t index) override;
     void deleteAll() override;
 
@@ -191,16 +195,16 @@
     sdbusplus::bus::bus &bus;
     std::chrono::time_point<std::chrono::steady_clock> firstPostCodeTimeSteady;
     uint64_t firstPostCodeUsSinceEpoch;
-    std::map<uint64_t, uint64_t> postCodes;
+    std::map<uint64_t, postcode_t> postCodes;
     std::string strPostCodeListPath;
     std::string strCurrentBootCycleIndexName;
     uint16_t currentBootCycleIndex;
     std::string strCurrentBootCycleCountName;
-    void savePostCodes(uint64_t code);
+    void savePostCodes(postcode_t code);
     sdbusplus::bus::match_t propertiesChangedSignalRaw;
     sdbusplus::bus::match_t propertiesChangedSignalCurrentHostState;
     fs::path serialize(const std::string &path);
     bool deserialize(const fs::path &path, uint16_t &index);
     bool deserializePostCodes(const fs::path &path,
-                              std::map<uint64_t, uint64_t> &codes);
+                              std::map<uint64_t, postcode_t> &codes);
 };
diff --git a/src/post_code.cpp b/src/post_code.cpp
index d0ba711..88035c5 100644
--- a/src/post_code.cpp
+++ b/src/post_code.cpp
@@ -34,9 +34,9 @@
     currentBootCycleCount(1);
 }
 
-std::vector<uint64_t> PostCode::getPostCodes(uint16_t index)
+std::vector<postcode_t> PostCode::getPostCodes(uint16_t index)
 {
-    std::vector<uint64_t> codesVec;
+    std::vector<postcode_t> codesVec;
     if (1 == index && !postCodes.empty())
     {
         for (auto& code : postCodes)
@@ -49,13 +49,14 @@
         decltype(postCodes) codes;
         deserializePostCodes(
             fs::path(strPostCodeListPath + std::to_string(bootNum)), codes);
-        for (std::pair<uint64_t, uint64_t> code : codes)
+        for (std::pair<uint64_t, postcode_t> code : codes)
             codesVec.push_back(code.second);
     }
     return codesVec;
 }
 
-std::map<uint64_t, uint64_t> PostCode::getPostCodesWithTimeStamp(uint16_t index)
+std::map<uint64_t, postcode_t>
+    PostCode::getPostCodesWithTimeStamp(uint16_t index)
 {
     if (1 == index && !postCodes.empty())
     {
@@ -69,7 +70,7 @@
     return codes;
 }
 
-void PostCode::savePostCodes(uint64_t code)
+void PostCode::savePostCodes(postcode_t code)
 {
     // steady_clock is a monotonic clock that is guaranteed to never be adjusted
     auto postCodeTimeSteady = std::chrono::steady_clock::now();
@@ -158,7 +159,7 @@
 }
 
 bool PostCode::deserializePostCodes(const fs::path& path,
-                                    std::map<uint64_t, uint64_t>& codes)
+                                    std::map<uint64_t, postcode_t>& codes)
 {
     try
     {