summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDeepak Kodihalli <dkodihal@in.ibm.com>2016-11-21 21:33:28 -0600
committerDeepak Kodihalli <dkodihal@in.ibm.com>2016-12-08 03:52:20 -0600
commit158c0464b6ffe993953c379b8f91e4d219a609ee (patch)
tree5f68da714c0e8e4358b3abcffbc14ac400b5bbfd
parent86c7388cab815058eeb61f7f44e17c490328ff5d (diff)
downloadopenpower-vpd-parser-158c0464b6ffe993953c379b8f91e4d219a609ee.tar.gz
openpower-vpd-parser-158c0464b6ffe993953c379b8f91e4d219a609ee.zip
Implement access to parsed OpenPOWER VPD
This change implements the access API to retrieve parsed OpenPOWER VPD. Access is provided only to supported and valid VPD. This is achieved by having template specializations for a valid record:keyword combination. Change-Id: I1ec39a94bf947bebade861fd7d9c74ccaa4ac96d Signed-off-by: Deepak Kodihalli <dkodihal@in.ibm.com>
-rw-r--r--defines.hpp86
-rw-r--r--store.hpp18
2 files changed, 104 insertions, 0 deletions
diff --git a/defines.hpp b/defines.hpp
index 1da3ab6..6b0ce45 100644
--- a/defines.hpp
+++ b/defines.hpp
@@ -13,6 +13,31 @@ enum class Record
OSYS /**< Information specific to a system board */
};
+/** @brief Convert VPD Record name from enum to string
+ * @tparam R - VPD Record
+ * @returns string representation of Record name
+ */
+template<Record R>
+constexpr const char* getRecord() = delete;
+
+template<>
+constexpr const char* getRecord<Record::VINI>()
+{
+ return "VINI";
+}
+
+template<>
+constexpr const char* getRecord<Record::OPFR>()
+{
+ return "OPFR";
+}
+
+template<>
+constexpr const char* getRecord<Record::OSYS>()
+{
+ return "OSYS";
+}
+
namespace record
{
@@ -30,6 +55,67 @@ enum class Keyword
MM /**< FRU model */
};
+/** @brief Convert VPD Keyword name from enum to string
+ * @tparam K - VPD Keyword
+ * @returns string representation of Keyword name
+ */
+template<Keyword K>
+constexpr const char* getKeyword() = delete;
+
+template<>
+constexpr const char* getKeyword<Keyword::DR>()
+{
+ return "DR";
+}
+
+template<>
+constexpr const char* getKeyword<Keyword::PN>()
+{
+ return "PN";
+}
+
+template<>
+constexpr const char* getKeyword<Keyword::SN>()
+{
+ return "SN";
+}
+
+template<>
+constexpr const char* getKeyword<Keyword::CC>()
+{
+ return "CC";
+}
+
+template<>
+constexpr const char* getKeyword<Keyword::HW>()
+{
+ return "HW";
+}
+
+template<>
+constexpr const char* getKeyword<Keyword::B1>()
+{
+ return "B1";
+}
+
+template<>
+constexpr const char* getKeyword<Keyword::VN>()
+{
+ return "VN";
+}
+
+template<>
+constexpr const char* getKeyword<Keyword::MB>()
+{
+ return "MB";
+}
+
+template<>
+constexpr const char* getKeyword<Keyword::MM>()
+{
+ return "MM";
+}
+
} // namespace record
} // namespace vpd
} // namespace openpower
diff --git a/store.hpp b/store.hpp
index e9cbeba..9da07f4 100644
--- a/store.hpp
+++ b/store.hpp
@@ -53,5 +53,23 @@ class Store final
Parsed vpd;
};
+template<Record R, record::Keyword K>
+inline const std::string& Store::get() const
+{
+ static const std::string record = getRecord<R>();
+ static const std::string keyword = record::getKeyword<K>();
+ static const std::string empty = "";
+ auto kw = vpd.find(record);
+ if (vpd.end() != kw)
+ {
+ auto value = (kw->second).find(keyword);
+ if ((kw->second).end() != value)
+ {
+ return value->second;
+ }
+ }
+ return empty;
+}
+
} // namespace vpd
} // namespace openpower
OpenPOWER on IntegriCloud