blob: 4d0b05206e62a2d33918c434a6cabd69539654bc [file] [log] [blame]
#ifndef FW_UPDATE_H
#define FW_UPDATE_H
#ifdef __cplusplus
extern "C" {
#endif
#include "base.h"
#define PLDM_QUERY_DEVICE_IDENTIFIERS_REQ_BYTES 0
/** @brief Minimum length of device descriptor, 2 bytes for descriptor type,
* 2 bytes for descriptor length and atleast 1 byte of descriptor data
*/
#define PLDM_FWUP_DEVICE_DESCRIPTOR_MIN_LEN 5
#define PLDM_GET_FIRMWARE_PARAMETERS_REQ_BYTES 0
/** @brief PLDM Firmware update commands
*/
enum pldm_firmware_update_commands {
PLDM_QUERY_DEVICE_IDENTIFIERS = 0x01,
PLDM_GET_FIRMWARE_PARAMETERS = 0x02
};
/** @struct pldm_query_device_identifiers_resp
*
* Structure representing query device identifiers response.
*/
struct pldm_query_device_identifiers_resp {
uint8_t completion_code;
uint32_t device_identifiers_len;
uint8_t descriptor_count;
} __attribute__((packed));
/** @brief Create a PLDM request message for QueryDeviceIdentifiers
*
* @param[in] instance_id - Message's instance id
* @param[in] payload_length - Length of the request message payload
* @param[in,out] msg - Message will be written to this
*
* @return pldm_completion_codes
*
* @note Caller is responsible for memory alloc and dealloc of param
* 'msg.payload'
*/
int encode_query_device_identifiers_req(uint8_t instance_id,
size_t payload_length,
struct pldm_msg *msg);
/** @brief Decode QueryDeviceIdentifiers 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] device_identifiers_len - Pointer to device identifiers length
* @param[out] descriptor_count - Pointer to descriptor count
* @param[out] descriptor_data - Pointer to descriptor data
*
* @return pldm_completion_codes
*/
int decode_query_device_identifiers_resp(const struct pldm_msg *msg,
size_t payload_length,
uint8_t *completion_code,
uint32_t *device_identifiers_len,
uint8_t *descriptor_count,
uint8_t **descriptor_data);
/** @brief Create a PLDM request message for GetFirmwareParameters
*
* @param[in] instance_id - Message's instance id
* @param[in] payload_length - Length of the request message payload
* @param[in,out] msg - Message will be written to this
*
* @return pldm_completion_codes
*
* @note Caller is responsible for memory alloc and dealloc of param
* 'msg.payload'
*/
int encode_get_firmware_parameters_req(uint8_t instance_id,
size_t payload_length,
struct pldm_msg *msg);
#ifdef __cplusplus
}
#endif
#endif // End of FW_UPDATE_H