blob: 065e53e35f4b41f293f2019f117320903006d582 [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"
13
14/* Response lengths are inclusive of completion code */
15#define PLDM_GET_DATE_TIME_RESP_BYTES 8
16
Sampa Misrab37be312019-07-03 02:26:41 -050017#define PLDM_GET_BIOS_TABLE_REQ_BYTES 6
18#define PLDM_GET_BIOS_TABLE_MIN_RESP_BYTES 6
John Wang4d844792019-08-15 15:51:40 +080019#define PLDM_SET_BIOS_ATTR_CURR_VAL_MIN_REQ_BYTES 5
20#define PLDM_SET_BIOS_ATTR_CURR_VAL_RESP_BYTES 5
Zahed Hossaind69af0b2019-07-30 01:33:31 -050021#define PLDM_GET_BIOS_ATTR_CURR_VAL_BY_HANDLE_REQ_BYTES 7
John Wang8721ed62019-12-05 14:44:43 +080022#define PLDM_GET_BIOS_ATTR_CURR_VAL_BY_HANDLE_MIN_RESP_BYTES 6
Sampa Misrab37be312019-07-03 02:26:41 -050023
24enum pldm_bios_completion_codes {
25 PLDM_BIOS_TABLE_UNAVAILABLE = 0x83,
26 PLDM_INVALID_BIOS_TABLE_DATA_INTEGRITY_CHECK = 0x84,
27 PLDM_INVALID_BIOS_TABLE_TYPE = 0x85,
John Wang8721ed62019-12-05 14:44:43 +080028 PLDM_INVALID_BIOS_ATTR_HANDLE = 0x88,
Sampa Misrab37be312019-07-03 02:26:41 -050029};
30enum pldm_bios_commands {
31 PLDM_GET_BIOS_TABLE = 0x01,
John Wang4d844792019-08-15 15:51:40 +080032 PLDM_SET_BIOS_ATTRIBUTE_CURRENT_VALUE = 0x07,
Zahed Hossaind69af0b2019-07-30 01:33:31 -050033 PLDM_GET_BIOS_ATTRIBUTE_CURRENT_VALUE_BY_HANDLE = 0x08,
34 PLDM_GET_DATE_TIME = 0x0c,
Xiaochao Ma39ae2a92019-11-12 20:30:34 +080035 PLDM_SET_DATE_TIME = 0x0d,
Sampa Misrab37be312019-07-03 02:26:41 -050036};
Sampa Misra032bd502019-03-06 05:03:22 -060037
Deepak Kodihallicb7f2d42019-06-19 13:25:31 +053038enum pldm_bios_table_types {
39 PLDM_BIOS_STRING_TABLE,
40 PLDM_BIOS_ATTR_TABLE,
41 PLDM_BIOS_ATTR_VAL_TABLE,
42};
43
44struct pldm_bios_string_table_entry {
45 uint16_t string_handle;
46 uint16_t string_length;
47 char name[1];
48} __attribute__((packed));
49
50struct pldm_bios_attr_table_entry {
51 uint16_t attr_handle;
52 uint8_t attr_type;
53 uint16_t string_handle;
54 uint8_t metadata[1];
55} __attribute__((packed));
56
57struct pldm_bios_enum_attr {
58 uint8_t num_possible_values;
59 uint16_t indices[1];
60} __attribute__((packed));
61
62struct pldm_bios_attr_val_table_entry {
63 uint16_t attr_handle;
64 uint8_t attr_type;
65 uint8_t value[1];
66} __attribute__((packed));
67
Sampa Misrab37be312019-07-03 02:26:41 -050068enum pldm_bios_attribute_type {
69 PLDM_BIOS_ENUMERATION = 0x0,
70 PLDM_BIOS_STRING = 0x1,
71 PLDM_BIOS_PASSWORD = 0x2,
72 PLDM_BIOS_INTEGER = 0x3,
73 PLDM_BIOS_ENUMERATION_READ_ONLY = 0x80,
74 PLDM_BIOS_STRING_READ_ONLY = 0x81,
75 PLDM_BIOS_PASSWORD_READ_ONLY = 0x82,
76 PLDM_BIOS_INTEGER_READ_ONLY = 0x83,
77};
78
79/** @struct pldm_get_bios_table_req
80 *
81 * structure representing GetBIOSTable request packet
82 */
83struct pldm_get_bios_table_req {
84 uint32_t transfer_handle;
85 uint8_t transfer_op_flag;
86 uint8_t table_type;
87} __attribute__((packed));
88
89/** @struct pldm_get_bios_table_resp
90 *
91 * structure representing GetBIOSTable response packet
92 */
93struct pldm_get_bios_table_resp {
94 uint8_t completion_code;
95 uint32_t next_transfer_handle;
96 uint8_t transfer_flag;
97 uint8_t table_data[1];
98} __attribute__((packed));
99
Priyanga5dcd1802019-06-10 01:50:39 -0500100/** @struct pldm_get_date_time_resp
101 *
102 * Structure representing PLDM get date time response
103 */
104struct pldm_get_date_time_resp {
105 uint8_t completion_code; //!< completion code
106 uint8_t seconds; //!< Seconds in BCD format
107 uint8_t minutes; //!< Minutes in BCD format
108 uint8_t hours; //!< Hours in BCD format
109 uint8_t day; //!< Day of the month in BCD format
110 uint8_t month; //!< Month in BCD format
111 uint16_t year; //!< Year in BCD format
112} __attribute__((packed));
113
Xiaochao Ma39ae2a92019-11-12 20:30:34 +0800114/** @struct pldm_set_date_time_req
115 *
116 * structure representing SetDateTime request packet
117 *
118 */
119struct pldm_set_date_time_req {
120 uint8_t seconds; //!< Seconds in BCD format
121 uint8_t minutes; //!< Minutes in BCD format
122 uint8_t hours; //!< Hours in BCD format
123 uint8_t day; //!< Day of the month in BCD format
124 uint8_t month; //!< Month in BCD format
125 uint16_t year; //!< Year in BCD format
126} __attribute__((packed));
127
128/** @struct pldm_only_cc_resp
129 *
130 * Structure representing PLDM responses only have completion code
131 */
132struct pldm_only_cc_resp {
133 uint8_t completion_code;
134} __attribute__((packed));
135
Zahed Hossaind69af0b2019-07-30 01:33:31 -0500136/** @struct pldm_get_bios_attribute_current_value_by_handle_req
137 *
138 * structure representing GetBIOSAttributeCurrentValueByHandle request packet
139 */
140struct pldm_get_bios_attribute_current_value_by_handle_req {
141 uint32_t transfer_handle;
142 uint8_t transfer_op_flag;
143 uint16_t attribute_handle;
144} __attribute__((packed));
145
146/** @struct pldm_get_bios_attribute_current_value_by_handle_resp
147 *
148 * structure representing GetBIOSAttributeCurrentValueByHandle response
149 */
150struct pldm_get_bios_attribute_current_value_by_handle_resp {
151 uint8_t completion_code;
152 uint32_t next_transfer_handle;
153 uint8_t transfer_flag;
154 uint8_t attribute_data[1];
155} __attribute__((packed));
156
John Wang4d844792019-08-15 15:51:40 +0800157/** @struct pldm_set_bios_attribute_current_value_req
158 *
159 * structure representing SetBiosAttributeCurrentValue request packet
160 *
161 */
162struct pldm_set_bios_attribute_current_value_req {
163 uint32_t transfer_handle;
164 uint8_t transfer_flag;
165 uint8_t attribute_data[1];
166} __attribute__((packed));
167
168/** @struct pldm_set_bios_attribute_current_value_resp
169 *
170 * structure representing SetBiosCurrentValue response packet
171 *
172 */
173struct pldm_set_bios_attribute_current_value_resp {
174 uint8_t completion_code;
175 uint32_t next_transfer_handle;
176} __attribute__((packed));
177
Sampa Misra032bd502019-03-06 05:03:22 -0600178/* Requester */
179
180/* GetDateTime */
181
182/** @brief Create a PLDM request message for GetDateTime
183 *
184 * @param[in] instance_id - Message's instance id
185 * @param[out] msg - Message will be written to this
186 * @return pldm_completion_codes
187 * @note Caller is responsible for memory alloc and dealloc of param
188 * 'msg.body.payload'
189 */
190
191int encode_get_date_time_req(uint8_t instance_id, struct pldm_msg *msg);
192
193/** @brief Decode a GetDateTime response message
194 *
George Liu684a7162019-12-06 15:10:52 +0800195 * Note:
196 * * If the return value is not PLDM_SUCCESS, it represents a
197 * transport layer error.
198 * * If the completion_code value is not PLDM_SUCCESS, it represents a
199 * protocol layer error and all the out-parameters are invalid.
200 *
Zahed Hossain223a73d2019-07-04 12:46:18 -0500201 * @param[in] msg - Response message
vkaverapa6575b82019-04-03 05:33:52 -0500202 * @param[in] payload_length - Length of response message payload
Sampa Misra032bd502019-03-06 05:03:22 -0600203 * @param[out] completion_code - Pointer to response msg's PLDM completion code
204 * @param[out] seconds - Seconds in BCD format
205 * @param[out] minutes - minutes in BCD format
206 * @param[out] hours - hours in BCD format
207 * @param[out] day - day of month in BCD format
208 * @param[out] month - number of month in BCD format
209 * @param[out] year - year in BCD format
210 * @return pldm_completion_codes
211 */
Zahed Hossain223a73d2019-07-04 12:46:18 -0500212int decode_get_date_time_resp(const struct pldm_msg *msg, size_t payload_length,
Sampa Misra032bd502019-03-06 05:03:22 -0600213 uint8_t *completion_code, uint8_t *seconds,
214 uint8_t *minutes, uint8_t *hours, uint8_t *day,
215 uint8_t *month, uint16_t *year);
216
John Wang4d844792019-08-15 15:51:40 +0800217/* SetBiosAttributeCurrentValue */
218
219/** @brief Create a PLDM request message for SetBiosAttributeCurrentValue
220 *
221 * @param[in] instance_id - Message's instance id
222 * @param[in] transfer_handle - Handle to identify a BIOS table transfer
223 * @param[in] transfer_flag - Flag to indicate what part of the transfer
224 * this request represents
225 * @param[in] attribute_data - Contains current value of attribute
226 * @param[in] attribute_length - Length of attribute
227 * @param[out] msg - Message will be written to this
228 * @param[in] payload_length - Length of message payload
229 * @return pldm_completion_codes
230 * @note Caller is responsible for memory alloc and dealloc of params
231 * 'msg.payload'
232 */
233int encode_set_bios_attribute_current_value_req(
234 uint8_t instance_id, uint32_t transfer_handle, uint8_t transfer_flag,
235 const uint8_t *attribute_data, size_t attribute_length,
236 struct pldm_msg *msg, size_t payload_length);
237
238/** @brief Decode a SetBiosAttributeCurrentValue response message
239 *
George Liu684a7162019-12-06 15:10:52 +0800240 * Note:
241 * * If the return value is not PLDM_SUCCESS, it represents a
242 * transport layer error.
243 * * If the completion_code value is not PLDM_SUCCESS, it represents a
244 * protocol layer error and all the out-parameters are invalid.
245 *
John Wang4d844792019-08-15 15:51:40 +0800246 * @param[in] msg - Response message
247 * @param[in] payload_length - Length of response message payload
248 * @param[out] completion_code - Pointer to response msg's PLDM completion code
249 * @param[out] next_transfer_handle - Pointer to a handle that identify the
George Liu684a7162019-12-06 15:10:52 +0800250 * next portion of the transfer
John Wang4d844792019-08-15 15:51:40 +0800251 * @return pldm_completion_codes
252 */
253int decode_set_bios_attribute_current_value_resp(
254 const struct pldm_msg *msg, size_t payload_length, uint8_t *completion_code,
255 uint32_t *next_transfer_handle);
256
Sampa Misra032bd502019-03-06 05:03:22 -0600257/* Responder */
258
259/* GetDateTime */
260
261/** @brief Create a PLDM response message for GetDateTime
262 *
263 * @param[in] instance_id - Message's instance id
264 * @param[in] completion_code - PLDM completion code
265 * @param[in] seconds - seconds in BCD format
266 * @param[in] minutes - minutes in BCD format
267 * @param[in] hours - hours in BCD format
268 * @param[in] day - day of the month in BCD format
269 * @param[in] month - number of month in BCD format
270 * @param[in] year - year in BCD format
271 * @param[out] msg - Message will be written to this
272 * @return pldm_completion_codes
273 * @note Caller is responsible for memory alloc and dealloc of param
274 * 'msg.body.payload'
275 */
276
277int encode_get_date_time_resp(uint8_t instance_id, uint8_t completion_code,
278 uint8_t seconds, uint8_t minutes, uint8_t hours,
279 uint8_t day, uint8_t month, uint16_t year,
280 struct pldm_msg *msg);
281
Sampa Misrab37be312019-07-03 02:26:41 -0500282/* GetBIOSTable */
283
284/** @brief Create a PLDM response message for GetBIOSTable
285 *
286 * @param[in] instance_id - Message's instance id
287 * @param[in] completion_code - PLDM completion code
288 * @param[in] next_transfer_handle - handle to identify the next portion of the
289 * transfer
290 * @param[in] transfer_flag - To indicate what part of the transfer this
291 * response represents
292 * @param[in] table_data - BIOS Table type specific data
293 * @param[in] payload_length - Length of payload message
294 * @param[out] msg - Message will be written to this
295 * @return pldm_completion_codes
296 */
297int encode_get_bios_table_resp(uint8_t instance_id, uint8_t completion_code,
298 uint32_t next_transfer_handle,
299 uint8_t transfer_flag, uint8_t *table_data,
300 size_t payload_length, struct pldm_msg *msg);
301
Sridevi Rameshd3d5fa82019-10-29 11:45:16 -0500302/** @brief Encode GetBIOSTable request packet
303 *
304 * @param[in] instance_id - Message's instance id
305 * @param[in] transfer_handle - Handle to identify a BIOS table transfer
306 * @param[in] transfer_op_flag - Flag to indicate the start of a multipart
307 * transfer
308 * @param[in] table_type - BIOS table type
309 * @param[out] msg - Message will be written to this
310 * @return pldm_completion_codes
311 */
312int encode_get_bios_table_req(uint8_t instance_id, uint32_t transfer_handle,
313 uint8_t transfer_op_flag, uint8_t table_type,
314 struct pldm_msg *msg);
315
Sampa Misrab37be312019-07-03 02:26:41 -0500316/** @brief Decode GetBIOSTable request packet
317 *
318 * @param[in] msg - Request message
319 * @param[in] payload_length - Length of request message payload
320 * @param[out] transfer_handle - Handle to identify a BIOS table transfer
321 * @param[out] transfer_op_flag - Flag to indicate the start of a multipart
322 * transfer
323 * @param[out] table_type - BIOS table type
324 * @return pldm_completion_codes
325 */
326int decode_get_bios_table_req(const struct pldm_msg *msg, size_t payload_length,
327 uint32_t *transfer_handle,
328 uint8_t *transfer_op_flag, uint8_t *table_type);
329
Sridevi Ramesh08efc7b2019-12-05 05:39:46 -0600330/** @brief Decode GetBIOSTable response packet
331 *
332 * @param[in] msg - Response message
333 * @param[in] payload_length - Length of response message payload
334 * @param[in] completion_code - PLDM completion code
335 * @param[in] next_transfer_handle - handle to identify the next portion of the
336 * transfer
337 * @param[in] transfer_flag - To indicate what part of the transfer this
338 * response represents
339 * @param[out] bios_table_offset - Offset where bios table data should be read
340 * in pldm msg
341 * @return pldm_completion_codes
342 */
343int decode_get_bios_table_resp(const struct pldm_msg *msg,
344 size_t payload_length, uint8_t *completion_code,
345 uint32_t *next_transfer_handle,
346 uint8_t *transfer_flag,
347 size_t *bios_table_offset);
348
Zahed Hossaind69af0b2019-07-30 01:33:31 -0500349/* GetBIOSAttributeCurrentValueByHandle */
350
351/** @brief Decode GetBIOSAttributeCurrentValueByHandle request packet
352 *
353 * @param[in] msg - Request message
354 * @param[in] payload_length - Length of request message payload
355 * @param[out] transfer_handle - Handle to identify a BIOS table transfer
356 * @param[out] transfer_op_flag - Flag to indicate the start of a multipart
357 * transfer
358 * @param[out] attribute_handle - Handle to identify the BIOS attribute
359 * @return pldm_completion_codes
360 */
361int decode_get_bios_attribute_current_value_by_handle_req(
362 const struct pldm_msg *msg, size_t payload_length,
363 uint32_t *transfer_handle, uint8_t *transfer_op_flag,
364 uint16_t *attribute_handle);
365
366/** @brief Create a PLDM response message for
367 * GetBIOSAttributeCurrentValueByHandle
368 *
369 * @param[in] instance_id - Message's instance id
370 * @param[in] completion_code - PLDM completion code
371 * @param[in] next_transfer_handle - handle to identify the next portion of the
372 * transfer
373 * @param[in] transfer_flag - To indicate what part of the transfer this
374 * response represents
375 * @param[in] attribute_data - contains current value of attribute
376 * @param[in] attribute_length - Length of attribute
377 * @param[out] msg - Message will be written to this
378 * @return pldm_completion_codes
379 */
380int encode_get_bios_current_value_by_handle_resp(
381 uint8_t instance_id, uint8_t completion_code, uint32_t next_transfer_handle,
382 uint8_t transfer_flag, const uint8_t *attribute_data,
383 size_t attribute_length, struct pldm_msg *msg);
384
John Wang4d844792019-08-15 15:51:40 +0800385/* SetBiosAttributeCurrentValue */
386
387/** @brief Decode SetBIOSAttributeCurrentValue request packet
388 *
389 * @param[in] msg - Request message
390 * @param[in] payload_length - Length of request message payload
391 * @param[out] transfer_handle - Handle to identify a BIOS table transfer
392 * @param[out] transfer_flag - Flag to indicate what part of the transfer
393 * this request represents
394 * @param[out] attribute_data - Contains current value of attribute
395 * @param[out] attribute_length - Pointer to length of attribute
396 * @return pldm_completion_codes
397 */
398int decode_set_bios_attribute_current_value_req(const struct pldm_msg *msg,
399 size_t payload_length,
400 uint32_t *transfer_handle,
401 uint8_t *transfer_flag,
402 uint8_t *attribute_data,
403 size_t *attribute_length);
404
405/** @brief Create a PLDM response message for SetBiosAttributeCurrentValue
406 *
407 * @param[in] instance_id - Message's instance id
408 * @param[in] completion_code - PLDM completion code
409 * @param[in] next_transfer_handle - handle to identify the next portion of the
410 * @param[out] msg - Message will be written to this
411 */
412int encode_set_bios_attribute_current_value_resp(uint8_t instance_id,
413 uint8_t completion_code,
414 uint32_t next_transfer_handle,
415 struct pldm_msg *msg);
416
Xiaochao Ma39ae2a92019-11-12 20:30:34 +0800417/** @brief Create a PLDM request message for SetDateTime
418 *
419 * @param[in] instance_id - Message's instance id
Xiaochao Ma501a6fd2019-12-17 14:44:57 +0800420 * @param[in] seconds - Seconds in decimal format. Value range 0~59
421 * @param[in] minutes - minutes in decimal format. Value range 0~59
422 * @param[in] hours - hours in decimal format. Value range 0~23
423 * @param[in] day - day of month in decimal format. Value range 1~31
424 * @param[in] month - number of month in decimal format. Value range 1~12
425 * @param[in] year - year in decimal format. Value range 1970~
Xiaochao Ma39ae2a92019-11-12 20:30:34 +0800426 * @param[out] msg - Message will be written to this
427 * @param[in] payload_length - Length of request message payload
428 * @return pldm_completion_codes
429 * @note Caller is responsible for memory alloc and dealloc of param
430 * 'msg.body.payload'
431 */
432int encode_set_date_time_req(uint8_t instance_id, uint8_t seconds,
433 uint8_t minutes, uint8_t hours, uint8_t day,
434 uint8_t month, uint16_t year, struct pldm_msg *msg,
435 size_t payload_length);
436
437/** @brief Decode a SetDateTime request message
438 *
439 * @param[in] msg - Response message
440 * @param[in] payload_length - Length of request message payload
441 * @param[out] seconds - seconds in BCD format
442 * @param[out] minutes - minutes in BCD format
443 * @param[out] hours - hours in BCD format
444 * @param[out] day - day of the month in BCD format
445 * @param[out] month - number of month in BCD format
446 * @param[out] year - year in BCD format
447 * @return pldm_completion_codes
448 */
449int decode_set_date_time_req(const struct pldm_msg *msg, size_t payload_length,
450 uint8_t *seconds, uint8_t *minutes, uint8_t *hours,
451 uint8_t *day, uint8_t *month, uint16_t *year);
452
453/** @brief Create a PLDM response message for SetDateTime
454 *
455 * @param[in] instance_id - Message's instance id
456 * @param[in] completion_code - PLDM completion code
457 * @param[out] msg - Message will be written to this
458 * @param[in] payload_length - Length of response message payload
459 * @return pldm_completion_codes
460 * @note Caller is responsible for memory alloc and dealloc of param
461 * 'msg.body.payload'
462 */
463int encode_set_date_time_resp(uint8_t instance_id, uint8_t completion_code,
464 struct pldm_msg *msg, size_t payload_length);
465
466/** @brief Decode a SetDateTime response message
467 *
George Liu684a7162019-12-06 15:10:52 +0800468 * Note:
469 * * If the return value is not PLDM_SUCCESS, it represents a
470 * transport layer error.
471 * * If the completion_code value is not PLDM_SUCCESS, it represents a
472 * protocol layer error and all the out-parameters are invalid.
473 *
Xiaochao Ma39ae2a92019-11-12 20:30:34 +0800474 * @param[in] msg - Response message
475 * @param[in] payload_length - Length of response message payload
476 * @param[out] completion_code - Pointer to response msg's PLDM completion code
477 * @return pldm_completion_codes
478 */
479int decode_set_date_time_resp(const struct pldm_msg *msg, size_t payload_length,
480 uint8_t *completion_code);
481
Sampa Misra032bd502019-03-06 05:03:22 -0600482#ifdef __cplusplus
483}
484#endif
485
486#endif /* BIOS_H */