| #ifndef BIOS_H |
| #define BIOS_H |
| |
| #ifdef __cplusplus |
| extern "C" { |
| #endif |
| |
| #include <asm/byteorder.h> |
| #include <stddef.h> |
| #include <stdint.h> |
| |
| #include "base.h" |
| |
| /* Response lengths are inclusive of completion code */ |
| #define PLDM_GET_DATE_TIME_RESP_BYTES 8 |
| |
| #define PLDM_GET_BIOS_TABLE_REQ_BYTES 6 |
| #define PLDM_GET_BIOS_TABLE_MIN_RESP_BYTES 6 |
| |
| enum pldm_bios_completion_codes { |
| PLDM_BIOS_TABLE_UNAVAILABLE = 0x83, |
| PLDM_INVALID_BIOS_TABLE_DATA_INTEGRITY_CHECK = 0x84, |
| PLDM_INVALID_BIOS_TABLE_TYPE = 0x85, |
| }; |
| enum pldm_bios_commands { |
| PLDM_GET_BIOS_TABLE = 0x01, |
| PLDM_GET_DATE_TIME = 0x0c |
| }; |
| |
| enum pldm_bios_table_types { |
| PLDM_BIOS_STRING_TABLE, |
| PLDM_BIOS_ATTR_TABLE, |
| PLDM_BIOS_ATTR_VAL_TABLE, |
| }; |
| |
| struct pldm_bios_string_table_entry { |
| uint16_t string_handle; |
| uint16_t string_length; |
| char name[1]; |
| } __attribute__((packed)); |
| |
| struct pldm_bios_attr_table_entry { |
| uint16_t attr_handle; |
| uint8_t attr_type; |
| uint16_t string_handle; |
| uint8_t metadata[1]; |
| } __attribute__((packed)); |
| |
| struct pldm_bios_enum_attr { |
| uint8_t num_possible_values; |
| uint16_t indices[1]; |
| } __attribute__((packed)); |
| |
| struct pldm_bios_attr_val_table_entry { |
| uint16_t attr_handle; |
| uint8_t attr_type; |
| uint8_t value[1]; |
| } __attribute__((packed)); |
| |
| enum pldm_bios_attribute_type { |
| PLDM_BIOS_ENUMERATION = 0x0, |
| PLDM_BIOS_STRING = 0x1, |
| PLDM_BIOS_PASSWORD = 0x2, |
| PLDM_BIOS_INTEGER = 0x3, |
| PLDM_BIOS_ENUMERATION_READ_ONLY = 0x80, |
| PLDM_BIOS_STRING_READ_ONLY = 0x81, |
| PLDM_BIOS_PASSWORD_READ_ONLY = 0x82, |
| PLDM_BIOS_INTEGER_READ_ONLY = 0x83, |
| }; |
| |
| /** @struct pldm_get_bios_table_req |
| * |
| * structure representing GetBIOSTable request packet |
| */ |
| struct pldm_get_bios_table_req { |
| uint32_t transfer_handle; |
| uint8_t transfer_op_flag; |
| uint8_t table_type; |
| } __attribute__((packed)); |
| |
| /** @struct pldm_get_bios_table_resp |
| * |
| * structure representing GetBIOSTable response packet |
| */ |
| struct pldm_get_bios_table_resp { |
| uint8_t completion_code; |
| uint32_t next_transfer_handle; |
| uint8_t transfer_flag; |
| uint8_t table_data[1]; |
| } __attribute__((packed)); |
| |
| /** @struct pldm_get_date_time_resp |
| * |
| * Structure representing PLDM get date time response |
| */ |
| struct pldm_get_date_time_resp { |
| uint8_t completion_code; //!< completion code |
| uint8_t seconds; //!< Seconds in BCD format |
| uint8_t minutes; //!< Minutes in BCD format |
| uint8_t hours; //!< Hours in BCD format |
| uint8_t day; //!< Day of the month in BCD format |
| uint8_t month; //!< Month in BCD format |
| uint16_t year; //!< Year in BCD format |
| } __attribute__((packed)); |
| |
| /* Requester */ |
| |
| /* GetDateTime */ |
| |
| /** @brief Create a PLDM request message for GetDateTime |
| * |
| * @param[in] instance_id - Message's instance id |
| * @param[out] msg - Message will be written to this |
| * @return pldm_completion_codes |
| * @note Caller is responsible for memory alloc and dealloc of param |
| * 'msg.body.payload' |
| */ |
| |
| int encode_get_date_time_req(uint8_t instance_id, struct pldm_msg *msg); |
| |
| /** @brief Decode a GetDateTime response message |
| * |
| * @param[in] msg - Response message |
| * @param[in] payload_length - Length of response message payload |
| * @param[out] completion_code - Pointer to response msg's PLDM completion code |
| * @param[out] seconds - Seconds in BCD format |
| * @param[out] minutes - minutes in BCD format |
| * @param[out] hours - hours in BCD format |
| * @param[out] day - day of month in BCD format |
| * @param[out] month - number of month in BCD format |
| * @param[out] year - year in BCD format |
| * @return pldm_completion_codes |
| */ |
| int decode_get_date_time_resp(const struct pldm_msg *msg, size_t payload_length, |
| uint8_t *completion_code, uint8_t *seconds, |
| uint8_t *minutes, uint8_t *hours, uint8_t *day, |
| uint8_t *month, uint16_t *year); |
| |
| /* Responder */ |
| |
| /* GetDateTime */ |
| |
| /** @brief Create a PLDM response message for GetDateTime |
| * |
| * @param[in] instance_id - Message's instance id |
| * @param[in] completion_code - PLDM completion code |
| * @param[in] seconds - seconds in BCD format |
| * @param[in] minutes - minutes in BCD format |
| * @param[in] hours - hours in BCD format |
| * @param[in] day - day of the month in BCD format |
| * @param[in] month - number of month in BCD format |
| * @param[in] year - year in BCD format |
| * @param[out] msg - Message will be written to this |
| * @return pldm_completion_codes |
| * @note Caller is responsible for memory alloc and dealloc of param |
| * 'msg.body.payload' |
| */ |
| |
| int encode_get_date_time_resp(uint8_t instance_id, uint8_t completion_code, |
| uint8_t seconds, uint8_t minutes, uint8_t hours, |
| uint8_t day, uint8_t month, uint16_t year, |
| struct pldm_msg *msg); |
| |
| /* GetBIOSTable */ |
| |
| /** @brief Create a PLDM response message for GetBIOSTable |
| * |
| * @param[in] instance_id - Message's instance id |
| * @param[in] completion_code - PLDM completion code |
| * @param[in] next_transfer_handle - handle to identify the next portion of the |
| * transfer |
| * @param[in] transfer_flag - To indicate what part of the transfer this |
| * response represents |
| * @param[in] table_data - BIOS Table type specific data |
| * @param[in] payload_length - Length of payload message |
| * @param[out] msg - Message will be written to this |
| * @return pldm_completion_codes |
| */ |
| int encode_get_bios_table_resp(uint8_t instance_id, uint8_t completion_code, |
| uint32_t next_transfer_handle, |
| uint8_t transfer_flag, uint8_t *table_data, |
| size_t payload_length, struct pldm_msg *msg); |
| |
| /** @brief Decode GetBIOSTable request packet |
| * |
| * @param[in] msg - Request message |
| * @param[in] payload_length - Length of request message payload |
| * @param[out] transfer_handle - Handle to identify a BIOS table transfer |
| * @param[out] transfer_op_flag - Flag to indicate the start of a multipart |
| * transfer |
| * @param[out] table_type - BIOS table type |
| * @return pldm_completion_codes |
| */ |
| int decode_get_bios_table_req(const struct pldm_msg *msg, size_t payload_length, |
| uint32_t *transfer_handle, |
| uint8_t *transfer_op_flag, uint8_t *table_type); |
| |
| #ifdef __cplusplus |
| } |
| #endif |
| |
| #endif /* BIOS_H */ |