parser : process OpenPOWER VPD record
This change adds implementation to look at record information within
OpenPOWER VPD, check if the record is of interest to us, and if yes -
proceed to read record information, for further parsing and storage.
Change-Id: Ic6df6c88c104fc588d645e626391561a754e741e
Signed-off-by: Deepak Kodihalli <dkodihal@in.ibm.com>
diff --git a/impl.cpp b/impl.cpp
index 091d6f9..834cc6c 100644
--- a/impl.cpp
+++ b/impl.cpp
@@ -10,6 +10,13 @@
namespace parser
{
+static const std::unordered_map<std::string, Record> supportedRecords =
+{
+ {"VINI", Record::VINI},
+ {"OPFR", Record::OPFR},
+ {"OSYS", Record::OSYS}
+};
+
namespace
{
@@ -141,6 +148,33 @@
return offsets;
}
+void Impl::processRecord(std::size_t recordOffset)
+{
+ // Jump to record name
+ auto nameOffset = recordOffset +
+ sizeof(RecordId) +
+ sizeof(RecordSize) +
+ // Skip past the RT keyword, which contains
+ // the record name.
+ lengths::KW_NAME +
+ sizeof(KwSize);
+ // Get record name
+ auto iterator = vpd.cbegin();
+ std::advance(iterator, nameOffset);
+
+ std::string name(iterator, iterator + lengths::RECORD_NAME);
+ if (supportedRecords.end() != supportedRecords.find(name))
+ {
+ // If it's a record we're interested in, proceed to find
+ // contained keywords and their values.
+ std::advance(iterator, lengths::RECORD_NAME);
+ auto kwMap = readKeywords(iterator);
+ // Add entry for this record (and contained keyword:value pairs)
+ // to the parsed vpd output.
+ out.emplace(std::move(name), std::move(kwMap));
+ }
+}
+
} // namespace parser
} // namespace vpd
} // namespace openpower
diff --git a/impl.hpp b/impl.hpp
index 31bf22a..846d34a 100644
--- a/impl.hpp
+++ b/impl.hpp
@@ -79,6 +79,14 @@
internal::OffsetList readPT(Binary::const_iterator iterator,
std::size_t ptLen) const;
+ /** @brief Read VPD information contained within a record
+ *
+ * @param[in] recordOffset - offset to a record location
+ * within the binary OpenPOWER VPD
+ */
+ void processRecord(std::size_t recordOffset);
+
+
/** @brief Checks if the VHDR record is present in the VPD */
void checkHeader() const;