diff options
Diffstat (limited to 'extensions/openpower-pels/src.hpp')
-rw-r--r-- | extensions/openpower-pels/src.hpp | 127 |
1 files changed, 120 insertions, 7 deletions
diff --git a/extensions/openpower-pels/src.hpp b/extensions/openpower-pels/src.hpp index 365f12b..ab29c0b 100644 --- a/extensions/openpower-pels/src.hpp +++ b/extensions/openpower-pels/src.hpp @@ -4,6 +4,7 @@ #include "ascii_string.hpp" #include "callouts.hpp" #include "pel_types.hpp" +#include "registry.hpp" #include "section.hpp" #include "stream.hpp" @@ -12,8 +13,13 @@ namespace openpower namespace pels { +constexpr uint8_t srcSectionVersion = 0x01; +constexpr uint8_t srcSectionSubtype = 0x01; constexpr size_t numSRCHexDataWords = 8; -constexpr uint8_t srcSectionVersion = 0x02; +constexpr uint8_t srcVersion = 0x02; +constexpr uint8_t bmcSRCFormat = 0x55; +constexpr uint8_t primaryBMCPosition = 0x10; +constexpr size_t baseSRCSize = 72; /** * @class SRC @@ -38,7 +44,8 @@ class SRC : public Section public: enum HeaderFlags { - additionalSections = 0x01 + additionalSections = 0x01, + powerFaultEvent = 0x02 }; SRC() = delete; @@ -58,6 +65,19 @@ class SRC : public Section explicit SRC(Stream& pel); /** + * @brief Constructor + * + * Creates the section with data from the PEL message registry entry for + * this error, along with the AdditionalData property contents from the + * corresponding event log. + * + * @param[in] regEntry - The message registry entry for this event log + * @param[in] additionalData - The AdditionalData properties in this event + * log + */ + SRC(const message::Entry& regEntry, const AdditionalData& additionalData); + + /** * @brief Flatten the section into the stream * * @param[in] stream - The stream to write to @@ -140,13 +160,15 @@ class SRC : public Section return _callouts; } - private: /** - * @brief Fills in the object from the stream data + * @brief Returns the size of this section when flattened into a PEL * - * @param[in] stream - The stream to read from + * @return size_t - the size of the section */ - void unflatten(Stream& stream); + size_t flattenedSize() const + { + return _header.size; + } /** * @brief Says if this SRC has additional subsections in it @@ -157,7 +179,98 @@ class SRC : public Section */ inline bool hasAdditionalSections() const { - return _flags & static_cast<uint8_t>(HeaderFlags::additionalSections); + return _flags & additionalSections; + } + + /** + * @brief Indicates if this event log is for a power fault. + * + * This comes from a field in the message registry for BMC + * generated PELs. + * + * @return bool + */ + inline bool isPowerFaultEvent() const + { + return _flags & powerFaultEvent; + } + + private: + /** + * @brief Fills in the user defined hex words from the + * AdditionalData fields. + * + * When creating this section from a message registry entry, + * that entry has a field that says which AdditionalData property + * fields to use to fill in the user defined hex data words 6-9 + * (which correspond to hexData words 4-7). + * + * For example, given that AdditionalData is a map of string keys + * to string values, find the AdditionalData value for AdditionalData + * key X, convert it to a uint32_t, and save it in user data word Y. + * + * @param[in] regEntry - The message registry entry for the error + * @param[in] additionalData - The AdditionalData map + */ + void setUserDefinedHexWords(const message::Entry& regEntry, + const AdditionalData& additionalData); + /** + * @brief Fills in the object from the stream data + * + * @param[in] stream - The stream to read from + */ + void unflatten(Stream& stream); + + /** + * @brief Get the _hexData[] index to use based on the corresponding + * SRC word number. + * + * Converts the specification nomenclature to this data structure. + * See the _hexData documentation below for more information. + * + * @param[in] wordNum - The SRC word number, as defined by the spec. + * + * @return size_t The corresponding index into _hexData. + */ + inline size_t getWordIndexFromWordNum(size_t wordNum) const + { + assert(wordNum >= 2 && wordNum <= 9); + return wordNum - 2; + } + + /** + * @brief Says if the word number is in the range of user defined words. + * + * This is only used for BMC generated SRCs, where words 6 - 9 are the + * user defined ones, meaning that setUserDefinedHexWords() will be + * used to fill them in based on the contents of the OpenBMC event log. + * + * @param[in] wordNum - The SRC word number, as defined by the spec. + * + * @return bool - If this word number can be filled in by the creator. + */ + inline bool isUserDefinedWord(size_t wordNum) const + { + return (wordNum >= 6) && (wordNum <= 9); + } + + /** + * @brief Sets the SRC format byte in the hex word data. + */ + inline void setBMCFormat() + { + _hexData[0] |= bmcSRCFormat; + } + + /** + * @brief Sets the hex word field that specifies which BMC + * (primary vs backup) created the error. + * + * Can be hardcoded until there are systems with redundant BMCs. + */ + inline void setBMCPosition() + { + _hexData[1] |= primaryBMCPosition; } /** |