blob: d316b670f5d0bcfac57c959089c407fcd941baf6 [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
Sampa Misrab37be312019-07-03 02:26:41 -050022
23enum pldm_bios_completion_codes {
24 PLDM_BIOS_TABLE_UNAVAILABLE = 0x83,
25 PLDM_INVALID_BIOS_TABLE_DATA_INTEGRITY_CHECK = 0x84,
26 PLDM_INVALID_BIOS_TABLE_TYPE = 0x85,
27};
28enum pldm_bios_commands {
29 PLDM_GET_BIOS_TABLE = 0x01,
John Wang4d844792019-08-15 15:51:40 +080030 PLDM_SET_BIOS_ATTRIBUTE_CURRENT_VALUE = 0x07,
Zahed Hossaind69af0b2019-07-30 01:33:31 -050031 PLDM_GET_BIOS_ATTRIBUTE_CURRENT_VALUE_BY_HANDLE = 0x08,
32 PLDM_GET_DATE_TIME = 0x0c,
Xiaochao Ma39ae2a92019-11-12 20:30:34 +080033 PLDM_SET_DATE_TIME = 0x0d,
Sampa Misrab37be312019-07-03 02:26:41 -050034};
Sampa Misra032bd502019-03-06 05:03:22 -060035
Deepak Kodihallicb7f2d42019-06-19 13:25:31 +053036enum pldm_bios_table_types {
37 PLDM_BIOS_STRING_TABLE,
38 PLDM_BIOS_ATTR_TABLE,
39 PLDM_BIOS_ATTR_VAL_TABLE,
40};
41
42struct pldm_bios_string_table_entry {
43 uint16_t string_handle;
44 uint16_t string_length;
45 char name[1];
46} __attribute__((packed));
47
48struct pldm_bios_attr_table_entry {
49 uint16_t attr_handle;
50 uint8_t attr_type;
51 uint16_t string_handle;
52 uint8_t metadata[1];
53} __attribute__((packed));
54
55struct pldm_bios_enum_attr {
56 uint8_t num_possible_values;
57 uint16_t indices[1];
58} __attribute__((packed));
59
60struct pldm_bios_attr_val_table_entry {
61 uint16_t attr_handle;
62 uint8_t attr_type;
63 uint8_t value[1];
64} __attribute__((packed));
65
Sampa Misrab37be312019-07-03 02:26:41 -050066enum pldm_bios_attribute_type {
67 PLDM_BIOS_ENUMERATION = 0x0,
68 PLDM_BIOS_STRING = 0x1,
69 PLDM_BIOS_PASSWORD = 0x2,
70 PLDM_BIOS_INTEGER = 0x3,
71 PLDM_BIOS_ENUMERATION_READ_ONLY = 0x80,
72 PLDM_BIOS_STRING_READ_ONLY = 0x81,
73 PLDM_BIOS_PASSWORD_READ_ONLY = 0x82,
74 PLDM_BIOS_INTEGER_READ_ONLY = 0x83,
75};
76
77/** @struct pldm_get_bios_table_req
78 *
79 * structure representing GetBIOSTable request packet
80 */
81struct pldm_get_bios_table_req {
82 uint32_t transfer_handle;
83 uint8_t transfer_op_flag;
84 uint8_t table_type;
85} __attribute__((packed));
86
87/** @struct pldm_get_bios_table_resp
88 *
89 * structure representing GetBIOSTable response packet
90 */
91struct pldm_get_bios_table_resp {
92 uint8_t completion_code;
93 uint32_t next_transfer_handle;
94 uint8_t transfer_flag;
95 uint8_t table_data[1];
96} __attribute__((packed));
97
Priyanga5dcd1802019-06-10 01:50:39 -050098/** @struct pldm_get_date_time_resp
99 *
100 * Structure representing PLDM get date time response
101 */
102struct pldm_get_date_time_resp {
103 uint8_t completion_code; //!< completion code
104 uint8_t seconds; //!< Seconds in BCD format
105 uint8_t minutes; //!< Minutes in BCD format
106 uint8_t hours; //!< Hours in BCD format
107 uint8_t day; //!< Day of the month in BCD format
108 uint8_t month; //!< Month in BCD format
109 uint16_t year; //!< Year in BCD format
110} __attribute__((packed));
111
Xiaochao Ma39ae2a92019-11-12 20:30:34 +0800112/** @struct pldm_set_date_time_req
113 *
114 * structure representing SetDateTime request packet
115 *
116 */
117struct pldm_set_date_time_req {
118 uint8_t seconds; //!< Seconds in BCD format
119 uint8_t minutes; //!< Minutes in BCD format
120 uint8_t hours; //!< Hours in BCD format
121 uint8_t day; //!< Day of the month in BCD format
122 uint8_t month; //!< Month in BCD format
123 uint16_t year; //!< Year in BCD format
124} __attribute__((packed));
125
126/** @struct pldm_only_cc_resp
127 *
128 * Structure representing PLDM responses only have completion code
129 */
130struct pldm_only_cc_resp {
131 uint8_t completion_code;
132} __attribute__((packed));
133
Zahed Hossaind69af0b2019-07-30 01:33:31 -0500134/** @struct pldm_get_bios_attribute_current_value_by_handle_req
135 *
136 * structure representing GetBIOSAttributeCurrentValueByHandle request packet
137 */
138struct pldm_get_bios_attribute_current_value_by_handle_req {
139 uint32_t transfer_handle;
140 uint8_t transfer_op_flag;
141 uint16_t attribute_handle;
142} __attribute__((packed));
143
144/** @struct pldm_get_bios_attribute_current_value_by_handle_resp
145 *
146 * structure representing GetBIOSAttributeCurrentValueByHandle response
147 */
148struct pldm_get_bios_attribute_current_value_by_handle_resp {
149 uint8_t completion_code;
150 uint32_t next_transfer_handle;
151 uint8_t transfer_flag;
152 uint8_t attribute_data[1];
153} __attribute__((packed));
154
John Wang4d844792019-08-15 15:51:40 +0800155/** @struct pldm_set_bios_attribute_current_value_req
156 *
157 * structure representing SetBiosAttributeCurrentValue request packet
158 *
159 */
160struct pldm_set_bios_attribute_current_value_req {
161 uint32_t transfer_handle;
162 uint8_t transfer_flag;
163 uint8_t attribute_data[1];
164} __attribute__((packed));
165
166/** @struct pldm_set_bios_attribute_current_value_resp
167 *
168 * structure representing SetBiosCurrentValue response packet
169 *
170 */
171struct pldm_set_bios_attribute_current_value_resp {
172 uint8_t completion_code;
173 uint32_t next_transfer_handle;
174} __attribute__((packed));
175
Sampa Misra032bd502019-03-06 05:03:22 -0600176/* Requester */
177
178/* GetDateTime */
179
180/** @brief Create a PLDM request message for GetDateTime
181 *
182 * @param[in] instance_id - Message's instance id
183 * @param[out] msg - Message will be written to this
184 * @return pldm_completion_codes
185 * @note Caller is responsible for memory alloc and dealloc of param
186 * 'msg.body.payload'
187 */
188
189int encode_get_date_time_req(uint8_t instance_id, struct pldm_msg *msg);
190
191/** @brief Decode a GetDateTime response message
192 *
Zahed Hossain223a73d2019-07-04 12:46:18 -0500193 * @param[in] msg - Response message
vkaverapa6575b82019-04-03 05:33:52 -0500194 * @param[in] payload_length - Length of response message payload
Sampa Misra032bd502019-03-06 05:03:22 -0600195 * @param[out] completion_code - Pointer to response msg's PLDM completion code
196 * @param[out] seconds - Seconds in BCD format
197 * @param[out] minutes - minutes in BCD format
198 * @param[out] hours - hours in BCD format
199 * @param[out] day - day of month in BCD format
200 * @param[out] month - number of month in BCD format
201 * @param[out] year - year in BCD format
202 * @return pldm_completion_codes
203 */
Zahed Hossain223a73d2019-07-04 12:46:18 -0500204int decode_get_date_time_resp(const struct pldm_msg *msg, size_t payload_length,
Sampa Misra032bd502019-03-06 05:03:22 -0600205 uint8_t *completion_code, uint8_t *seconds,
206 uint8_t *minutes, uint8_t *hours, uint8_t *day,
207 uint8_t *month, uint16_t *year);
208
John Wang4d844792019-08-15 15:51:40 +0800209/* SetBiosAttributeCurrentValue */
210
211/** @brief Create a PLDM request message for SetBiosAttributeCurrentValue
212 *
213 * @param[in] instance_id - Message's instance id
214 * @param[in] transfer_handle - Handle to identify a BIOS table transfer
215 * @param[in] transfer_flag - Flag to indicate what part of the transfer
216 * this request represents
217 * @param[in] attribute_data - Contains current value of attribute
218 * @param[in] attribute_length - Length of attribute
219 * @param[out] msg - Message will be written to this
220 * @param[in] payload_length - Length of message payload
221 * @return pldm_completion_codes
222 * @note Caller is responsible for memory alloc and dealloc of params
223 * 'msg.payload'
224 */
225int encode_set_bios_attribute_current_value_req(
226 uint8_t instance_id, uint32_t transfer_handle, uint8_t transfer_flag,
227 const uint8_t *attribute_data, size_t attribute_length,
228 struct pldm_msg *msg, size_t payload_length);
229
230/** @brief Decode a SetBiosAttributeCurrentValue response message
231 *
232 * @param[in] msg - Response message
233 * @param[in] payload_length - Length of response message payload
234 * @param[out] completion_code - Pointer to response msg's PLDM completion code
235 * @param[out] next_transfer_handle - Pointer to a handle that identify the
236 * next portion of the transfer
237 * @return pldm_completion_codes
238 */
239int decode_set_bios_attribute_current_value_resp(
240 const struct pldm_msg *msg, size_t payload_length, uint8_t *completion_code,
241 uint32_t *next_transfer_handle);
242
Sampa Misra032bd502019-03-06 05:03:22 -0600243/* Responder */
244
245/* GetDateTime */
246
247/** @brief Create a PLDM response message for GetDateTime
248 *
249 * @param[in] instance_id - Message's instance id
250 * @param[in] completion_code - PLDM completion code
251 * @param[in] seconds - seconds in BCD format
252 * @param[in] minutes - minutes in BCD format
253 * @param[in] hours - hours in BCD format
254 * @param[in] day - day of the month in BCD format
255 * @param[in] month - number of month in BCD format
256 * @param[in] year - year in BCD format
257 * @param[out] msg - Message will be written to this
258 * @return pldm_completion_codes
259 * @note Caller is responsible for memory alloc and dealloc of param
260 * 'msg.body.payload'
261 */
262
263int encode_get_date_time_resp(uint8_t instance_id, uint8_t completion_code,
264 uint8_t seconds, uint8_t minutes, uint8_t hours,
265 uint8_t day, uint8_t month, uint16_t year,
266 struct pldm_msg *msg);
267
Sampa Misrab37be312019-07-03 02:26:41 -0500268/* GetBIOSTable */
269
270/** @brief Create a PLDM response message for GetBIOSTable
271 *
272 * @param[in] instance_id - Message's instance id
273 * @param[in] completion_code - PLDM completion code
274 * @param[in] next_transfer_handle - handle to identify the next portion of the
275 * transfer
276 * @param[in] transfer_flag - To indicate what part of the transfer this
277 * response represents
278 * @param[in] table_data - BIOS Table type specific data
279 * @param[in] payload_length - Length of payload message
280 * @param[out] msg - Message will be written to this
281 * @return pldm_completion_codes
282 */
283int encode_get_bios_table_resp(uint8_t instance_id, uint8_t completion_code,
284 uint32_t next_transfer_handle,
285 uint8_t transfer_flag, uint8_t *table_data,
286 size_t payload_length, struct pldm_msg *msg);
287
Sridevi Rameshd3d5fa82019-10-29 11:45:16 -0500288/** @brief Encode GetBIOSTable request packet
289 *
290 * @param[in] instance_id - Message's instance id
291 * @param[in] transfer_handle - Handle to identify a BIOS table transfer
292 * @param[in] transfer_op_flag - Flag to indicate the start of a multipart
293 * transfer
294 * @param[in] table_type - BIOS table type
295 * @param[out] msg - Message will be written to this
296 * @return pldm_completion_codes
297 */
298int encode_get_bios_table_req(uint8_t instance_id, uint32_t transfer_handle,
299 uint8_t transfer_op_flag, uint8_t table_type,
300 struct pldm_msg *msg);
301
Sampa Misrab37be312019-07-03 02:26:41 -0500302/** @brief Decode GetBIOSTable request packet
303 *
304 * @param[in] msg - Request message
305 * @param[in] payload_length - Length of request message payload
306 * @param[out] transfer_handle - Handle to identify a BIOS table transfer
307 * @param[out] transfer_op_flag - Flag to indicate the start of a multipart
308 * transfer
309 * @param[out] table_type - BIOS table type
310 * @return pldm_completion_codes
311 */
312int decode_get_bios_table_req(const struct pldm_msg *msg, size_t payload_length,
313 uint32_t *transfer_handle,
314 uint8_t *transfer_op_flag, uint8_t *table_type);
315
Zahed Hossaind69af0b2019-07-30 01:33:31 -0500316/* GetBIOSAttributeCurrentValueByHandle */
317
318/** @brief Decode GetBIOSAttributeCurrentValueByHandle request packet
319 *
320 * @param[in] msg - Request message
321 * @param[in] payload_length - Length of request message payload
322 * @param[out] transfer_handle - Handle to identify a BIOS table transfer
323 * @param[out] transfer_op_flag - Flag to indicate the start of a multipart
324 * transfer
325 * @param[out] attribute_handle - Handle to identify the BIOS attribute
326 * @return pldm_completion_codes
327 */
328int decode_get_bios_attribute_current_value_by_handle_req(
329 const struct pldm_msg *msg, size_t payload_length,
330 uint32_t *transfer_handle, uint8_t *transfer_op_flag,
331 uint16_t *attribute_handle);
332
333/** @brief Create a PLDM response message for
334 * GetBIOSAttributeCurrentValueByHandle
335 *
336 * @param[in] instance_id - Message's instance id
337 * @param[in] completion_code - PLDM completion code
338 * @param[in] next_transfer_handle - handle to identify the next portion of the
339 * transfer
340 * @param[in] transfer_flag - To indicate what part of the transfer this
341 * response represents
342 * @param[in] attribute_data - contains current value of attribute
343 * @param[in] attribute_length - Length of attribute
344 * @param[out] msg - Message will be written to this
345 * @return pldm_completion_codes
346 */
347int encode_get_bios_current_value_by_handle_resp(
348 uint8_t instance_id, uint8_t completion_code, uint32_t next_transfer_handle,
349 uint8_t transfer_flag, const uint8_t *attribute_data,
350 size_t attribute_length, struct pldm_msg *msg);
351
John Wang4d844792019-08-15 15:51:40 +0800352/* SetBiosAttributeCurrentValue */
353
354/** @brief Decode SetBIOSAttributeCurrentValue request packet
355 *
356 * @param[in] msg - Request message
357 * @param[in] payload_length - Length of request message payload
358 * @param[out] transfer_handle - Handle to identify a BIOS table transfer
359 * @param[out] transfer_flag - Flag to indicate what part of the transfer
360 * this request represents
361 * @param[out] attribute_data - Contains current value of attribute
362 * @param[out] attribute_length - Pointer to length of attribute
363 * @return pldm_completion_codes
364 */
365int decode_set_bios_attribute_current_value_req(const struct pldm_msg *msg,
366 size_t payload_length,
367 uint32_t *transfer_handle,
368 uint8_t *transfer_flag,
369 uint8_t *attribute_data,
370 size_t *attribute_length);
371
372/** @brief Create a PLDM response message for SetBiosAttributeCurrentValue
373 *
374 * @param[in] instance_id - Message's instance id
375 * @param[in] completion_code - PLDM completion code
376 * @param[in] next_transfer_handle - handle to identify the next portion of the
377 * @param[out] msg - Message will be written to this
378 */
379int encode_set_bios_attribute_current_value_resp(uint8_t instance_id,
380 uint8_t completion_code,
381 uint32_t next_transfer_handle,
382 struct pldm_msg *msg);
383
Xiaochao Ma39ae2a92019-11-12 20:30:34 +0800384/** @brief Create a PLDM request message for SetDateTime
385 *
386 * @param[in] instance_id - Message's instance id
387 * @param[in] seconds - Seconds in BCD format
388 * @param[in] minutes - minutes in BCD format
389 * @param[in] hours - hours in BCD format
390 * @param[in] day - day of month in BCD format
391 * @param[in] month - number of month in BCD format
392 * @param[in] year - year in BCD format
393 * @param[out] msg - Message will be written to this
394 * @param[in] payload_length - Length of request message payload
395 * @return pldm_completion_codes
396 * @note Caller is responsible for memory alloc and dealloc of param
397 * 'msg.body.payload'
398 */
399int encode_set_date_time_req(uint8_t instance_id, uint8_t seconds,
400 uint8_t minutes, uint8_t hours, uint8_t day,
401 uint8_t month, uint16_t year, struct pldm_msg *msg,
402 size_t payload_length);
403
404/** @brief Decode a SetDateTime request message
405 *
406 * @param[in] msg - Response message
407 * @param[in] payload_length - Length of request message payload
408 * @param[out] seconds - seconds in BCD format
409 * @param[out] minutes - minutes in BCD format
410 * @param[out] hours - hours in BCD format
411 * @param[out] day - day of the month in BCD format
412 * @param[out] month - number of month in BCD format
413 * @param[out] year - year in BCD format
414 * @return pldm_completion_codes
415 */
416int decode_set_date_time_req(const struct pldm_msg *msg, size_t payload_length,
417 uint8_t *seconds, uint8_t *minutes, uint8_t *hours,
418 uint8_t *day, uint8_t *month, uint16_t *year);
419
420/** @brief Create a PLDM response message for SetDateTime
421 *
422 * @param[in] instance_id - Message's instance id
423 * @param[in] completion_code - PLDM completion code
424 * @param[out] msg - Message will be written to this
425 * @param[in] payload_length - Length of response message payload
426 * @return pldm_completion_codes
427 * @note Caller is responsible for memory alloc and dealloc of param
428 * 'msg.body.payload'
429 */
430int encode_set_date_time_resp(uint8_t instance_id, uint8_t completion_code,
431 struct pldm_msg *msg, size_t payload_length);
432
433/** @brief Decode a SetDateTime response message
434 *
435 * @param[in] msg - Response message
436 * @param[in] payload_length - Length of response message payload
437 * @param[out] completion_code - Pointer to response msg's PLDM completion code
438 * @return pldm_completion_codes
439 */
440int decode_set_date_time_resp(const struct pldm_msg *msg, size_t payload_length,
441 uint8_t *completion_code);
442
Sampa Misra032bd502019-03-06 05:03:22 -0600443#ifdef __cplusplus
444}
445#endif
446
447#endif /* BIOS_H */