blob: 270413c0e086ddad764217ac8943aa6ad81a95aa [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,
Sampa Misrab37be312019-07-03 02:26:41 -050033};
Sampa Misra032bd502019-03-06 05:03:22 -060034
Deepak Kodihallicb7f2d42019-06-19 13:25:31 +053035enum pldm_bios_table_types {
36 PLDM_BIOS_STRING_TABLE,
37 PLDM_BIOS_ATTR_TABLE,
38 PLDM_BIOS_ATTR_VAL_TABLE,
39};
40
41struct pldm_bios_string_table_entry {
42 uint16_t string_handle;
43 uint16_t string_length;
44 char name[1];
45} __attribute__((packed));
46
47struct pldm_bios_attr_table_entry {
48 uint16_t attr_handle;
49 uint8_t attr_type;
50 uint16_t string_handle;
51 uint8_t metadata[1];
52} __attribute__((packed));
53
54struct pldm_bios_enum_attr {
55 uint8_t num_possible_values;
56 uint16_t indices[1];
57} __attribute__((packed));
58
59struct pldm_bios_attr_val_table_entry {
60 uint16_t attr_handle;
61 uint8_t attr_type;
62 uint8_t value[1];
63} __attribute__((packed));
64
Sampa Misrab37be312019-07-03 02:26:41 -050065enum pldm_bios_attribute_type {
66 PLDM_BIOS_ENUMERATION = 0x0,
67 PLDM_BIOS_STRING = 0x1,
68 PLDM_BIOS_PASSWORD = 0x2,
69 PLDM_BIOS_INTEGER = 0x3,
70 PLDM_BIOS_ENUMERATION_READ_ONLY = 0x80,
71 PLDM_BIOS_STRING_READ_ONLY = 0x81,
72 PLDM_BIOS_PASSWORD_READ_ONLY = 0x82,
73 PLDM_BIOS_INTEGER_READ_ONLY = 0x83,
74};
75
76/** @struct pldm_get_bios_table_req
77 *
78 * structure representing GetBIOSTable request packet
79 */
80struct pldm_get_bios_table_req {
81 uint32_t transfer_handle;
82 uint8_t transfer_op_flag;
83 uint8_t table_type;
84} __attribute__((packed));
85
86/** @struct pldm_get_bios_table_resp
87 *
88 * structure representing GetBIOSTable response packet
89 */
90struct pldm_get_bios_table_resp {
91 uint8_t completion_code;
92 uint32_t next_transfer_handle;
93 uint8_t transfer_flag;
94 uint8_t table_data[1];
95} __attribute__((packed));
96
Priyanga5dcd1802019-06-10 01:50:39 -050097/** @struct pldm_get_date_time_resp
98 *
99 * Structure representing PLDM get date time response
100 */
101struct pldm_get_date_time_resp {
102 uint8_t completion_code; //!< completion code
103 uint8_t seconds; //!< Seconds in BCD format
104 uint8_t minutes; //!< Minutes in BCD format
105 uint8_t hours; //!< Hours in BCD format
106 uint8_t day; //!< Day of the month in BCD format
107 uint8_t month; //!< Month in BCD format
108 uint16_t year; //!< Year in BCD format
109} __attribute__((packed));
110
Zahed Hossaind69af0b2019-07-30 01:33:31 -0500111/** @struct pldm_get_bios_attribute_current_value_by_handle_req
112 *
113 * structure representing GetBIOSAttributeCurrentValueByHandle request packet
114 */
115struct pldm_get_bios_attribute_current_value_by_handle_req {
116 uint32_t transfer_handle;
117 uint8_t transfer_op_flag;
118 uint16_t attribute_handle;
119} __attribute__((packed));
120
121/** @struct pldm_get_bios_attribute_current_value_by_handle_resp
122 *
123 * structure representing GetBIOSAttributeCurrentValueByHandle response
124 */
125struct pldm_get_bios_attribute_current_value_by_handle_resp {
126 uint8_t completion_code;
127 uint32_t next_transfer_handle;
128 uint8_t transfer_flag;
129 uint8_t attribute_data[1];
130} __attribute__((packed));
131
John Wang4d844792019-08-15 15:51:40 +0800132/** @struct pldm_set_bios_attribute_current_value_req
133 *
134 * structure representing SetBiosAttributeCurrentValue request packet
135 *
136 */
137struct pldm_set_bios_attribute_current_value_req {
138 uint32_t transfer_handle;
139 uint8_t transfer_flag;
140 uint8_t attribute_data[1];
141} __attribute__((packed));
142
143/** @struct pldm_set_bios_attribute_current_value_resp
144 *
145 * structure representing SetBiosCurrentValue response packet
146 *
147 */
148struct pldm_set_bios_attribute_current_value_resp {
149 uint8_t completion_code;
150 uint32_t next_transfer_handle;
151} __attribute__((packed));
152
Sampa Misra032bd502019-03-06 05:03:22 -0600153/* Requester */
154
155/* GetDateTime */
156
157/** @brief Create a PLDM request message for GetDateTime
158 *
159 * @param[in] instance_id - Message's instance id
160 * @param[out] msg - Message will be written to this
161 * @return pldm_completion_codes
162 * @note Caller is responsible for memory alloc and dealloc of param
163 * 'msg.body.payload'
164 */
165
166int encode_get_date_time_req(uint8_t instance_id, struct pldm_msg *msg);
167
168/** @brief Decode a GetDateTime response message
169 *
Zahed Hossain223a73d2019-07-04 12:46:18 -0500170 * @param[in] msg - Response message
vkaverapa6575b82019-04-03 05:33:52 -0500171 * @param[in] payload_length - Length of response message payload
Sampa Misra032bd502019-03-06 05:03:22 -0600172 * @param[out] completion_code - Pointer to response msg's PLDM completion code
173 * @param[out] seconds - Seconds in BCD format
174 * @param[out] minutes - minutes in BCD format
175 * @param[out] hours - hours in BCD format
176 * @param[out] day - day of month in BCD format
177 * @param[out] month - number of month in BCD format
178 * @param[out] year - year in BCD format
179 * @return pldm_completion_codes
180 */
Zahed Hossain223a73d2019-07-04 12:46:18 -0500181int decode_get_date_time_resp(const struct pldm_msg *msg, size_t payload_length,
Sampa Misra032bd502019-03-06 05:03:22 -0600182 uint8_t *completion_code, uint8_t *seconds,
183 uint8_t *minutes, uint8_t *hours, uint8_t *day,
184 uint8_t *month, uint16_t *year);
185
John Wang4d844792019-08-15 15:51:40 +0800186/* SetBiosAttributeCurrentValue */
187
188/** @brief Create a PLDM request message for SetBiosAttributeCurrentValue
189 *
190 * @param[in] instance_id - Message's instance id
191 * @param[in] transfer_handle - Handle to identify a BIOS table transfer
192 * @param[in] transfer_flag - Flag to indicate what part of the transfer
193 * this request represents
194 * @param[in] attribute_data - Contains current value of attribute
195 * @param[in] attribute_length - Length of attribute
196 * @param[out] msg - Message will be written to this
197 * @param[in] payload_length - Length of message payload
198 * @return pldm_completion_codes
199 * @note Caller is responsible for memory alloc and dealloc of params
200 * 'msg.payload'
201 */
202int encode_set_bios_attribute_current_value_req(
203 uint8_t instance_id, uint32_t transfer_handle, uint8_t transfer_flag,
204 const uint8_t *attribute_data, size_t attribute_length,
205 struct pldm_msg *msg, size_t payload_length);
206
207/** @brief Decode a SetBiosAttributeCurrentValue response message
208 *
209 * @param[in] msg - Response message
210 * @param[in] payload_length - Length of response message payload
211 * @param[out] completion_code - Pointer to response msg's PLDM completion code
212 * @param[out] next_transfer_handle - Pointer to a handle that identify the
213 * next portion of the transfer
214 * @return pldm_completion_codes
215 */
216int decode_set_bios_attribute_current_value_resp(
217 const struct pldm_msg *msg, size_t payload_length, uint8_t *completion_code,
218 uint32_t *next_transfer_handle);
219
Sampa Misra032bd502019-03-06 05:03:22 -0600220/* Responder */
221
222/* GetDateTime */
223
224/** @brief Create a PLDM response message for GetDateTime
225 *
226 * @param[in] instance_id - Message's instance id
227 * @param[in] completion_code - PLDM completion code
228 * @param[in] seconds - seconds in BCD format
229 * @param[in] minutes - minutes in BCD format
230 * @param[in] hours - hours in BCD format
231 * @param[in] day - day of the month in BCD format
232 * @param[in] month - number of month in BCD format
233 * @param[in] year - year in BCD format
234 * @param[out] msg - Message will be written to this
235 * @return pldm_completion_codes
236 * @note Caller is responsible for memory alloc and dealloc of param
237 * 'msg.body.payload'
238 */
239
240int encode_get_date_time_resp(uint8_t instance_id, uint8_t completion_code,
241 uint8_t seconds, uint8_t minutes, uint8_t hours,
242 uint8_t day, uint8_t month, uint16_t year,
243 struct pldm_msg *msg);
244
Sampa Misrab37be312019-07-03 02:26:41 -0500245/* GetBIOSTable */
246
247/** @brief Create a PLDM response message for GetBIOSTable
248 *
249 * @param[in] instance_id - Message's instance id
250 * @param[in] completion_code - PLDM completion code
251 * @param[in] next_transfer_handle - handle to identify the next portion of the
252 * transfer
253 * @param[in] transfer_flag - To indicate what part of the transfer this
254 * response represents
255 * @param[in] table_data - BIOS Table type specific data
256 * @param[in] payload_length - Length of payload message
257 * @param[out] msg - Message will be written to this
258 * @return pldm_completion_codes
259 */
260int encode_get_bios_table_resp(uint8_t instance_id, uint8_t completion_code,
261 uint32_t next_transfer_handle,
262 uint8_t transfer_flag, uint8_t *table_data,
263 size_t payload_length, struct pldm_msg *msg);
264
Sridevi Rameshd3d5fa82019-10-29 11:45:16 -0500265/** @brief Encode GetBIOSTable request packet
266 *
267 * @param[in] instance_id - Message's instance id
268 * @param[in] transfer_handle - Handle to identify a BIOS table transfer
269 * @param[in] transfer_op_flag - Flag to indicate the start of a multipart
270 * transfer
271 * @param[in] table_type - BIOS table type
272 * @param[out] msg - Message will be written to this
273 * @return pldm_completion_codes
274 */
275int encode_get_bios_table_req(uint8_t instance_id, uint32_t transfer_handle,
276 uint8_t transfer_op_flag, uint8_t table_type,
277 struct pldm_msg *msg);
278
Sampa Misrab37be312019-07-03 02:26:41 -0500279/** @brief Decode GetBIOSTable request packet
280 *
281 * @param[in] msg - Request message
282 * @param[in] payload_length - Length of request message payload
283 * @param[out] transfer_handle - Handle to identify a BIOS table transfer
284 * @param[out] transfer_op_flag - Flag to indicate the start of a multipart
285 * transfer
286 * @param[out] table_type - BIOS table type
287 * @return pldm_completion_codes
288 */
289int decode_get_bios_table_req(const struct pldm_msg *msg, size_t payload_length,
290 uint32_t *transfer_handle,
291 uint8_t *transfer_op_flag, uint8_t *table_type);
292
Zahed Hossaind69af0b2019-07-30 01:33:31 -0500293/* GetBIOSAttributeCurrentValueByHandle */
294
295/** @brief Decode GetBIOSAttributeCurrentValueByHandle request packet
296 *
297 * @param[in] msg - Request message
298 * @param[in] payload_length - Length of request message payload
299 * @param[out] transfer_handle - Handle to identify a BIOS table transfer
300 * @param[out] transfer_op_flag - Flag to indicate the start of a multipart
301 * transfer
302 * @param[out] attribute_handle - Handle to identify the BIOS attribute
303 * @return pldm_completion_codes
304 */
305int decode_get_bios_attribute_current_value_by_handle_req(
306 const struct pldm_msg *msg, size_t payload_length,
307 uint32_t *transfer_handle, uint8_t *transfer_op_flag,
308 uint16_t *attribute_handle);
309
310/** @brief Create a PLDM response message for
311 * GetBIOSAttributeCurrentValueByHandle
312 *
313 * @param[in] instance_id - Message's instance id
314 * @param[in] completion_code - PLDM completion code
315 * @param[in] next_transfer_handle - handle to identify the next portion of the
316 * transfer
317 * @param[in] transfer_flag - To indicate what part of the transfer this
318 * response represents
319 * @param[in] attribute_data - contains current value of attribute
320 * @param[in] attribute_length - Length of attribute
321 * @param[out] msg - Message will be written to this
322 * @return pldm_completion_codes
323 */
324int encode_get_bios_current_value_by_handle_resp(
325 uint8_t instance_id, uint8_t completion_code, uint32_t next_transfer_handle,
326 uint8_t transfer_flag, const uint8_t *attribute_data,
327 size_t attribute_length, struct pldm_msg *msg);
328
John Wang4d844792019-08-15 15:51:40 +0800329/* SetBiosAttributeCurrentValue */
330
331/** @brief Decode SetBIOSAttributeCurrentValue request packet
332 *
333 * @param[in] msg - Request message
334 * @param[in] payload_length - Length of request message payload
335 * @param[out] transfer_handle - Handle to identify a BIOS table transfer
336 * @param[out] transfer_flag - Flag to indicate what part of the transfer
337 * this request represents
338 * @param[out] attribute_data - Contains current value of attribute
339 * @param[out] attribute_length - Pointer to length of attribute
340 * @return pldm_completion_codes
341 */
342int decode_set_bios_attribute_current_value_req(const struct pldm_msg *msg,
343 size_t payload_length,
344 uint32_t *transfer_handle,
345 uint8_t *transfer_flag,
346 uint8_t *attribute_data,
347 size_t *attribute_length);
348
349/** @brief Create a PLDM response message for SetBiosAttributeCurrentValue
350 *
351 * @param[in] instance_id - Message's instance id
352 * @param[in] completion_code - PLDM completion code
353 * @param[in] next_transfer_handle - handle to identify the next portion of the
354 * @param[out] msg - Message will be written to this
355 */
356int encode_set_bios_attribute_current_value_resp(uint8_t instance_id,
357 uint8_t completion_code,
358 uint32_t next_transfer_handle,
359 struct pldm_msg *msg);
360
Sampa Misra032bd502019-03-06 05:03:22 -0600361#ifdef __cplusplus
362}
363#endif
364
365#endif /* BIOS_H */