summaryrefslogtreecommitdiffstats
path: root/extensions/openpower-pels
diff options
context:
space:
mode:
authorMatt Spinler <spinler@us.ibm.com>2020-01-22 14:10:04 -0600
committerMatt Spinler <spinler@us.ibm.com>2020-01-31 15:00:11 +0000
commitf1b46ff4a5db819f36888259d14364006e2b54da (patch)
tree1372214a749b9c29e57a5489474d9242bb28afa0 /extensions/openpower-pels
parent9694ba6295ad961c4b95e93b26f46dc98bd5b048 (diff)
downloadphosphor-logging-f1b46ff4a5db819f36888259d14364006e2b54da.tar.gz
phosphor-logging-f1b46ff4a5db819f36888259d14364006e2b54da.zip
PEL: Add function to get PEL size
Add a size() function to the PEL class that adds up the size fields in the header of every PEL section. This required a fix to some testcases where the size field was wrong in a header. Signed-off-by: Matt Spinler <spinler@us.ibm.com> Change-Id: I0d70deae116cd3835f2c0ab34e13811da471fb14
Diffstat (limited to 'extensions/openpower-pels')
-rw-r--r--extensions/openpower-pels/pel.cpp22
-rw-r--r--extensions/openpower-pels/pel.hpp7
2 files changed, 29 insertions, 0 deletions
diff --git a/extensions/openpower-pels/pel.cpp b/extensions/openpower-pels/pel.cpp
index 262865f..d1c9620 100644
--- a/extensions/openpower-pels/pel.cpp
+++ b/extensions/openpower-pels/pel.cpp
@@ -153,6 +153,28 @@ std::vector<uint8_t> PEL::data() const
return pelData;
}
+size_t PEL::size() const
+{
+ size_t size = 0;
+
+ if (_ph)
+ {
+ size += _ph->header().size;
+ }
+
+ if (_uh)
+ {
+ size += _uh->header().size;
+ }
+
+ for (const auto& section : _optionalSections)
+ {
+ size += section->header().size;
+ }
+
+ return size;
+}
+
std::optional<SRC*> PEL::primarySRC() const
{
auto src = std::find_if(
diff --git a/extensions/openpower-pels/pel.hpp b/extensions/openpower-pels/pel.hpp
index ccbef91..c3c9f5a 100644
--- a/extensions/openpower-pels/pel.hpp
+++ b/extensions/openpower-pels/pel.hpp
@@ -198,6 +198,13 @@ class PEL
std::vector<uint8_t> data() const;
/**
+ * @brief Returns the size of the PEL
+ *
+ * @return size_t The PEL size in bytes
+ */
+ size_t size() const;
+
+ /**
* @brief Says if the PEL is valid (the sections are all valid)
*
* @return bool - if the PEL is valid
OpenPOWER on IntegriCloud