bios: Add en/decodes for integer attribute
Add encode/decode functions for integer attribute to
construct attribute table and attribute value table
Signed-off-by: John Wang <wangzqbj@inspur.com>
Change-Id: I1b61e33c169ea9f78864f9919af0f09fb5ffe5e0
diff --git a/libpldm/bios_table.h b/libpldm/bios_table.h
index 97c64ce..0a4fcd6 100644
--- a/libpldm/bios_table.h
+++ b/libpldm/bios_table.h
@@ -314,6 +314,49 @@
const struct pldm_bios_attr_table_entry *entry,
uint16_t *def_string_length);
+/** @struct pldm_bios_table_attr_entry_integer_info
+ *
+ * An auxiliary structure for passing parameters to @ref
+ * pldm_bios_table_attr_entry_integer_encode
+ *
+ */
+struct pldm_bios_table_attr_entry_integer_info {
+ uint16_t name_handle; //!< attribute name handle
+ bool read_only; //!< indicate whether the attribute is read-only
+ uint64_t lower_bound; //!< The lower bound on the integer value
+ uint64_t upper_bound; //!< The upper bound on the integer value
+ uint32_t scalar_increment; //!< The scalar value that is used for the
+ //!< increments to this integer
+ uint64_t default_value; //!< The default value of the integer
+};
+
+/** @brief Get length that an attribute entry(type: integer) will take
+ * @return The length that an entry(type: integer) will take
+ */
+size_t pldm_bios_table_attr_entry_integer_encode_length();
+
+/** @brief Create an entry of BIOS Attribute Table (type: integer)
+ * @param[out] entry - Pointer to a buffer to create an entry
+ * @param[in] entry_length - Length of the buffer to create an entry
+ * @param[in] info - Pointer to an auxiliary structure @ref
+ * pldm_bios_table_attr_entry_integer_info
+ */
+void pldm_bios_table_attr_entry_integer_encode(
+ void *entry, size_t entry_length,
+ const struct pldm_bios_table_attr_entry_integer_info *info);
+
+/** @brief Create an entry of BIOS Attribute Table (type: integer) and check the
+ * validity of the parameters
+ * @param[out] entry - Pointer to a buffer to create an entry
+ * @param[in] entry_length - Length of the buffer to create an entry
+ * @param[in] info - Pointer to an auxiliary structure @ref
+ * pldm_bios_table_attr_entry_integer_info
+ * @return pldm_completion_codes
+ */
+int pldm_bios_table_attr_entry_integer_encode_check(
+ void *entry, size_t entry_length,
+ const struct pldm_bios_table_attr_entry_integer_info *info);
+
/** @brief Get length that an attribute value entry(type: enum) will take
* @param[in] count - Total number of current values for this enumeration
* @return The length that an entry(type: enum) will take
@@ -391,6 +434,42 @@
void *entry, size_t entry_length, uint16_t attr_handle, uint8_t attr_type,
uint16_t string_length, const char *string);
+/** @brief Get length that an attribute value entry(type: integer) will take
+ * @return The length that an entry(type: integer) will take
+ */
+size_t pldm_bios_table_attr_value_entry_encode_integer_length();
+
+/** @brief Create an attribute value entry(type: integer)
+ * @param[out] entry - Pointer to bios attribute value entry
+ * @param[in] entry_length - Length of attribute value entry
+ * @param[in] attr_handle - This handle points to an attribute in the
+ * BIOS Attribute Vlaue Table.
+ * @param[in] attr_type - Type of this attribute in the BIOS Attribute Value
+ * Table
+ * @param[in] cv - Current Value
+ */
+void pldm_bios_table_attr_value_entry_encode_integer(void *entry,
+ size_t entry_length,
+ uint16_t attr_handle,
+ uint8_t attr_type,
+ uint64_t cv);
+
+/** @brief Create an attribute value entry(type: integer) and check the validity
+ * of the parameters
+ * @param[out] entry - Pointer to bios attribute value entry
+ * @param[in] entry_length - Length of attribute value entry
+ * @param[in] attr_handle - This handle points to an attribute in the
+ * BIOS Attribute Vlaue Table.
+ * @param[in] attr_type - Type of this attribute in the BIOS Attribute Value
+ * Table
+ * @param[in] cv - Current Value
+ * @return pldm_completion_codes
+ */
+int pldm_bios_table_attr_value_entry_encode_integer_check(void *entry,
+ size_t entry_length,
+ uint16_t attr_handle,
+ uint8_t attr_type,
+ uint64_t cv);
#ifdef __cplusplus
}
#endif