Jinu Joy Thomas | 7f57f44 | 2019-06-13 20:38:49 +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 | |
Jinu Joy Thomas | 7f57f44 | 2019-06-13 20:38:49 +0530 | [diff] [blame] | 13 | /** @brief PLDM Commands in IBM OEM type |
| 14 | */ |
| 15 | enum pldm_fileio_commands { |
Tom Joseph | 0c6d22c | 2019-06-26 09:58:41 +0530 | [diff] [blame] | 16 | PLDM_GET_FILE_TABLE = 0x1, |
vkaverap | 2ffe329 | 2019-06-24 00:08:13 -0500 | [diff] [blame] | 17 | PLDM_READ_FILE = 0x4, |
| 18 | PLDM_WRITE_FILE = 0x5, |
Jinu Joy Thomas | 7f57f44 | 2019-06-13 20:38:49 +0530 | [diff] [blame] | 19 | PLDM_READ_FILE_INTO_MEMORY = 0x6, |
| 20 | PLDM_WRITE_FILE_FROM_MEMORY = 0x7, |
vkaverap | 0740456 | 2019-08-05 22:57:11 -0500 | [diff] [blame] | 21 | PLDM_READ_FILE_BY_TYPE_INTO_MEMORY = 0x8, |
| 22 | PLDM_WRITE_FILE_BY_TYPE_FROM_MEMORY = 0x9, |
vkaverap | a9aac72 | 2019-08-22 02:10:15 -0500 | [diff] [blame] | 23 | PLDM_NEW_FILE_AVAILABLE = 0xA, |
Deepak Kodihalli | dce1c99 | 2019-11-19 07:06:53 -0600 | [diff] [blame] | 24 | PLDM_READ_FILE_BY_TYPE = 0xB, |
vkaverap | f4e0a49 | 2019-11-19 01:47:35 -0600 | [diff] [blame] | 25 | PLDM_WRITE_FILE_BY_TYPE = 0xC, |
| 26 | PLDM_FILE_ACK = 0xD, |
Sridevi Ramesh | 8b51fa2 | 2022-06-13 06:28:13 -0500 | [diff] [blame] | 27 | PLDM_NEW_FILE_AVAILABLE_WITH_META_DATA = 0xE, |
| 28 | PLDM_FILE_ACK_WITH_META_DATA = 0xF, |
Jinu Joy Thomas | 7f57f44 | 2019-06-13 20:38:49 +0530 | [diff] [blame] | 29 | }; |
| 30 | |
| 31 | /** @brief PLDM Command specific codes |
| 32 | */ |
| 33 | enum pldm_fileio_completion_codes { |
Deepak Kodihalli | 3bf5c55 | 2020-04-20 06:16:01 -0500 | [diff] [blame] | 34 | PLDM_FILE_TABLE_UNAVAILABLE = 0x83, |
Tom Joseph | 0c6d22c | 2019-06-26 09:58:41 +0530 | [diff] [blame] | 35 | PLDM_INVALID_FILE_TABLE_TYPE = 0x85, |
Deepak Kodihalli | 3bf5c55 | 2020-04-20 06:16:01 -0500 | [diff] [blame] | 36 | PLDM_INVALID_FILE_HANDLE = 0x86, |
| 37 | PLDM_DATA_OUT_OF_RANGE = 0x87, |
| 38 | PLDM_INVALID_FILE_TYPE = 0x89, |
Tom Joseph | 0c6d22c | 2019-06-26 09:58:41 +0530 | [diff] [blame] | 39 | }; |
| 40 | |
| 41 | /** @brief PLDM File I/O table types |
| 42 | */ |
| 43 | enum pldm_fileio_table_type { |
| 44 | PLDM_FILE_ATTRIBUTE_TABLE = 0, |
| 45 | PLDM_OEM_FILE_ATTRIBUTE_TABLE = 1, |
Jinu Joy Thomas | 7f57f44 | 2019-06-13 20:38:49 +0530 | [diff] [blame] | 46 | }; |
| 47 | |
Sampa Misra | 854e61f | 2019-08-22 04:36:47 -0500 | [diff] [blame] | 48 | /** @brief PLDM File I/O table types |
| 49 | */ |
| 50 | enum pldm_fileio_file_type { |
Jayashankar Padath | db12436 | 2021-01-28 21:12:34 -0600 | [diff] [blame] | 51 | PLDM_FILE_TYPE_PEL = 0x0, |
| 52 | PLDM_FILE_TYPE_LID_PERM = 0x1, |
| 53 | PLDM_FILE_TYPE_LID_TEMP = 0x2, |
| 54 | PLDM_FILE_TYPE_DUMP = 0x3, |
| 55 | PLDM_FILE_TYPE_CERT_SIGNING_REQUEST = 0x4, |
| 56 | PLDM_FILE_TYPE_SIGNED_CERT = 0x5, |
| 57 | PLDM_FILE_TYPE_ROOT_CERT = 0x6, |
| 58 | PLDM_FILE_TYPE_LID_MARKER = 0x7, |
| 59 | PLDM_FILE_TYPE_RESOURCE_DUMP_PARMS = 0x8, |
| 60 | PLDM_FILE_TYPE_RESOURCE_DUMP = 0x9, |
Manojkiran Eda | d94bb83 | 2021-02-17 11:40:22 +0530 | [diff] [blame] | 61 | PLDM_FILE_TYPE_PROGRESS_SRC = 0xA, |
Sampa Misra | 854e61f | 2019-08-22 04:36:47 -0500 | [diff] [blame] | 62 | }; |
| 63 | |
Jinu Joy Thomas | 7f57f44 | 2019-06-13 20:38:49 +0530 | [diff] [blame] | 64 | #define PLDM_RW_FILE_MEM_REQ_BYTES 20 |
| 65 | #define PLDM_RW_FILE_MEM_RESP_BYTES 5 |
Tom Joseph | 0c6d22c | 2019-06-26 09:58:41 +0530 | [diff] [blame] | 66 | #define PLDM_GET_FILE_TABLE_REQ_BYTES 6 |
| 67 | #define PLDM_GET_FILE_TABLE_MIN_RESP_BYTES 6 |
vkaverap | 2ffe329 | 2019-06-24 00:08:13 -0500 | [diff] [blame] | 68 | #define PLDM_READ_FILE_REQ_BYTES 12 |
| 69 | #define PLDM_READ_FILE_RESP_BYTES 5 |
| 70 | #define PLDM_WRITE_FILE_REQ_BYTES 12 |
| 71 | #define PLDM_WRITE_FILE_RESP_BYTES 5 |
vkaverap | 0740456 | 2019-08-05 22:57:11 -0500 | [diff] [blame] | 72 | #define PLDM_RW_FILE_BY_TYPE_MEM_REQ_BYTES 22 |
| 73 | #define PLDM_RW_FILE_BY_TYPE_MEM_RESP_BYTES 5 |
Deepak Kodihalli | 8338876 | 2020-01-28 04:09:58 -0600 | [diff] [blame] | 74 | #define PLDM_NEW_FILE_REQ_BYTES 14 |
vkaverap | a9aac72 | 2019-08-22 02:10:15 -0500 | [diff] [blame] | 75 | #define PLDM_NEW_FILE_RESP_BYTES 1 |
Deepak Kodihalli | dce1c99 | 2019-11-19 07:06:53 -0600 | [diff] [blame] | 76 | #define PLDM_RW_FILE_BY_TYPE_REQ_BYTES 14 |
| 77 | #define PLDM_RW_FILE_BY_TYPE_RESP_BYTES 5 |
vkaverap | f4e0a49 | 2019-11-19 01:47:35 -0600 | [diff] [blame] | 78 | #define PLDM_FILE_ACK_REQ_BYTES 7 |
| 79 | #define PLDM_FILE_ACK_RESP_BYTES 1 |
Sridevi Ramesh | 8b51fa2 | 2022-06-13 06:28:13 -0500 | [diff] [blame] | 80 | #define PLDM_FILE_ACK_WITH_META_DATA_REQ_BYTES 23 |
| 81 | #define PLDM_FILE_ACK_WITH_META_DATA_RESP_BYTES 1 |
Sridevi Ramesh | 07c2f0a | 2022-07-03 03:32:52 -0500 | [diff] [blame^] | 82 | #define PLDM_NEW_FILE_AVAILABLE_WITH_META_DATA_REQ_BYTES 30 |
| 83 | #define PLDM_NEW_FILE_AVAILABLE_WITH_META_DATA_RESP_BYTES 1 |
Jinu Joy Thomas | 7f57f44 | 2019-06-13 20:38:49 +0530 | [diff] [blame] | 84 | |
Priyanga | 8b97665 | 2019-06-27 11:30:33 -0500 | [diff] [blame] | 85 | /** @struct pldm_read_write_file_memory_req |
| 86 | * |
| 87 | * Structure representing ReadFileIntoMemory request and WriteFileFromMemory |
| 88 | * request |
| 89 | */ |
| 90 | struct pldm_read_write_file_memory_req { |
| 91 | uint32_t file_handle; //!< A Handle to the file |
| 92 | uint32_t offset; //!< Offset to the file |
| 93 | uint32_t length; //!< Number of bytes to be read/write |
| 94 | uint64_t address; //!< Memory address of the file |
| 95 | } __attribute__((packed)); |
| 96 | |
| 97 | /** @struct pldm_read_write_file_memory_resp |
| 98 | * |
| 99 | * Structure representing ReadFileIntoMemory response and WriteFileFromMemory |
| 100 | * response |
| 101 | */ |
| 102 | struct pldm_read_write_file_memory_resp { |
| 103 | uint8_t completion_code; //!< completion code |
| 104 | uint32_t length; //!< Number of bytes read/written |
| 105 | } __attribute__((packed)); |
| 106 | |
Jinu Joy Thomas | 7f57f44 | 2019-06-13 20:38:49 +0530 | [diff] [blame] | 107 | /** @brief Decode ReadFileIntoMemory and WriteFileFromMemory commands request |
| 108 | * data |
| 109 | * |
Zahed Hossain | 223a73d | 2019-07-04 12:46:18 -0500 | [diff] [blame] | 110 | * @param[in] msg - Pointer to PLDM request message |
Jinu Joy Thomas | 7f57f44 | 2019-06-13 20:38:49 +0530 | [diff] [blame] | 111 | * @param[in] payload_length - Length of request payload |
| 112 | * @param[out] file_handle - A handle to the file |
| 113 | * @param[out] offset - Offset to the file at which the read should begin |
| 114 | * @param[out] length - Number of bytes to be read |
| 115 | * @param[out] address - Memory address where the file content has to be |
| 116 | * written to |
| 117 | * @return pldm_completion_codes |
| 118 | */ |
Zahed Hossain | 223a73d | 2019-07-04 12:46:18 -0500 | [diff] [blame] | 119 | int decode_rw_file_memory_req(const struct pldm_msg *msg, size_t payload_length, |
Jinu Joy Thomas | 7f57f44 | 2019-06-13 20:38:49 +0530 | [diff] [blame] | 120 | uint32_t *file_handle, uint32_t *offset, |
| 121 | uint32_t *length, uint64_t *address); |
| 122 | |
| 123 | /** @brief Create a PLDM response for ReadFileIntoMemory and |
| 124 | * WriteFileFromMemory |
| 125 | * |
| 126 | * @param[in] instance_id - Message's instance id |
| 127 | * @param[in] command - PLDM command |
| 128 | * @param[in] completion_code - PLDM completion code |
| 129 | * @param[in] length - Number of bytes read. This could be less than what the |
| 130 | requester asked for. |
| 131 | * @param[in,out] msg - Message will be written to this |
| 132 | * @return pldm_completion_codes |
| 133 | * @note Caller is responsible for memory alloc and dealloc of param 'msg' |
| 134 | */ |
| 135 | int encode_rw_file_memory_resp(uint8_t instance_id, uint8_t command, |
| 136 | uint8_t completion_code, uint32_t length, |
| 137 | struct pldm_msg *msg); |
| 138 | |
Priyanga | 8b97665 | 2019-06-27 11:30:33 -0500 | [diff] [blame] | 139 | /** @brief Encode ReadFileIntoMemory and WriteFileFromMemory |
| 140 | * commands request data |
| 141 | * |
| 142 | * @param[in] instance_id - Message's instance id |
| 143 | * @param[in] command - PLDM command |
| 144 | * @param[in] file_handle - A handle to the file |
| 145 | * @param[in] offset - Offset to the file at which the read should begin |
| 146 | * @param[in] length - Number of bytes to be read/written |
| 147 | * @param[in] address - Memory address where the file content has to be |
| 148 | * written to |
| 149 | * @param[out] msg - Message will be written to this |
| 150 | * @return pldm_completion_codes |
| 151 | */ |
| 152 | int encode_rw_file_memory_req(uint8_t instance_id, uint8_t command, |
| 153 | uint32_t file_handle, uint32_t offset, |
| 154 | uint32_t length, uint64_t address, |
| 155 | struct pldm_msg *msg); |
| 156 | |
| 157 | /** @brief Decode ReadFileIntoMemory and WriteFileFromMemory |
| 158 | * commands response data |
| 159 | * |
Zahed Hossain | 223a73d | 2019-07-04 12:46:18 -0500 | [diff] [blame] | 160 | * @param[in] msg - pointer to PLDM response message |
Priyanga | 8b97665 | 2019-06-27 11:30:33 -0500 | [diff] [blame] | 161 | * @param[in] payload_length - Length of response payload |
| 162 | * @param[out] completion_code - PLDM completion code |
| 163 | * @param[out] length - Number of bytes to be read/written |
| 164 | * @return pldm_completion_codes |
| 165 | */ |
Zahed Hossain | 223a73d | 2019-07-04 12:46:18 -0500 | [diff] [blame] | 166 | int decode_rw_file_memory_resp(const struct pldm_msg *msg, |
| 167 | size_t payload_length, uint8_t *completion_code, |
| 168 | uint32_t *length); |
Priyanga | 8b97665 | 2019-06-27 11:30:33 -0500 | [diff] [blame] | 169 | |
Tom Joseph | 0c6d22c | 2019-06-26 09:58:41 +0530 | [diff] [blame] | 170 | /** @struct pldm_get_file_table_req |
| 171 | * |
| 172 | * Structure representing GetFileTable request |
| 173 | */ |
| 174 | struct pldm_get_file_table_req { |
| 175 | uint32_t transfer_handle; //!< Data transfer handle |
Deepak Kodihalli | 826c9d4 | 2020-05-26 01:58:06 -0500 | [diff] [blame] | 176 | uint8_t operation_flag; //!< Transfer operation flag |
| 177 | uint8_t table_type; //!< Table type |
Tom Joseph | 0c6d22c | 2019-06-26 09:58:41 +0530 | [diff] [blame] | 178 | } __attribute__((packed)); |
| 179 | |
| 180 | /** @struct pldm_get_file_table_resp |
| 181 | * |
| 182 | * Structure representing GetFileTable response fixed data |
| 183 | */ |
| 184 | struct pldm_get_file_table_resp { |
| 185 | uint8_t completion_code; //!< Completion code |
| 186 | uint32_t next_transfer_handle; //!< Next data transfer handle |
Deepak Kodihalli | 826c9d4 | 2020-05-26 01:58:06 -0500 | [diff] [blame] | 187 | uint8_t transfer_flag; //!< Transfer flag |
| 188 | uint8_t table_data[1]; //!< Table Data |
Tom Joseph | 0c6d22c | 2019-06-26 09:58:41 +0530 | [diff] [blame] | 189 | } __attribute__((packed)); |
| 190 | |
Pavithra Barithaya | c4e80cc | 2020-05-26 07:00:26 -0500 | [diff] [blame] | 191 | /** @struct pldm_file_attr_table_entry |
| 192 | * |
| 193 | * Structure representing File attribute table entry |
| 194 | */ |
| 195 | struct pldm_file_attr_table_entry { |
| 196 | uint32_t file_handle; //!< File Handle |
| 197 | uint16_t file_name_length; //!< File name length |
| 198 | uint8_t file_attr_table_nst[1]; //!< File name size traits |
| 199 | } __attribute__((packed)); |
| 200 | |
Tom Joseph | 0c6d22c | 2019-06-26 09:58:41 +0530 | [diff] [blame] | 201 | /** @brief Decode GetFileTable command request data |
| 202 | * |
Zahed Hossain | 223a73d | 2019-07-04 12:46:18 -0500 | [diff] [blame] | 203 | * @param[in] msg - Pointer to PLDM request message |
Tom Joseph | 0c6d22c | 2019-06-26 09:58:41 +0530 | [diff] [blame] | 204 | * @param[in] payload_length - Length of request payload |
| 205 | * @param[out] trasnfer_handle - the handle of data |
| 206 | * @param[out] transfer_opflag - Transfer operation flag |
| 207 | * @param[out] table_type - the type of file table |
| 208 | * @return pldm_completion_codes |
| 209 | */ |
Zahed Hossain | 223a73d | 2019-07-04 12:46:18 -0500 | [diff] [blame] | 210 | int decode_get_file_table_req(const struct pldm_msg *msg, size_t payload_length, |
Tom Joseph | 0c6d22c | 2019-06-26 09:58:41 +0530 | [diff] [blame] | 211 | uint32_t *transfer_handle, |
| 212 | uint8_t *transfer_opflag, uint8_t *table_type); |
| 213 | |
| 214 | /** @brief Create a PLDM response for GetFileTable command |
| 215 | * |
| 216 | * @param[in] instance_id - Message's instance id |
| 217 | * @param[in] completion_code - PLDM completion code |
| 218 | * @param[in] next_transfer_handle - Handle to identify next portion of |
| 219 | * data transfer |
| 220 | * @param[in] transfer_flag - Represents the part of transfer |
| 221 | * @param[in] table_data - pointer to file table data |
| 222 | * @param[in] table_size - file table size |
| 223 | * @param[in,out] msg - Message will be written to this |
| 224 | * @return pldm_completion_codes |
| 225 | * @note Caller is responsible for memory alloc and dealloc of param 'msg' |
| 226 | */ |
| 227 | int encode_get_file_table_resp(uint8_t instance_id, uint8_t completion_code, |
| 228 | uint32_t next_transfer_handle, |
| 229 | uint8_t transfer_flag, const uint8_t *table_data, |
| 230 | size_t table_size, struct pldm_msg *msg); |
| 231 | |
Pavithra Barithaya | d15c809 | 2020-05-12 02:26:26 -0500 | [diff] [blame] | 232 | /** @brief Encode GetFileTable command request data |
| 233 | * |
| 234 | * @param[in] instance_id - Message's instance id |
| 235 | * @param[in] transfer_handle - the handle of data |
| 236 | * @param[in] transfer_opflag - Transfer operation flag |
| 237 | * @param[in] table_type - the type of file table |
| 238 | * @param[out] msg - Message will be written to this |
| 239 | * @return pldm_completion_codes |
| 240 | */ |
| 241 | int encode_get_file_table_req(uint8_t instance_id, uint32_t transfer_handle, |
| 242 | uint8_t transfer_opflag, uint8_t table_type, |
| 243 | struct pldm_msg *msg); |
| 244 | |
| 245 | /** @brief Decode GetFileTable command response data |
| 246 | * @param[in] msg - Response message |
| 247 | * @param[in] payload_length - length of response message payload |
| 248 | * @param[out] completion_code - PLDM completion code |
| 249 | * @param[out] next_transfer_handle - Handle to identify next portion of data |
| 250 | * transfer |
| 251 | * @param[out] transfer_flag - Represents the part of transfer |
| 252 | * @param[out] file_table_data_start_offset - This data is a portion of the |
| 253 | * overall File Table |
| 254 | * @param[out] file_table_length - Length of the File table data |
| 255 | * @return pldm_completion_codes |
| 256 | */ |
| 257 | int decode_get_file_table_resp(const struct pldm_msg *msg, |
| 258 | size_t payload_length, uint8_t *completion_code, |
| 259 | uint32_t *next_transfer_handle, |
| 260 | uint8_t *transfer_flag, |
| 261 | uint8_t *file_table_data_start_offset, |
| 262 | size_t *file_table_length); |
| 263 | |
vkaverap | 2ffe329 | 2019-06-24 00:08:13 -0500 | [diff] [blame] | 264 | /** @struct pldm_read_file_req |
| 265 | * |
| 266 | * Structure representing ReadFile request |
| 267 | */ |
| 268 | struct pldm_read_file_req { |
| 269 | uint32_t file_handle; //!< Handle to file |
| 270 | uint32_t offset; //!< Offset to file where read starts |
| 271 | uint32_t length; //!< Bytes to be read |
| 272 | } __attribute__((packed)); |
| 273 | |
| 274 | /** @struct pldm_read_file_resp |
| 275 | * |
| 276 | * Structure representing ReadFile response data |
| 277 | */ |
| 278 | struct pldm_read_file_resp { |
| 279 | uint8_t completion_code; //!< Completion code |
| 280 | uint32_t length; //!< Number of bytes read |
Deepak Kodihalli | 826c9d4 | 2020-05-26 01:58:06 -0500 | [diff] [blame] | 281 | uint8_t file_data[1]; //!< Address of this is where file data starts |
vkaverap | 2ffe329 | 2019-06-24 00:08:13 -0500 | [diff] [blame] | 282 | } __attribute__((packed)); |
| 283 | |
| 284 | /** @struct pldm_write_file_req |
| 285 | * |
| 286 | * Structure representing WriteFile request |
| 287 | */ |
| 288 | struct pldm_write_file_req { |
| 289 | uint32_t file_handle; //!< Handle to file |
| 290 | uint32_t offset; //!< Offset to file where write starts |
| 291 | uint32_t length; //!< Bytes to be written |
| 292 | uint8_t file_data[1]; //!< Address of this is where file data starts |
| 293 | } __attribute__((packed)); |
| 294 | |
| 295 | /** @struct pldm_write_file_resp |
| 296 | * |
| 297 | * Structure representing WriteFile response data |
| 298 | */ |
| 299 | struct pldm_write_file_resp { |
| 300 | uint8_t completion_code; //!< Completion code |
| 301 | uint32_t length; //!< Bytes written |
| 302 | } __attribute__((packed)); |
| 303 | |
| 304 | /** @brief Decode Read File commands request |
| 305 | * |
| 306 | * @param[in] msg - PLDM request message payload |
| 307 | * @param[in] payload_length - Length of request payload |
| 308 | * @param[out] file_handle - A handle to the file |
| 309 | * @param[out] offset - Offset to the file at which the read should begin |
| 310 | * @param[out] length - Number of bytes read |
| 311 | * @return pldm_completion_codes |
| 312 | */ |
| 313 | int decode_read_file_req(const struct pldm_msg *msg, size_t payload_length, |
| 314 | uint32_t *file_handle, uint32_t *offset, |
| 315 | uint32_t *length); |
| 316 | |
| 317 | /** @brief Encode Read File commands request |
| 318 | * |
| 319 | * @param[in] instance_id - Message's instance id |
| 320 | * @param[in] file_handle - A handle to the file |
| 321 | * @param[in] offset - Offset to the file at which the read should begin |
| 322 | * @param[in] length - Number of bytes read |
| 323 | * @param[in,out] msg - Message will be written to this |
| 324 | * @return pldm_completion_codes |
| 325 | * @note Caller is responsible for memory alloc and dealloc of param 'msg' |
| 326 | */ |
| 327 | int encode_read_file_req(uint8_t instance_id, uint32_t file_handle, |
| 328 | uint32_t offset, uint32_t length, |
| 329 | struct pldm_msg *msg); |
| 330 | |
| 331 | /** @brief Decode Read File commands response |
| 332 | * |
| 333 | * @param[in] msg - PLDM response message payload |
| 334 | * @param[in] payload_length - Length of request payload |
| 335 | * @param[out] completion_code - PLDM completion code |
| 336 | * @param[out] length - Number of bytes read. This could be less than what the |
| 337 | * requester asked for. |
| 338 | * @param[out] file_data_offset - Offset where file data should be read in pldm |
| 339 | * msg. |
| 340 | * @return pldm_completion_codes |
| 341 | */ |
| 342 | int decode_read_file_resp(const struct pldm_msg *msg, size_t payload_length, |
| 343 | uint8_t *completion_code, uint32_t *length, |
| 344 | size_t *file_data_offset); |
| 345 | |
| 346 | /** @brief Create a PLDM response for Read File |
| 347 | * |
| 348 | * @param[in] instance_id - Message's instance id |
| 349 | * @param[in] completion_code - PLDM completion code |
| 350 | * @param[in] length - Number of bytes read. This could be less than what the |
| 351 | * requester asked for. |
| 352 | * @param[in,out] msg - Message will be written to this |
| 353 | * @return pldm_completion_codes |
| 354 | * @note Caller is responsible for memory alloc and dealloc of param 'msg'. |
| 355 | * Although read file command response includes file data, this function |
| 356 | * does not encode the file data to prevent additional copying of the data. |
| 357 | * The position of file data is calculated by caller from address and size |
| 358 | * of other input arguments. |
| 359 | */ |
| 360 | int encode_read_file_resp(uint8_t instance_id, uint8_t completion_code, |
| 361 | uint32_t length, struct pldm_msg *msg); |
| 362 | |
| 363 | /** @brief Decode Write File commands request |
| 364 | * |
| 365 | * @param[in] msg - PLDM request message payload |
| 366 | * @param[in] payload_length - Length of request payload |
| 367 | * @param[out] file_handle - A handle to the file |
| 368 | * @param[out] offset - Offset to the file at which the write should begin |
| 369 | * @param[out] length - Number of bytes to write |
| 370 | * @param[out] file_data_offset - Offset where file data write begins in pldm |
| 371 | * msg. |
| 372 | * @return pldm_completion_codes |
| 373 | */ |
| 374 | int decode_write_file_req(const struct pldm_msg *msg, size_t payload_length, |
| 375 | uint32_t *file_handle, uint32_t *offset, |
| 376 | uint32_t *length, size_t *file_data_offset); |
| 377 | |
| 378 | /** @brief Create a PLDM request for Write File |
| 379 | * |
| 380 | * @param[in] instance_id - Message's instance id |
| 381 | * @param[in] file_handle - A handle to the file |
| 382 | * @param[in] offset - Offset to the file at which the read should begin |
| 383 | * @param[in] length - Number of bytes written. This could be less than what |
| 384 | * the requester asked for. |
| 385 | * @param[in,out] msg - Message will be written to this |
| 386 | * @return pldm_completion_codes |
| 387 | * @note Caller is responsible for memory alloc and dealloc of param 'msg'. |
| 388 | * Although write file command request includes file data, this function |
| 389 | * does not encode the file data to prevent additional copying of the data. |
| 390 | * The position of file data is calculated by caller from address and size |
| 391 | * of other input arguments. |
| 392 | */ |
| 393 | int encode_write_file_req(uint8_t instance_id, uint32_t file_handle, |
| 394 | uint32_t offset, uint32_t length, |
| 395 | struct pldm_msg *msg); |
| 396 | |
| 397 | /** @brief Decode Write File commands response |
| 398 | * |
| 399 | * @param[in] msg - PLDM request message payload |
| 400 | * @param[in] payload_length - Length of request payload |
| 401 | * @param[out] completion_code - PLDM completion code |
| 402 | * @param[out] length - Number of bytes written |
| 403 | * @return pldm_completion_codes |
| 404 | */ |
| 405 | int decode_write_file_resp(const struct pldm_msg *msg, size_t payload_length, |
| 406 | uint8_t *completion_code, uint32_t *length); |
| 407 | |
| 408 | /** @brief Create a PLDM response for Write File |
| 409 | * |
| 410 | * @param[in] instance_id - Message's instance id |
| 411 | * @param[in] completion_code - PLDM completion code |
| 412 | * @param[in] length - Number of bytes written. This could be less than what |
| 413 | * the requester asked for. |
| 414 | * @param[in,out] msg - Message will be written to this |
| 415 | * @return pldm_completion_codes |
| 416 | * @note Caller is responsible for memory alloc and dealloc of param 'msg' |
| 417 | */ |
| 418 | int encode_write_file_resp(uint8_t instance_id, uint8_t completion_code, |
| 419 | uint32_t length, struct pldm_msg *msg); |
| 420 | |
vkaverap | 0740456 | 2019-08-05 22:57:11 -0500 | [diff] [blame] | 421 | /** @struct pldm_read_write_file_by_type_memory_req |
| 422 | * |
| 423 | * Structure representing ReadFileByTypeIntoMemory and |
| 424 | * WriteFileByTypeFromMemory request |
| 425 | */ |
| 426 | struct pldm_read_write_file_by_type_memory_req { |
| 427 | uint16_t file_type; //!< Type of file |
| 428 | uint32_t file_handle; //!< Handle to file |
| 429 | uint32_t offset; //!< Offset to file where read starts |
| 430 | uint32_t length; //!< Bytes to be read |
| 431 | uint64_t address; //!< Memory address of the file |
| 432 | } __attribute__((packed)); |
| 433 | |
| 434 | /** @struct pldm_read_write_file_by_type_memory_resp |
| 435 | * |
| 436 | * Structure representing ReadFileByTypeIntoMemory and |
| 437 | * WriteFileByTypeFromMemory response |
| 438 | */ |
| 439 | struct pldm_read_write_file_by_type_memory_resp { |
| 440 | uint8_t completion_code; //!< Completion code |
| 441 | uint32_t length; //!< Number of bytes read |
| 442 | } __attribute__((packed)); |
| 443 | |
| 444 | /** @brief Decode ReadFileByTypeIntoMemory and WriteFileByTypeFromMemory |
| 445 | * commands request data |
| 446 | * |
| 447 | * @param[in] msg - Pointer to PLDM request message |
| 448 | * @param[in] payload_length - Length of request payload |
| 449 | * @param[in] file_type - Type of the file |
| 450 | * @param[out] file_handle - A handle to the file |
| 451 | * @param[out] offset - Offset to the file at which the read should begin |
| 452 | * @param[out] length - Number of bytes to be read |
| 453 | * @param[out] address - Memory address of the file content |
| 454 | * @return pldm_completion_codes |
| 455 | */ |
| 456 | int decode_rw_file_by_type_memory_req(const struct pldm_msg *msg, |
| 457 | size_t payload_length, |
| 458 | uint16_t *file_type, |
| 459 | uint32_t *file_handle, uint32_t *offset, |
| 460 | uint32_t *length, uint64_t *address); |
| 461 | |
| 462 | /** @brief Create a PLDM response for ReadFileByTypeIntoMemory and |
| 463 | * WriteFileByTypeFromMemory |
| 464 | * |
| 465 | * @param[in] instance_id - Message's instance id |
| 466 | * @param[in] command - PLDM command |
| 467 | * @param[in] completion_code - PLDM completion code |
| 468 | * @param[in] length - Number of bytes read. This could be less than what the |
| 469 | * requester asked for. |
| 470 | * @param[in,out] msg - Message will be written to this |
| 471 | * @return pldm_completion_codes |
| 472 | * @note Caller is responsible for memory alloc and dealloc of param 'msg' |
| 473 | */ |
| 474 | int encode_rw_file_by_type_memory_resp(uint8_t instance_id, uint8_t command, |
| 475 | uint8_t completion_code, uint32_t length, |
| 476 | struct pldm_msg *msg); |
| 477 | |
| 478 | /** @brief Encode ReadFileByTypeIntoMemory and WriteFileByTypeFromMemory |
| 479 | * commands request data |
| 480 | * |
| 481 | * @param[in] instance_id - Message's instance id |
| 482 | * @param[in] command - PLDM command |
| 483 | * @param[in] file_type - Type of the file |
| 484 | * @param[in] file_handle - A handle to the file |
| 485 | * @param[in] offset - Offset to the file at which the read should begin |
| 486 | * @param[in] length - Number of bytes to be read/written |
| 487 | * @param[in] address - Memory address where the file content has to be |
| 488 | * written to |
| 489 | * @param[out] msg - Message will be written to this |
| 490 | * @return pldm_completion_codes |
| 491 | */ |
| 492 | int encode_rw_file_by_type_memory_req(uint8_t instance_id, uint8_t command, |
| 493 | uint16_t file_type, uint32_t file_handle, |
| 494 | uint32_t offset, uint32_t length, |
| 495 | uint64_t address, struct pldm_msg *msg); |
| 496 | |
| 497 | /** @brief Decode ReadFileTypeIntoMemory and WriteFileTypeFromMemory |
| 498 | * commands response data |
| 499 | * |
| 500 | * @param[in] msg - pointer to PLDM response message |
| 501 | * @param[in] payload_length - Length of response payload |
| 502 | * @param[out] completion_code - PLDM completion code |
| 503 | * @param[out] length - Number of bytes to be read/written |
| 504 | * @return pldm_completion_codes |
| 505 | */ |
| 506 | int decode_rw_file_by_type_memory_resp(const struct pldm_msg *msg, |
| 507 | size_t payload_length, |
| 508 | uint8_t *completion_code, |
| 509 | uint32_t *length); |
| 510 | |
vkaverap | a9aac72 | 2019-08-22 02:10:15 -0500 | [diff] [blame] | 511 | /** @struct pldm_new_file_req |
| 512 | * |
| 513 | * Structure representing NewFile request |
| 514 | */ |
| 515 | struct pldm_new_file_req { |
| 516 | uint16_t file_type; //!< Type of file |
| 517 | uint32_t file_handle; //!< Handle to file |
Deepak Kodihalli | 8338876 | 2020-01-28 04:09:58 -0600 | [diff] [blame] | 518 | uint64_t length; //!< Number of bytes in new file |
vkaverap | a9aac72 | 2019-08-22 02:10:15 -0500 | [diff] [blame] | 519 | } __attribute__((packed)); |
| 520 | |
| 521 | /** @struct pldm_new_file_resp |
| 522 | * |
| 523 | * Structure representing NewFile response data |
| 524 | */ |
| 525 | struct pldm_new_file_resp { |
| 526 | uint8_t completion_code; //!< Completion code |
| 527 | } __attribute__((packed)); |
| 528 | |
| 529 | /** @brief Decode NewFileAvailable command request data |
| 530 | * |
| 531 | * @param[in] msg - Pointer to PLDM request message |
| 532 | * @param[in] payload_length - Length of request payload |
| 533 | * @param[in] file_type - Type of the file |
| 534 | * @param[out] file_handle - A handle to the file |
| 535 | * @param[out] length - Number of bytes in new file |
| 536 | * @return pldm_completion_codes |
| 537 | */ |
| 538 | int decode_new_file_req(const struct pldm_msg *msg, size_t payload_length, |
| 539 | uint16_t *file_type, uint32_t *file_handle, |
Deepak Kodihalli | 8338876 | 2020-01-28 04:09:58 -0600 | [diff] [blame] | 540 | uint64_t *length); |
vkaverap | a9aac72 | 2019-08-22 02:10:15 -0500 | [diff] [blame] | 541 | |
| 542 | /** @brief Create a PLDM response for NewFileAvailable |
| 543 | * |
| 544 | * @param[in] instance_id - Message's instance id |
| 545 | * @param[in] completion_code - PLDM completion code |
| 546 | * @param[in,out] msg - Message will be written to this |
| 547 | * @return pldm_completion_codes |
| 548 | * @note Caller is responsible for memory alloc and dealloc of param 'msg' |
| 549 | */ |
| 550 | int encode_new_file_resp(uint8_t instance_id, uint8_t completion_code, |
| 551 | struct pldm_msg *msg); |
| 552 | |
| 553 | /** @brief Encode NewFileAvailable command request data |
| 554 | * |
| 555 | * @param[in] instance_id - Message's instance id |
| 556 | * @param[in] file_type - Type of the file |
| 557 | * @param[in] file_handle - A handle to the file |
| 558 | * @param[in] length - Number of bytes in new file |
| 559 | * @param[out] msg - Message will be written to this |
| 560 | * @return pldm_completion_codes |
| 561 | */ |
| 562 | int encode_new_file_req(uint8_t instance_id, uint16_t file_type, |
Deepak Kodihalli | 8338876 | 2020-01-28 04:09:58 -0600 | [diff] [blame] | 563 | uint32_t file_handle, uint64_t length, |
vkaverap | a9aac72 | 2019-08-22 02:10:15 -0500 | [diff] [blame] | 564 | struct pldm_msg *msg); |
| 565 | |
| 566 | /** @brief Decode NewFileAvailable command response data |
| 567 | * |
| 568 | * @param[in] msg - pointer to PLDM response message |
| 569 | * @param[in] payload_length - Length of response payload |
| 570 | * @param[out] completion_code - PLDM completion code |
| 571 | * @return pldm_completion_codes |
| 572 | */ |
| 573 | int decode_new_file_resp(const struct pldm_msg *msg, size_t payload_length, |
| 574 | uint8_t *completion_code); |
| 575 | |
Deepak Kodihalli | dce1c99 | 2019-11-19 07:06:53 -0600 | [diff] [blame] | 576 | /** @struct pldm_read_write_file_by_type_req |
| 577 | * |
| 578 | * Structure representing ReadFileByType and |
| 579 | * WriteFileByType request |
| 580 | */ |
| 581 | struct pldm_read_write_file_by_type_req { |
| 582 | uint16_t file_type; //!< Type of file |
| 583 | uint32_t file_handle; //!< Handle to file |
| 584 | uint32_t offset; //!< Offset to file where read/write starts |
| 585 | uint32_t length; //!< Bytes to be read |
| 586 | } __attribute__((packed)); |
| 587 | |
| 588 | /** @struct pldm_read_write_file_by_type_resp |
| 589 | * |
| 590 | * Structure representing ReadFileByType and |
| 591 | * WriteFileByType response |
| 592 | */ |
| 593 | struct pldm_read_write_file_by_type_resp { |
| 594 | uint8_t completion_code; //!< Completion code |
| 595 | uint32_t length; //!< Number of bytes read |
| 596 | } __attribute__((packed)); |
| 597 | |
| 598 | /** @brief Decode ReadFileByType and WriteFileByType |
| 599 | * commands request data |
| 600 | * |
| 601 | * @param[in] msg - Pointer to PLDM request message |
| 602 | * @param[in] payload_length - Length of request payload |
vkaverap | f4e0a49 | 2019-11-19 01:47:35 -0600 | [diff] [blame] | 603 | * @param[out] file_type - Type of the file |
Deepak Kodihalli | dce1c99 | 2019-11-19 07:06:53 -0600 | [diff] [blame] | 604 | * @param[out] file_handle - A handle to the file |
| 605 | * @param[out] offset - Offset to the file at which the read/write should begin |
| 606 | * @param[out] length - Number of bytes to be read/written |
| 607 | * @return pldm_completion_codes |
| 608 | */ |
| 609 | int decode_rw_file_by_type_req(const struct pldm_msg *msg, |
| 610 | size_t payload_length, uint16_t *file_type, |
| 611 | uint32_t *file_handle, uint32_t *offset, |
| 612 | uint32_t *length); |
| 613 | |
| 614 | /** @brief Create a PLDM response for ReadFileByType and |
| 615 | * WriteFileByType |
| 616 | * |
| 617 | * @param[in] instance_id - Message's instance id |
| 618 | * @param[in] command - PLDM command |
| 619 | * @param[in] completion_code - PLDM completion code |
| 620 | * @param[in] length - Number of bytes read/written. This could be less than |
vkaverap | f4e0a49 | 2019-11-19 01:47:35 -0600 | [diff] [blame] | 621 | * what the requester asked for. |
Deepak Kodihalli | dce1c99 | 2019-11-19 07:06:53 -0600 | [diff] [blame] | 622 | * @param[in,out] msg - Message will be written to this |
| 623 | * @return pldm_completion_codes |
| 624 | * @note Caller is responsible for memory alloc and dealloc of param 'msg' |
| 625 | * @note File content has to be copied directly by the caller. |
| 626 | */ |
| 627 | int encode_rw_file_by_type_resp(uint8_t instance_id, uint8_t command, |
| 628 | uint8_t completion_code, uint32_t length, |
| 629 | struct pldm_msg *msg); |
| 630 | |
| 631 | /** @brief Encode ReadFileByType and WriteFileByType |
| 632 | * commands request data |
| 633 | * |
| 634 | * @param[in] instance_id - Message's instance id |
| 635 | * @param[in] command - PLDM command |
| 636 | * @param[in] file_type - Type of the file |
| 637 | * @param[in] file_handle - A handle to the file |
| 638 | * @param[in] offset - Offset to the file at which the read should begin |
| 639 | * @param[in] length - Number of bytes to be read/written |
| 640 | * @param[out] msg - Message will be written to this |
| 641 | * @return pldm_completion_codes |
| 642 | * @note File content has to be read directly by the caller. |
| 643 | */ |
| 644 | int encode_rw_file_by_type_req(uint8_t instance_id, uint8_t command, |
| 645 | uint16_t file_type, uint32_t file_handle, |
| 646 | uint32_t offset, uint32_t length, |
| 647 | struct pldm_msg *msg); |
| 648 | |
| 649 | /** @brief Decode ReadFileByType and WriteFileByType |
| 650 | * commands response data |
| 651 | * |
| 652 | * @param[in] msg - pointer to PLDM response message |
| 653 | * @param[in] payload_length - Length of response payload |
| 654 | * @param[out] completion_code - PLDM completion code |
| 655 | * @param[out] length - Number of bytes to be read/written |
| 656 | * @return pldm_completion_codes |
| 657 | */ |
| 658 | int decode_rw_file_by_type_resp(const struct pldm_msg *msg, |
| 659 | size_t payload_length, uint8_t *completion_code, |
| 660 | uint32_t *length); |
| 661 | |
vkaverap | f4e0a49 | 2019-11-19 01:47:35 -0600 | [diff] [blame] | 662 | /** @struct pldm_file_ack_req |
| 663 | * |
| 664 | * Structure representing FileAck request |
| 665 | */ |
| 666 | struct pldm_file_ack_req { |
| 667 | uint16_t file_type; //!< Type of file |
| 668 | uint32_t file_handle; //!< Handle to file |
| 669 | uint8_t file_status; //!< Status of file processing |
| 670 | } __attribute__((packed)); |
| 671 | |
| 672 | /** @struct pldm_file_ack_resp |
| 673 | * |
| 674 | * Structure representing NewFile response data |
| 675 | */ |
| 676 | struct pldm_file_ack_resp { |
| 677 | uint8_t completion_code; //!< Completion code |
| 678 | } __attribute__((packed)); |
| 679 | |
| 680 | /** @brief Decode FileAck command request data |
| 681 | * |
| 682 | * @param[in] msg - Pointer to PLDM request message |
| 683 | * @param[in] payload_length - Length of request payload |
| 684 | * @param[out] file_type - Type of the file |
| 685 | * @param[out] file_handle - A handle to the file |
| 686 | * @param[out] file_status - Status of file processing |
| 687 | * @return pldm_completion_codes |
| 688 | */ |
| 689 | int decode_file_ack_req(const struct pldm_msg *msg, size_t payload_length, |
| 690 | uint16_t *file_type, uint32_t *file_handle, |
| 691 | uint8_t *file_status); |
| 692 | |
| 693 | /** @brief Create a PLDM response for FileAck |
| 694 | * |
| 695 | * @param[in] instance_id - Message's instance id |
| 696 | * @param[in] completion_code - PLDM completion code |
| 697 | * @param[in,out] msg - Message will be written to this |
| 698 | * @return pldm_completion_codes |
| 699 | * @note Caller is responsible for memory alloc and dealloc of param 'msg' |
| 700 | */ |
| 701 | int encode_file_ack_resp(uint8_t instance_id, uint8_t completion_code, |
| 702 | struct pldm_msg *msg); |
| 703 | |
| 704 | /** @brief Encode FileAck command request data |
| 705 | * |
| 706 | * @param[in] instance_id - Message's instance id |
| 707 | * @param[in] file_type - Type of the file |
| 708 | * @param[in] file_handle - A handle to the file |
| 709 | * @param[in] file_status - Status of file processing |
| 710 | * @param[out] msg - Message will be written to this |
| 711 | * @return pldm_completion_codes |
| 712 | */ |
| 713 | int encode_file_ack_req(uint8_t instance_id, uint16_t file_type, |
| 714 | uint32_t file_handle, uint8_t file_status, |
| 715 | struct pldm_msg *msg); |
| 716 | |
| 717 | /** @brief Decode FileAck command response data |
| 718 | * |
| 719 | * @param[in] msg - pointer to PLDM response message |
| 720 | * @param[in] payload_length - Length of response payload |
| 721 | * @param[out] completion_code - PLDM completion code |
| 722 | * @return pldm_completion_codes |
| 723 | */ |
| 724 | int decode_file_ack_resp(const struct pldm_msg *msg, size_t payload_length, |
| 725 | uint8_t *completion_code); |
| 726 | |
Sridevi Ramesh | 8b51fa2 | 2022-06-13 06:28:13 -0500 | [diff] [blame] | 727 | /* FileAckWithMetadata */ |
| 728 | |
| 729 | /** @struct pldm_file_ack_with_meta_data_req |
| 730 | * |
| 731 | * Structure representing FileAckWithMetadata request |
| 732 | */ |
| 733 | struct pldm_file_ack_with_meta_data_req { |
| 734 | uint16_t file_type; //!< Type of file |
| 735 | uint32_t file_handle; //!< Handle to file |
| 736 | uint8_t file_status; //!< Status of file processing |
| 737 | uint32_t file_meta_data_1; //!< Meta data specific to file type 1 |
| 738 | uint32_t file_meta_data_2; //!< Meta data specific to file type 2 |
| 739 | uint32_t file_meta_data_3; //!< Meta data specific to file type 3 |
| 740 | uint32_t file_meta_data_4; //!< meta data specific to file type 4 |
| 741 | } __attribute__((packed)); |
| 742 | |
| 743 | /** @struct pldm_file_ack_with_meta_data_resp |
| 744 | * |
| 745 | * Structure representing FileAckWithMetadata response |
| 746 | */ |
| 747 | struct pldm_file_ack_with_meta_data_resp { |
| 748 | uint8_t completion_code; //!< Completion code |
| 749 | } __attribute__((packed)); |
| 750 | |
| 751 | /** @brief Encode FileAckWithMetadata request data |
| 752 | * |
| 753 | * @param[in] instance_id - Message's instance id |
| 754 | * @param[in] file_type - Type of the file |
| 755 | * @param[in] file_handle - A handle to the file |
| 756 | * @param[in] file_status - Status of file processing |
| 757 | * @param[in] file_meta_data_1 - meta data specific to file type 1 |
| 758 | * @param[in] file_meta_data_2 - meta data specific to file type 2 |
| 759 | * @param[in] file_meta_data_3 - meta data specific to file type 3 |
| 760 | * @param[in] file_meta_data_4 - Meta data specific to file type 4 |
| 761 | * @param[out] msg - Message will be written to this |
| 762 | * @return pldm_completion_codes |
| 763 | */ |
| 764 | int encode_file_ack_with_meta_data_req( |
| 765 | uint8_t instance_id, uint16_t file_type, uint32_t file_handle, |
| 766 | uint8_t file_status, uint32_t file_meta_data_1, uint32_t file_meta_data_2, |
| 767 | uint32_t file_meta_data_3, uint32_t file_meta_data_4, struct pldm_msg *msg); |
| 768 | |
| 769 | /** @brief Decode FileAckWithMetadata command response data |
| 770 | * |
| 771 | * @param[in] msg - pointer to PLDM response message |
| 772 | * @param[in] payload_length - Length of response payload |
| 773 | * @param[out] completion_code - PLDM completion code |
| 774 | * @return pldm_completion_codes |
| 775 | */ |
| 776 | int decode_file_ack_with_meta_data_resp(const struct pldm_msg *msg, |
| 777 | size_t payload_length, |
| 778 | uint8_t *completion_code); |
| 779 | |
| 780 | /** @brief Decode FileAckWithMetadata request data |
| 781 | * |
| 782 | * @param[in] msg - Pointer to PLDM request message |
| 783 | * @param[in] payload_length - Length of request payload |
| 784 | * @param[out] file_type - Type of the file |
| 785 | * @param[out] file_handle - A handle to the file |
| 786 | * @param[out] file_status - Status of file processing |
| 787 | * @param[out] file_meta_data_1 - meta data specific to file type 1 |
| 788 | * @param[out] file_meta_data_2 - meta data specific to file type 2 |
| 789 | * @param[out] file_meta_data_3 - meta data specific to file type 3 |
| 790 | * @param[out] file_meta_data_4 - Meta data specific to file type 4 |
| 791 | * @return pldm_completion_codes |
| 792 | */ |
| 793 | int decode_file_ack_with_meta_data_req( |
| 794 | const struct pldm_msg *msg, size_t payload_length, uint16_t *file_type, |
| 795 | uint32_t *file_handle, uint8_t *file_status, uint32_t *file_meta_data_1, |
| 796 | uint32_t *file_meta_data_2, uint32_t *file_meta_data_3, |
| 797 | uint32_t *file_meta_data_4); |
| 798 | |
| 799 | /** @brief Create a PLDM response message for FileAckWithMetadata |
| 800 | * |
| 801 | * @param[in] instance_id - Message's instance id |
| 802 | * @param[in] completion_code - PLDM completion code |
| 803 | * @param[in,out] msg - Message will be written to this |
| 804 | * @return pldm_completion_codes |
| 805 | */ |
| 806 | int encode_file_ack_with_meta_data_resp(uint8_t instance_id, |
| 807 | uint8_t completion_code, |
| 808 | struct pldm_msg *msg); |
| 809 | |
Sridevi Ramesh | 07c2f0a | 2022-07-03 03:32:52 -0500 | [diff] [blame^] | 810 | /* NewFileAvailableWithMetaData */ |
| 811 | |
| 812 | /** @struct pldm_new_file_with_metadata_req |
| 813 | * |
| 814 | * Structure representing NewFileAvailableWithMetaData request |
| 815 | */ |
| 816 | |
| 817 | struct pldm_new_file_with_metadata_req { |
| 818 | uint16_t file_type; //!< Type of file |
| 819 | uint32_t file_handle; //!< Handle to file |
| 820 | uint64_t length; //!< Number of bytes in new file |
| 821 | uint32_t file_meta_data_1; //!< Meta data specific to file type 1 |
| 822 | uint32_t file_meta_data_2; //!< Meta data specific to file type 2 |
| 823 | uint32_t file_meta_data_3; //!< Meta data specific to file type 3 |
| 824 | uint32_t file_meta_data_4; //!< Meta data specific to file type 4 |
| 825 | } __attribute__((packed)); |
| 826 | |
| 827 | /** @struct pldm_new_file_with_metadata_resp |
| 828 | * |
| 829 | * Structure representing NewFileAvailableWithMetaData response data |
| 830 | */ |
| 831 | struct pldm_new_file_with_metadata_resp { |
| 832 | uint8_t completion_code; //!< Completion code |
| 833 | } __attribute__((packed)); |
| 834 | |
| 835 | /** @brief Encode NewFileAvailableWithMetaData request data |
| 836 | * |
| 837 | * @param[in] instance_id - Message's instance id |
| 838 | * @param[in] file_type - Type of the file |
| 839 | * @param[in] file_handle - A handle to the file |
| 840 | * @param[in] length - Number of bytes in new file |
| 841 | * @param[in] file_meta_data_1 - Meta data specific to file type 1 |
| 842 | * @param[in] file_meta_data_2 - Meta data specific to file type 2 |
| 843 | * @param[in] file_meta_data_3 - Meta data specific to file type 3 |
| 844 | * @param[in] file_meta_data_4 - Meta data specific to file type 4 |
| 845 | * @param[out] msg - Message will be written to this |
| 846 | * @return pldm_completion_codes |
| 847 | */ |
| 848 | int encode_new_file_with_metadata_req( |
| 849 | uint8_t instance_id, uint16_t file_type, uint32_t file_handle, |
| 850 | uint64_t length, uint32_t file_meta_data_1, uint32_t file_meta_data_2, |
| 851 | uint32_t file_meta_data_3, uint32_t file_meta_data_4, struct pldm_msg *msg); |
| 852 | |
| 853 | /** @brief Decode NewFileAvailableWithMetaData response data |
| 854 | * |
| 855 | * @param[in] msg - pointer to PLDM response message |
| 856 | * @param[in] payload_length - Length of response payload |
| 857 | * @param[out] completion_code - PLDM completion code |
| 858 | * @return pldm_completion_codes |
| 859 | */ |
| 860 | int decode_new_file_with_metadata_resp(const struct pldm_msg *msg, |
| 861 | size_t payload_length, |
| 862 | uint8_t *completion_code); |
| 863 | |
| 864 | /** @brief Decode NewFileAvailableWithMetaData request data |
| 865 | * |
| 866 | * @param[in] msg - Pointer to PLDM request message |
| 867 | * @param[in] payload_length - Length of request payload |
| 868 | * @param[out] file_type - Type of the file |
| 869 | * @param[out] file_handle - A handle to the file |
| 870 | * @param[out] length - Number of bytes in new file |
| 871 | * @param[out] file_meta_data_1 - Meta data specific to file type 1 |
| 872 | * @param[out] file_meta_data_2 - Meta data specific to file type 2 |
| 873 | * @param[out] file_meta_data_3 - Meta data specific to file type 3 |
| 874 | * @param[out] file_meta_data_4 - Meta data specific to file type 4 |
| 875 | * @return pldm_completion_codes |
| 876 | */ |
| 877 | int decode_new_file_with_metadata_req( |
| 878 | const struct pldm_msg *msg, size_t payload_length, uint16_t *file_type, |
| 879 | uint32_t *file_handle, uint64_t *length, uint32_t *file_meta_data_1, |
| 880 | uint32_t *file_meta_data_2, uint32_t *file_meta_data_3, |
| 881 | uint32_t *file_meta_data_4); |
| 882 | |
| 883 | /** @brief Create a PLDM response for NewFileAvailableWithMetaData |
| 884 | * |
| 885 | * @param[in] instance_id - Message's instance id |
| 886 | * @param[in] completion_code - PLDM completion code |
| 887 | * @param[in,out] msg - Message will be written to this |
| 888 | * @return pldm_completion_codes |
| 889 | * @note Caller is responsible for memory alloc and dealloc of param 'msg' |
| 890 | */ |
| 891 | int encode_new_file_with_metadata_resp(uint8_t instance_id, |
| 892 | uint8_t completion_code, |
| 893 | struct pldm_msg *msg); |
| 894 | |
Jinu Joy Thomas | 7f57f44 | 2019-06-13 20:38:49 +0530 | [diff] [blame] | 895 | #ifdef __cplusplus |
| 896 | } |
| 897 | #endif |
| 898 | |
| 899 | #endif /* FILEIO_H */ |