summaryrefslogtreecommitdiffstats
path: root/extensions/openpower-pels/src.cpp
diff options
context:
space:
mode:
authorMatt Spinler <spinler@us.ibm.com>2019-10-15 10:54:11 -0500
committerMatt Spinler <spinler@us.ibm.com>2019-11-04 16:14:12 -0600
commitbd716f00dbdf910da44935785611b49c8719249c (patch)
treeeb06bfc2a646a19ec02f9f82836191984eb30a6d /extensions/openpower-pels/src.cpp
parent55a697842f5d474877bb92afec2cd1c0e3100dbd (diff)
downloadphosphor-logging-bd716f00dbdf910da44935785611b49c8719249c.tar.gz
phosphor-logging-bd716f00dbdf910da44935785611b49c8719249c.zip
PEL: Create SRC section from message registry
This adds the ability to create an SRC PEL section based on the message registry entry for an OpenBMC event log. The event log's AdditionalData property is used as a source for the user defined data words of the SRC, while the other fields in the SRC's data words are filled in either from the message registry fields or from current system state or configuration. The ASCII string field of the SRC is filled in based on the message registry entry. This commit doesn't fill in every system status field, as many aren't even available anywhere yet. Also, this commit doesn't support adding callouts to an SRC, that will also be handled in the future. Signed-off-by: Matt Spinler <spinler@us.ibm.com> Change-Id: I67fe44e07e4eda6bdeedb4af2eacfc197deb6eb3
Diffstat (limited to 'extensions/openpower-pels/src.cpp')
-rw-r--r--extensions/openpower-pels/src.cpp85
1 files changed, 82 insertions, 3 deletions
diff --git a/extensions/openpower-pels/src.cpp b/extensions/openpower-pels/src.cpp
index 7fd7b0e..a79df8d 100644
--- a/extensions/openpower-pels/src.cpp
+++ b/extensions/openpower-pels/src.cpp
@@ -60,6 +60,86 @@ SRC::SRC(Stream& pel)
}
}
+SRC::SRC(const message::Entry& regEntry, const AdditionalData& additionalData)
+{
+ _header.id = static_cast<uint16_t>(SectionID::primarySRC);
+ _header.version = srcSectionVersion;
+ _header.subType = srcSectionSubtype;
+ _header.componentID = regEntry.componentID;
+
+ _version = srcVersion;
+
+ _flags = 0;
+ if (regEntry.src.powerFault.value_or(false))
+ {
+ _flags |= powerFaultEvent;
+ }
+
+ _reserved1B = 0;
+
+ _wordCount = numSRCHexDataWords + 1;
+
+ _reserved2B = 0;
+
+ // There are multiple fields encoded in the hex data words.
+ std::for_each(_hexData.begin(), _hexData.end(),
+ [](auto& word) { word = 0; });
+ setBMCFormat();
+ setBMCPosition();
+ // Partition dump status and partition boot type always 0 for BMC errors.
+ //
+ // TODO: Fill in other fields that aren't available yet.
+
+ // Fill in the last 4 words from the AdditionalData property contents.
+ setUserDefinedHexWords(regEntry, additionalData);
+
+ _asciiString = std::make_unique<src::AsciiString>(regEntry);
+
+ // TODO: add callouts using the Callouts object
+
+ _size = baseSRCSize;
+ _size += _callouts ? _callouts->flattenedSize() : 0;
+ _header.size = Section::flattenedSize() + _size;
+
+ _valid = true;
+}
+
+void SRC::setUserDefinedHexWords(const message::Entry& regEntry,
+ const AdditionalData& ad)
+{
+ if (!regEntry.src.hexwordADFields)
+ {
+ return;
+ }
+
+ // Save the AdditionalData value corresponding to the
+ // adName key in _hexData[wordNum].
+ for (const auto& [wordNum, adName] : *regEntry.src.hexwordADFields)
+ {
+ // Can only set words 6 - 9
+ if (!isUserDefinedWord(wordNum))
+ {
+ log<level::WARNING>("SRC user data word out of range",
+ entry("WORD_NUM=%d", wordNum),
+ entry("ERROR_NAME=%s", regEntry.name.c_str()));
+ continue;
+ }
+
+ auto value = ad.getValue(adName);
+ if (value)
+ {
+ _hexData[getWordIndexFromWordNum(wordNum)] =
+ std::strtoul(value.value().c_str(), nullptr, 0);
+ }
+ else
+ {
+ log<level::WARNING>("Source for user data SRC word not found",
+ entry("ADDITIONALDATA_KEY=%s", adName.c_str()),
+ entry("ERROR_NAME=%s", regEntry.name.c_str()));
+ }
+ }
+}
+
void SRC::validate()
{
bool failed = false;
@@ -73,10 +153,9 @@ void SRC::validate()
}
// Check the version in the SRC, not in the header
- if (_version != srcSectionVersion)
+ if (_version != srcVersion)
{
- log<level::ERR>("Invalid SRC section version",
- entry("VERSION=0x%X", _version));
+ log<level::ERR>("Invalid SRC version", entry("VERSION=0x%X", _version));
failed = true;
}
OpenPOWER on IntegriCloud