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);
};