oem: meta: Add decode_oem_meta_file_io_req()
Support decode_oem_meta_file_io_req() cmd to decode the incoming post
code.
PLDM OEM Meta Write File IO cmd:
Example:
Request:
Byte 0: 0x3F (OEM cmd)
Byte 1: 0x02 (FILE IO)
Byte 2: 0x00 (File io type : POST CODE)
Byte 3-6: 0x04 (Data length)
Byte 7-10: 0x93 0xE0 0x00 0xEA (post code)
Response:
Byte 0: 0x00 (success)
Tested:
- Unit Tests passed.
Change-Id: I85437698642dd3cbe6084acf1feada842d206eac
Signed-off-by: Delphine CC Chiu <Delphine_CC_Chiu@wiwynn.com>
diff --git a/src/oem/meta/file_io.c b/src/oem/meta/file_io.c
new file mode 100644
index 0000000..6662e8f
--- /dev/null
+++ b/src/oem/meta/file_io.c
@@ -0,0 +1,34 @@
+/* SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later */
+#include <libpldm/oem/meta/file_io.h>
+#include <endian.h>
+#include <string.h>
+#include <stdio.h>
+#include "msgbuf.h"
+
+#define PLDM_OEM_META_DECODE_WRITE_FILE_IO_MIN_SIZE 6
+LIBPLDM_ABI_TESTING
+int decode_oem_meta_file_io_req(const struct pldm_msg *msg,
+ size_t payload_length, uint8_t *file_handle,
+ uint32_t *length, uint8_t *data)
+{
+ struct pldm_msgbuf _buf;
+ struct pldm_msgbuf *buf = &_buf;
+
+ if (msg == NULL || file_handle == NULL || length == NULL ||
+ data == NULL) {
+ return PLDM_ERROR_INVALID_DATA;
+ }
+
+ int rc = pldm_msgbuf_init(buf,
+ PLDM_OEM_META_DECODE_WRITE_FILE_IO_MIN_SIZE,
+ msg->payload, payload_length);
+ if (rc) {
+ return rc;
+ }
+
+ pldm_msgbuf_extract(buf, file_handle);
+ pldm_msgbuf_extract(buf, length);
+ pldm_msgbuf_extract_array_uint8(buf, data, *length);
+
+ return pldm_msgbuf_destroy_consumed(buf);
+}
diff --git a/src/oem/meta/meson.build b/src/oem/meta/meson.build
new file mode 100644
index 0000000..6c89286
--- /dev/null
+++ b/src/oem/meta/meson.build
@@ -0,0 +1,3 @@
+libpldm_sources += files(
+ 'file_io.c'
+ )