Sampa Misra | 032bd50 | 2019-03-06 05:03:22 -0600 | [diff] [blame] | 1 | #ifndef BIOS_H |
| 2 | #define BIOS_H |
| 3 | |
| 4 | #ifdef __cplusplus |
| 5 | extern "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 Misra | b37be31 | 2019-07-03 02:26:41 -0500 | [diff] [blame] | 17 | #define PLDM_GET_BIOS_TABLE_REQ_BYTES 6 |
| 18 | #define PLDM_GET_BIOS_TABLE_MIN_RESP_BYTES 6 |
John Wang | 4d84479 | 2019-08-15 15:51:40 +0800 | [diff] [blame] | 19 | #define PLDM_SET_BIOS_ATTR_CURR_VAL_MIN_REQ_BYTES 5 |
| 20 | #define PLDM_SET_BIOS_ATTR_CURR_VAL_RESP_BYTES 5 |
Zahed Hossain | d69af0b | 2019-07-30 01:33:31 -0500 | [diff] [blame] | 21 | #define PLDM_GET_BIOS_ATTR_CURR_VAL_BY_HANDLE_REQ_BYTES 7 |
Sampa Misra | b37be31 | 2019-07-03 02:26:41 -0500 | [diff] [blame] | 22 | |
| 23 | enum 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 | }; |
| 28 | enum pldm_bios_commands { |
| 29 | PLDM_GET_BIOS_TABLE = 0x01, |
John Wang | 4d84479 | 2019-08-15 15:51:40 +0800 | [diff] [blame] | 30 | PLDM_SET_BIOS_ATTRIBUTE_CURRENT_VALUE = 0x07, |
Zahed Hossain | d69af0b | 2019-07-30 01:33:31 -0500 | [diff] [blame] | 31 | PLDM_GET_BIOS_ATTRIBUTE_CURRENT_VALUE_BY_HANDLE = 0x08, |
| 32 | PLDM_GET_DATE_TIME = 0x0c, |
Sampa Misra | b37be31 | 2019-07-03 02:26:41 -0500 | [diff] [blame] | 33 | }; |
Sampa Misra | 032bd50 | 2019-03-06 05:03:22 -0600 | [diff] [blame] | 34 | |
Deepak Kodihalli | cb7f2d4 | 2019-06-19 13:25:31 +0530 | [diff] [blame] | 35 | enum pldm_bios_table_types { |
| 36 | PLDM_BIOS_STRING_TABLE, |
| 37 | PLDM_BIOS_ATTR_TABLE, |
| 38 | PLDM_BIOS_ATTR_VAL_TABLE, |
| 39 | }; |
| 40 | |
| 41 | struct pldm_bios_string_table_entry { |
| 42 | uint16_t string_handle; |
| 43 | uint16_t string_length; |
| 44 | char name[1]; |
| 45 | } __attribute__((packed)); |
| 46 | |
| 47 | struct 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 | |
| 54 | struct pldm_bios_enum_attr { |
| 55 | uint8_t num_possible_values; |
| 56 | uint16_t indices[1]; |
| 57 | } __attribute__((packed)); |
| 58 | |
| 59 | struct 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 Misra | b37be31 | 2019-07-03 02:26:41 -0500 | [diff] [blame] | 65 | enum 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 | */ |
| 80 | struct 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 | */ |
| 90 | struct 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 | |
Priyanga | 5dcd180 | 2019-06-10 01:50:39 -0500 | [diff] [blame] | 97 | /** @struct pldm_get_date_time_resp |
| 98 | * |
| 99 | * Structure representing PLDM get date time response |
| 100 | */ |
| 101 | struct 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 Hossain | d69af0b | 2019-07-30 01:33:31 -0500 | [diff] [blame] | 111 | /** @struct pldm_get_bios_attribute_current_value_by_handle_req |
| 112 | * |
| 113 | * structure representing GetBIOSAttributeCurrentValueByHandle request packet |
| 114 | */ |
| 115 | struct 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 | */ |
| 125 | struct 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 Wang | 4d84479 | 2019-08-15 15:51:40 +0800 | [diff] [blame] | 132 | /** @struct pldm_set_bios_attribute_current_value_req |
| 133 | * |
| 134 | * structure representing SetBiosAttributeCurrentValue request packet |
| 135 | * |
| 136 | */ |
| 137 | struct 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 | */ |
| 148 | struct pldm_set_bios_attribute_current_value_resp { |
| 149 | uint8_t completion_code; |
| 150 | uint32_t next_transfer_handle; |
| 151 | } __attribute__((packed)); |
| 152 | |
Sampa Misra | 032bd50 | 2019-03-06 05:03:22 -0600 | [diff] [blame] | 153 | /* 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 | |
| 166 | int encode_get_date_time_req(uint8_t instance_id, struct pldm_msg *msg); |
| 167 | |
| 168 | /** @brief Decode a GetDateTime response message |
| 169 | * |
Zahed Hossain | 223a73d | 2019-07-04 12:46:18 -0500 | [diff] [blame] | 170 | * @param[in] msg - Response message |
vkaverap | a6575b8 | 2019-04-03 05:33:52 -0500 | [diff] [blame] | 171 | * @param[in] payload_length - Length of response message payload |
Sampa Misra | 032bd50 | 2019-03-06 05:03:22 -0600 | [diff] [blame] | 172 | * @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 Hossain | 223a73d | 2019-07-04 12:46:18 -0500 | [diff] [blame] | 181 | int decode_get_date_time_resp(const struct pldm_msg *msg, size_t payload_length, |
Sampa Misra | 032bd50 | 2019-03-06 05:03:22 -0600 | [diff] [blame] | 182 | 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 Wang | 4d84479 | 2019-08-15 15:51:40 +0800 | [diff] [blame] | 186 | /* 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 | */ |
| 202 | int 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 | */ |
| 216 | int 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 Misra | 032bd50 | 2019-03-06 05:03:22 -0600 | [diff] [blame] | 220 | /* 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 | |
| 240 | int 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 Misra | b37be31 | 2019-07-03 02:26:41 -0500 | [diff] [blame] | 245 | /* 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 | */ |
| 260 | int 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 | |
| 265 | /** @brief Decode GetBIOSTable request packet |
| 266 | * |
| 267 | * @param[in] msg - Request message |
| 268 | * @param[in] payload_length - Length of request message payload |
| 269 | * @param[out] transfer_handle - Handle to identify a BIOS table transfer |
| 270 | * @param[out] transfer_op_flag - Flag to indicate the start of a multipart |
| 271 | * transfer |
| 272 | * @param[out] table_type - BIOS table type |
| 273 | * @return pldm_completion_codes |
| 274 | */ |
| 275 | int decode_get_bios_table_req(const struct pldm_msg *msg, size_t payload_length, |
| 276 | uint32_t *transfer_handle, |
| 277 | uint8_t *transfer_op_flag, uint8_t *table_type); |
| 278 | |
Zahed Hossain | d69af0b | 2019-07-30 01:33:31 -0500 | [diff] [blame] | 279 | /* GetBIOSAttributeCurrentValueByHandle */ |
| 280 | |
| 281 | /** @brief Decode GetBIOSAttributeCurrentValueByHandle request packet |
| 282 | * |
| 283 | * @param[in] msg - Request message |
| 284 | * @param[in] payload_length - Length of request message payload |
| 285 | * @param[out] transfer_handle - Handle to identify a BIOS table transfer |
| 286 | * @param[out] transfer_op_flag - Flag to indicate the start of a multipart |
| 287 | * transfer |
| 288 | * @param[out] attribute_handle - Handle to identify the BIOS attribute |
| 289 | * @return pldm_completion_codes |
| 290 | */ |
| 291 | int decode_get_bios_attribute_current_value_by_handle_req( |
| 292 | const struct pldm_msg *msg, size_t payload_length, |
| 293 | uint32_t *transfer_handle, uint8_t *transfer_op_flag, |
| 294 | uint16_t *attribute_handle); |
| 295 | |
| 296 | /** @brief Create a PLDM response message for |
| 297 | * GetBIOSAttributeCurrentValueByHandle |
| 298 | * |
| 299 | * @param[in] instance_id - Message's instance id |
| 300 | * @param[in] completion_code - PLDM completion code |
| 301 | * @param[in] next_transfer_handle - handle to identify the next portion of the |
| 302 | * transfer |
| 303 | * @param[in] transfer_flag - To indicate what part of the transfer this |
| 304 | * response represents |
| 305 | * @param[in] attribute_data - contains current value of attribute |
| 306 | * @param[in] attribute_length - Length of attribute |
| 307 | * @param[out] msg - Message will be written to this |
| 308 | * @return pldm_completion_codes |
| 309 | */ |
| 310 | int encode_get_bios_current_value_by_handle_resp( |
| 311 | uint8_t instance_id, uint8_t completion_code, uint32_t next_transfer_handle, |
| 312 | uint8_t transfer_flag, const uint8_t *attribute_data, |
| 313 | size_t attribute_length, struct pldm_msg *msg); |
| 314 | |
John Wang | 4d84479 | 2019-08-15 15:51:40 +0800 | [diff] [blame] | 315 | /* SetBiosAttributeCurrentValue */ |
| 316 | |
| 317 | /** @brief Decode SetBIOSAttributeCurrentValue request packet |
| 318 | * |
| 319 | * @param[in] msg - Request message |
| 320 | * @param[in] payload_length - Length of request message payload |
| 321 | * @param[out] transfer_handle - Handle to identify a BIOS table transfer |
| 322 | * @param[out] transfer_flag - Flag to indicate what part of the transfer |
| 323 | * this request represents |
| 324 | * @param[out] attribute_data - Contains current value of attribute |
| 325 | * @param[out] attribute_length - Pointer to length of attribute |
| 326 | * @return pldm_completion_codes |
| 327 | */ |
| 328 | int decode_set_bios_attribute_current_value_req(const struct pldm_msg *msg, |
| 329 | size_t payload_length, |
| 330 | uint32_t *transfer_handle, |
| 331 | uint8_t *transfer_flag, |
| 332 | uint8_t *attribute_data, |
| 333 | size_t *attribute_length); |
| 334 | |
| 335 | /** @brief Create a PLDM response message for SetBiosAttributeCurrentValue |
| 336 | * |
| 337 | * @param[in] instance_id - Message's instance id |
| 338 | * @param[in] completion_code - PLDM completion code |
| 339 | * @param[in] next_transfer_handle - handle to identify the next portion of the |
| 340 | * @param[out] msg - Message will be written to this |
| 341 | */ |
| 342 | int encode_set_bios_attribute_current_value_resp(uint8_t instance_id, |
| 343 | uint8_t completion_code, |
| 344 | uint32_t next_transfer_handle, |
| 345 | struct pldm_msg *msg); |
| 346 | |
Sampa Misra | 032bd50 | 2019-03-06 05:03:22 -0600 | [diff] [blame] | 347 | #ifdef __cplusplus |
| 348 | } |
| 349 | #endif |
| 350 | |
| 351 | #endif /* BIOS_H */ |