Tom Joseph | 7dae777 | 2019-04-10 14:44:44 +0530 | [diff] [blame^] | 1 | #ifndef FILEIO_H |
| 2 | #define FILEIO_H |
| 3 | |
| 4 | #ifdef __cplusplus |
| 5 | extern "C" { |
| 6 | #endif |
| 7 | |
| 8 | #include <stddef.h> |
| 9 | #include <stdint.h> |
| 10 | |
| 11 | #include "base.h" |
| 12 | |
| 13 | #define PLDM_IBM_OEM_TYPE 0x3F |
| 14 | |
| 15 | /** @brief PLDM Commands in IBM OEM type |
| 16 | */ |
| 17 | enum pldm_fileio_commands { PLDM_READ_FILE_INTO_MEMORY = 0x6 }; |
| 18 | |
| 19 | /** @brief PLDM Command specific codes |
| 20 | */ |
| 21 | enum pldm_fileio_completion_codes { |
| 22 | PLDM_INVALID_FILE_HANDLE = 0x80, |
| 23 | PLDM_DATA_OUT_OF_RANGE = 0x81, |
| 24 | PLDM_INVALID_READ_LENGTH = 0x82 |
| 25 | }; |
| 26 | |
| 27 | #define PLDM_READ_FILE_MEM_REQ_BYTES 20 |
| 28 | #define PLDM_READ_FILE_MEM_RESP_BYTES 5 |
| 29 | |
| 30 | /* ReadFileIntoMemory */ |
| 31 | |
| 32 | /** @brief Decode ReadFileIntoMemory commands request data |
| 33 | * |
| 34 | * @param[in] msg - Pointer to PLDM request message payload |
| 35 | * @param[in] payload_length - Length of request payload |
| 36 | * @param[out] file_handle - A handle to the file |
| 37 | * @param[out] offset - Offset to the file at which the read should begin |
| 38 | * @param[out] length - Number of bytes to be read |
| 39 | * @param[out] address - Memory address where the file content has to be |
| 40 | * written to |
| 41 | * @return pldm_completion_codes |
| 42 | */ |
| 43 | int decode_read_file_memory_req(const uint8_t *msg, size_t payload_length, |
| 44 | uint32_t *file_handle, uint32_t *offset, |
| 45 | uint32_t *length, uint64_t *address); |
| 46 | |
| 47 | /** @brief Create a PLDM response for ReadFileIntoMemory |
| 48 | * |
| 49 | * @param[in] instance_id - Message's instance id |
| 50 | * @param[in] completion_code - PLDM completion code |
| 51 | * @param[in] length - Number of bytes read. This could be less than what the |
| 52 | requester asked for. |
| 53 | * @param[in,out] msg - Message will be written to this |
| 54 | * @return pldm_completion_codes |
| 55 | * @note Caller is responsible for memory alloc and dealloc of param 'msg' |
| 56 | */ |
| 57 | int encode_read_file_memory_resp(uint8_t instance_id, uint8_t completion_code, |
| 58 | uint32_t length, struct pldm_msg *msg); |
| 59 | |
| 60 | #ifdef __cplusplus |
| 61 | } |
| 62 | #endif |
| 63 | |
| 64 | #endif /* FILEIO_H */ |