blob: 72892da384c19d56202b4e6519bb5fe8c0e2abb6 [file] [log] [blame]
Jinu Joy Thomas7f57f442019-06-13 20:38:49 +05301#ifndef FILEIO_H
2#define FILEIO_H
3
4#ifdef __cplusplus
5extern "C" {
6#endif
7
8#include <stddef.h>
9#include <stdint.h>
10
11#include "base.h"
12
Jinu Joy Thomas7f57f442019-06-13 20:38:49 +053013/** @brief PLDM Commands in IBM OEM type
14 */
15enum pldm_fileio_commands {
Tom Joseph0c6d22c2019-06-26 09:58:41 +053016 PLDM_GET_FILE_TABLE = 0x1,
vkaverap2ffe3292019-06-24 00:08:13 -050017 PLDM_READ_FILE = 0x4,
18 PLDM_WRITE_FILE = 0x5,
Jinu Joy Thomas7f57f442019-06-13 20:38:49 +053019 PLDM_READ_FILE_INTO_MEMORY = 0x6,
20 PLDM_WRITE_FILE_FROM_MEMORY = 0x7,
vkaverap07404562019-08-05 22:57:11 -050021 PLDM_READ_FILE_BY_TYPE_INTO_MEMORY = 0x8,
22 PLDM_WRITE_FILE_BY_TYPE_FROM_MEMORY = 0x9,
vkaverapa9aac722019-08-22 02:10:15 -050023 PLDM_NEW_FILE_AVAILABLE = 0xA,
Deepak Kodihallidce1c992019-11-19 07:06:53 -060024 PLDM_READ_FILE_BY_TYPE = 0xB,
vkaverapf4e0a492019-11-19 01:47:35 -060025 PLDM_WRITE_FILE_BY_TYPE = 0xC,
26 PLDM_FILE_ACK = 0xD,
Sridevi Ramesh8b51fa22022-06-13 06:28:13 -050027 PLDM_NEW_FILE_AVAILABLE_WITH_META_DATA = 0xE,
28 PLDM_FILE_ACK_WITH_META_DATA = 0xF,
Jinu Joy Thomas7f57f442019-06-13 20:38:49 +053029};
30
31/** @brief PLDM Command specific codes
32 */
33enum pldm_fileio_completion_codes {
Deepak Kodihalli3bf5c552020-04-20 06:16:01 -050034 PLDM_FILE_TABLE_UNAVAILABLE = 0x83,
Tom Joseph0c6d22c2019-06-26 09:58:41 +053035 PLDM_INVALID_FILE_TABLE_TYPE = 0x85,
Deepak Kodihalli3bf5c552020-04-20 06:16:01 -050036 PLDM_INVALID_FILE_HANDLE = 0x86,
37 PLDM_DATA_OUT_OF_RANGE = 0x87,
38 PLDM_INVALID_FILE_TYPE = 0x89,
Tom Joseph0c6d22c2019-06-26 09:58:41 +053039};
40
41/** @brief PLDM File I/O table types
42 */
43enum pldm_fileio_table_type {
44 PLDM_FILE_ATTRIBUTE_TABLE = 0,
45 PLDM_OEM_FILE_ATTRIBUTE_TABLE = 1,
Jinu Joy Thomas7f57f442019-06-13 20:38:49 +053046};
47
Sampa Misra854e61f2019-08-22 04:36:47 -050048/** @brief PLDM File I/O table types
49 */
50enum pldm_fileio_file_type {
Jayashankar Padathdb124362021-01-28 21:12:34 -060051 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 Edad94bb832021-02-17 11:40:22 +053061 PLDM_FILE_TYPE_PROGRESS_SRC = 0xA,
Sampa Misra854e61f2019-08-22 04:36:47 -050062};
63
Jinu Joy Thomas7f57f442019-06-13 20:38:49 +053064#define PLDM_RW_FILE_MEM_REQ_BYTES 20
65#define PLDM_RW_FILE_MEM_RESP_BYTES 5
Tom Joseph0c6d22c2019-06-26 09:58:41 +053066#define PLDM_GET_FILE_TABLE_REQ_BYTES 6
67#define PLDM_GET_FILE_TABLE_MIN_RESP_BYTES 6
vkaverap2ffe3292019-06-24 00:08:13 -050068#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
vkaverap07404562019-08-05 22:57:11 -050072#define PLDM_RW_FILE_BY_TYPE_MEM_REQ_BYTES 22
73#define PLDM_RW_FILE_BY_TYPE_MEM_RESP_BYTES 5
Deepak Kodihalli83388762020-01-28 04:09:58 -060074#define PLDM_NEW_FILE_REQ_BYTES 14
vkaverapa9aac722019-08-22 02:10:15 -050075#define PLDM_NEW_FILE_RESP_BYTES 1
Deepak Kodihallidce1c992019-11-19 07:06:53 -060076#define PLDM_RW_FILE_BY_TYPE_REQ_BYTES 14
77#define PLDM_RW_FILE_BY_TYPE_RESP_BYTES 5
vkaverapf4e0a492019-11-19 01:47:35 -060078#define PLDM_FILE_ACK_REQ_BYTES 7
79#define PLDM_FILE_ACK_RESP_BYTES 1
Sridevi Ramesh8b51fa22022-06-13 06:28:13 -050080#define PLDM_FILE_ACK_WITH_META_DATA_REQ_BYTES 23
81#define PLDM_FILE_ACK_WITH_META_DATA_RESP_BYTES 1
Jinu Joy Thomas7f57f442019-06-13 20:38:49 +053082
Priyanga8b976652019-06-27 11:30:33 -050083/** @struct pldm_read_write_file_memory_req
84 *
85 * Structure representing ReadFileIntoMemory request and WriteFileFromMemory
86 * request
87 */
88struct pldm_read_write_file_memory_req {
89 uint32_t file_handle; //!< A Handle to the file
90 uint32_t offset; //!< Offset to the file
91 uint32_t length; //!< Number of bytes to be read/write
92 uint64_t address; //!< Memory address of the file
93} __attribute__((packed));
94
95/** @struct pldm_read_write_file_memory_resp
96 *
97 * Structure representing ReadFileIntoMemory response and WriteFileFromMemory
98 * response
99 */
100struct pldm_read_write_file_memory_resp {
101 uint8_t completion_code; //!< completion code
102 uint32_t length; //!< Number of bytes read/written
103} __attribute__((packed));
104
Jinu Joy Thomas7f57f442019-06-13 20:38:49 +0530105/** @brief Decode ReadFileIntoMemory and WriteFileFromMemory commands request
106 * data
107 *
Zahed Hossain223a73d2019-07-04 12:46:18 -0500108 * @param[in] msg - Pointer to PLDM request message
Jinu Joy Thomas7f57f442019-06-13 20:38:49 +0530109 * @param[in] payload_length - Length of request payload
110 * @param[out] file_handle - A handle to the file
111 * @param[out] offset - Offset to the file at which the read should begin
112 * @param[out] length - Number of bytes to be read
113 * @param[out] address - Memory address where the file content has to be
114 * written to
115 * @return pldm_completion_codes
116 */
Zahed Hossain223a73d2019-07-04 12:46:18 -0500117int decode_rw_file_memory_req(const struct pldm_msg *msg, size_t payload_length,
Jinu Joy Thomas7f57f442019-06-13 20:38:49 +0530118 uint32_t *file_handle, uint32_t *offset,
119 uint32_t *length, uint64_t *address);
120
121/** @brief Create a PLDM response for ReadFileIntoMemory and
122 * WriteFileFromMemory
123 *
124 * @param[in] instance_id - Message's instance id
125 * @param[in] command - PLDM command
126 * @param[in] completion_code - PLDM completion code
127 * @param[in] length - Number of bytes read. This could be less than what the
128 requester asked for.
129 * @param[in,out] msg - Message will be written to this
130 * @return pldm_completion_codes
131 * @note Caller is responsible for memory alloc and dealloc of param 'msg'
132 */
133int encode_rw_file_memory_resp(uint8_t instance_id, uint8_t command,
134 uint8_t completion_code, uint32_t length,
135 struct pldm_msg *msg);
136
Priyanga8b976652019-06-27 11:30:33 -0500137/** @brief Encode ReadFileIntoMemory and WriteFileFromMemory
138 * commands request data
139 *
140 * @param[in] instance_id - Message's instance id
141 * @param[in] command - PLDM command
142 * @param[in] file_handle - A handle to the file
143 * @param[in] offset - Offset to the file at which the read should begin
144 * @param[in] length - Number of bytes to be read/written
145 * @param[in] address - Memory address where the file content has to be
146 * written to
147 * @param[out] msg - Message will be written to this
148 * @return pldm_completion_codes
149 */
150int encode_rw_file_memory_req(uint8_t instance_id, uint8_t command,
151 uint32_t file_handle, uint32_t offset,
152 uint32_t length, uint64_t address,
153 struct pldm_msg *msg);
154
155/** @brief Decode ReadFileIntoMemory and WriteFileFromMemory
156 * commands response data
157 *
Zahed Hossain223a73d2019-07-04 12:46:18 -0500158 * @param[in] msg - pointer to PLDM response message
Priyanga8b976652019-06-27 11:30:33 -0500159 * @param[in] payload_length - Length of response payload
160 * @param[out] completion_code - PLDM completion code
161 * @param[out] length - Number of bytes to be read/written
162 * @return pldm_completion_codes
163 */
Zahed Hossain223a73d2019-07-04 12:46:18 -0500164int decode_rw_file_memory_resp(const struct pldm_msg *msg,
165 size_t payload_length, uint8_t *completion_code,
166 uint32_t *length);
Priyanga8b976652019-06-27 11:30:33 -0500167
Tom Joseph0c6d22c2019-06-26 09:58:41 +0530168/** @struct pldm_get_file_table_req
169 *
170 * Structure representing GetFileTable request
171 */
172struct pldm_get_file_table_req {
173 uint32_t transfer_handle; //!< Data transfer handle
Deepak Kodihalli826c9d42020-05-26 01:58:06 -0500174 uint8_t operation_flag; //!< Transfer operation flag
175 uint8_t table_type; //!< Table type
Tom Joseph0c6d22c2019-06-26 09:58:41 +0530176} __attribute__((packed));
177
178/** @struct pldm_get_file_table_resp
179 *
180 * Structure representing GetFileTable response fixed data
181 */
182struct pldm_get_file_table_resp {
183 uint8_t completion_code; //!< Completion code
184 uint32_t next_transfer_handle; //!< Next data transfer handle
Deepak Kodihalli826c9d42020-05-26 01:58:06 -0500185 uint8_t transfer_flag; //!< Transfer flag
186 uint8_t table_data[1]; //!< Table Data
Tom Joseph0c6d22c2019-06-26 09:58:41 +0530187} __attribute__((packed));
188
Pavithra Barithayac4e80cc2020-05-26 07:00:26 -0500189/** @struct pldm_file_attr_table_entry
190 *
191 * Structure representing File attribute table entry
192 */
193struct pldm_file_attr_table_entry {
194 uint32_t file_handle; //!< File Handle
195 uint16_t file_name_length; //!< File name length
196 uint8_t file_attr_table_nst[1]; //!< File name size traits
197} __attribute__((packed));
198
Tom Joseph0c6d22c2019-06-26 09:58:41 +0530199/** @brief Decode GetFileTable command request data
200 *
Zahed Hossain223a73d2019-07-04 12:46:18 -0500201 * @param[in] msg - Pointer to PLDM request message
Tom Joseph0c6d22c2019-06-26 09:58:41 +0530202 * @param[in] payload_length - Length of request payload
203 * @param[out] trasnfer_handle - the handle of data
204 * @param[out] transfer_opflag - Transfer operation flag
205 * @param[out] table_type - the type of file table
206 * @return pldm_completion_codes
207 */
Zahed Hossain223a73d2019-07-04 12:46:18 -0500208int decode_get_file_table_req(const struct pldm_msg *msg, size_t payload_length,
Tom Joseph0c6d22c2019-06-26 09:58:41 +0530209 uint32_t *transfer_handle,
210 uint8_t *transfer_opflag, uint8_t *table_type);
211
212/** @brief Create a PLDM response for GetFileTable command
213 *
214 * @param[in] instance_id - Message's instance id
215 * @param[in] completion_code - PLDM completion code
216 * @param[in] next_transfer_handle - Handle to identify next portion of
217 * data transfer
218 * @param[in] transfer_flag - Represents the part of transfer
219 * @param[in] table_data - pointer to file table data
220 * @param[in] table_size - file table size
221 * @param[in,out] msg - Message will be written to this
222 * @return pldm_completion_codes
223 * @note Caller is responsible for memory alloc and dealloc of param 'msg'
224 */
225int encode_get_file_table_resp(uint8_t instance_id, uint8_t completion_code,
226 uint32_t next_transfer_handle,
227 uint8_t transfer_flag, const uint8_t *table_data,
228 size_t table_size, struct pldm_msg *msg);
229
Pavithra Barithayad15c8092020-05-12 02:26:26 -0500230/** @brief Encode GetFileTable command request data
231 *
232 * @param[in] instance_id - Message's instance id
233 * @param[in] transfer_handle - the handle of data
234 * @param[in] transfer_opflag - Transfer operation flag
235 * @param[in] table_type - the type of file table
236 * @param[out] msg - Message will be written to this
237 * @return pldm_completion_codes
238 */
239int encode_get_file_table_req(uint8_t instance_id, uint32_t transfer_handle,
240 uint8_t transfer_opflag, uint8_t table_type,
241 struct pldm_msg *msg);
242
243/** @brief Decode GetFileTable command response data
244 * @param[in] msg - Response message
245 * @param[in] payload_length - length of response message payload
246 * @param[out] completion_code - PLDM completion code
247 * @param[out] next_transfer_handle - Handle to identify next portion of data
248 * transfer
249 * @param[out] transfer_flag - Represents the part of transfer
250 * @param[out] file_table_data_start_offset - This data is a portion of the
251 * overall File Table
252 * @param[out] file_table_length - Length of the File table data
253 * @return pldm_completion_codes
254 */
255int decode_get_file_table_resp(const struct pldm_msg *msg,
256 size_t payload_length, uint8_t *completion_code,
257 uint32_t *next_transfer_handle,
258 uint8_t *transfer_flag,
259 uint8_t *file_table_data_start_offset,
260 size_t *file_table_length);
261
vkaverap2ffe3292019-06-24 00:08:13 -0500262/** @struct pldm_read_file_req
263 *
264 * Structure representing ReadFile request
265 */
266struct pldm_read_file_req {
267 uint32_t file_handle; //!< Handle to file
268 uint32_t offset; //!< Offset to file where read starts
269 uint32_t length; //!< Bytes to be read
270} __attribute__((packed));
271
272/** @struct pldm_read_file_resp
273 *
274 * Structure representing ReadFile response data
275 */
276struct pldm_read_file_resp {
277 uint8_t completion_code; //!< Completion code
278 uint32_t length; //!< Number of bytes read
Deepak Kodihalli826c9d42020-05-26 01:58:06 -0500279 uint8_t file_data[1]; //!< Address of this is where file data starts
vkaverap2ffe3292019-06-24 00:08:13 -0500280} __attribute__((packed));
281
282/** @struct pldm_write_file_req
283 *
284 * Structure representing WriteFile request
285 */
286struct pldm_write_file_req {
287 uint32_t file_handle; //!< Handle to file
288 uint32_t offset; //!< Offset to file where write starts
289 uint32_t length; //!< Bytes to be written
290 uint8_t file_data[1]; //!< Address of this is where file data starts
291} __attribute__((packed));
292
293/** @struct pldm_write_file_resp
294 *
295 * Structure representing WriteFile response data
296 */
297struct pldm_write_file_resp {
298 uint8_t completion_code; //!< Completion code
299 uint32_t length; //!< Bytes written
300} __attribute__((packed));
301
302/** @brief Decode Read File commands request
303 *
304 * @param[in] msg - PLDM request message payload
305 * @param[in] payload_length - Length of request payload
306 * @param[out] file_handle - A handle to the file
307 * @param[out] offset - Offset to the file at which the read should begin
308 * @param[out] length - Number of bytes read
309 * @return pldm_completion_codes
310 */
311int decode_read_file_req(const struct pldm_msg *msg, size_t payload_length,
312 uint32_t *file_handle, uint32_t *offset,
313 uint32_t *length);
314
315/** @brief Encode Read File commands request
316 *
317 * @param[in] instance_id - Message's instance id
318 * @param[in] file_handle - A handle to the file
319 * @param[in] offset - Offset to the file at which the read should begin
320 * @param[in] length - Number of bytes read
321 * @param[in,out] msg - Message will be written to this
322 * @return pldm_completion_codes
323 * @note Caller is responsible for memory alloc and dealloc of param 'msg'
324 */
325int encode_read_file_req(uint8_t instance_id, uint32_t file_handle,
326 uint32_t offset, uint32_t length,
327 struct pldm_msg *msg);
328
329/** @brief Decode Read File commands response
330 *
331 * @param[in] msg - PLDM response message payload
332 * @param[in] payload_length - Length of request payload
333 * @param[out] completion_code - PLDM completion code
334 * @param[out] length - Number of bytes read. This could be less than what the
335 * requester asked for.
336 * @param[out] file_data_offset - Offset where file data should be read in pldm
337 * msg.
338 * @return pldm_completion_codes
339 */
340int decode_read_file_resp(const struct pldm_msg *msg, size_t payload_length,
341 uint8_t *completion_code, uint32_t *length,
342 size_t *file_data_offset);
343
344/** @brief Create a PLDM response for Read File
345 *
346 * @param[in] instance_id - Message's instance id
347 * @param[in] completion_code - PLDM completion code
348 * @param[in] length - Number of bytes read. This could be less than what the
349 * requester asked for.
350 * @param[in,out] msg - Message will be written to this
351 * @return pldm_completion_codes
352 * @note Caller is responsible for memory alloc and dealloc of param 'msg'.
353 * Although read file command response includes file data, this function
354 * does not encode the file data to prevent additional copying of the data.
355 * The position of file data is calculated by caller from address and size
356 * of other input arguments.
357 */
358int encode_read_file_resp(uint8_t instance_id, uint8_t completion_code,
359 uint32_t length, struct pldm_msg *msg);
360
361/** @brief Decode Write File commands request
362 *
363 * @param[in] msg - PLDM request message payload
364 * @param[in] payload_length - Length of request payload
365 * @param[out] file_handle - A handle to the file
366 * @param[out] offset - Offset to the file at which the write should begin
367 * @param[out] length - Number of bytes to write
368 * @param[out] file_data_offset - Offset where file data write begins in pldm
369 * msg.
370 * @return pldm_completion_codes
371 */
372int decode_write_file_req(const struct pldm_msg *msg, size_t payload_length,
373 uint32_t *file_handle, uint32_t *offset,
374 uint32_t *length, size_t *file_data_offset);
375
376/** @brief Create a PLDM request for Write File
377 *
378 * @param[in] instance_id - Message's instance id
379 * @param[in] file_handle - A handle to the file
380 * @param[in] offset - Offset to the file at which the read should begin
381 * @param[in] length - Number of bytes written. This could be less than what
382 * the requester asked for.
383 * @param[in,out] msg - Message will be written to this
384 * @return pldm_completion_codes
385 * @note Caller is responsible for memory alloc and dealloc of param 'msg'.
386 * Although write file command request includes file data, this function
387 * does not encode the file data to prevent additional copying of the data.
388 * The position of file data is calculated by caller from address and size
389 * of other input arguments.
390 */
391int encode_write_file_req(uint8_t instance_id, uint32_t file_handle,
392 uint32_t offset, uint32_t length,
393 struct pldm_msg *msg);
394
395/** @brief Decode Write File commands response
396 *
397 * @param[in] msg - PLDM request message payload
398 * @param[in] payload_length - Length of request payload
399 * @param[out] completion_code - PLDM completion code
400 * @param[out] length - Number of bytes written
401 * @return pldm_completion_codes
402 */
403int decode_write_file_resp(const struct pldm_msg *msg, size_t payload_length,
404 uint8_t *completion_code, uint32_t *length);
405
406/** @brief Create a PLDM response for Write File
407 *
408 * @param[in] instance_id - Message's instance id
409 * @param[in] completion_code - PLDM completion code
410 * @param[in] length - Number of bytes written. This could be less than what
411 * the requester asked for.
412 * @param[in,out] msg - Message will be written to this
413 * @return pldm_completion_codes
414 * @note Caller is responsible for memory alloc and dealloc of param 'msg'
415 */
416int encode_write_file_resp(uint8_t instance_id, uint8_t completion_code,
417 uint32_t length, struct pldm_msg *msg);
418
vkaverap07404562019-08-05 22:57:11 -0500419/** @struct pldm_read_write_file_by_type_memory_req
420 *
421 * Structure representing ReadFileByTypeIntoMemory and
422 * WriteFileByTypeFromMemory request
423 */
424struct pldm_read_write_file_by_type_memory_req {
425 uint16_t file_type; //!< Type of file
426 uint32_t file_handle; //!< Handle to file
427 uint32_t offset; //!< Offset to file where read starts
428 uint32_t length; //!< Bytes to be read
429 uint64_t address; //!< Memory address of the file
430} __attribute__((packed));
431
432/** @struct pldm_read_write_file_by_type_memory_resp
433 *
434 * Structure representing ReadFileByTypeIntoMemory and
435 * WriteFileByTypeFromMemory response
436 */
437struct pldm_read_write_file_by_type_memory_resp {
438 uint8_t completion_code; //!< Completion code
439 uint32_t length; //!< Number of bytes read
440} __attribute__((packed));
441
442/** @brief Decode ReadFileByTypeIntoMemory and WriteFileByTypeFromMemory
443 * commands request data
444 *
445 * @param[in] msg - Pointer to PLDM request message
446 * @param[in] payload_length - Length of request payload
447 * @param[in] file_type - Type of the file
448 * @param[out] file_handle - A handle to the file
449 * @param[out] offset - Offset to the file at which the read should begin
450 * @param[out] length - Number of bytes to be read
451 * @param[out] address - Memory address of the file content
452 * @return pldm_completion_codes
453 */
454int decode_rw_file_by_type_memory_req(const struct pldm_msg *msg,
455 size_t payload_length,
456 uint16_t *file_type,
457 uint32_t *file_handle, uint32_t *offset,
458 uint32_t *length, uint64_t *address);
459
460/** @brief Create a PLDM response for ReadFileByTypeIntoMemory and
461 * WriteFileByTypeFromMemory
462 *
463 * @param[in] instance_id - Message's instance id
464 * @param[in] command - PLDM command
465 * @param[in] completion_code - PLDM completion code
466 * @param[in] length - Number of bytes read. This could be less than what the
467 * requester asked for.
468 * @param[in,out] msg - Message will be written to this
469 * @return pldm_completion_codes
470 * @note Caller is responsible for memory alloc and dealloc of param 'msg'
471 */
472int encode_rw_file_by_type_memory_resp(uint8_t instance_id, uint8_t command,
473 uint8_t completion_code, uint32_t length,
474 struct pldm_msg *msg);
475
476/** @brief Encode ReadFileByTypeIntoMemory and WriteFileByTypeFromMemory
477 * commands request data
478 *
479 * @param[in] instance_id - Message's instance id
480 * @param[in] command - PLDM command
481 * @param[in] file_type - Type of the file
482 * @param[in] file_handle - A handle to the file
483 * @param[in] offset - Offset to the file at which the read should begin
484 * @param[in] length - Number of bytes to be read/written
485 * @param[in] address - Memory address where the file content has to be
486 * written to
487 * @param[out] msg - Message will be written to this
488 * @return pldm_completion_codes
489 */
490int encode_rw_file_by_type_memory_req(uint8_t instance_id, uint8_t command,
491 uint16_t file_type, uint32_t file_handle,
492 uint32_t offset, uint32_t length,
493 uint64_t address, struct pldm_msg *msg);
494
495/** @brief Decode ReadFileTypeIntoMemory and WriteFileTypeFromMemory
496 * commands response data
497 *
498 * @param[in] msg - pointer to PLDM response message
499 * @param[in] payload_length - Length of response payload
500 * @param[out] completion_code - PLDM completion code
501 * @param[out] length - Number of bytes to be read/written
502 * @return pldm_completion_codes
503 */
504int decode_rw_file_by_type_memory_resp(const struct pldm_msg *msg,
505 size_t payload_length,
506 uint8_t *completion_code,
507 uint32_t *length);
508
vkaverapa9aac722019-08-22 02:10:15 -0500509/** @struct pldm_new_file_req
510 *
511 * Structure representing NewFile request
512 */
513struct pldm_new_file_req {
514 uint16_t file_type; //!< Type of file
515 uint32_t file_handle; //!< Handle to file
Deepak Kodihalli83388762020-01-28 04:09:58 -0600516 uint64_t length; //!< Number of bytes in new file
vkaverapa9aac722019-08-22 02:10:15 -0500517} __attribute__((packed));
518
519/** @struct pldm_new_file_resp
520 *
521 * Structure representing NewFile response data
522 */
523struct pldm_new_file_resp {
524 uint8_t completion_code; //!< Completion code
525} __attribute__((packed));
526
527/** @brief Decode NewFileAvailable command request data
528 *
529 * @param[in] msg - Pointer to PLDM request message
530 * @param[in] payload_length - Length of request payload
531 * @param[in] file_type - Type of the file
532 * @param[out] file_handle - A handle to the file
533 * @param[out] length - Number of bytes in new file
534 * @return pldm_completion_codes
535 */
536int decode_new_file_req(const struct pldm_msg *msg, size_t payload_length,
537 uint16_t *file_type, uint32_t *file_handle,
Deepak Kodihalli83388762020-01-28 04:09:58 -0600538 uint64_t *length);
vkaverapa9aac722019-08-22 02:10:15 -0500539
540/** @brief Create a PLDM response for NewFileAvailable
541 *
542 * @param[in] instance_id - Message's instance id
543 * @param[in] completion_code - PLDM completion code
544 * @param[in,out] msg - Message will be written to this
545 * @return pldm_completion_codes
546 * @note Caller is responsible for memory alloc and dealloc of param 'msg'
547 */
548int encode_new_file_resp(uint8_t instance_id, uint8_t completion_code,
549 struct pldm_msg *msg);
550
551/** @brief Encode NewFileAvailable command request data
552 *
553 * @param[in] instance_id - Message's instance id
554 * @param[in] file_type - Type of the file
555 * @param[in] file_handle - A handle to the file
556 * @param[in] length - Number of bytes in new file
557 * @param[out] msg - Message will be written to this
558 * @return pldm_completion_codes
559 */
560int encode_new_file_req(uint8_t instance_id, uint16_t file_type,
Deepak Kodihalli83388762020-01-28 04:09:58 -0600561 uint32_t file_handle, uint64_t length,
vkaverapa9aac722019-08-22 02:10:15 -0500562 struct pldm_msg *msg);
563
564/** @brief Decode NewFileAvailable command response data
565 *
566 * @param[in] msg - pointer to PLDM response message
567 * @param[in] payload_length - Length of response payload
568 * @param[out] completion_code - PLDM completion code
569 * @return pldm_completion_codes
570 */
571int decode_new_file_resp(const struct pldm_msg *msg, size_t payload_length,
572 uint8_t *completion_code);
573
Deepak Kodihallidce1c992019-11-19 07:06:53 -0600574/** @struct pldm_read_write_file_by_type_req
575 *
576 * Structure representing ReadFileByType and
577 * WriteFileByType request
578 */
579struct pldm_read_write_file_by_type_req {
580 uint16_t file_type; //!< Type of file
581 uint32_t file_handle; //!< Handle to file
582 uint32_t offset; //!< Offset to file where read/write starts
583 uint32_t length; //!< Bytes to be read
584} __attribute__((packed));
585
586/** @struct pldm_read_write_file_by_type_resp
587 *
588 * Structure representing ReadFileByType and
589 * WriteFileByType response
590 */
591struct pldm_read_write_file_by_type_resp {
592 uint8_t completion_code; //!< Completion code
593 uint32_t length; //!< Number of bytes read
594} __attribute__((packed));
595
596/** @brief Decode ReadFileByType and WriteFileByType
597 * commands request data
598 *
599 * @param[in] msg - Pointer to PLDM request message
600 * @param[in] payload_length - Length of request payload
vkaverapf4e0a492019-11-19 01:47:35 -0600601 * @param[out] file_type - Type of the file
Deepak Kodihallidce1c992019-11-19 07:06:53 -0600602 * @param[out] file_handle - A handle to the file
603 * @param[out] offset - Offset to the file at which the read/write should begin
604 * @param[out] length - Number of bytes to be read/written
605 * @return pldm_completion_codes
606 */
607int decode_rw_file_by_type_req(const struct pldm_msg *msg,
608 size_t payload_length, uint16_t *file_type,
609 uint32_t *file_handle, uint32_t *offset,
610 uint32_t *length);
611
612/** @brief Create a PLDM response for ReadFileByType and
613 * WriteFileByType
614 *
615 * @param[in] instance_id - Message's instance id
616 * @param[in] command - PLDM command
617 * @param[in] completion_code - PLDM completion code
618 * @param[in] length - Number of bytes read/written. This could be less than
vkaverapf4e0a492019-11-19 01:47:35 -0600619 * what the requester asked for.
Deepak Kodihallidce1c992019-11-19 07:06:53 -0600620 * @param[in,out] msg - Message will be written to this
621 * @return pldm_completion_codes
622 * @note Caller is responsible for memory alloc and dealloc of param 'msg'
623 * @note File content has to be copied directly by the caller.
624 */
625int encode_rw_file_by_type_resp(uint8_t instance_id, uint8_t command,
626 uint8_t completion_code, uint32_t length,
627 struct pldm_msg *msg);
628
629/** @brief Encode ReadFileByType and WriteFileByType
630 * commands request data
631 *
632 * @param[in] instance_id - Message's instance id
633 * @param[in] command - PLDM command
634 * @param[in] file_type - Type of the file
635 * @param[in] file_handle - A handle to the file
636 * @param[in] offset - Offset to the file at which the read should begin
637 * @param[in] length - Number of bytes to be read/written
638 * @param[out] msg - Message will be written to this
639 * @return pldm_completion_codes
640 * @note File content has to be read directly by the caller.
641 */
642int encode_rw_file_by_type_req(uint8_t instance_id, uint8_t command,
643 uint16_t file_type, uint32_t file_handle,
644 uint32_t offset, uint32_t length,
645 struct pldm_msg *msg);
646
647/** @brief Decode ReadFileByType and WriteFileByType
648 * commands response data
649 *
650 * @param[in] msg - pointer to PLDM response message
651 * @param[in] payload_length - Length of response payload
652 * @param[out] completion_code - PLDM completion code
653 * @param[out] length - Number of bytes to be read/written
654 * @return pldm_completion_codes
655 */
656int decode_rw_file_by_type_resp(const struct pldm_msg *msg,
657 size_t payload_length, uint8_t *completion_code,
658 uint32_t *length);
659
vkaverapf4e0a492019-11-19 01:47:35 -0600660/** @struct pldm_file_ack_req
661 *
662 * Structure representing FileAck request
663 */
664struct pldm_file_ack_req {
665 uint16_t file_type; //!< Type of file
666 uint32_t file_handle; //!< Handle to file
667 uint8_t file_status; //!< Status of file processing
668} __attribute__((packed));
669
670/** @struct pldm_file_ack_resp
671 *
672 * Structure representing NewFile response data
673 */
674struct pldm_file_ack_resp {
675 uint8_t completion_code; //!< Completion code
676} __attribute__((packed));
677
678/** @brief Decode FileAck command request data
679 *
680 * @param[in] msg - Pointer to PLDM request message
681 * @param[in] payload_length - Length of request payload
682 * @param[out] file_type - Type of the file
683 * @param[out] file_handle - A handle to the file
684 * @param[out] file_status - Status of file processing
685 * @return pldm_completion_codes
686 */
687int decode_file_ack_req(const struct pldm_msg *msg, size_t payload_length,
688 uint16_t *file_type, uint32_t *file_handle,
689 uint8_t *file_status);
690
691/** @brief Create a PLDM response for FileAck
692 *
693 * @param[in] instance_id - Message's instance id
694 * @param[in] completion_code - PLDM completion code
695 * @param[in,out] msg - Message will be written to this
696 * @return pldm_completion_codes
697 * @note Caller is responsible for memory alloc and dealloc of param 'msg'
698 */
699int encode_file_ack_resp(uint8_t instance_id, uint8_t completion_code,
700 struct pldm_msg *msg);
701
702/** @brief Encode FileAck command request data
703 *
704 * @param[in] instance_id - Message's instance id
705 * @param[in] file_type - Type of the file
706 * @param[in] file_handle - A handle to the file
707 * @param[in] file_status - Status of file processing
708 * @param[out] msg - Message will be written to this
709 * @return pldm_completion_codes
710 */
711int encode_file_ack_req(uint8_t instance_id, uint16_t file_type,
712 uint32_t file_handle, uint8_t file_status,
713 struct pldm_msg *msg);
714
715/** @brief Decode FileAck command response data
716 *
717 * @param[in] msg - pointer to PLDM response message
718 * @param[in] payload_length - Length of response payload
719 * @param[out] completion_code - PLDM completion code
720 * @return pldm_completion_codes
721 */
722int decode_file_ack_resp(const struct pldm_msg *msg, size_t payload_length,
723 uint8_t *completion_code);
724
Sridevi Ramesh8b51fa22022-06-13 06:28:13 -0500725/* FileAckWithMetadata */
726
727/** @struct pldm_file_ack_with_meta_data_req
728 *
729 * Structure representing FileAckWithMetadata request
730 */
731struct pldm_file_ack_with_meta_data_req {
732 uint16_t file_type; //!< Type of file
733 uint32_t file_handle; //!< Handle to file
734 uint8_t file_status; //!< Status of file processing
735 uint32_t file_meta_data_1; //!< Meta data specific to file type 1
736 uint32_t file_meta_data_2; //!< Meta data specific to file type 2
737 uint32_t file_meta_data_3; //!< Meta data specific to file type 3
738 uint32_t file_meta_data_4; //!< meta data specific to file type 4
739} __attribute__((packed));
740
741/** @struct pldm_file_ack_with_meta_data_resp
742 *
743 * Structure representing FileAckWithMetadata response
744 */
745struct pldm_file_ack_with_meta_data_resp {
746 uint8_t completion_code; //!< Completion code
747} __attribute__((packed));
748
749/** @brief Encode FileAckWithMetadata request data
750 *
751 * @param[in] instance_id - Message's instance id
752 * @param[in] file_type - Type of the file
753 * @param[in] file_handle - A handle to the file
754 * @param[in] file_status - Status of file processing
755 * @param[in] file_meta_data_1 - meta data specific to file type 1
756 * @param[in] file_meta_data_2 - meta data specific to file type 2
757 * @param[in] file_meta_data_3 - meta data specific to file type 3
758 * @param[in] file_meta_data_4 - Meta data specific to file type 4
759 * @param[out] msg - Message will be written to this
760 * @return pldm_completion_codes
761 */
762int encode_file_ack_with_meta_data_req(
763 uint8_t instance_id, uint16_t file_type, uint32_t file_handle,
764 uint8_t file_status, uint32_t file_meta_data_1, uint32_t file_meta_data_2,
765 uint32_t file_meta_data_3, uint32_t file_meta_data_4, struct pldm_msg *msg);
766
767/** @brief Decode FileAckWithMetadata command response data
768 *
769 * @param[in] msg - pointer to PLDM response message
770 * @param[in] payload_length - Length of response payload
771 * @param[out] completion_code - PLDM completion code
772 * @return pldm_completion_codes
773 */
774int decode_file_ack_with_meta_data_resp(const struct pldm_msg *msg,
775 size_t payload_length,
776 uint8_t *completion_code);
777
778/** @brief Decode FileAckWithMetadata request data
779 *
780 * @param[in] msg - Pointer to PLDM request message
781 * @param[in] payload_length - Length of request payload
782 * @param[out] file_type - Type of the file
783 * @param[out] file_handle - A handle to the file
784 * @param[out] file_status - Status of file processing
785 * @param[out] file_meta_data_1 - meta data specific to file type 1
786 * @param[out] file_meta_data_2 - meta data specific to file type 2
787 * @param[out] file_meta_data_3 - meta data specific to file type 3
788 * @param[out] file_meta_data_4 - Meta data specific to file type 4
789 * @return pldm_completion_codes
790 */
791int decode_file_ack_with_meta_data_req(
792 const struct pldm_msg *msg, size_t payload_length, uint16_t *file_type,
793 uint32_t *file_handle, uint8_t *file_status, uint32_t *file_meta_data_1,
794 uint32_t *file_meta_data_2, uint32_t *file_meta_data_3,
795 uint32_t *file_meta_data_4);
796
797/** @brief Create a PLDM response message for FileAckWithMetadata
798 *
799 * @param[in] instance_id - Message's instance id
800 * @param[in] completion_code - PLDM completion code
801 * @param[in,out] msg - Message will be written to this
802 * @return pldm_completion_codes
803 */
804int encode_file_ack_with_meta_data_resp(uint8_t instance_id,
805 uint8_t completion_code,
806 struct pldm_msg *msg);
807
Jinu Joy Thomas7f57f442019-06-13 20:38:49 +0530808#ifdef __cplusplus
809}
810#endif
811
812#endif /* FILEIO_H */