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