Refactor DMA function and add responder for WriteFileFromMemory command

The WriteFileFromMemory command transfers data to the BMC from the Host
using DMA. Refactor the DMA transfer function so that the code between
the read and write file commands is common.

Signed-off-by: Eddie James <eajames@us.ibm.com>
Change-Id: I1ce5739c312c4789b882bff04f0e686cc438ab52
diff --git a/libpldm/file_io.c b/libpldm/file_io.c
index 426033a..ca33cef 100644
--- a/libpldm/file_io.c
+++ b/libpldm/file_io.c
@@ -2,16 +2,16 @@
 #include <endian.h>
 #include <string.h>
 
-int decode_read_file_memory_req(const uint8_t *msg, size_t payload_length,
-				uint32_t *file_handle, uint32_t *offset,
-				uint32_t *length, uint64_t *address)
+int decode_rw_file_memory_req(const uint8_t *msg, size_t payload_length,
+			      uint32_t *file_handle, uint32_t *offset,
+			      uint32_t *length, uint64_t *address)
 {
 	if (msg == NULL || file_handle == NULL || offset == NULL ||
 	    length == NULL || address == NULL) {
 		return PLDM_ERROR_INVALID_DATA;
 	}
 
-	if (payload_length != PLDM_READ_FILE_MEM_REQ_BYTES) {
+	if (payload_length != PLDM_RW_FILE_MEM_REQ_BYTES) {
 		return PLDM_ERROR_INVALID_LENGTH;
 	}
 
@@ -25,8 +25,9 @@
 	return PLDM_SUCCESS;
 }
 
-int encode_read_file_memory_resp(uint8_t instance_id, uint8_t completion_code,
-				 uint32_t length, struct pldm_msg *msg)
+int encode_rw_file_memory_resp(uint8_t instance_id, uint8_t command,
+			       uint8_t completion_code, uint32_t length,
+			       struct pldm_msg *msg)
 {
 	struct pldm_header_info header = {0};
 	int rc = PLDM_SUCCESS;
@@ -37,7 +38,7 @@
 	header.msg_type = PLDM_RESPONSE;
 	header.instance = instance_id;
 	header.pldm_type = PLDM_IBM_OEM_TYPE;
-	header.command = PLDM_READ_FILE_INTO_MEMORY;
+	header.command = command;
 
 	if ((rc = pack_pldm_header(&header, &(msg->hdr))) > PLDM_SUCCESS) {
 		return rc;