bios: Implement BIOSEnumAttribute
Implement BIOSEnumAttribute, most of the code is copied from
bios/bios_parser.cpp.
Implement SetAttrValueOnDbus and constructEntry for enum attribute
Signed-off-by: John Wang <wangzqbj@inspur.com>
Change-Id: Ia6230485fd2d6d05f9f2ddb3a80b81f6556aee9f
diff --git a/libpldmresponder/bios_table.hpp b/libpldmresponder/bios_table.hpp
index aab6f53..cb1873c 100644
--- a/libpldmresponder/bios_table.hpp
+++ b/libpldmresponder/bios_table.hpp
@@ -252,6 +252,31 @@
*/
IntegerField decodeIntegerEntry(const pldm_bios_attr_table_entry* entry);
+/** @struct EnumField
+ * @brief Enum field of attribute table
+ */
+struct EnumField
+{
+ std::vector<uint16_t> possibleValueStringHandle;
+ std::vector<uint8_t> defaultValueIndex;
+};
+
+/** @brief decode enum entry of attribute table
+ * @param[in] entry - Pointer to an attribute table entry
+ * @return Enum field of the entry
+ */
+EnumField decodeEnumEntry(const pldm_bios_attr_table_entry* entry);
+
+/** @brief construct enum entry of attribute table at the end of the
+ * given table
+ * @param[in,out] table - The given table
+ * @param[in] info - enum info
+ * @return pointer to the constructed entry
+ */
+const pldm_bios_attr_table_entry*
+ constructEnumEntry(Table& table,
+ pldm_bios_table_attr_entry_enum_info* info);
+
} // namespace attribute
namespace attribute_value
@@ -284,6 +309,13 @@
*/
uint64_t decodeIntegerEntry(const pldm_bios_attr_val_table_entry* entry);
+/** @brief Decode enum entry of attribute value table
+ * @param[in] entry - Pointer to an attribute value table entry
+ * @return Current value string handle indices
+ */
+std::vector<uint8_t>
+ decodeEnumEntry(const pldm_bios_attr_val_table_entry* entry);
+
/** @brief Construct string entry of attribute value table at the end of the
* given table
* @param[in] table - The given table
@@ -309,6 +341,18 @@
uint8_t attrType,
uint64_t value);
+/** @brief Construct enum entry of attribute value table at the end of
+ * the given table
+ * @param[in] table - The given table
+ * @param[in] attrHandle - attribute handle
+ * @param[in] attrType - attribute type
+ * @param[in] handleIndices - handle indices
+ * @return Pointer to the constructed entry
+ */
+const pldm_bios_attr_val_table_entry*
+ constructEnumEntry(Table& table, uint16_t attrHandle, uint8_t attrType,
+ const std::vector<uint8_t>& handleIndices);
+
/** @brief construct a table with an new entry
* @param[in] table - the table need to be updated
* @param[in] entry - the new attribute value entry