bios: Implement BIOSIntegerAttribute
Implement BIOSIntegerAttribute, most of the code is copied from
bios/bios_parser.cpp.
Implement SetAttrValueOnDbus and constructEntry for integer attribute
Signed-off-by: John Wang <wangzqbj@inspur.com>
Change-Id: I57d5b5dbcb74f9a404f5133426208f4c6851dea2
diff --git a/libpldmresponder/bios_table.hpp b/libpldmresponder/bios_table.hpp
index 4a482db..aab6f53 100644
--- a/libpldmresponder/bios_table.hpp
+++ b/libpldmresponder/bios_table.hpp
@@ -225,6 +225,33 @@
constructStringEntry(Table& table,
pldm_bios_table_attr_entry_string_info* info);
+/** @struct IntegerField
+ * @brief Integer field of attribute table
+ */
+struct IntegerField
+{
+ uint64_t lowerBound;
+ uint64_t upperBound;
+ uint32_t scalarIncrement;
+ uint64_t defaultValue;
+};
+
+/** @brief construct integer entry of attribute table at the end of the
+ * given table
+ * @param[in,out] table - The given table
+ * @param[in] info - integer info
+ * @return pointer to the constructed entry
+ */
+const pldm_bios_attr_table_entry*
+ constructIntegerEntry(Table& table,
+ pldm_bios_table_attr_entry_integer_info* info);
+
+/** @brief decode integer entry of attribute table
+ * @param[in] entry - Pointer to an attribute table entry
+ * @return Integer field of the entry
+ */
+IntegerField decodeIntegerEntry(const pldm_bios_attr_table_entry* entry);
+
} // namespace attribute
namespace attribute_value
@@ -251,6 +278,12 @@
*/
std::string decodeStringEntry(const pldm_bios_attr_val_table_entry* entry);
+/** @brief Decode integer entry of attribute value table
+ * @param[in] entry - Pointer to an attribute value table entry
+ * @return The decoded integer
+ */
+uint64_t decodeIntegerEntry(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
@@ -263,6 +296,19 @@
constructStringEntry(Table& table, uint16_t attrHandle, uint8_t attrType,
const std::string& str);
+/** @brief Construct integer 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] value - The integer
+ * @return Pointer to the constructed entry
+ */
+const pldm_bios_attr_val_table_entry* constructIntegerEntry(Table& table,
+ uint16_t attrHandle,
+ uint8_t attrType,
+ uint64_t value);
+
/** @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