diff options
author | Deepak Kodihalli <dkodihal@in.ibm.com> | 2016-11-24 06:28:45 -0600 |
---|---|---|
committer | Patrick Williams <patrick@stwcx.xyz> | 2016-12-08 17:54:40 +0000 |
commit | a1143460569a61869892e87f9b7a89682c596b46 (patch) | |
tree | 5ad0e704fd533d69836026a5902b70db239825a1 | |
parent | 023112f485be11b6c4d93dee32e195f143335130 (diff) | |
download | openpower-vpd-parser-a1143460569a61869892e87f9b7a89682c596b46.tar.gz openpower-vpd-parser-a1143460569a61869892e87f9b7a89682c596b46.zip |
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>
-rw-r--r-- | impl.cpp | 34 | ||||
-rw-r--r-- | impl.hpp | 8 |
2 files changed, 42 insertions, 0 deletions
@@ -10,6 +10,13 @@ namespace vpd 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 @@ internal::OffsetList Impl::readPT(Binary::const_iterator iterator, 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 @@ -79,6 +79,14 @@ class Impl 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; |