bios: Implement SetBiosAttributeCurrentValue encode/decode API

Implement encode/decode APIs for SetBiosAttributeCurrentValue
command for both request and responder flow. The unit tests
functions also have been added to check these APIs.

Signed-off-by: John Wang <wangzqbj@inspur.com>
Change-Id: I5ae03778f2c47df6fc7f41c2ccb41f040cd85359
diff --git a/libpldm/bios.h b/libpldm/bios.h
index c018d07..1856b8d 100644
--- a/libpldm/bios.h
+++ b/libpldm/bios.h
@@ -16,6 +16,8 @@
 
 #define PLDM_GET_BIOS_TABLE_REQ_BYTES 6
 #define PLDM_GET_BIOS_TABLE_MIN_RESP_BYTES 6
+#define PLDM_SET_BIOS_ATTR_CURR_VAL_MIN_REQ_BYTES 5
+#define PLDM_SET_BIOS_ATTR_CURR_VAL_RESP_BYTES 5
 #define PLDM_GET_BIOS_ATTR_CURR_VAL_BY_HANDLE_REQ_BYTES 7
 
 enum pldm_bios_completion_codes {
@@ -25,6 +27,7 @@
 };
 enum pldm_bios_commands {
 	PLDM_GET_BIOS_TABLE = 0x01,
+	PLDM_SET_BIOS_ATTRIBUTE_CURRENT_VALUE = 0x07,
 	PLDM_GET_BIOS_ATTRIBUTE_CURRENT_VALUE_BY_HANDLE = 0x08,
 	PLDM_GET_DATE_TIME = 0x0c,
 };
@@ -126,6 +129,27 @@
 	uint8_t attribute_data[1];
 } __attribute__((packed));
 
+/** @struct pldm_set_bios_attribute_current_value_req
+ *
+ *  structure representing SetBiosAttributeCurrentValue request packet
+ *
+ */
+struct pldm_set_bios_attribute_current_value_req {
+	uint32_t transfer_handle;
+	uint8_t transfer_flag;
+	uint8_t attribute_data[1];
+} __attribute__((packed));
+
+/** @struct pldm_set_bios_attribute_current_value_resp
+ *
+ *  structure representing SetBiosCurrentValue response packet
+ *
+ */
+struct pldm_set_bios_attribute_current_value_resp {
+	uint8_t completion_code;
+	uint32_t next_transfer_handle;
+} __attribute__((packed));
+
 /* Requester */
 
 /* GetDateTime */
@@ -159,6 +183,40 @@
 			      uint8_t *minutes, uint8_t *hours, uint8_t *day,
 			      uint8_t *month, uint16_t *year);
 
+/* SetBiosAttributeCurrentValue */
+
+/** @brief Create a PLDM request message for SetBiosAttributeCurrentValue
+ *
+ *  @param[in] instance_id - Message's instance id
+ *  @param[in] transfer_handle - Handle to identify a BIOS table transfer
+ *  @param[in] transfer_flag - Flag to indicate what part of the transfer
+ * this request represents
+ *  @param[in] attribute_data - Contains current value of attribute
+ *  @param[in] attribute_length - Length of attribute
+ *  @param[out] msg - Message will be written to this
+ *  @param[in] payload_length - Length of message payload
+ *  @return pldm_completion_codes
+ *  @note  Caller is responsible for memory alloc and dealloc of params
+ *         'msg.payload'
+ */
+int encode_set_bios_attribute_current_value_req(
+    uint8_t instance_id, uint32_t transfer_handle, uint8_t transfer_flag,
+    const uint8_t *attribute_data, size_t attribute_length,
+    struct pldm_msg *msg, size_t payload_length);
+
+/** @brief Decode a SetBiosAttributeCurrentValue response message
+ *
+ *  @param[in] msg - Response message
+ *  @param[in] payload_length - Length of response message payload
+ *  @param[out] completion_code - Pointer to response msg's PLDM completion code
+ *  @param[out] next_transfer_handle - Pointer to a handle that identify the
+ * next portion of the transfer
+ *  @return pldm_completion_codes
+ */
+int decode_set_bios_attribute_current_value_resp(
+    const struct pldm_msg *msg, size_t payload_length, uint8_t *completion_code,
+    uint32_t *next_transfer_handle);
+
 /* Responder */
 
 /* GetDateTime */
@@ -254,6 +312,38 @@
     uint8_t transfer_flag, const uint8_t *attribute_data,
     size_t attribute_length, struct pldm_msg *msg);
 
+/* SetBiosAttributeCurrentValue */
+
+/** @brief Decode SetBIOSAttributeCurrentValue request packet
+ *
+ *  @param[in] msg - Request message
+ *  @param[in] payload_length - Length of request message payload
+ *  @param[out] transfer_handle - Handle to identify a BIOS table transfer
+ *  @param[out] transfer_flag - Flag to indicate what part of the transfer
+ * this request represents
+ *  @param[out] attribute_data - Contains current value of attribute
+ *  @param[out] attribute_length - Pointer to length of attribute
+ *  @return pldm_completion_codes
+ */
+int decode_set_bios_attribute_current_value_req(const struct pldm_msg *msg,
+						size_t payload_length,
+						uint32_t *transfer_handle,
+						uint8_t *transfer_flag,
+						uint8_t *attribute_data,
+						size_t *attribute_length);
+
+/** @brief Create a PLDM response message for SetBiosAttributeCurrentValue
+ *
+ *  @param[in] instance_id - Message's instance id
+ *  @param[in] completion_code - PLDM completion code
+ *  @param[in] next_transfer_handle - handle to identify the next portion of the
+ *  @param[out] msg - Message will be written to this
+ */
+int encode_set_bios_attribute_current_value_resp(uint8_t instance_id,
+						 uint8_t completion_code,
+						 uint32_t next_transfer_handle,
+						 struct pldm_msg *msg);
+
 #ifdef __cplusplus
 }
 #endif