summaryrefslogtreecommitdiffstats
path: root/extensions/openpower-pels/src.cpp
diff options
context:
space:
mode:
authorMatt Spinler <spinler@us.ibm.com>2019-10-09 13:37:38 -0500
committerMatt Spinler <spinler@us.ibm.com>2019-10-22 14:09:56 +0000
commitf9bae18539eca100632d462083698b57d9687c82 (patch)
tree1fa8904d5e82750314bcbc1bbf0b0b6ee957b26c /extensions/openpower-pels/src.cpp
parent32f13c915fa4b27520ca0aea476804c37f5516b9 (diff)
downloadphosphor-logging-f9bae18539eca100632d462083698b57d9687c82.tar.gz
phosphor-logging-f9bae18539eca100632d462083698b57d9687c82.zip
PEL: Add SRC PEL section class
This section consists of: - An 8B header - 8 4B words of hex data - Some data is predefined based on the SRC format, some is free format. - A 32B ASCII character string (The AsciiString class) - An optional section for FRU callouts (The Callouts class) Usually, the term SRC (System Reference Code) refers to the contents of the ASCII string and the hex data words, which can then be looked up in service documentation to find the meaning of the event log. This PEL section wraps this pure SRC with additional data like callouts. This commit only adds support for unflattening the section from an existing PEL, and flattening it again. Future commits will add support for creating an SRC from message registry data. Signed-off-by: Matt Spinler <spinler@us.ibm.com> Change-Id: I3dd97c6aca59cc6d6d6fadef84465164090d5658
Diffstat (limited to 'extensions/openpower-pels/src.cpp')
-rw-r--r--extensions/openpower-pels/src.cpp87
1 files changed, 87 insertions, 0 deletions
diff --git a/extensions/openpower-pels/src.cpp b/extensions/openpower-pels/src.cpp
new file mode 100644
index 0000000..7fd7b0e
--- /dev/null
+++ b/extensions/openpower-pels/src.cpp
@@ -0,0 +1,87 @@
+#include "src.hpp"
+
+#include <phosphor-logging/log.hpp>
+
+namespace openpower
+{
+namespace pels
+{
+
+using namespace phosphor::logging;
+
+void SRC::unflatten(Stream& stream)
+{
+ stream >> _header >> _version >> _flags >> _reserved1B >> _wordCount >>
+ _reserved2B >> _size;
+
+ for (auto& word : _hexData)
+ {
+ stream >> word;
+ }
+
+ _asciiString = std::make_unique<src::AsciiString>(stream);
+
+ if (hasAdditionalSections())
+ {
+ // The callouts section is currently the only extra subsection type
+ _callouts = std::make_unique<src::Callouts>(stream);
+ }
+}
+
+void SRC::flatten(Stream& stream)
+{
+ stream << _header << _version << _flags << _reserved1B << _wordCount
+ << _reserved2B << _size;
+
+ for (auto& word : _hexData)
+ {
+ stream << word;
+ }
+
+ _asciiString->flatten(stream);
+
+ if (_callouts)
+ {
+ _callouts->flatten(stream);
+ }
+}
+
+SRC::SRC(Stream& pel)
+{
+ try
+ {
+ unflatten(pel);
+ validate();
+ }
+ catch (const std::exception& e)
+ {
+ log<level::ERR>("Cannot unflatten SRC", entry("ERROR=%s", e.what()));
+ _valid = false;
+ }
+}
+
+void SRC::validate()
+{
+ bool failed = false;
+
+ if ((header().id != static_cast<uint16_t>(SectionID::primarySRC)) &&
+ (header().id != static_cast<uint16_t>(SectionID::secondarySRC)))
+ {
+ log<level::ERR>("Invalid SRC section ID",
+ entry("ID=0x%X", header().id));
+ failed = true;
+ }
+
+ // Check the version in the SRC, not in the header
+ if (_version != srcSectionVersion)
+ {
+ log<level::ERR>("Invalid SRC section version",
+ entry("VERSION=0x%X", _version));
+ failed = true;
+ }
+
+ _valid = failed ? false : true;
+}
+
+} // namespace pels
+} // namespace openpower
OpenPOWER on IntegriCloud