PEL: Update system info into HB PEL extended user data section
Hostboot requested BMC add a UserData section containing debug
information like internal code level name and the bmc/host/chassis
states that are added to the BMC PELs. To accomodate this BMC code will
look in incoming PELs for an ED section with specific
compID/version/subtype fields, and then modify it with the appropriate
debug contents as mentioned above.
Test: Verified PEL tool output by injecting error to generate
hostboot PEL
Signed-off-by: Sumit Kumar <sumit_kumar@in.ibm.com>
Change-Id: I72288089f2768412eb9033b121e7f02f72f11fc7
diff --git a/extensions/openpower-pels/extended_user_data.hpp b/extensions/openpower-pels/extended_user_data.hpp
index 421a6f8..be3db5b 100644
--- a/extensions/openpower-pels/extended_user_data.hpp
+++ b/extensions/openpower-pels/extended_user_data.hpp
@@ -95,6 +95,47 @@
}
/**
+ * @brief Returns the section data updated with new data
+ *
+ * @param[in] subType - The type of user data
+ * @param[in] componentID - Component ID of the creator
+ * @param[in] newData - The new data
+ *
+ */
+ void updateDataSection(const uint8_t subType, const uint16_t componentId,
+ const std::vector<uint8_t>& newData)
+ {
+ auto origDataSize = 0;
+
+ if (newData.size() >= 4)
+ {
+ // Update component Id & subtype in section header of ED
+ _header.componentID = static_cast<uint16_t>(componentId);
+ _header.subType = static_cast<uint8_t>(subType);
+
+ if (newData.size() > _data.size())
+ {
+ // Don't allow section to get bigger
+ origDataSize = _data.size();
+ _data = newData;
+ _data.resize(origDataSize);
+ }
+ else
+ {
+ // Use shrink to handle 4B alignment and update the header size
+ auto status =
+ shrink(Section::flattenedSize() + 4 + newData.size());
+ if (status)
+ {
+ origDataSize = _data.size();
+ _data = newData;
+ _data.resize(origDataSize);
+ }
+ }
+ }
+ }
+
+ /**
* @brief Get the section contents in JSON
*
* @param[in] creatorID - Creator Subsystem ID - unused (see the .cpp)