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, |
Jinu Joy Thomas | 7f57f44 | 2019-06-13 20:38:49 +0530 | [diff] [blame] | 27 | }; |
| 28 | |
| 29 | /** @brief PLDM Command specific codes |
| 30 | */ |
| 31 | enum pldm_fileio_completion_codes { |
| 32 | PLDM_INVALID_FILE_HANDLE = 0x80, |
| 33 | PLDM_DATA_OUT_OF_RANGE = 0x81, |
| 34 | PLDM_INVALID_READ_LENGTH = 0x82, |
| 35 | PLDM_INVALID_WRITE_LENGTH = 0x83, |
Tom Joseph | 0c6d22c | 2019-06-26 09:58:41 +0530 | [diff] [blame] | 36 | PLDM_FILE_TABLE_UNAVAILABLE = 0x84, |
| 37 | PLDM_INVALID_FILE_TABLE_TYPE = 0x85, |
Sampa Misra | 854e61f | 2019-08-22 04:36:47 -0500 | [diff] [blame] | 38 | PLDM_INVALID_FILE_TYPE = 0x86, |
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 { |
| 51 | PLDM_FILE_TYPE_PEL = 0, |
Deepak Kodihalli | f6d3a83 | 2019-11-19 07:00:29 -0600 | [diff] [blame] | 52 | PLDM_FILE_TYPE_LID_PERM = 1, |
| 53 | PLDM_FILE_TYPE_LID_TEMP = 2, |
Sampa Misra | 1896716 | 2020-01-14 02:31:41 -0600 | [diff] [blame] | 54 | PLDM_FILE_TYPE_DUMP = 3, |
Sampa Misra | 854e61f | 2019-08-22 04:36:47 -0500 | [diff] [blame] | 55 | }; |
| 56 | |
Jinu Joy Thomas | 7f57f44 | 2019-06-13 20:38:49 +0530 | [diff] [blame] | 57 | #define PLDM_RW_FILE_MEM_REQ_BYTES 20 |
| 58 | #define PLDM_RW_FILE_MEM_RESP_BYTES 5 |
Tom Joseph | 0c6d22c | 2019-06-26 09:58:41 +0530 | [diff] [blame] | 59 | #define PLDM_GET_FILE_TABLE_REQ_BYTES 6 |
| 60 | #define PLDM_GET_FILE_TABLE_MIN_RESP_BYTES 6 |
vkaverap | 2ffe329 | 2019-06-24 00:08:13 -0500 | [diff] [blame] | 61 | #define PLDM_READ_FILE_REQ_BYTES 12 |
| 62 | #define PLDM_READ_FILE_RESP_BYTES 5 |
| 63 | #define PLDM_WRITE_FILE_REQ_BYTES 12 |
| 64 | #define PLDM_WRITE_FILE_RESP_BYTES 5 |
vkaverap | 0740456 | 2019-08-05 22:57:11 -0500 | [diff] [blame] | 65 | #define PLDM_RW_FILE_BY_TYPE_MEM_REQ_BYTES 22 |
| 66 | #define PLDM_RW_FILE_BY_TYPE_MEM_RESP_BYTES 5 |
Deepak Kodihalli | 8338876 | 2020-01-28 04:09:58 -0600 | [diff] [blame] | 67 | #define PLDM_NEW_FILE_REQ_BYTES 14 |
vkaverap | a9aac72 | 2019-08-22 02:10:15 -0500 | [diff] [blame] | 68 | #define PLDM_NEW_FILE_RESP_BYTES 1 |
Deepak Kodihalli | dce1c99 | 2019-11-19 07:06:53 -0600 | [diff] [blame] | 69 | #define PLDM_RW_FILE_BY_TYPE_REQ_BYTES 14 |
| 70 | #define PLDM_RW_FILE_BY_TYPE_RESP_BYTES 5 |
vkaverap | f4e0a49 | 2019-11-19 01:47:35 -0600 | [diff] [blame] | 71 | #define PLDM_FILE_ACK_REQ_BYTES 7 |
| 72 | #define PLDM_FILE_ACK_RESP_BYTES 1 |
Jinu Joy Thomas | 7f57f44 | 2019-06-13 20:38:49 +0530 | [diff] [blame] | 73 | |
Priyanga | 8b97665 | 2019-06-27 11:30:33 -0500 | [diff] [blame] | 74 | /** @struct pldm_read_write_file_memory_req |
| 75 | * |
| 76 | * Structure representing ReadFileIntoMemory request and WriteFileFromMemory |
| 77 | * request |
| 78 | */ |
| 79 | struct pldm_read_write_file_memory_req { |
| 80 | uint32_t file_handle; //!< A Handle to the file |
| 81 | uint32_t offset; //!< Offset to the file |
| 82 | uint32_t length; //!< Number of bytes to be read/write |
| 83 | uint64_t address; //!< Memory address of the file |
| 84 | } __attribute__((packed)); |
| 85 | |
| 86 | /** @struct pldm_read_write_file_memory_resp |
| 87 | * |
| 88 | * Structure representing ReadFileIntoMemory response and WriteFileFromMemory |
| 89 | * response |
| 90 | */ |
| 91 | struct pldm_read_write_file_memory_resp { |
| 92 | uint8_t completion_code; //!< completion code |
| 93 | uint32_t length; //!< Number of bytes read/written |
| 94 | } __attribute__((packed)); |
| 95 | |
Jinu Joy Thomas | 7f57f44 | 2019-06-13 20:38:49 +0530 | [diff] [blame] | 96 | /** @brief Decode ReadFileIntoMemory and WriteFileFromMemory commands request |
| 97 | * data |
| 98 | * |
Zahed Hossain | 223a73d | 2019-07-04 12:46:18 -0500 | [diff] [blame] | 99 | * @param[in] msg - Pointer to PLDM request message |
Jinu Joy Thomas | 7f57f44 | 2019-06-13 20:38:49 +0530 | [diff] [blame] | 100 | * @param[in] payload_length - Length of request payload |
| 101 | * @param[out] file_handle - A handle to the file |
| 102 | * @param[out] offset - Offset to the file at which the read should begin |
| 103 | * @param[out] length - Number of bytes to be read |
| 104 | * @param[out] address - Memory address where the file content has to be |
| 105 | * written to |
| 106 | * @return pldm_completion_codes |
| 107 | */ |
Zahed Hossain | 223a73d | 2019-07-04 12:46:18 -0500 | [diff] [blame] | 108 | 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] | 109 | uint32_t *file_handle, uint32_t *offset, |
| 110 | uint32_t *length, uint64_t *address); |
| 111 | |
| 112 | /** @brief Create a PLDM response for ReadFileIntoMemory and |
| 113 | * WriteFileFromMemory |
| 114 | * |
| 115 | * @param[in] instance_id - Message's instance id |
| 116 | * @param[in] command - PLDM command |
| 117 | * @param[in] completion_code - PLDM completion code |
| 118 | * @param[in] length - Number of bytes read. This could be less than what the |
| 119 | requester asked for. |
| 120 | * @param[in,out] msg - Message will be written to this |
| 121 | * @return pldm_completion_codes |
| 122 | * @note Caller is responsible for memory alloc and dealloc of param 'msg' |
| 123 | */ |
| 124 | int encode_rw_file_memory_resp(uint8_t instance_id, uint8_t command, |
| 125 | uint8_t completion_code, uint32_t length, |
| 126 | struct pldm_msg *msg); |
| 127 | |
Priyanga | 8b97665 | 2019-06-27 11:30:33 -0500 | [diff] [blame] | 128 | /** @brief Encode ReadFileIntoMemory and WriteFileFromMemory |
| 129 | * commands request data |
| 130 | * |
| 131 | * @param[in] instance_id - Message's instance id |
| 132 | * @param[in] command - PLDM command |
| 133 | * @param[in] file_handle - A handle to the file |
| 134 | * @param[in] offset - Offset to the file at which the read should begin |
| 135 | * @param[in] length - Number of bytes to be read/written |
| 136 | * @param[in] address - Memory address where the file content has to be |
| 137 | * written to |
| 138 | * @param[out] msg - Message will be written to this |
| 139 | * @return pldm_completion_codes |
| 140 | */ |
| 141 | int encode_rw_file_memory_req(uint8_t instance_id, uint8_t command, |
| 142 | uint32_t file_handle, uint32_t offset, |
| 143 | uint32_t length, uint64_t address, |
| 144 | struct pldm_msg *msg); |
| 145 | |
| 146 | /** @brief Decode ReadFileIntoMemory and WriteFileFromMemory |
| 147 | * commands response data |
| 148 | * |
Zahed Hossain | 223a73d | 2019-07-04 12:46:18 -0500 | [diff] [blame] | 149 | * @param[in] msg - pointer to PLDM response message |
Priyanga | 8b97665 | 2019-06-27 11:30:33 -0500 | [diff] [blame] | 150 | * @param[in] payload_length - Length of response payload |
| 151 | * @param[out] completion_code - PLDM completion code |
| 152 | * @param[out] length - Number of bytes to be read/written |
| 153 | * @return pldm_completion_codes |
| 154 | */ |
Zahed Hossain | 223a73d | 2019-07-04 12:46:18 -0500 | [diff] [blame] | 155 | int decode_rw_file_memory_resp(const struct pldm_msg *msg, |
| 156 | size_t payload_length, uint8_t *completion_code, |
| 157 | uint32_t *length); |
Priyanga | 8b97665 | 2019-06-27 11:30:33 -0500 | [diff] [blame] | 158 | |
Tom Joseph | 0c6d22c | 2019-06-26 09:58:41 +0530 | [diff] [blame] | 159 | /** @struct pldm_get_file_table_req |
| 160 | * |
| 161 | * Structure representing GetFileTable request |
| 162 | */ |
| 163 | struct pldm_get_file_table_req { |
| 164 | uint32_t transfer_handle; //!< Data transfer handle |
| 165 | uint8_t operation_flag; //!< Transfer operation flag |
| 166 | uint8_t table_type; //!< Table type |
| 167 | } __attribute__((packed)); |
| 168 | |
| 169 | /** @struct pldm_get_file_table_resp |
| 170 | * |
| 171 | * Structure representing GetFileTable response fixed data |
| 172 | */ |
| 173 | struct pldm_get_file_table_resp { |
| 174 | uint8_t completion_code; //!< Completion code |
| 175 | uint32_t next_transfer_handle; //!< Next data transfer handle |
| 176 | uint8_t transfer_flag; //!< Transfer flag |
| 177 | uint8_t table_data[1]; //!< Table Data |
| 178 | } __attribute__((packed)); |
| 179 | |
| 180 | /** @brief Decode GetFileTable command request data |
| 181 | * |
Zahed Hossain | 223a73d | 2019-07-04 12:46:18 -0500 | [diff] [blame] | 182 | * @param[in] msg - Pointer to PLDM request message |
Tom Joseph | 0c6d22c | 2019-06-26 09:58:41 +0530 | [diff] [blame] | 183 | * @param[in] payload_length - Length of request payload |
| 184 | * @param[out] trasnfer_handle - the handle of data |
| 185 | * @param[out] transfer_opflag - Transfer operation flag |
| 186 | * @param[out] table_type - the type of file table |
| 187 | * @return pldm_completion_codes |
| 188 | */ |
Zahed Hossain | 223a73d | 2019-07-04 12:46:18 -0500 | [diff] [blame] | 189 | 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] | 190 | uint32_t *transfer_handle, |
| 191 | uint8_t *transfer_opflag, uint8_t *table_type); |
| 192 | |
| 193 | /** @brief Create a PLDM response for GetFileTable command |
| 194 | * |
| 195 | * @param[in] instance_id - Message's instance id |
| 196 | * @param[in] completion_code - PLDM completion code |
| 197 | * @param[in] next_transfer_handle - Handle to identify next portion of |
| 198 | * data transfer |
| 199 | * @param[in] transfer_flag - Represents the part of transfer |
| 200 | * @param[in] table_data - pointer to file table data |
| 201 | * @param[in] table_size - file table size |
| 202 | * @param[in,out] msg - Message will be written to this |
| 203 | * @return pldm_completion_codes |
| 204 | * @note Caller is responsible for memory alloc and dealloc of param 'msg' |
| 205 | */ |
| 206 | int encode_get_file_table_resp(uint8_t instance_id, uint8_t completion_code, |
| 207 | uint32_t next_transfer_handle, |
| 208 | uint8_t transfer_flag, const uint8_t *table_data, |
| 209 | size_t table_size, struct pldm_msg *msg); |
| 210 | |
vkaverap | 2ffe329 | 2019-06-24 00:08:13 -0500 | [diff] [blame] | 211 | /** @struct pldm_read_file_req |
| 212 | * |
| 213 | * Structure representing ReadFile request |
| 214 | */ |
| 215 | struct pldm_read_file_req { |
| 216 | uint32_t file_handle; //!< Handle to file |
| 217 | uint32_t offset; //!< Offset to file where read starts |
| 218 | uint32_t length; //!< Bytes to be read |
| 219 | } __attribute__((packed)); |
| 220 | |
| 221 | /** @struct pldm_read_file_resp |
| 222 | * |
| 223 | * Structure representing ReadFile response data |
| 224 | */ |
| 225 | struct pldm_read_file_resp { |
| 226 | uint8_t completion_code; //!< Completion code |
| 227 | uint32_t length; //!< Number of bytes read |
| 228 | uint8_t file_data[1]; //!< Address of this is where file data starts |
| 229 | } __attribute__((packed)); |
| 230 | |
| 231 | /** @struct pldm_write_file_req |
| 232 | * |
| 233 | * Structure representing WriteFile request |
| 234 | */ |
| 235 | struct pldm_write_file_req { |
| 236 | uint32_t file_handle; //!< Handle to file |
| 237 | uint32_t offset; //!< Offset to file where write starts |
| 238 | uint32_t length; //!< Bytes to be written |
| 239 | uint8_t file_data[1]; //!< Address of this is where file data starts |
| 240 | } __attribute__((packed)); |
| 241 | |
| 242 | /** @struct pldm_write_file_resp |
| 243 | * |
| 244 | * Structure representing WriteFile response data |
| 245 | */ |
| 246 | struct pldm_write_file_resp { |
| 247 | uint8_t completion_code; //!< Completion code |
| 248 | uint32_t length; //!< Bytes written |
| 249 | } __attribute__((packed)); |
| 250 | |
| 251 | /** @brief Decode Read File commands request |
| 252 | * |
| 253 | * @param[in] msg - PLDM request message payload |
| 254 | * @param[in] payload_length - Length of request payload |
| 255 | * @param[out] file_handle - A handle to the file |
| 256 | * @param[out] offset - Offset to the file at which the read should begin |
| 257 | * @param[out] length - Number of bytes read |
| 258 | * @return pldm_completion_codes |
| 259 | */ |
| 260 | int decode_read_file_req(const struct pldm_msg *msg, size_t payload_length, |
| 261 | uint32_t *file_handle, uint32_t *offset, |
| 262 | uint32_t *length); |
| 263 | |
| 264 | /** @brief Encode Read File commands request |
| 265 | * |
| 266 | * @param[in] instance_id - Message's instance id |
| 267 | * @param[in] file_handle - A handle to the file |
| 268 | * @param[in] offset - Offset to the file at which the read should begin |
| 269 | * @param[in] length - Number of bytes read |
| 270 | * @param[in,out] msg - Message will be written to this |
| 271 | * @return pldm_completion_codes |
| 272 | * @note Caller is responsible for memory alloc and dealloc of param 'msg' |
| 273 | */ |
| 274 | int encode_read_file_req(uint8_t instance_id, uint32_t file_handle, |
| 275 | uint32_t offset, uint32_t length, |
| 276 | struct pldm_msg *msg); |
| 277 | |
| 278 | /** @brief Decode Read File commands response |
| 279 | * |
| 280 | * @param[in] msg - PLDM response message payload |
| 281 | * @param[in] payload_length - Length of request payload |
| 282 | * @param[out] completion_code - PLDM completion code |
| 283 | * @param[out] length - Number of bytes read. This could be less than what the |
| 284 | * requester asked for. |
| 285 | * @param[out] file_data_offset - Offset where file data should be read in pldm |
| 286 | * msg. |
| 287 | * @return pldm_completion_codes |
| 288 | */ |
| 289 | int decode_read_file_resp(const struct pldm_msg *msg, size_t payload_length, |
| 290 | uint8_t *completion_code, uint32_t *length, |
| 291 | size_t *file_data_offset); |
| 292 | |
| 293 | /** @brief Create a PLDM response for Read File |
| 294 | * |
| 295 | * @param[in] instance_id - Message's instance id |
| 296 | * @param[in] completion_code - PLDM completion code |
| 297 | * @param[in] length - Number of bytes read. This could be less than what the |
| 298 | * requester asked for. |
| 299 | * @param[in,out] msg - Message will be written to this |
| 300 | * @return pldm_completion_codes |
| 301 | * @note Caller is responsible for memory alloc and dealloc of param 'msg'. |
| 302 | * Although read file command response includes file data, this function |
| 303 | * does not encode the file data to prevent additional copying of the data. |
| 304 | * The position of file data is calculated by caller from address and size |
| 305 | * of other input arguments. |
| 306 | */ |
| 307 | int encode_read_file_resp(uint8_t instance_id, uint8_t completion_code, |
| 308 | uint32_t length, struct pldm_msg *msg); |
| 309 | |
| 310 | /** @brief Decode Write File commands request |
| 311 | * |
| 312 | * @param[in] msg - PLDM request message payload |
| 313 | * @param[in] payload_length - Length of request payload |
| 314 | * @param[out] file_handle - A handle to the file |
| 315 | * @param[out] offset - Offset to the file at which the write should begin |
| 316 | * @param[out] length - Number of bytes to write |
| 317 | * @param[out] file_data_offset - Offset where file data write begins in pldm |
| 318 | * msg. |
| 319 | * @return pldm_completion_codes |
| 320 | */ |
| 321 | int decode_write_file_req(const struct pldm_msg *msg, size_t payload_length, |
| 322 | uint32_t *file_handle, uint32_t *offset, |
| 323 | uint32_t *length, size_t *file_data_offset); |
| 324 | |
| 325 | /** @brief Create a PLDM request for Write File |
| 326 | * |
| 327 | * @param[in] instance_id - Message's instance id |
| 328 | * @param[in] file_handle - A handle to the file |
| 329 | * @param[in] offset - Offset to the file at which the read should begin |
| 330 | * @param[in] length - Number of bytes written. This could be less than what |
| 331 | * the requester asked for. |
| 332 | * @param[in,out] msg - Message will be written to this |
| 333 | * @return pldm_completion_codes |
| 334 | * @note Caller is responsible for memory alloc and dealloc of param 'msg'. |
| 335 | * Although write file command request includes file data, this function |
| 336 | * does not encode the file data to prevent additional copying of the data. |
| 337 | * The position of file data is calculated by caller from address and size |
| 338 | * of other input arguments. |
| 339 | */ |
| 340 | int encode_write_file_req(uint8_t instance_id, uint32_t file_handle, |
| 341 | uint32_t offset, uint32_t length, |
| 342 | struct pldm_msg *msg); |
| 343 | |
| 344 | /** @brief Decode Write File commands response |
| 345 | * |
| 346 | * @param[in] msg - PLDM request message payload |
| 347 | * @param[in] payload_length - Length of request payload |
| 348 | * @param[out] completion_code - PLDM completion code |
| 349 | * @param[out] length - Number of bytes written |
| 350 | * @return pldm_completion_codes |
| 351 | */ |
| 352 | int decode_write_file_resp(const struct pldm_msg *msg, size_t payload_length, |
| 353 | uint8_t *completion_code, uint32_t *length); |
| 354 | |
| 355 | /** @brief Create a PLDM response for Write File |
| 356 | * |
| 357 | * @param[in] instance_id - Message's instance id |
| 358 | * @param[in] completion_code - PLDM completion code |
| 359 | * @param[in] length - Number of bytes written. This could be less than what |
| 360 | * the requester asked for. |
| 361 | * @param[in,out] msg - Message will be written to this |
| 362 | * @return pldm_completion_codes |
| 363 | * @note Caller is responsible for memory alloc and dealloc of param 'msg' |
| 364 | */ |
| 365 | int encode_write_file_resp(uint8_t instance_id, uint8_t completion_code, |
| 366 | uint32_t length, struct pldm_msg *msg); |
| 367 | |
vkaverap | 0740456 | 2019-08-05 22:57:11 -0500 | [diff] [blame] | 368 | /** @struct pldm_read_write_file_by_type_memory_req |
| 369 | * |
| 370 | * Structure representing ReadFileByTypeIntoMemory and |
| 371 | * WriteFileByTypeFromMemory request |
| 372 | */ |
| 373 | struct pldm_read_write_file_by_type_memory_req { |
| 374 | uint16_t file_type; //!< Type of file |
| 375 | uint32_t file_handle; //!< Handle to file |
| 376 | uint32_t offset; //!< Offset to file where read starts |
| 377 | uint32_t length; //!< Bytes to be read |
| 378 | uint64_t address; //!< Memory address of the file |
| 379 | } __attribute__((packed)); |
| 380 | |
| 381 | /** @struct pldm_read_write_file_by_type_memory_resp |
| 382 | * |
| 383 | * Structure representing ReadFileByTypeIntoMemory and |
| 384 | * WriteFileByTypeFromMemory response |
| 385 | */ |
| 386 | struct pldm_read_write_file_by_type_memory_resp { |
| 387 | uint8_t completion_code; //!< Completion code |
| 388 | uint32_t length; //!< Number of bytes read |
| 389 | } __attribute__((packed)); |
| 390 | |
| 391 | /** @brief Decode ReadFileByTypeIntoMemory and WriteFileByTypeFromMemory |
| 392 | * commands request data |
| 393 | * |
| 394 | * @param[in] msg - Pointer to PLDM request message |
| 395 | * @param[in] payload_length - Length of request payload |
| 396 | * @param[in] file_type - Type of the file |
| 397 | * @param[out] file_handle - A handle to the file |
| 398 | * @param[out] offset - Offset to the file at which the read should begin |
| 399 | * @param[out] length - Number of bytes to be read |
| 400 | * @param[out] address - Memory address of the file content |
| 401 | * @return pldm_completion_codes |
| 402 | */ |
| 403 | int decode_rw_file_by_type_memory_req(const struct pldm_msg *msg, |
| 404 | size_t payload_length, |
| 405 | uint16_t *file_type, |
| 406 | uint32_t *file_handle, uint32_t *offset, |
| 407 | uint32_t *length, uint64_t *address); |
| 408 | |
| 409 | /** @brief Create a PLDM response for ReadFileByTypeIntoMemory and |
| 410 | * WriteFileByTypeFromMemory |
| 411 | * |
| 412 | * @param[in] instance_id - Message's instance id |
| 413 | * @param[in] command - PLDM command |
| 414 | * @param[in] completion_code - PLDM completion code |
| 415 | * @param[in] length - Number of bytes read. This could be less than what the |
| 416 | * requester asked for. |
| 417 | * @param[in,out] msg - Message will be written to this |
| 418 | * @return pldm_completion_codes |
| 419 | * @note Caller is responsible for memory alloc and dealloc of param 'msg' |
| 420 | */ |
| 421 | int encode_rw_file_by_type_memory_resp(uint8_t instance_id, uint8_t command, |
| 422 | uint8_t completion_code, uint32_t length, |
| 423 | struct pldm_msg *msg); |
| 424 | |
| 425 | /** @brief Encode ReadFileByTypeIntoMemory and WriteFileByTypeFromMemory |
| 426 | * commands request data |
| 427 | * |
| 428 | * @param[in] instance_id - Message's instance id |
| 429 | * @param[in] command - PLDM command |
| 430 | * @param[in] file_type - Type of the file |
| 431 | * @param[in] file_handle - A handle to the file |
| 432 | * @param[in] offset - Offset to the file at which the read should begin |
| 433 | * @param[in] length - Number of bytes to be read/written |
| 434 | * @param[in] address - Memory address where the file content has to be |
| 435 | * written to |
| 436 | * @param[out] msg - Message will be written to this |
| 437 | * @return pldm_completion_codes |
| 438 | */ |
| 439 | int encode_rw_file_by_type_memory_req(uint8_t instance_id, uint8_t command, |
| 440 | uint16_t file_type, uint32_t file_handle, |
| 441 | uint32_t offset, uint32_t length, |
| 442 | uint64_t address, struct pldm_msg *msg); |
| 443 | |
| 444 | /** @brief Decode ReadFileTypeIntoMemory and WriteFileTypeFromMemory |
| 445 | * commands response data |
| 446 | * |
| 447 | * @param[in] msg - pointer to PLDM response message |
| 448 | * @param[in] payload_length - Length of response payload |
| 449 | * @param[out] completion_code - PLDM completion code |
| 450 | * @param[out] length - Number of bytes to be read/written |
| 451 | * @return pldm_completion_codes |
| 452 | */ |
| 453 | int decode_rw_file_by_type_memory_resp(const struct pldm_msg *msg, |
| 454 | size_t payload_length, |
| 455 | uint8_t *completion_code, |
| 456 | uint32_t *length); |
| 457 | |
vkaverap | a9aac72 | 2019-08-22 02:10:15 -0500 | [diff] [blame] | 458 | /** @struct pldm_new_file_req |
| 459 | * |
| 460 | * Structure representing NewFile request |
| 461 | */ |
| 462 | struct pldm_new_file_req { |
| 463 | uint16_t file_type; //!< Type of file |
| 464 | uint32_t file_handle; //!< Handle to file |
Deepak Kodihalli | 8338876 | 2020-01-28 04:09:58 -0600 | [diff] [blame] | 465 | uint64_t length; //!< Number of bytes in new file |
vkaverap | a9aac72 | 2019-08-22 02:10:15 -0500 | [diff] [blame] | 466 | } __attribute__((packed)); |
| 467 | |
| 468 | /** @struct pldm_new_file_resp |
| 469 | * |
| 470 | * Structure representing NewFile response data |
| 471 | */ |
| 472 | struct pldm_new_file_resp { |
| 473 | uint8_t completion_code; //!< Completion code |
| 474 | } __attribute__((packed)); |
| 475 | |
| 476 | /** @brief Decode NewFileAvailable command request data |
| 477 | * |
| 478 | * @param[in] msg - Pointer to PLDM request message |
| 479 | * @param[in] payload_length - Length of request payload |
| 480 | * @param[in] file_type - Type of the file |
| 481 | * @param[out] file_handle - A handle to the file |
| 482 | * @param[out] length - Number of bytes in new file |
| 483 | * @return pldm_completion_codes |
| 484 | */ |
| 485 | int decode_new_file_req(const struct pldm_msg *msg, size_t payload_length, |
| 486 | uint16_t *file_type, uint32_t *file_handle, |
Deepak Kodihalli | 8338876 | 2020-01-28 04:09:58 -0600 | [diff] [blame] | 487 | uint64_t *length); |
vkaverap | a9aac72 | 2019-08-22 02:10:15 -0500 | [diff] [blame] | 488 | |
| 489 | /** @brief Create a PLDM response for NewFileAvailable |
| 490 | * |
| 491 | * @param[in] instance_id - Message's instance id |
| 492 | * @param[in] completion_code - PLDM completion code |
| 493 | * @param[in,out] msg - Message will be written to this |
| 494 | * @return pldm_completion_codes |
| 495 | * @note Caller is responsible for memory alloc and dealloc of param 'msg' |
| 496 | */ |
| 497 | int encode_new_file_resp(uint8_t instance_id, uint8_t completion_code, |
| 498 | struct pldm_msg *msg); |
| 499 | |
| 500 | /** @brief Encode NewFileAvailable command request data |
| 501 | * |
| 502 | * @param[in] instance_id - Message's instance id |
| 503 | * @param[in] file_type - Type of the file |
| 504 | * @param[in] file_handle - A handle to the file |
| 505 | * @param[in] length - Number of bytes in new file |
| 506 | * @param[out] msg - Message will be written to this |
| 507 | * @return pldm_completion_codes |
| 508 | */ |
| 509 | 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] | 510 | uint32_t file_handle, uint64_t length, |
vkaverap | a9aac72 | 2019-08-22 02:10:15 -0500 | [diff] [blame] | 511 | struct pldm_msg *msg); |
| 512 | |
| 513 | /** @brief Decode NewFileAvailable command response data |
| 514 | * |
| 515 | * @param[in] msg - pointer to PLDM response message |
| 516 | * @param[in] payload_length - Length of response payload |
| 517 | * @param[out] completion_code - PLDM completion code |
| 518 | * @return pldm_completion_codes |
| 519 | */ |
| 520 | int decode_new_file_resp(const struct pldm_msg *msg, size_t payload_length, |
| 521 | uint8_t *completion_code); |
| 522 | |
Deepak Kodihalli | dce1c99 | 2019-11-19 07:06:53 -0600 | [diff] [blame] | 523 | /** @struct pldm_read_write_file_by_type_req |
| 524 | * |
| 525 | * Structure representing ReadFileByType and |
| 526 | * WriteFileByType request |
| 527 | */ |
| 528 | struct pldm_read_write_file_by_type_req { |
| 529 | uint16_t file_type; //!< Type of file |
| 530 | uint32_t file_handle; //!< Handle to file |
| 531 | uint32_t offset; //!< Offset to file where read/write starts |
| 532 | uint32_t length; //!< Bytes to be read |
| 533 | } __attribute__((packed)); |
| 534 | |
| 535 | /** @struct pldm_read_write_file_by_type_resp |
| 536 | * |
| 537 | * Structure representing ReadFileByType and |
| 538 | * WriteFileByType response |
| 539 | */ |
| 540 | struct pldm_read_write_file_by_type_resp { |
| 541 | uint8_t completion_code; //!< Completion code |
| 542 | uint32_t length; //!< Number of bytes read |
| 543 | } __attribute__((packed)); |
| 544 | |
| 545 | /** @brief Decode ReadFileByType and WriteFileByType |
| 546 | * commands request data |
| 547 | * |
| 548 | * @param[in] msg - Pointer to PLDM request message |
| 549 | * @param[in] payload_length - Length of request payload |
vkaverap | f4e0a49 | 2019-11-19 01:47:35 -0600 | [diff] [blame] | 550 | * @param[out] file_type - Type of the file |
Deepak Kodihalli | dce1c99 | 2019-11-19 07:06:53 -0600 | [diff] [blame] | 551 | * @param[out] file_handle - A handle to the file |
| 552 | * @param[out] offset - Offset to the file at which the read/write should begin |
| 553 | * @param[out] length - Number of bytes to be read/written |
| 554 | * @return pldm_completion_codes |
| 555 | */ |
| 556 | int decode_rw_file_by_type_req(const struct pldm_msg *msg, |
| 557 | size_t payload_length, uint16_t *file_type, |
| 558 | uint32_t *file_handle, uint32_t *offset, |
| 559 | uint32_t *length); |
| 560 | |
| 561 | /** @brief Create a PLDM response for ReadFileByType and |
| 562 | * WriteFileByType |
| 563 | * |
| 564 | * @param[in] instance_id - Message's instance id |
| 565 | * @param[in] command - PLDM command |
| 566 | * @param[in] completion_code - PLDM completion code |
| 567 | * @param[in] length - Number of bytes read/written. This could be less than |
vkaverap | f4e0a49 | 2019-11-19 01:47:35 -0600 | [diff] [blame] | 568 | * what the requester asked for. |
Deepak Kodihalli | dce1c99 | 2019-11-19 07:06:53 -0600 | [diff] [blame] | 569 | * @param[in,out] msg - Message will be written to this |
| 570 | * @return pldm_completion_codes |
| 571 | * @note Caller is responsible for memory alloc and dealloc of param 'msg' |
| 572 | * @note File content has to be copied directly by the caller. |
| 573 | */ |
| 574 | int encode_rw_file_by_type_resp(uint8_t instance_id, uint8_t command, |
| 575 | uint8_t completion_code, uint32_t length, |
| 576 | struct pldm_msg *msg); |
| 577 | |
| 578 | /** @brief Encode ReadFileByType and WriteFileByType |
| 579 | * commands request data |
| 580 | * |
| 581 | * @param[in] instance_id - Message's instance id |
| 582 | * @param[in] command - PLDM command |
| 583 | * @param[in] file_type - Type of the file |
| 584 | * @param[in] file_handle - A handle to the file |
| 585 | * @param[in] offset - Offset to the file at which the read should begin |
| 586 | * @param[in] length - Number of bytes to be read/written |
| 587 | * @param[out] msg - Message will be written to this |
| 588 | * @return pldm_completion_codes |
| 589 | * @note File content has to be read directly by the caller. |
| 590 | */ |
| 591 | int encode_rw_file_by_type_req(uint8_t instance_id, uint8_t command, |
| 592 | uint16_t file_type, uint32_t file_handle, |
| 593 | uint32_t offset, uint32_t length, |
| 594 | struct pldm_msg *msg); |
| 595 | |
| 596 | /** @brief Decode ReadFileByType and WriteFileByType |
| 597 | * commands response data |
| 598 | * |
| 599 | * @param[in] msg - pointer to PLDM response message |
| 600 | * @param[in] payload_length - Length of response payload |
| 601 | * @param[out] completion_code - PLDM completion code |
| 602 | * @param[out] length - Number of bytes to be read/written |
| 603 | * @return pldm_completion_codes |
| 604 | */ |
| 605 | int decode_rw_file_by_type_resp(const struct pldm_msg *msg, |
| 606 | size_t payload_length, uint8_t *completion_code, |
| 607 | uint32_t *length); |
| 608 | |
vkaverap | f4e0a49 | 2019-11-19 01:47:35 -0600 | [diff] [blame] | 609 | /** @struct pldm_file_ack_req |
| 610 | * |
| 611 | * Structure representing FileAck request |
| 612 | */ |
| 613 | struct pldm_file_ack_req { |
| 614 | uint16_t file_type; //!< Type of file |
| 615 | uint32_t file_handle; //!< Handle to file |
| 616 | uint8_t file_status; //!< Status of file processing |
| 617 | } __attribute__((packed)); |
| 618 | |
| 619 | /** @struct pldm_file_ack_resp |
| 620 | * |
| 621 | * Structure representing NewFile response data |
| 622 | */ |
| 623 | struct pldm_file_ack_resp { |
| 624 | uint8_t completion_code; //!< Completion code |
| 625 | } __attribute__((packed)); |
| 626 | |
| 627 | /** @brief Decode FileAck command request data |
| 628 | * |
| 629 | * @param[in] msg - Pointer to PLDM request message |
| 630 | * @param[in] payload_length - Length of request payload |
| 631 | * @param[out] file_type - Type of the file |
| 632 | * @param[out] file_handle - A handle to the file |
| 633 | * @param[out] file_status - Status of file processing |
| 634 | * @return pldm_completion_codes |
| 635 | */ |
| 636 | int decode_file_ack_req(const struct pldm_msg *msg, size_t payload_length, |
| 637 | uint16_t *file_type, uint32_t *file_handle, |
| 638 | uint8_t *file_status); |
| 639 | |
| 640 | /** @brief Create a PLDM response for FileAck |
| 641 | * |
| 642 | * @param[in] instance_id - Message's instance id |
| 643 | * @param[in] completion_code - PLDM completion code |
| 644 | * @param[in,out] msg - Message will be written to this |
| 645 | * @return pldm_completion_codes |
| 646 | * @note Caller is responsible for memory alloc and dealloc of param 'msg' |
| 647 | */ |
| 648 | int encode_file_ack_resp(uint8_t instance_id, uint8_t completion_code, |
| 649 | struct pldm_msg *msg); |
| 650 | |
| 651 | /** @brief Encode FileAck command request data |
| 652 | * |
| 653 | * @param[in] instance_id - Message's instance id |
| 654 | * @param[in] file_type - Type of the file |
| 655 | * @param[in] file_handle - A handle to the file |
| 656 | * @param[in] file_status - Status of file processing |
| 657 | * @param[out] msg - Message will be written to this |
| 658 | * @return pldm_completion_codes |
| 659 | */ |
| 660 | int encode_file_ack_req(uint8_t instance_id, uint16_t file_type, |
| 661 | uint32_t file_handle, uint8_t file_status, |
| 662 | struct pldm_msg *msg); |
| 663 | |
| 664 | /** @brief Decode FileAck command response data |
| 665 | * |
| 666 | * @param[in] msg - pointer to PLDM response message |
| 667 | * @param[in] payload_length - Length of response payload |
| 668 | * @param[out] completion_code - PLDM completion code |
| 669 | * @return pldm_completion_codes |
| 670 | */ |
| 671 | int decode_file_ack_resp(const struct pldm_msg *msg, size_t payload_length, |
| 672 | uint8_t *completion_code); |
| 673 | |
Jinu Joy Thomas | 7f57f44 | 2019-06-13 20:38:49 +0530 | [diff] [blame] | 674 | #ifdef __cplusplus |
| 675 | } |
| 676 | #endif |
| 677 | |
| 678 | #endif /* FILEIO_H */ |