blob: c018d079326285cd5d2634ed363857cd107d34ea [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
Zahed Hossaind69af0b2019-07-30 01:33:31 -050019#define PLDM_GET_BIOS_ATTR_CURR_VAL_BY_HANDLE_REQ_BYTES 7
Sampa Misrab37be312019-07-03 02:26:41 -050020
21enum pldm_bios_completion_codes {
22 PLDM_BIOS_TABLE_UNAVAILABLE = 0x83,
23 PLDM_INVALID_BIOS_TABLE_DATA_INTEGRITY_CHECK = 0x84,
24 PLDM_INVALID_BIOS_TABLE_TYPE = 0x85,
25};
26enum pldm_bios_commands {
27 PLDM_GET_BIOS_TABLE = 0x01,
Zahed Hossaind69af0b2019-07-30 01:33:31 -050028 PLDM_GET_BIOS_ATTRIBUTE_CURRENT_VALUE_BY_HANDLE = 0x08,
29 PLDM_GET_DATE_TIME = 0x0c,
Sampa Misrab37be312019-07-03 02:26:41 -050030};
Sampa Misra032bd502019-03-06 05:03:22 -060031
Deepak Kodihallicb7f2d42019-06-19 13:25:31 +053032enum pldm_bios_table_types {
33 PLDM_BIOS_STRING_TABLE,
34 PLDM_BIOS_ATTR_TABLE,
35 PLDM_BIOS_ATTR_VAL_TABLE,
36};
37
38struct pldm_bios_string_table_entry {
39 uint16_t string_handle;
40 uint16_t string_length;
41 char name[1];
42} __attribute__((packed));
43
44struct pldm_bios_attr_table_entry {
45 uint16_t attr_handle;
46 uint8_t attr_type;
47 uint16_t string_handle;
48 uint8_t metadata[1];
49} __attribute__((packed));
50
51struct pldm_bios_enum_attr {
52 uint8_t num_possible_values;
53 uint16_t indices[1];
54} __attribute__((packed));
55
56struct pldm_bios_attr_val_table_entry {
57 uint16_t attr_handle;
58 uint8_t attr_type;
59 uint8_t value[1];
60} __attribute__((packed));
61
Sampa Misrab37be312019-07-03 02:26:41 -050062enum pldm_bios_attribute_type {
63 PLDM_BIOS_ENUMERATION = 0x0,
64 PLDM_BIOS_STRING = 0x1,
65 PLDM_BIOS_PASSWORD = 0x2,
66 PLDM_BIOS_INTEGER = 0x3,
67 PLDM_BIOS_ENUMERATION_READ_ONLY = 0x80,
68 PLDM_BIOS_STRING_READ_ONLY = 0x81,
69 PLDM_BIOS_PASSWORD_READ_ONLY = 0x82,
70 PLDM_BIOS_INTEGER_READ_ONLY = 0x83,
71};
72
73/** @struct pldm_get_bios_table_req
74 *
75 * structure representing GetBIOSTable request packet
76 */
77struct pldm_get_bios_table_req {
78 uint32_t transfer_handle;
79 uint8_t transfer_op_flag;
80 uint8_t table_type;
81} __attribute__((packed));
82
83/** @struct pldm_get_bios_table_resp
84 *
85 * structure representing GetBIOSTable response packet
86 */
87struct pldm_get_bios_table_resp {
88 uint8_t completion_code;
89 uint32_t next_transfer_handle;
90 uint8_t transfer_flag;
91 uint8_t table_data[1];
92} __attribute__((packed));
93
Priyanga5dcd1802019-06-10 01:50:39 -050094/** @struct pldm_get_date_time_resp
95 *
96 * Structure representing PLDM get date time response
97 */
98struct pldm_get_date_time_resp {
99 uint8_t completion_code; //!< completion code
100 uint8_t seconds; //!< Seconds in BCD format
101 uint8_t minutes; //!< Minutes in BCD format
102 uint8_t hours; //!< Hours in BCD format
103 uint8_t day; //!< Day of the month in BCD format
104 uint8_t month; //!< Month in BCD format
105 uint16_t year; //!< Year in BCD format
106} __attribute__((packed));
107
Zahed Hossaind69af0b2019-07-30 01:33:31 -0500108/** @struct pldm_get_bios_attribute_current_value_by_handle_req
109 *
110 * structure representing GetBIOSAttributeCurrentValueByHandle request packet
111 */
112struct pldm_get_bios_attribute_current_value_by_handle_req {
113 uint32_t transfer_handle;
114 uint8_t transfer_op_flag;
115 uint16_t attribute_handle;
116} __attribute__((packed));
117
118/** @struct pldm_get_bios_attribute_current_value_by_handle_resp
119 *
120 * structure representing GetBIOSAttributeCurrentValueByHandle response
121 */
122struct pldm_get_bios_attribute_current_value_by_handle_resp {
123 uint8_t completion_code;
124 uint32_t next_transfer_handle;
125 uint8_t transfer_flag;
126 uint8_t attribute_data[1];
127} __attribute__((packed));
128
Sampa Misra032bd502019-03-06 05:03:22 -0600129/* Requester */
130
131/* GetDateTime */
132
133/** @brief Create a PLDM request message for GetDateTime
134 *
135 * @param[in] instance_id - Message's instance id
136 * @param[out] msg - Message will be written to this
137 * @return pldm_completion_codes
138 * @note Caller is responsible for memory alloc and dealloc of param
139 * 'msg.body.payload'
140 */
141
142int encode_get_date_time_req(uint8_t instance_id, struct pldm_msg *msg);
143
144/** @brief Decode a GetDateTime response message
145 *
Zahed Hossain223a73d2019-07-04 12:46:18 -0500146 * @param[in] msg - Response message
vkaverapa6575b82019-04-03 05:33:52 -0500147 * @param[in] payload_length - Length of response message payload
Sampa Misra032bd502019-03-06 05:03:22 -0600148 * @param[out] completion_code - Pointer to response msg's PLDM completion code
149 * @param[out] seconds - Seconds in BCD format
150 * @param[out] minutes - minutes in BCD format
151 * @param[out] hours - hours in BCD format
152 * @param[out] day - day of month in BCD format
153 * @param[out] month - number of month in BCD format
154 * @param[out] year - year in BCD format
155 * @return pldm_completion_codes
156 */
Zahed Hossain223a73d2019-07-04 12:46:18 -0500157int decode_get_date_time_resp(const struct pldm_msg *msg, size_t payload_length,
Sampa Misra032bd502019-03-06 05:03:22 -0600158 uint8_t *completion_code, uint8_t *seconds,
159 uint8_t *minutes, uint8_t *hours, uint8_t *day,
160 uint8_t *month, uint16_t *year);
161
162/* Responder */
163
164/* GetDateTime */
165
166/** @brief Create a PLDM response message for GetDateTime
167 *
168 * @param[in] instance_id - Message's instance id
169 * @param[in] completion_code - PLDM completion code
170 * @param[in] seconds - seconds in BCD format
171 * @param[in] minutes - minutes in BCD format
172 * @param[in] hours - hours in BCD format
173 * @param[in] day - day of the month in BCD format
174 * @param[in] month - number of month in BCD format
175 * @param[in] year - year in BCD format
176 * @param[out] msg - Message will be written to this
177 * @return pldm_completion_codes
178 * @note Caller is responsible for memory alloc and dealloc of param
179 * 'msg.body.payload'
180 */
181
182int encode_get_date_time_resp(uint8_t instance_id, uint8_t completion_code,
183 uint8_t seconds, uint8_t minutes, uint8_t hours,
184 uint8_t day, uint8_t month, uint16_t year,
185 struct pldm_msg *msg);
186
Sampa Misrab37be312019-07-03 02:26:41 -0500187/* GetBIOSTable */
188
189/** @brief Create a PLDM response message for GetBIOSTable
190 *
191 * @param[in] instance_id - Message's instance id
192 * @param[in] completion_code - PLDM completion code
193 * @param[in] next_transfer_handle - handle to identify the next portion of the
194 * transfer
195 * @param[in] transfer_flag - To indicate what part of the transfer this
196 * response represents
197 * @param[in] table_data - BIOS Table type specific data
198 * @param[in] payload_length - Length of payload message
199 * @param[out] msg - Message will be written to this
200 * @return pldm_completion_codes
201 */
202int encode_get_bios_table_resp(uint8_t instance_id, uint8_t completion_code,
203 uint32_t next_transfer_handle,
204 uint8_t transfer_flag, uint8_t *table_data,
205 size_t payload_length, struct pldm_msg *msg);
206
207/** @brief Decode GetBIOSTable request packet
208 *
209 * @param[in] msg - Request message
210 * @param[in] payload_length - Length of request message payload
211 * @param[out] transfer_handle - Handle to identify a BIOS table transfer
212 * @param[out] transfer_op_flag - Flag to indicate the start of a multipart
213 * transfer
214 * @param[out] table_type - BIOS table type
215 * @return pldm_completion_codes
216 */
217int decode_get_bios_table_req(const struct pldm_msg *msg, size_t payload_length,
218 uint32_t *transfer_handle,
219 uint8_t *transfer_op_flag, uint8_t *table_type);
220
Zahed Hossaind69af0b2019-07-30 01:33:31 -0500221/* GetBIOSAttributeCurrentValueByHandle */
222
223/** @brief Decode GetBIOSAttributeCurrentValueByHandle request packet
224 *
225 * @param[in] msg - Request message
226 * @param[in] payload_length - Length of request message payload
227 * @param[out] transfer_handle - Handle to identify a BIOS table transfer
228 * @param[out] transfer_op_flag - Flag to indicate the start of a multipart
229 * transfer
230 * @param[out] attribute_handle - Handle to identify the BIOS attribute
231 * @return pldm_completion_codes
232 */
233int decode_get_bios_attribute_current_value_by_handle_req(
234 const struct pldm_msg *msg, size_t payload_length,
235 uint32_t *transfer_handle, uint8_t *transfer_op_flag,
236 uint16_t *attribute_handle);
237
238/** @brief Create a PLDM response message for
239 * GetBIOSAttributeCurrentValueByHandle
240 *
241 * @param[in] instance_id - Message's instance id
242 * @param[in] completion_code - PLDM completion code
243 * @param[in] next_transfer_handle - handle to identify the next portion of the
244 * transfer
245 * @param[in] transfer_flag - To indicate what part of the transfer this
246 * response represents
247 * @param[in] attribute_data - contains current value of attribute
248 * @param[in] attribute_length - Length of attribute
249 * @param[out] msg - Message will be written to this
250 * @return pldm_completion_codes
251 */
252int encode_get_bios_current_value_by_handle_resp(
253 uint8_t instance_id, uint8_t completion_code, uint32_t next_transfer_handle,
254 uint8_t transfer_flag, const uint8_t *attribute_data,
255 size_t attribute_length, struct pldm_msg *msg);
256
Sampa Misra032bd502019-03-06 05:03:22 -0600257#ifdef __cplusplus
258}
259#endif
260
261#endif /* BIOS_H */