blob: 83065768c2b4073c76e6f1f6f7584e4bc1be04b3 [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 *
Zahed Hossain223a73d2019-07-04 12:46:18 -0500195 * @param[in] msg - Response message
vkaverapa6575b82019-04-03 05:33:52 -0500196 * @param[in] payload_length - Length of response message payload
Sampa Misra032bd502019-03-06 05:03:22 -0600197 * @param[out] completion_code - Pointer to response msg's PLDM completion code
198 * @param[out] seconds - Seconds in BCD format
199 * @param[out] minutes - minutes in BCD format
200 * @param[out] hours - hours in BCD format
201 * @param[out] day - day of month in BCD format
202 * @param[out] month - number of month in BCD format
203 * @param[out] year - year in BCD format
204 * @return pldm_completion_codes
205 */
Zahed Hossain223a73d2019-07-04 12:46:18 -0500206int decode_get_date_time_resp(const struct pldm_msg *msg, size_t payload_length,
Sampa Misra032bd502019-03-06 05:03:22 -0600207 uint8_t *completion_code, uint8_t *seconds,
208 uint8_t *minutes, uint8_t *hours, uint8_t *day,
209 uint8_t *month, uint16_t *year);
210
John Wang4d844792019-08-15 15:51:40 +0800211/* SetBiosAttributeCurrentValue */
212
213/** @brief Create a PLDM request message for SetBiosAttributeCurrentValue
214 *
215 * @param[in] instance_id - Message's instance id
216 * @param[in] transfer_handle - Handle to identify a BIOS table transfer
217 * @param[in] transfer_flag - Flag to indicate what part of the transfer
218 * this request represents
219 * @param[in] attribute_data - Contains current value of attribute
220 * @param[in] attribute_length - Length of attribute
221 * @param[out] msg - Message will be written to this
222 * @param[in] payload_length - Length of message payload
223 * @return pldm_completion_codes
224 * @note Caller is responsible for memory alloc and dealloc of params
225 * 'msg.payload'
226 */
227int encode_set_bios_attribute_current_value_req(
228 uint8_t instance_id, uint32_t transfer_handle, uint8_t transfer_flag,
229 const uint8_t *attribute_data, size_t attribute_length,
230 struct pldm_msg *msg, size_t payload_length);
231
232/** @brief Decode a SetBiosAttributeCurrentValue response message
233 *
234 * @param[in] msg - Response message
235 * @param[in] payload_length - Length of response message payload
236 * @param[out] completion_code - Pointer to response msg's PLDM completion code
237 * @param[out] next_transfer_handle - Pointer to a handle that identify the
238 * next portion of the transfer
239 * @return pldm_completion_codes
240 */
241int decode_set_bios_attribute_current_value_resp(
242 const struct pldm_msg *msg, size_t payload_length, uint8_t *completion_code,
243 uint32_t *next_transfer_handle);
244
Sampa Misra032bd502019-03-06 05:03:22 -0600245/* Responder */
246
247/* GetDateTime */
248
249/** @brief Create a PLDM response message for GetDateTime
250 *
251 * @param[in] instance_id - Message's instance id
252 * @param[in] completion_code - PLDM completion code
253 * @param[in] seconds - seconds in BCD format
254 * @param[in] minutes - minutes in BCD format
255 * @param[in] hours - hours in BCD format
256 * @param[in] day - day of the month in BCD format
257 * @param[in] month - number of month in BCD format
258 * @param[in] year - year in BCD format
259 * @param[out] msg - Message will be written to this
260 * @return pldm_completion_codes
261 * @note Caller is responsible for memory alloc and dealloc of param
262 * 'msg.body.payload'
263 */
264
265int encode_get_date_time_resp(uint8_t instance_id, uint8_t completion_code,
266 uint8_t seconds, uint8_t minutes, uint8_t hours,
267 uint8_t day, uint8_t month, uint16_t year,
268 struct pldm_msg *msg);
269
Sampa Misrab37be312019-07-03 02:26:41 -0500270/* GetBIOSTable */
271
272/** @brief Create a PLDM response message for GetBIOSTable
273 *
274 * @param[in] instance_id - Message's instance id
275 * @param[in] completion_code - PLDM completion code
276 * @param[in] next_transfer_handle - handle to identify the next portion of the
277 * transfer
278 * @param[in] transfer_flag - To indicate what part of the transfer this
279 * response represents
280 * @param[in] table_data - BIOS Table type specific data
281 * @param[in] payload_length - Length of payload message
282 * @param[out] msg - Message will be written to this
283 * @return pldm_completion_codes
284 */
285int encode_get_bios_table_resp(uint8_t instance_id, uint8_t completion_code,
286 uint32_t next_transfer_handle,
287 uint8_t transfer_flag, uint8_t *table_data,
288 size_t payload_length, struct pldm_msg *msg);
289
Sridevi Rameshd3d5fa82019-10-29 11:45:16 -0500290/** @brief Encode GetBIOSTable request packet
291 *
292 * @param[in] instance_id - Message's instance id
293 * @param[in] transfer_handle - Handle to identify a BIOS table transfer
294 * @param[in] transfer_op_flag - Flag to indicate the start of a multipart
295 * transfer
296 * @param[in] table_type - BIOS table type
297 * @param[out] msg - Message will be written to this
298 * @return pldm_completion_codes
299 */
300int encode_get_bios_table_req(uint8_t instance_id, uint32_t transfer_handle,
301 uint8_t transfer_op_flag, uint8_t table_type,
302 struct pldm_msg *msg);
303
Sampa Misrab37be312019-07-03 02:26:41 -0500304/** @brief Decode GetBIOSTable request packet
305 *
306 * @param[in] msg - Request message
307 * @param[in] payload_length - Length of request message payload
308 * @param[out] transfer_handle - Handle to identify a BIOS table transfer
309 * @param[out] transfer_op_flag - Flag to indicate the start of a multipart
310 * transfer
311 * @param[out] table_type - BIOS table type
312 * @return pldm_completion_codes
313 */
314int decode_get_bios_table_req(const struct pldm_msg *msg, size_t payload_length,
315 uint32_t *transfer_handle,
316 uint8_t *transfer_op_flag, uint8_t *table_type);
317
Sridevi Ramesh08efc7b2019-12-05 05:39:46 -0600318/** @brief Decode GetBIOSTable response packet
319 *
320 * @param[in] msg - Response message
321 * @param[in] payload_length - Length of response message payload
322 * @param[in] completion_code - PLDM completion code
323 * @param[in] next_transfer_handle - handle to identify the next portion of the
324 * transfer
325 * @param[in] transfer_flag - To indicate what part of the transfer this
326 * response represents
327 * @param[out] bios_table_offset - Offset where bios table data should be read
328 * in pldm msg
329 * @return pldm_completion_codes
330 */
331int decode_get_bios_table_resp(const struct pldm_msg *msg,
332 size_t payload_length, uint8_t *completion_code,
333 uint32_t *next_transfer_handle,
334 uint8_t *transfer_flag,
335 size_t *bios_table_offset);
336
Zahed Hossaind69af0b2019-07-30 01:33:31 -0500337/* GetBIOSAttributeCurrentValueByHandle */
338
339/** @brief Decode GetBIOSAttributeCurrentValueByHandle request packet
340 *
341 * @param[in] msg - Request message
342 * @param[in] payload_length - Length of request message payload
343 * @param[out] transfer_handle - Handle to identify a BIOS table transfer
344 * @param[out] transfer_op_flag - Flag to indicate the start of a multipart
345 * transfer
346 * @param[out] attribute_handle - Handle to identify the BIOS attribute
347 * @return pldm_completion_codes
348 */
349int decode_get_bios_attribute_current_value_by_handle_req(
350 const struct pldm_msg *msg, size_t payload_length,
351 uint32_t *transfer_handle, uint8_t *transfer_op_flag,
352 uint16_t *attribute_handle);
353
354/** @brief Create a PLDM response message for
355 * GetBIOSAttributeCurrentValueByHandle
356 *
357 * @param[in] instance_id - Message's instance id
358 * @param[in] completion_code - PLDM completion code
359 * @param[in] next_transfer_handle - handle to identify the next portion of the
360 * transfer
361 * @param[in] transfer_flag - To indicate what part of the transfer this
362 * response represents
363 * @param[in] attribute_data - contains current value of attribute
364 * @param[in] attribute_length - Length of attribute
365 * @param[out] msg - Message will be written to this
366 * @return pldm_completion_codes
367 */
368int encode_get_bios_current_value_by_handle_resp(
369 uint8_t instance_id, uint8_t completion_code, uint32_t next_transfer_handle,
370 uint8_t transfer_flag, const uint8_t *attribute_data,
371 size_t attribute_length, struct pldm_msg *msg);
372
John Wang4d844792019-08-15 15:51:40 +0800373/* SetBiosAttributeCurrentValue */
374
375/** @brief Decode SetBIOSAttributeCurrentValue request packet
376 *
377 * @param[in] msg - Request message
378 * @param[in] payload_length - Length of request message payload
379 * @param[out] transfer_handle - Handle to identify a BIOS table transfer
380 * @param[out] transfer_flag - Flag to indicate what part of the transfer
381 * this request represents
382 * @param[out] attribute_data - Contains current value of attribute
383 * @param[out] attribute_length - Pointer to length of attribute
384 * @return pldm_completion_codes
385 */
386int decode_set_bios_attribute_current_value_req(const struct pldm_msg *msg,
387 size_t payload_length,
388 uint32_t *transfer_handle,
389 uint8_t *transfer_flag,
390 uint8_t *attribute_data,
391 size_t *attribute_length);
392
393/** @brief Create a PLDM response message for SetBiosAttributeCurrentValue
394 *
395 * @param[in] instance_id - Message's instance id
396 * @param[in] completion_code - PLDM completion code
397 * @param[in] next_transfer_handle - handle to identify the next portion of the
398 * @param[out] msg - Message will be written to this
399 */
400int encode_set_bios_attribute_current_value_resp(uint8_t instance_id,
401 uint8_t completion_code,
402 uint32_t next_transfer_handle,
403 struct pldm_msg *msg);
404
Xiaochao Ma39ae2a92019-11-12 20:30:34 +0800405/** @brief Create a PLDM request message for SetDateTime
406 *
407 * @param[in] instance_id - Message's instance id
Xiaochao Ma501a6fd2019-12-17 14:44:57 +0800408 * @param[in] seconds - Seconds in decimal format. Value range 0~59
409 * @param[in] minutes - minutes in decimal format. Value range 0~59
410 * @param[in] hours - hours in decimal format. Value range 0~23
411 * @param[in] day - day of month in decimal format. Value range 1~31
412 * @param[in] month - number of month in decimal format. Value range 1~12
413 * @param[in] year - year in decimal format. Value range 1970~
Xiaochao Ma39ae2a92019-11-12 20:30:34 +0800414 * @param[out] msg - Message will be written to this
415 * @param[in] payload_length - Length of request message payload
416 * @return pldm_completion_codes
417 * @note Caller is responsible for memory alloc and dealloc of param
418 * 'msg.body.payload'
419 */
420int encode_set_date_time_req(uint8_t instance_id, uint8_t seconds,
421 uint8_t minutes, uint8_t hours, uint8_t day,
422 uint8_t month, uint16_t year, struct pldm_msg *msg,
423 size_t payload_length);
424
425/** @brief Decode a SetDateTime request message
426 *
427 * @param[in] msg - Response message
428 * @param[in] payload_length - Length of request message payload
429 * @param[out] seconds - seconds in BCD format
430 * @param[out] minutes - minutes in BCD format
431 * @param[out] hours - hours in BCD format
432 * @param[out] day - day of the month in BCD format
433 * @param[out] month - number of month in BCD format
434 * @param[out] year - year in BCD format
435 * @return pldm_completion_codes
436 */
437int decode_set_date_time_req(const struct pldm_msg *msg, size_t payload_length,
438 uint8_t *seconds, uint8_t *minutes, uint8_t *hours,
439 uint8_t *day, uint8_t *month, uint16_t *year);
440
441/** @brief Create a PLDM response message for SetDateTime
442 *
443 * @param[in] instance_id - Message's instance id
444 * @param[in] completion_code - PLDM completion code
445 * @param[out] msg - Message will be written to this
446 * @param[in] payload_length - Length of response message payload
447 * @return pldm_completion_codes
448 * @note Caller is responsible for memory alloc and dealloc of param
449 * 'msg.body.payload'
450 */
451int encode_set_date_time_resp(uint8_t instance_id, uint8_t completion_code,
452 struct pldm_msg *msg, size_t payload_length);
453
454/** @brief Decode a SetDateTime response message
455 *
456 * @param[in] msg - Response message
457 * @param[in] payload_length - Length of response message payload
458 * @param[out] completion_code - Pointer to response msg's PLDM completion code
459 * @return pldm_completion_codes
460 */
461int decode_set_date_time_resp(const struct pldm_msg *msg, size_t payload_length,
462 uint8_t *completion_code);
463
Sampa Misra032bd502019-03-06 05:03:22 -0600464#ifdef __cplusplus
465}
466#endif
467
468#endif /* BIOS_H */