blob: a23a671bca10d809dac5474b55913392d040a6dd [file] [log] [blame]
Sampa Misra032bd502019-03-06 05:03:22 -06001#ifndef BIOS_H
2#define BIOS_H
3
4#ifdef __cplusplus
5extern "C" {
6#endif
7
8#include <asm/byteorder.h>
9#include <stddef.h>
10#include <stdint.h>
11
12#include "base.h"
John Wang08c05952019-12-20 15:40:39 +080013#include "utils.h"
Sampa Misra032bd502019-03-06 05:03:22 -060014
15/* Response lengths are inclusive of completion code */
16#define PLDM_GET_DATE_TIME_RESP_BYTES 8
17
Sampa Misrab37be312019-07-03 02:26:41 -050018#define PLDM_GET_BIOS_TABLE_REQ_BYTES 6
19#define PLDM_GET_BIOS_TABLE_MIN_RESP_BYTES 6
George Liu3eabde62020-07-15 12:32:33 +080020#define PLDM_SET_BIOS_TABLE_MIN_REQ_BYTES 6
21#define PLDM_SET_BIOS_TABLE_RESP_BYTES 5
John Wang4d844792019-08-15 15:51:40 +080022#define PLDM_SET_BIOS_ATTR_CURR_VAL_MIN_REQ_BYTES 5
23#define PLDM_SET_BIOS_ATTR_CURR_VAL_RESP_BYTES 5
Zahed Hossaind69af0b2019-07-30 01:33:31 -050024#define PLDM_GET_BIOS_ATTR_CURR_VAL_BY_HANDLE_REQ_BYTES 7
John Wang8721ed62019-12-05 14:44:43 +080025#define PLDM_GET_BIOS_ATTR_CURR_VAL_BY_HANDLE_MIN_RESP_BYTES 6
Sampa Misrab37be312019-07-03 02:26:41 -050026
27enum pldm_bios_completion_codes {
28 PLDM_BIOS_TABLE_UNAVAILABLE = 0x83,
29 PLDM_INVALID_BIOS_TABLE_DATA_INTEGRITY_CHECK = 0x84,
30 PLDM_INVALID_BIOS_TABLE_TYPE = 0x85,
John Wang8721ed62019-12-05 14:44:43 +080031 PLDM_INVALID_BIOS_ATTR_HANDLE = 0x88,
Sampa Misrab37be312019-07-03 02:26:41 -050032};
33enum pldm_bios_commands {
34 PLDM_GET_BIOS_TABLE = 0x01,
George Liu3eabde62020-07-15 12:32:33 +080035 PLDM_SET_BIOS_TABLE = 0x02,
John Wang4d844792019-08-15 15:51:40 +080036 PLDM_SET_BIOS_ATTRIBUTE_CURRENT_VALUE = 0x07,
Zahed Hossaind69af0b2019-07-30 01:33:31 -050037 PLDM_GET_BIOS_ATTRIBUTE_CURRENT_VALUE_BY_HANDLE = 0x08,
38 PLDM_GET_DATE_TIME = 0x0c,
Xiaochao Ma39ae2a92019-11-12 20:30:34 +080039 PLDM_SET_DATE_TIME = 0x0d,
Sampa Misrab37be312019-07-03 02:26:41 -050040};
Sampa Misra032bd502019-03-06 05:03:22 -060041
Deepak Kodihallicb7f2d42019-06-19 13:25:31 +053042enum pldm_bios_table_types {
43 PLDM_BIOS_STRING_TABLE,
44 PLDM_BIOS_ATTR_TABLE,
45 PLDM_BIOS_ATTR_VAL_TABLE,
46};
47
48struct pldm_bios_string_table_entry {
49 uint16_t string_handle;
50 uint16_t string_length;
51 char name[1];
52} __attribute__((packed));
53
54struct pldm_bios_attr_table_entry {
55 uint16_t attr_handle;
56 uint8_t attr_type;
57 uint16_t string_handle;
58 uint8_t metadata[1];
59} __attribute__((packed));
60
61struct pldm_bios_enum_attr {
62 uint8_t num_possible_values;
63 uint16_t indices[1];
64} __attribute__((packed));
65
66struct pldm_bios_attr_val_table_entry {
67 uint16_t attr_handle;
68 uint8_t attr_type;
69 uint8_t value[1];
70} __attribute__((packed));
71
Sampa Misrab37be312019-07-03 02:26:41 -050072enum pldm_bios_attribute_type {
73 PLDM_BIOS_ENUMERATION = 0x0,
74 PLDM_BIOS_STRING = 0x1,
75 PLDM_BIOS_PASSWORD = 0x2,
76 PLDM_BIOS_INTEGER = 0x3,
77 PLDM_BIOS_ENUMERATION_READ_ONLY = 0x80,
78 PLDM_BIOS_STRING_READ_ONLY = 0x81,
79 PLDM_BIOS_PASSWORD_READ_ONLY = 0x82,
80 PLDM_BIOS_INTEGER_READ_ONLY = 0x83,
81};
82
83/** @struct pldm_get_bios_table_req
84 *
85 * structure representing GetBIOSTable request packet
86 */
87struct pldm_get_bios_table_req {
88 uint32_t transfer_handle;
89 uint8_t transfer_op_flag;
90 uint8_t table_type;
91} __attribute__((packed));
92
93/** @struct pldm_get_bios_table_resp
94 *
95 * structure representing GetBIOSTable response packet
96 */
97struct pldm_get_bios_table_resp {
98 uint8_t completion_code;
99 uint32_t next_transfer_handle;
100 uint8_t transfer_flag;
101 uint8_t table_data[1];
102} __attribute__((packed));
103
Priyanga5dcd1802019-06-10 01:50:39 -0500104/** @struct pldm_get_date_time_resp
105 *
106 * Structure representing PLDM get date time response
107 */
108struct pldm_get_date_time_resp {
109 uint8_t completion_code; //!< completion code
110 uint8_t seconds; //!< Seconds in BCD format
111 uint8_t minutes; //!< Minutes in BCD format
112 uint8_t hours; //!< Hours in BCD format
113 uint8_t day; //!< Day of the month in BCD format
114 uint8_t month; //!< Month in BCD format
115 uint16_t year; //!< Year in BCD format
116} __attribute__((packed));
117
Xiaochao Ma39ae2a92019-11-12 20:30:34 +0800118/** @struct pldm_set_date_time_req
119 *
120 * structure representing SetDateTime request packet
121 *
122 */
123struct pldm_set_date_time_req {
124 uint8_t seconds; //!< Seconds in BCD format
125 uint8_t minutes; //!< Minutes in BCD format
Deepak Kodihalli826c9d42020-05-26 01:58:06 -0500126 uint8_t hours; //!< Hours in BCD format
127 uint8_t day; //!< Day of the month in BCD format
128 uint8_t month; //!< Month in BCD format
129 uint16_t year; //!< Year in BCD format
Xiaochao Ma39ae2a92019-11-12 20:30:34 +0800130} __attribute__((packed));
131
132/** @struct pldm_only_cc_resp
133 *
134 * Structure representing PLDM responses only have completion code
135 */
136struct pldm_only_cc_resp {
137 uint8_t completion_code;
138} __attribute__((packed));
139
Zahed Hossaind69af0b2019-07-30 01:33:31 -0500140/** @struct pldm_get_bios_attribute_current_value_by_handle_req
141 *
142 * structure representing GetBIOSAttributeCurrentValueByHandle request packet
143 */
144struct pldm_get_bios_attribute_current_value_by_handle_req {
145 uint32_t transfer_handle;
146 uint8_t transfer_op_flag;
147 uint16_t attribute_handle;
148} __attribute__((packed));
149
150/** @struct pldm_get_bios_attribute_current_value_by_handle_resp
151 *
152 * structure representing GetBIOSAttributeCurrentValueByHandle response
153 */
154struct pldm_get_bios_attribute_current_value_by_handle_resp {
155 uint8_t completion_code;
156 uint32_t next_transfer_handle;
157 uint8_t transfer_flag;
158 uint8_t attribute_data[1];
159} __attribute__((packed));
160
John Wang4d844792019-08-15 15:51:40 +0800161/** @struct pldm_set_bios_attribute_current_value_req
162 *
163 * structure representing SetBiosAttributeCurrentValue request packet
164 *
165 */
166struct pldm_set_bios_attribute_current_value_req {
167 uint32_t transfer_handle;
168 uint8_t transfer_flag;
169 uint8_t attribute_data[1];
170} __attribute__((packed));
171
172/** @struct pldm_set_bios_attribute_current_value_resp
173 *
174 * structure representing SetBiosCurrentValue response packet
175 *
176 */
177struct pldm_set_bios_attribute_current_value_resp {
178 uint8_t completion_code;
179 uint32_t next_transfer_handle;
180} __attribute__((packed));
181
George Liu3eabde62020-07-15 12:32:33 +0800182/** @struct pldm_set_bios_table_req
183 *
184 * structure representing SetBIOSTable request packet
185 *
186 */
187struct pldm_set_bios_table_req {
188 uint32_t transfer_handle;
189 uint8_t transfer_flag;
190 uint8_t table_type;
191 uint8_t table_data[1];
192} __attribute__((packed));
193
194/** @struct pldm_set_bios_table_resp
195 *
196 * structure representing SetBIOSTable response packet
197 *
198 */
199struct pldm_set_bios_table_resp {
200 uint8_t completion_code;
201 uint32_t next_transfer_handle;
202} __attribute__((packed));
203
Sampa Misra032bd502019-03-06 05:03:22 -0600204/* Requester */
205
206/* GetDateTime */
207
208/** @brief Create a PLDM request message for GetDateTime
209 *
210 * @param[in] instance_id - Message's instance id
211 * @param[out] msg - Message will be written to this
212 * @return pldm_completion_codes
213 * @note Caller is responsible for memory alloc and dealloc of param
214 * 'msg.body.payload'
215 */
216
217int encode_get_date_time_req(uint8_t instance_id, struct pldm_msg *msg);
218
219/** @brief Decode a GetDateTime response message
220 *
George Liu684a7162019-12-06 15:10:52 +0800221 * Note:
222 * * If the return value is not PLDM_SUCCESS, it represents a
223 * transport layer error.
224 * * If the completion_code value is not PLDM_SUCCESS, it represents a
225 * protocol layer error and all the out-parameters are invalid.
226 *
Zahed Hossain223a73d2019-07-04 12:46:18 -0500227 * @param[in] msg - Response message
vkaverapa6575b82019-04-03 05:33:52 -0500228 * @param[in] payload_length - Length of response message payload
Sampa Misra032bd502019-03-06 05:03:22 -0600229 * @param[out] completion_code - Pointer to response msg's PLDM completion code
230 * @param[out] seconds - Seconds in BCD format
231 * @param[out] minutes - minutes in BCD format
232 * @param[out] hours - hours in BCD format
233 * @param[out] day - day of month in BCD format
234 * @param[out] month - number of month in BCD format
235 * @param[out] year - year in BCD format
236 * @return pldm_completion_codes
237 */
Zahed Hossain223a73d2019-07-04 12:46:18 -0500238int decode_get_date_time_resp(const struct pldm_msg *msg, size_t payload_length,
Sampa Misra032bd502019-03-06 05:03:22 -0600239 uint8_t *completion_code, uint8_t *seconds,
240 uint8_t *minutes, uint8_t *hours, uint8_t *day,
241 uint8_t *month, uint16_t *year);
242
John Wang4d844792019-08-15 15:51:40 +0800243/* SetBiosAttributeCurrentValue */
244
245/** @brief Create a PLDM request message for SetBiosAttributeCurrentValue
246 *
247 * @param[in] instance_id - Message's instance id
248 * @param[in] transfer_handle - Handle to identify a BIOS table transfer
249 * @param[in] transfer_flag - Flag to indicate what part of the transfer
250 * this request represents
251 * @param[in] attribute_data - Contains current value of attribute
252 * @param[in] attribute_length - Length of attribute
253 * @param[out] msg - Message will be written to this
254 * @param[in] payload_length - Length of message payload
255 * @return pldm_completion_codes
256 * @note Caller is responsible for memory alloc and dealloc of params
257 * 'msg.payload'
258 */
259int encode_set_bios_attribute_current_value_req(
260 uint8_t instance_id, uint32_t transfer_handle, uint8_t transfer_flag,
261 const uint8_t *attribute_data, size_t attribute_length,
262 struct pldm_msg *msg, size_t payload_length);
263
264/** @brief Decode a SetBiosAttributeCurrentValue response message
265 *
George Liu684a7162019-12-06 15:10:52 +0800266 * Note:
267 * * If the return value is not PLDM_SUCCESS, it represents a
268 * transport layer error.
269 * * If the completion_code value is not PLDM_SUCCESS, it represents a
270 * protocol layer error and all the out-parameters are invalid.
271 *
John Wang4d844792019-08-15 15:51:40 +0800272 * @param[in] msg - Response message
273 * @param[in] payload_length - Length of response message payload
274 * @param[out] completion_code - Pointer to response msg's PLDM completion code
275 * @param[out] next_transfer_handle - Pointer to a handle that identify the
George Liu684a7162019-12-06 15:10:52 +0800276 * next portion of the transfer
John Wang4d844792019-08-15 15:51:40 +0800277 * @return pldm_completion_codes
278 */
279int decode_set_bios_attribute_current_value_resp(
280 const struct pldm_msg *msg, size_t payload_length, uint8_t *completion_code,
281 uint32_t *next_transfer_handle);
282
George Liu3eabde62020-07-15 12:32:33 +0800283/* SetBIOSTable */
284
285/** @brief Create a PLDM request message for SetBIOSTable
286 *
287 * @param[in] instance_id - Message's instance id
288 * @param[in] transfer_handle - Handle to identify a BIOS table transfer
289 * @param[in] transfer_flag - Flag to indicate what part of the transfer
290 * this request represents
291 * @param[in] table_type - Indicates what table is being transferred
292 * {BIOSStringTable=0x0, BIOSAttributeTable=0x1,
293 * BIOSAttributeValueTable=0x2}
294 * @param[in] table_data - Contains data specific to the table type
295 * @param[in] table_length - Length of table data
296 * @param[out] msg - Message will be written to this
297 * @param[in] payload_length - Length of message payload
298 * @return pldm_completion_codes
299 * @note Caller is responsible for memory alloc and dealloc of params
300 * 'msg.payload'
301 */
302int encode_set_bios_table_req(uint8_t instance_id, uint32_t transfer_handle,
303 uint8_t transfer_flag, uint8_t table_type,
304 const uint8_t *table_data, size_t table_length,
305 struct pldm_msg *msg, size_t payload_length);
306
307/** @brief Decode a SetBIOSTable response message
308 *
309 * Note:
310 * * If the return value is not PLDM_SUCCESS, it represents a
311 * transport layer error.
312 * * If the completion_code value is not PLDM_SUCCESS, it represents a
313 * protocol layer error and all the out-parameters are invalid.
314 *
315 * @param[in] msg - Response message
316 * @param[in] payload_length - Length of response message payload
317 * @param[out] completion_code - Pointer to response msg's PLDM completion code
318 * @param[out] next_transfer_handle - Pointer to a handle that identify the
319 * next portion of the transfer
320 * @return pldm_completion_codes
321 */
322int decode_set_bios_table_resp(const struct pldm_msg *msg,
323 size_t payload_length, uint8_t *completion_code,
324 uint32_t *next_transfer_handle);
325
Sampa Misra032bd502019-03-06 05:03:22 -0600326/* Responder */
327
328/* GetDateTime */
329
330/** @brief Create a PLDM response message for GetDateTime
331 *
332 * @param[in] instance_id - Message's instance id
333 * @param[in] completion_code - PLDM completion code
334 * @param[in] seconds - seconds in BCD format
335 * @param[in] minutes - minutes in BCD format
336 * @param[in] hours - hours in BCD format
337 * @param[in] day - day of the month in BCD format
338 * @param[in] month - number of month in BCD format
339 * @param[in] year - year in BCD format
340 * @param[out] msg - Message will be written to this
341 * @return pldm_completion_codes
342 * @note Caller is responsible for memory alloc and dealloc of param
343 * 'msg.body.payload'
344 */
345
346int encode_get_date_time_resp(uint8_t instance_id, uint8_t completion_code,
347 uint8_t seconds, uint8_t minutes, uint8_t hours,
348 uint8_t day, uint8_t month, uint16_t year,
349 struct pldm_msg *msg);
350
Sampa Misrab37be312019-07-03 02:26:41 -0500351/* GetBIOSTable */
352
353/** @brief Create a PLDM response message for GetBIOSTable
354 *
355 * @param[in] instance_id - Message's instance id
356 * @param[in] completion_code - PLDM completion code
357 * @param[in] next_transfer_handle - handle to identify the next portion of the
358 * transfer
359 * @param[in] transfer_flag - To indicate what part of the transfer this
360 * response represents
361 * @param[in] table_data - BIOS Table type specific data
362 * @param[in] payload_length - Length of payload message
363 * @param[out] msg - Message will be written to this
364 * @return pldm_completion_codes
365 */
366int encode_get_bios_table_resp(uint8_t instance_id, uint8_t completion_code,
367 uint32_t next_transfer_handle,
368 uint8_t transfer_flag, uint8_t *table_data,
369 size_t payload_length, struct pldm_msg *msg);
370
Sridevi Rameshd3d5fa82019-10-29 11:45:16 -0500371/** @brief Encode GetBIOSTable request packet
372 *
373 * @param[in] instance_id - Message's instance id
374 * @param[in] transfer_handle - Handle to identify a BIOS table transfer
375 * @param[in] transfer_op_flag - Flag to indicate the start of a multipart
376 * transfer
377 * @param[in] table_type - BIOS table type
378 * @param[out] msg - Message will be written to this
379 * @return pldm_completion_codes
380 */
381int encode_get_bios_table_req(uint8_t instance_id, uint32_t transfer_handle,
382 uint8_t transfer_op_flag, uint8_t table_type,
383 struct pldm_msg *msg);
384
Sampa Misrab37be312019-07-03 02:26:41 -0500385/** @brief Decode GetBIOSTable request packet
386 *
387 * @param[in] msg - Request message
388 * @param[in] payload_length - Length of request message payload
389 * @param[out] transfer_handle - Handle to identify a BIOS table transfer
390 * @param[out] transfer_op_flag - Flag to indicate the start of a multipart
391 * transfer
392 * @param[out] table_type - BIOS table type
393 * @return pldm_completion_codes
394 */
395int decode_get_bios_table_req(const struct pldm_msg *msg, size_t payload_length,
396 uint32_t *transfer_handle,
397 uint8_t *transfer_op_flag, uint8_t *table_type);
398
Sridevi Ramesh08efc7b2019-12-05 05:39:46 -0600399/** @brief Decode GetBIOSTable response packet
400 *
401 * @param[in] msg - Response message
402 * @param[in] payload_length - Length of response message payload
403 * @param[in] completion_code - PLDM completion code
404 * @param[in] next_transfer_handle - handle to identify the next portion of the
405 * transfer
406 * @param[in] transfer_flag - To indicate what part of the transfer this
407 * response represents
408 * @param[out] bios_table_offset - Offset where bios table data should be read
409 * in pldm msg
410 * @return pldm_completion_codes
411 */
412int decode_get_bios_table_resp(const struct pldm_msg *msg,
413 size_t payload_length, uint8_t *completion_code,
414 uint32_t *next_transfer_handle,
415 uint8_t *transfer_flag,
416 size_t *bios_table_offset);
417
Zahed Hossaind69af0b2019-07-30 01:33:31 -0500418/* GetBIOSAttributeCurrentValueByHandle */
419
420/** @brief Decode GetBIOSAttributeCurrentValueByHandle request packet
421 *
Adair Lica37ccb2020-04-24 14:32:58 +0800422 * @param[in] instance_id - Message's instance id
423 * @param[in] transfer_handle - Handle to identify a BIOS attribute transfer
424 * @param[in] transfer_op_flag - Flag to indicate the start of a multipart
425 * transfer
426 * @param[in] attribute_handle - Handle to identify the BIOS attribute
427 * @param[out] msg - Message will be written to this
428 * @return pldm_completion_codes
429 */
430int encode_get_bios_attribute_current_value_by_handle_req(
431 uint8_t instance_id, uint32_t transfer_handle, uint8_t transfer_op_flag,
432 uint16_t attribute_handle, struct pldm_msg *msg);
433
434/** @brief Decode GetBIOSAttributeCurrentValueByHandle response packet
435 *
436 * @param[in] msg - Response message
437 * @param[in] payload_length - Length of response message payload
438 * @param[out] completion_code - PLDM completion code
439 * @param[out] next_transfer_handle - handle to identify the next portion of
440 * the transfer
441 * @param[out] transfer_flag - To indicate what part of the transfer this
442 * response represents
443 * @param[out] attribute_data - contains current value of attribute
444 * @return pldm_completion_codes
445 */
446int decode_get_bios_attribute_current_value_by_handle_resp(
447 const struct pldm_msg *msg, size_t payload_length, uint8_t *completion_code,
448 uint32_t *next_transfer_handle, uint8_t *transfer_flag,
449 struct variable_field *attribute_data);
450
451/** @brief Decode GetBIOSAttributeCurrentValueByHandle request packet
452 *
Zahed Hossaind69af0b2019-07-30 01:33:31 -0500453 * @param[in] msg - Request message
454 * @param[in] payload_length - Length of request message payload
455 * @param[out] transfer_handle - Handle to identify a BIOS table transfer
456 * @param[out] transfer_op_flag - Flag to indicate the start of a multipart
457 * transfer
458 * @param[out] attribute_handle - Handle to identify the BIOS attribute
459 * @return pldm_completion_codes
460 */
461int decode_get_bios_attribute_current_value_by_handle_req(
462 const struct pldm_msg *msg, size_t payload_length,
463 uint32_t *transfer_handle, uint8_t *transfer_op_flag,
464 uint16_t *attribute_handle);
465
466/** @brief Create a PLDM response message for
467 * GetBIOSAttributeCurrentValueByHandle
468 *
469 * @param[in] instance_id - Message's instance id
470 * @param[in] completion_code - PLDM completion code
471 * @param[in] next_transfer_handle - handle to identify the next portion of the
472 * transfer
473 * @param[in] transfer_flag - To indicate what part of the transfer this
474 * response represents
475 * @param[in] attribute_data - contains current value of attribute
476 * @param[in] attribute_length - Length of attribute
477 * @param[out] msg - Message will be written to this
478 * @return pldm_completion_codes
479 */
480int encode_get_bios_current_value_by_handle_resp(
481 uint8_t instance_id, uint8_t completion_code, uint32_t next_transfer_handle,
482 uint8_t transfer_flag, const uint8_t *attribute_data,
483 size_t attribute_length, struct pldm_msg *msg);
484
John Wang4d844792019-08-15 15:51:40 +0800485/* SetBiosAttributeCurrentValue */
486
487/** @brief Decode SetBIOSAttributeCurrentValue request packet
488 *
489 * @param[in] msg - Request message
490 * @param[in] payload_length - Length of request message payload
491 * @param[out] transfer_handle - Handle to identify a BIOS table transfer
492 * @param[out] transfer_flag - Flag to indicate what part of the transfer
John Wang08c05952019-12-20 15:40:39 +0800493 * this request represents
494 * @param[out] attribute - Struct variable_field, contains a pointer to the
495 * attribute field in the buffer of \p msg, \p msg must
496 * be valid when \p attribute is used.
John Wang4d844792019-08-15 15:51:40 +0800497 * @return pldm_completion_codes
498 */
John Wang08c05952019-12-20 15:40:39 +0800499int decode_set_bios_attribute_current_value_req(
500 const struct pldm_msg *msg, size_t payload_length,
501 uint32_t *transfer_handle, uint8_t *transfer_flag,
502 struct variable_field *attribute);
John Wang4d844792019-08-15 15:51:40 +0800503
504/** @brief Create a PLDM response message for SetBiosAttributeCurrentValue
505 *
506 * @param[in] instance_id - Message's instance id
507 * @param[in] completion_code - PLDM completion code
508 * @param[in] next_transfer_handle - handle to identify the next portion of the
509 * @param[out] msg - Message will be written to this
510 */
511int encode_set_bios_attribute_current_value_resp(uint8_t instance_id,
512 uint8_t completion_code,
513 uint32_t next_transfer_handle,
514 struct pldm_msg *msg);
515
Xiaochao Ma39ae2a92019-11-12 20:30:34 +0800516/** @brief Create a PLDM request message for SetDateTime
517 *
518 * @param[in] instance_id - Message's instance id
Xiaochao Ma501a6fd2019-12-17 14:44:57 +0800519 * @param[in] seconds - Seconds in decimal format. Value range 0~59
520 * @param[in] minutes - minutes in decimal format. Value range 0~59
521 * @param[in] hours - hours in decimal format. Value range 0~23
522 * @param[in] day - day of month in decimal format. Value range 1~31
523 * @param[in] month - number of month in decimal format. Value range 1~12
524 * @param[in] year - year in decimal format. Value range 1970~
Xiaochao Ma39ae2a92019-11-12 20:30:34 +0800525 * @param[out] msg - Message will be written to this
526 * @param[in] payload_length - Length of request message payload
527 * @return pldm_completion_codes
528 * @note Caller is responsible for memory alloc and dealloc of param
529 * 'msg.body.payload'
530 */
531int encode_set_date_time_req(uint8_t instance_id, uint8_t seconds,
532 uint8_t minutes, uint8_t hours, uint8_t day,
533 uint8_t month, uint16_t year, struct pldm_msg *msg,
534 size_t payload_length);
535
536/** @brief Decode a SetDateTime request message
537 *
538 * @param[in] msg - Response message
539 * @param[in] payload_length - Length of request message payload
540 * @param[out] seconds - seconds in BCD format
541 * @param[out] minutes - minutes in BCD format
542 * @param[out] hours - hours in BCD format
543 * @param[out] day - day of the month in BCD format
544 * @param[out] month - number of month in BCD format
545 * @param[out] year - year in BCD format
546 * @return pldm_completion_codes
547 */
548int decode_set_date_time_req(const struct pldm_msg *msg, size_t payload_length,
549 uint8_t *seconds, uint8_t *minutes, uint8_t *hours,
550 uint8_t *day, uint8_t *month, uint16_t *year);
551
552/** @brief Create a PLDM response message for SetDateTime
553 *
554 * @param[in] instance_id - Message's instance id
555 * @param[in] completion_code - PLDM completion code
556 * @param[out] msg - Message will be written to this
557 * @param[in] payload_length - Length of response message payload
558 * @return pldm_completion_codes
559 * @note Caller is responsible for memory alloc and dealloc of param
560 * 'msg.body.payload'
561 */
562int encode_set_date_time_resp(uint8_t instance_id, uint8_t completion_code,
563 struct pldm_msg *msg, size_t payload_length);
564
565/** @brief Decode a SetDateTime response message
566 *
George Liu684a7162019-12-06 15:10:52 +0800567 * Note:
568 * * If the return value is not PLDM_SUCCESS, it represents a
569 * transport layer error.
570 * * If the completion_code value is not PLDM_SUCCESS, it represents a
571 * protocol layer error and all the out-parameters are invalid.
572 *
Xiaochao Ma39ae2a92019-11-12 20:30:34 +0800573 * @param[in] msg - Response message
574 * @param[in] payload_length - Length of response message payload
575 * @param[out] completion_code - Pointer to response msg's PLDM completion code
576 * @return pldm_completion_codes
577 */
578int decode_set_date_time_resp(const struct pldm_msg *msg, size_t payload_length,
579 uint8_t *completion_code);
580
George Liub371f8d2020-07-15 14:13:17 +0800581/* SetBIOSTable */
582
583/** @brief Create a PLDM response message for SetBIOSTable
584 *
585 * @param[in] instance_id - Message's instance id
586 * @param[in] completion_code - PLDM completion code
587 * @param[in] next_transfer_handle - handle to identify the next portion of the
588 * transfer
589 * @param[out] msg - Message will be written to this
590 */
591int encode_set_bios_table_resp(uint8_t instance_id, uint8_t completion_code,
592 uint32_t next_transfer_handle,
593 struct pldm_msg *msg);
594
595/** @brief Decode SetBIOSTable request packet
596 *
597 * @param[in] msg - Request message
598 * @param[in] payload_length - Length of request message payload
599 * @param[out] transfer_handle - Handle to identify a BIOS table transfer
600 * @param[out] transfer_flag - Flag to indicate what part of the transfer
601 * this request represents
602 * @param[out] table_type - Indicates what table is being transferred
603 * {BIOSStringTable=0x0, BIOSAttributeTable=0x1,
604 * BIOSAttributeValueTable=0x2}
605 * @param[out] table - Struct variable_field, contains data specific to the
606 * table type and the length of table data.
607 * @return pldm_completion_codes
608 */
609int decode_set_bios_table_req(const struct pldm_msg *msg, size_t payload_length,
610 uint32_t *transfer_handle, uint8_t *transfer_flag,
611 uint8_t *table_type,
612 struct variable_field *table);
613
Sampa Misra032bd502019-03-06 05:03:22 -0600614#ifdef __cplusplus
615}
616#endif
617
618#endif /* BIOS_H */