Add encode_get_bios_table() function in PLDM BIOS

Signed-off-by: Sridevi Ramesh <sridevra@in.ibm.com>
Change-Id: Id0acee69d3ba13e6c39a569f37c005f1e94a5603
diff --git a/libpldm/bios.c b/libpldm/bios.c
index 017ae4a..abf7df4 100644
--- a/libpldm/bios.c
+++ b/libpldm/bios.c
@@ -1,8 +1,7 @@
+#include "bios.h"
 #include <endian.h>
 #include <string.h>
 
-#include "bios.h"
-
 int encode_get_date_time_req(uint8_t instance_id, struct pldm_msg *msg)
 {
 	struct pldm_header_info header = {0};
@@ -127,6 +126,31 @@
 	return PLDM_SUCCESS;
 }
 
+int encode_get_bios_table_req(uint8_t instance_id, uint32_t transfer_handle,
+			      uint8_t transfer_op_flag, uint8_t table_type,
+			      struct pldm_msg *msg)
+{
+	struct pldm_header_info header = {0};
+
+	if (msg == NULL) {
+		return PLDM_ERROR_INVALID_DATA;
+	}
+
+	header.msg_type = PLDM_REQUEST;
+	header.instance = instance_id;
+	header.pldm_type = PLDM_BIOS;
+	header.command = PLDM_GET_BIOS_TABLE;
+	pack_pldm_header(&header, &(msg->hdr));
+
+	struct pldm_get_bios_table_req *request =
+	    (struct pldm_get_bios_table_req *)msg->payload;
+
+	request->transfer_handle = htole32(transfer_handle);
+	request->transfer_op_flag = transfer_op_flag;
+	request->table_type = table_type;
+	return PLDM_SUCCESS;
+}
+
 int decode_get_bios_table_req(const struct pldm_msg *msg, size_t payload_length,
 			      uint32_t *transfer_handle,
 			      uint8_t *transfer_op_flag, uint8_t *table_type)
diff --git a/libpldm/bios.h b/libpldm/bios.h
index 1856b8d..270413c 100644
--- a/libpldm/bios.h
+++ b/libpldm/bios.h
@@ -262,6 +262,20 @@
 			       uint8_t transfer_flag, uint8_t *table_data,
 			       size_t payload_length, struct pldm_msg *msg);
 
+/** @brief Encode  GetBIOSTable request packet
+ *
+ *  @param[in] instance_id - Message's instance id
+ *  @param[in] transfer_handle - Handle to identify a BIOS table transfer
+ *  @param[in] transfer_op_flag - Flag to indicate the start of a multipart
+ *                                 transfer
+ *  @param[in] table_type - BIOS table type
+ *  @param[out] msg - Message will be written to this
+ *  @return pldm_completion_codes
+ */
+int encode_get_bios_table_req(uint8_t instance_id, uint32_t transfer_handle,
+			      uint8_t transfer_op_flag, uint8_t table_type,
+			      struct pldm_msg *msg);
+
 /** @brief Decode GetBIOSTable request packet
  *
  *  @param[in] msg - Request message