Patrick Williams | 70a47ba | 2021-09-02 09:53:31 -0500 | [diff] [blame] | 1 | #ifndef FW_UPDATE_H |
| 2 | #define FW_UPDATE_H |
| 3 | |
| 4 | #ifdef __cplusplus |
| 5 | extern "C" { |
| 6 | #endif |
| 7 | #include "base.h" |
| 8 | #include "stdbool.h" |
| 9 | #include "utils.h" |
| 10 | |
| 11 | #define PLDM_FWUP_COMPONENT_BITMAP_MULTIPLE 8 |
| 12 | #define PLDM_FWUP_INVALID_COMPONENT_COMPARISON_TIMESTAMP 0xFFFFFFFF |
| 13 | #define PLDM_QUERY_DEVICE_IDENTIFIERS_REQ_BYTES 0 |
| 14 | /** @brief Minimum length of device descriptor, 2 bytes for descriptor type, |
| 15 | * 2 bytes for descriptor length and atleast 1 byte of descriptor data |
| 16 | */ |
| 17 | #define PLDM_FWUP_DEVICE_DESCRIPTOR_MIN_LEN 5 |
| 18 | #define PLDM_GET_FIRMWARE_PARAMETERS_REQ_BYTES 0 |
| 19 | #define PLDM_FWUP_BASELINE_TRANSFER_SIZE 32 |
| 20 | #define PLDM_FWUP_MIN_OUTSTANDING_REQ 1 |
| 21 | #define PLDM_GET_STATUS_REQ_BYTES 0 |
| 22 | /* Maximum progress percentage value*/ |
| 23 | #define PLDM_FWUP_MAX_PROGRESS_PERCENT 0x65 |
| 24 | #define PLDM_CANCEL_UPDATE_COMPONENT_REQ_BYTES 0 |
| 25 | #define PLDM_CANCEL_UPDATE_REQ_BYTES 0 |
| 26 | |
| 27 | /** @brief PLDM Firmware update commands |
| 28 | */ |
| 29 | enum pldm_firmware_update_commands { |
| 30 | PLDM_QUERY_DEVICE_IDENTIFIERS = 0x01, |
| 31 | PLDM_GET_FIRMWARE_PARAMETERS = 0x02, |
| 32 | PLDM_REQUEST_UPDATE = 0x10, |
| 33 | PLDM_PASS_COMPONENT_TABLE = 0x13, |
| 34 | PLDM_UPDATE_COMPONENT = 0x14, |
| 35 | PLDM_REQUEST_FIRMWARE_DATA = 0x15, |
| 36 | PLDM_TRANSFER_COMPLETE = 0x16, |
| 37 | PLDM_VERIFY_COMPLETE = 0x17, |
| 38 | PLDM_APPLY_COMPLETE = 0x18, |
| 39 | PLDM_ACTIVATE_FIRMWARE = 0x1A, |
| 40 | PLDM_GET_STATUS = 0x1B, |
| 41 | PLDM_CANCEL_UPDATE_COMPONENT = 0x1C, |
| 42 | PLDM_CANCEL_UPDATE = 0x1D |
| 43 | }; |
| 44 | |
| 45 | /** @brief PLDM Firmware update completion codes |
| 46 | */ |
| 47 | enum pldm_firmware_update_completion_codes { |
| 48 | PLDM_FWUP_NOT_IN_UPDATE_MODE = 0x80, |
| 49 | PLDM_FWUP_ALREADY_IN_UPDATE_MODE = 0x81, |
| 50 | PLDM_FWUP_DATA_OUT_OF_RANGE = 0x82, |
| 51 | PLDM_FWUP_INVALID_TRANSFER_LENGTH = 0x83, |
| 52 | PLDM_FWUP_INVALID_STATE_FOR_COMMAND = 0x84, |
| 53 | PLDM_FWUP_INCOMPLETE_UPDATE = 0x85, |
| 54 | PLDM_FWUP_BUSY_IN_BACKGROUND = 0x86, |
| 55 | PLDM_FWUP_CANCEL_PENDING = 0x87, |
Tom Joseph | e5bbe0d | 2021-09-03 17:44:54 +0530 | [diff] [blame] | 56 | PLDM_FWUP_COMMAND_NOT_EXPECTED = 0x88, |
Patrick Williams | 70a47ba | 2021-09-02 09:53:31 -0500 | [diff] [blame] | 57 | PLDM_FWUP_RETRY_REQUEST_FW_DATA = 0x89, |
| 58 | PLDM_FWUP_UNABLE_TO_INITIATE_UPDATE = 0x8A, |
| 59 | PLDM_FWUP_ACTIVATION_NOT_REQUIRED = 0x8B, |
| 60 | PLDM_FWUP_SELF_CONTAINED_ACTIVATION_NOT_PERMITTED = 0x8C, |
| 61 | PLDM_FWUP_NO_DEVICE_METADATA = 0x8D, |
| 62 | PLDM_FWUP_RETRY_REQUEST_UPDATE = 0x8E, |
| 63 | PLDM_FWUP_NO_PACKAGE_DATA = 0x8F, |
| 64 | PLDM_FWUP_INVALID_TRANSFER_HANDLE = 0x90, |
| 65 | PLDM_FWUP_INVALID_TRANSFER_OPERATION_FLAG = 0x91, |
| 66 | PLDM_FWUP_ACTIVATE_PENDING_IMAGE_NOT_PERMITTED = 0x92, |
| 67 | PLDM_FWUP_PACKAGE_DATA_ERROR = 0x93 |
| 68 | }; |
| 69 | |
| 70 | /** @brief String type values defined in the PLDM firmware update specification |
| 71 | */ |
| 72 | enum pldm_firmware_update_string_type { |
| 73 | PLDM_STR_TYPE_UNKNOWN = 0, |
| 74 | PLDM_STR_TYPE_ASCII = 1, |
| 75 | PLDM_STR_TYPE_UTF_8 = 2, |
| 76 | PLDM_STR_TYPE_UTF_16 = 3, |
| 77 | PLDM_STR_TYPE_UTF_16LE = 4, |
| 78 | PLDM_STR_TYPE_UTF_16BE = 5 |
| 79 | }; |
| 80 | |
| 81 | /** @brief Descriptor types defined in PLDM firmware update specification |
| 82 | */ |
| 83 | enum pldm_firmware_update_descriptor_types { |
| 84 | PLDM_FWUP_PCI_VENDOR_ID = 0x0000, |
| 85 | PLDM_FWUP_IANA_ENTERPRISE_ID = 0x0001, |
| 86 | PLDM_FWUP_UUID = 0x0002, |
| 87 | PLDM_FWUP_PNP_VENDOR_ID = 0x0003, |
| 88 | PLDM_FWUP_ACPI_VENDOR_ID = 0x0004, |
| 89 | PLDM_FWUP_IEEE_ASSIGNED_COMPANY_ID = 0x0005, |
| 90 | PLDM_FWUP_SCSI_VENDOR_ID = 0x0006, |
| 91 | PLDM_FWUP_PCI_DEVICE_ID = 0x0100, |
| 92 | PLDM_FWUP_PCI_SUBSYSTEM_VENDOR_ID = 0x0101, |
| 93 | PLDM_FWUP_PCI_SUBSYSTEM_ID = 0x0102, |
| 94 | PLDM_FWUP_PCI_REVISION_ID = 0x0103, |
| 95 | PLDM_FWUP_PNP_PRODUCT_IDENTIFIER = 0x0104, |
| 96 | PLDM_FWUP_ACPI_PRODUCT_IDENTIFIER = 0x0105, |
| 97 | PLDM_FWUP_ASCII_MODEL_NUMBER_LONG_STRING = 0x0106, |
| 98 | PLDM_FWUP_ASCII_MODEL_NUMBER_SHORT_STRING = 0x0107, |
| 99 | PLDM_FWUP_SCSI_PRODUCT_ID = 0x0108, |
| 100 | PLDM_FWUP_UBM_CONTROLLER_DEVICE_CODE = 0x0109, |
| 101 | PLDM_FWUP_VENDOR_DEFINED = 0xFFFF |
| 102 | }; |
| 103 | |
| 104 | /** @brief Descriptor types length defined in PLDM firmware update specification |
| 105 | */ |
| 106 | enum pldm_firmware_update_descriptor_types_length { |
| 107 | PLDM_FWUP_PCI_VENDOR_ID_LENGTH = 2, |
| 108 | PLDM_FWUP_IANA_ENTERPRISE_ID_LENGTH = 4, |
| 109 | PLDM_FWUP_UUID_LENGTH = 16, |
| 110 | PLDM_FWUP_PNP_VENDOR_ID_LENGTH = 3, |
| 111 | PLDM_FWUP_ACPI_VENDOR_ID_LENGTH = 4, |
| 112 | PLDM_FWUP_IEEE_ASSIGNED_COMPANY_ID_LENGTH = 3, |
| 113 | PLDM_FWUP_SCSI_VENDOR_ID_LENGTH = 8, |
| 114 | PLDM_FWUP_PCI_DEVICE_ID_LENGTH = 2, |
| 115 | PLDM_FWUP_PCI_SUBSYSTEM_VENDOR_ID_LENGTH = 2, |
| 116 | PLDM_FWUP_PCI_SUBSYSTEM_ID_LENGTH = 2, |
| 117 | PLDM_FWUP_PCI_REVISION_ID_LENGTH = 1, |
| 118 | PLDM_FWUP_PNP_PRODUCT_IDENTIFIER_LENGTH = 4, |
| 119 | PLDM_FWUP_ACPI_PRODUCT_IDENTIFIER_LENGTH = 4, |
| 120 | PLDM_FWUP_ASCII_MODEL_NUMBER_LONG_STRING_LENGTH = 40, |
| 121 | PLDM_FWUP_ASCII_MODEL_NUMBER_SHORT_STRING_LENGTH = 10, |
| 122 | PLDM_FWUP_SCSI_PRODUCT_ID_LENGTH = 16, |
| 123 | PLDM_FWUP_UBM_CONTROLLER_DEVICE_CODE_LENGTH = 4 |
| 124 | }; |
| 125 | |
| 126 | /** @brief ComponentClassification values defined in firmware update |
| 127 | * specification |
| 128 | */ |
| 129 | enum pldm_component_classification_values { |
| 130 | PLDM_COMP_UNKNOWN = 0x0000, |
| 131 | PLDM_COMP_OTHER = 0x0001, |
| 132 | PLDM_COMP_DRIVER = 0x0002, |
| 133 | PLDM_COMP_CONFIGURATION_SOFTWARE = 0x0003, |
| 134 | PLDM_COMP_APPLICATION_SOFTWARE = 0x0004, |
| 135 | PLDM_COMP_INSTRUMENTATION = 0x0005, |
| 136 | PLDM_COMP_FIRMWARE_OR_BIOS = 0x0006, |
| 137 | PLDM_COMP_DIAGNOSTIC_SOFTWARE = 0x0007, |
| 138 | PLDM_COMP_OPERATING_SYSTEM = 0x0008, |
| 139 | PLDM_COMP_MIDDLEWARE = 0x0009, |
| 140 | PLDM_COMP_FIRMWARE = 0x000A, |
| 141 | PLDM_COMP_BIOS_OR_FCODE = 0x000B, |
| 142 | PLDM_COMP_SUPPORT_OR_SERVICEPACK = 0x000C, |
| 143 | PLDM_COMP_SOFTWARE_BUNDLE = 0x000D, |
| 144 | PLDM_COMP_DOWNSTREAM_DEVICE = 0xFFFF |
| 145 | }; |
| 146 | |
| 147 | /** @brief ComponentActivationMethods is the bit position in the bitfield that |
| 148 | * provides the capability of the FD for firmware activation. Multiple |
| 149 | * activation methods can be supported. |
| 150 | */ |
| 151 | enum pldm_comp_activation_methods { |
| 152 | PLDM_ACTIVATION_AUTOMATIC = 0, |
| 153 | PLDM_ACTIVATION_SELF_CONTAINED = 1, |
| 154 | PLDM_ACTIVATION_MEDIUM_SPECIFIC_RESET = 2, |
| 155 | PLDM_ACTIVATION_SYSTEM_REBOOT = 3, |
| 156 | PLDM_ACTIVATION_DC_POWER_CYCLE = 4, |
| 157 | PLDM_ACTIVATION_AC_POWER_CYCLE = 5, |
| 158 | PLDM_SUPPORTS_ACTIVATE_PENDING_IMAGE = 6, |
| 159 | PLDM_SUPPORTS_ACTIVATE_PENDING_IMAGE_SET = 7 |
| 160 | }; |
| 161 | |
| 162 | /** @brief ComponentResponse values in the response of PassComponentTable |
| 163 | */ |
| 164 | enum pldm_component_responses { |
| 165 | PLDM_CR_COMP_CAN_BE_UPDATED = 0, |
| 166 | PLDM_CR_COMP_MAY_BE_UPDATEABLE = 1 |
| 167 | }; |
| 168 | |
| 169 | /** @brief ComponentResponseCode values in the response of PassComponentTable |
| 170 | */ |
| 171 | enum pldm_component_response_codes { |
| 172 | PLDM_CRC_COMP_CAN_BE_UPDATED = 0x00, |
| 173 | PLDM_CRC_COMP_COMPARISON_STAMP_IDENTICAL = 0x01, |
| 174 | PLDM_CRC_COMP_COMPARISON_STAMP_LOWER = 0x02, |
| 175 | PLDM_CRC_INVALID_COMP_COMPARISON_STAMP = 0x03, |
| 176 | PLDM_CRC_COMP_CONFLICT = 0x04, |
| 177 | PLDM_CRC_COMP_PREREQUISITES_NOT_MET = 0x05, |
| 178 | PLDM_CRC_COMP_NOT_SUPPORTED = 0x06, |
| 179 | PLDM_CRC_COMP_SECURITY_RESTRICTIONS = 0x07, |
| 180 | PLDM_CRC_INCOMPLETE_COMP_IMAGE_SET = 0x08, |
| 181 | PLDM_CRC_ACTIVE_IMAGE_NOT_UPDATEABLE_SUBSEQUENTLY = 0x09, |
| 182 | PLDM_CRC_COMP_VER_STR_IDENTICAL = 0x0A, |
| 183 | PLDM_CRC_COMP_VER_STR_LOWER = 0x0B, |
| 184 | PLDM_CRC_VENDOR_COMP_RESP_CODE_RANGE_MIN = 0xD0, |
| 185 | PLDM_CRC_VENDOR_COMP_RESP_CODE_RANGE_MAX = 0xEF |
| 186 | }; |
| 187 | |
| 188 | /** @brief ComponentCompatibilityResponse values in the response of |
| 189 | * UpdateComponent |
| 190 | */ |
| 191 | enum pldm_component_compatability_responses { |
| 192 | PLDM_CCR_COMP_CAN_BE_UPDATED = 0, |
| 193 | PLDM_CCR_COMP_CANNOT_BE_UPDATED = 1 |
| 194 | }; |
| 195 | |
| 196 | /** @brief ComponentCompatibilityResponse Code values in the response of |
| 197 | * UpdateComponent |
| 198 | */ |
| 199 | enum pldm_component_compatability_response_codes { |
| 200 | PLDM_CCRC_NO_RESPONSE_CODE = 0x00, |
| 201 | PLDM_CCRC_COMP_COMPARISON_STAMP_IDENTICAL = 0x01, |
| 202 | PLDM_CCRC_COMP_COMPARISON_STAMP_LOWER = 0x02, |
| 203 | PLDM_CCRC_INVALID_COMP_COMPARISON_STAMP = 0x03, |
| 204 | PLDM_CCRC_COMP_CONFLICT = 0x04, |
| 205 | PLDM_CCRC_COMP_PREREQUISITES_NOT_MET = 0x05, |
| 206 | PLDM_CCRC_COMP_NOT_SUPPORTED = 0x06, |
| 207 | PLDM_CCRC_COMP_SECURITY_RESTRICTIONS = 0x07, |
| 208 | PLDM_CCRC_INCOMPLETE_COMP_IMAGE_SET = 0x08, |
| 209 | PLDM_CCRC_COMP_INFO_NO_MATCH = 0x09, |
| 210 | PLDM_CCRC_COMP_VER_STR_IDENTICAL = 0x0A, |
| 211 | PLDM_CCRC_COMP_VER_STR_LOWER = 0x0B, |
| 212 | PLDM_CCRC_VENDOR_COMP_RESP_CODE_RANGE_MIN = 0xD0, |
| 213 | PLDM_CCRC_VENDOR_COMP_RESP_CODE_RANGE_MAX = 0xEF |
| 214 | }; |
| 215 | |
| 216 | /** @brief Common error codes in TransferComplete, VerifyComplete and |
| 217 | * ApplyComplete request |
| 218 | */ |
| 219 | enum pldm_firmware_update_common_error_codes { |
| 220 | PLDM_FWUP_TIME_OUT = 0x09, |
| 221 | PLDM_FWUP_GENERIC_ERROR = 0x0A |
| 222 | }; |
| 223 | |
| 224 | /** @brief TransferResult values in the request of TransferComplete |
| 225 | */ |
| 226 | enum pldm_firmware_update_transfer_result_values { |
| 227 | PLDM_FWUP_TRANSFER_SUCCESS = 0x00, |
| 228 | PLDM_FWUP_TRANSFER_ERROR_IMAGE_CORRUPT = 0x02, |
| 229 | PLDM_FWUP_TRANSFER_ERROR_VERSION_MISMATCH = 0x02, |
| 230 | PLDM_FWUP_FD_ABORTED_TRANSFER = 0x03, |
| 231 | PLDM_FWUP_FD_ABORTED_TRANSFER_LOW_POWER_STATE = 0x0B, |
| 232 | PLDM_FWUP_FD_ABORTED_TRANSFER_RESET_NEEDED = 0x0C, |
| 233 | PLDM_FWUP_FD_ABORTED_TRANSFER_STORAGE_ISSUE = 0x0D, |
| 234 | PLDM_FWUP_VENDOR_TRANSFER_RESULT_RANGE_MIN = 0x70, |
| 235 | PLDM_FWUP_VENDOR_TRANSFER_RESULT_RANGE_MAX = 0x8F |
| 236 | }; |
| 237 | |
| 238 | /**@brief VerifyResult values in the request of VerifyComplete |
| 239 | */ |
| 240 | enum pldm_firmware_update_verify_result_values { |
| 241 | PLDM_FWUP_VERIFY_SUCCESS = 0x00, |
| 242 | PLDM_FWUP_VERIFY_ERROR_VERIFICATION_FAILURE = 0x01, |
| 243 | PLDM_FWUP_VERIFY_ERROR_VERSION_MISMATCH = 0x02, |
| 244 | PLDM_FWUP_VERIFY_FAILED_FD_SECURITY_CHECKS = 0x03, |
| 245 | PLDM_FWUP_VERIFY_ERROR_IMAGE_INCOMPLETE = 0x04, |
| 246 | PLDM_FWUP_VENDOR_VERIFY_RESULT_RANGE_MIN = 0x90, |
| 247 | PLDM_FWUP_VENDOR_VERIFY_RESULT_RANGE_MAX = 0xAF |
| 248 | }; |
| 249 | |
| 250 | /**@brief ApplyResult values in the request of ApplyComplete |
| 251 | */ |
| 252 | enum pldm_firmware_update_apply_result_values { |
| 253 | PLDM_FWUP_APPLY_SUCCESS = 0x00, |
| 254 | PLDM_FWUP_APPLY_SUCCESS_WITH_ACTIVATION_METHOD = 0x01, |
| 255 | PLDM_FWUP_APPLY_FAILURE_MEMORY_ISSUE = 0x02, |
| 256 | PLDM_FWUP_VENDOR_APPLY_RESULT_RANGE_MIN = 0xB0, |
| 257 | PLDM_FWUP_VENDOR_APPLY_RESULT_RANGE_MAX = 0xCF |
| 258 | }; |
| 259 | |
| 260 | /** @brief SelfContainedActivationRequest in the request of ActivateFirmware |
| 261 | */ |
| 262 | enum pldm_self_contained_activation_req { |
| 263 | PLDM_NOT_ACTIVATE_SELF_CONTAINED_COMPONENTS = false, |
| 264 | PLDM_ACTIVATE_SELF_CONTAINED_COMPONENTS = true |
| 265 | }; |
| 266 | |
| 267 | /** @brief Current state/previous state of the FD or FDP returned in GetStatus |
| 268 | * response |
| 269 | */ |
| 270 | enum pldm_firmware_device_states { |
| 271 | PLDM_FD_STATE_IDLE = 0, |
| 272 | PLDM_FD_STATE_LEARN_COMPONENTS = 1, |
| 273 | PLDM_FD_STATE_READY_XFER = 2, |
| 274 | PLDM_FD_STATE_DOWNLOAD = 3, |
| 275 | PLDM_FD_STATE_VERIFY = 4, |
| 276 | PLDM_FD_STATE_APPLY = 5, |
| 277 | PLDM_FD_STATE_ACTIVATE = 6 |
| 278 | }; |
| 279 | |
| 280 | /** @brief Firmware device aux state in GetStatus response |
| 281 | */ |
| 282 | enum pldm_get_status_aux_states { |
| 283 | PLDM_FD_OPERATION_IN_PROGRESS = 0, |
| 284 | PLDM_FD_OPERATION_SUCCESSFUL = 1, |
| 285 | PLDM_FD_OPERATION_FAILED = 2, |
| 286 | PLDM_FD_IDLE_LEARN_COMPONENTS_READ_XFER = 3 |
| 287 | }; |
| 288 | |
| 289 | /** @brief Firmware device aux state status in GetStatus response |
| 290 | */ |
| 291 | enum pldm_get_status_aux_state_status_values { |
| 292 | PLDM_FD_AUX_STATE_IN_PROGRESS_OR_SUCCESS = 0x00, |
| 293 | PLDM_FD_TIMEOUT = 0x09, |
| 294 | PLDM_FD_GENERIC_ERROR = 0x0A, |
| 295 | PLDM_FD_VENDOR_DEFINED_STATUS_CODE_START = 0x70, |
| 296 | PLDM_FD_VENDOR_DEFINED_STATUS_CODE_END = 0xEF |
| 297 | }; |
| 298 | |
| 299 | /** @brief Firmware device reason code in GetStatus response |
| 300 | */ |
| 301 | enum pldm_get_status_reason_code_values { |
| 302 | PLDM_FD_INITIALIZATION = 0, |
| 303 | PLDM_FD_ACTIVATE_FW = 1, |
| 304 | PLDM_FD_CANCEL_UPDATE = 2, |
| 305 | PLDM_FD_TIMEOUT_LEARN_COMPONENT = 3, |
| 306 | PLDM_FD_TIMEOUT_READY_XFER = 4, |
| 307 | PLDM_FD_TIMEOUT_DOWNLOAD = 5, |
| 308 | PLDM_FD_TIMEOUT_VERIFY = 6, |
| 309 | PLDM_FD_TIMEOUT_APPLY = 7, |
| 310 | PLDM_FD_STATUS_VENDOR_DEFINED_MIN = 200, |
| 311 | PLDM_FD_STATUS_VENDOR_DEFINED_MAX = 255 |
| 312 | }; |
| 313 | |
| 314 | /** @brief Components functional indicator in CancelUpdate response |
| 315 | */ |
| 316 | enum pldm_firmware_update_non_functioning_component_indication { |
| 317 | PLDM_FWUP_COMPONENTS_FUNCTIONING = 0, |
| 318 | PLDM_FWUP_COMPONENTS_NOT_FUNCTIONING = 1 |
| 319 | }; |
| 320 | |
| 321 | /** @struct pldm_package_header_information |
| 322 | * |
| 323 | * Structure representing fixed part of package header information |
| 324 | */ |
| 325 | struct pldm_package_header_information { |
| 326 | uint8_t uuid[PLDM_FWUP_UUID_LENGTH]; |
| 327 | uint8_t package_header_format_version; |
| 328 | uint16_t package_header_size; |
| 329 | uint8_t timestamp104[PLDM_TIMESTAMP104_SIZE]; |
| 330 | uint16_t component_bitmap_bit_length; |
| 331 | uint8_t package_version_string_type; |
| 332 | uint8_t package_version_string_length; |
| 333 | } __attribute__((packed)); |
| 334 | |
| 335 | /** @struct pldm_firmware_device_id_record |
| 336 | * |
| 337 | * Structure representing firmware device ID record |
| 338 | */ |
| 339 | struct pldm_firmware_device_id_record { |
| 340 | uint16_t record_length; |
| 341 | uint8_t descriptor_count; |
| 342 | bitfield32_t device_update_option_flags; |
| 343 | uint8_t comp_image_set_version_string_type; |
| 344 | uint8_t comp_image_set_version_string_length; |
| 345 | uint16_t fw_device_pkg_data_length; |
| 346 | } __attribute__((packed)); |
| 347 | |
| 348 | /** @struct pldm_descriptor_tlv |
| 349 | * |
| 350 | * Structure representing descriptor type, length and value |
| 351 | */ |
| 352 | struct pldm_descriptor_tlv { |
| 353 | uint16_t descriptor_type; |
| 354 | uint16_t descriptor_length; |
| 355 | uint8_t descriptor_data[1]; |
| 356 | } __attribute__((packed)); |
| 357 | |
| 358 | /** @struct pldm_vendor_defined_descriptor_title_data |
| 359 | * |
| 360 | * Structure representing vendor defined descriptor title sections |
| 361 | */ |
| 362 | struct pldm_vendor_defined_descriptor_title_data { |
| 363 | uint8_t vendor_defined_descriptor_title_str_type; |
| 364 | uint8_t vendor_defined_descriptor_title_str_len; |
| 365 | uint8_t vendor_defined_descriptor_title_str[1]; |
| 366 | } __attribute__((packed)); |
| 367 | |
| 368 | /** @struct pldm_component_image_information |
| 369 | * |
| 370 | * Structure representing fixed part of individual component information in |
| 371 | * PLDM firmware update package |
| 372 | */ |
| 373 | struct pldm_component_image_information { |
| 374 | uint16_t comp_classification; |
| 375 | uint16_t comp_identifier; |
| 376 | uint32_t comp_comparison_stamp; |
| 377 | bitfield16_t comp_options; |
| 378 | bitfield16_t requested_comp_activation_method; |
| 379 | uint32_t comp_location_offset; |
| 380 | uint32_t comp_size; |
| 381 | uint8_t comp_version_string_type; |
| 382 | uint8_t comp_version_string_length; |
| 383 | } __attribute__((packed)); |
| 384 | |
| 385 | /** @struct pldm_query_device_identifiers_resp |
| 386 | * |
| 387 | * Structure representing query device identifiers response. |
| 388 | */ |
| 389 | struct pldm_query_device_identifiers_resp { |
| 390 | uint8_t completion_code; |
| 391 | uint32_t device_identifiers_len; |
| 392 | uint8_t descriptor_count; |
| 393 | } __attribute__((packed)); |
| 394 | |
| 395 | /** @struct pldm_get_firmware_parameters_resp |
| 396 | * |
| 397 | * Structure representing the fixed part of GetFirmwareParameters response |
| 398 | */ |
| 399 | struct pldm_get_firmware_parameters_resp { |
| 400 | uint8_t completion_code; |
| 401 | bitfield32_t capabilities_during_update; |
| 402 | uint16_t comp_count; |
| 403 | uint8_t active_comp_image_set_ver_str_type; |
| 404 | uint8_t active_comp_image_set_ver_str_len; |
| 405 | uint8_t pending_comp_image_set_ver_str_type; |
| 406 | uint8_t pending_comp_image_set_ver_str_len; |
| 407 | } __attribute__((packed)); |
| 408 | |
| 409 | /** @struct pldm_component_parameter_entry |
| 410 | * |
| 411 | * Structure representing component parameter table entry. |
| 412 | */ |
| 413 | struct pldm_component_parameter_entry { |
| 414 | uint16_t comp_classification; |
| 415 | uint16_t comp_identifier; |
| 416 | uint8_t comp_classification_index; |
| 417 | uint32_t active_comp_comparison_stamp; |
| 418 | uint8_t active_comp_ver_str_type; |
| 419 | uint8_t active_comp_ver_str_len; |
| 420 | uint8_t active_comp_release_date[8]; |
| 421 | uint32_t pending_comp_comparison_stamp; |
| 422 | uint8_t pending_comp_ver_str_type; |
| 423 | uint8_t pending_comp_ver_str_len; |
| 424 | uint8_t pending_comp_release_date[8]; |
| 425 | bitfield16_t comp_activation_methods; |
| 426 | bitfield32_t capabilities_during_update; |
| 427 | } __attribute__((packed)); |
| 428 | |
| 429 | /** @struct pldm_request_update_req |
| 430 | * |
| 431 | * Structure representing fixed part of Request Update request |
| 432 | */ |
| 433 | struct pldm_request_update_req { |
| 434 | uint32_t max_transfer_size; |
| 435 | uint16_t num_of_comp; |
| 436 | uint8_t max_outstanding_transfer_req; |
| 437 | uint16_t pkg_data_len; |
| 438 | uint8_t comp_image_set_ver_str_type; |
| 439 | uint8_t comp_image_set_ver_str_len; |
| 440 | } __attribute__((packed)); |
| 441 | |
| 442 | /** @struct pldm_request_update_resp |
| 443 | * |
| 444 | * Structure representing Request Update response |
| 445 | */ |
| 446 | struct pldm_request_update_resp { |
| 447 | uint8_t completion_code; |
| 448 | uint16_t fd_meta_data_len; |
| 449 | uint8_t fd_will_send_pkg_data; |
| 450 | } __attribute__((packed)); |
| 451 | |
| 452 | /** @struct pldm_pass_component_table_req |
| 453 | * |
| 454 | * Structure representing PassComponentTable request |
| 455 | */ |
| 456 | struct pldm_pass_component_table_req { |
| 457 | uint8_t transfer_flag; |
| 458 | uint16_t comp_classification; |
| 459 | uint16_t comp_identifier; |
| 460 | uint8_t comp_classification_index; |
| 461 | uint32_t comp_comparison_stamp; |
| 462 | uint8_t comp_ver_str_type; |
| 463 | uint8_t comp_ver_str_len; |
| 464 | } __attribute__((packed)); |
| 465 | |
| 466 | /** @struct pldm_pass_component_table_resp |
| 467 | * |
| 468 | * Structure representing PassComponentTable response |
| 469 | */ |
| 470 | struct pldm_pass_component_table_resp { |
| 471 | uint8_t completion_code; |
| 472 | uint8_t comp_resp; |
| 473 | uint8_t comp_resp_code; |
| 474 | } __attribute__((packed)); |
| 475 | |
| 476 | /** @struct pldm_update_component_req |
| 477 | * |
| 478 | * Structure representing UpdateComponent request |
| 479 | */ |
| 480 | struct pldm_update_component_req { |
| 481 | uint16_t comp_classification; |
| 482 | uint16_t comp_identifier; |
| 483 | uint8_t comp_classification_index; |
| 484 | uint32_t comp_comparison_stamp; |
| 485 | uint32_t comp_image_size; |
| 486 | bitfield32_t update_option_flags; |
| 487 | uint8_t comp_ver_str_type; |
| 488 | uint8_t comp_ver_str_len; |
| 489 | } __attribute__((packed)); |
| 490 | |
| 491 | /** @struct pldm_update_component_resp |
| 492 | * |
| 493 | * Structure representing UpdateComponent response |
| 494 | */ |
| 495 | struct pldm_update_component_resp { |
| 496 | uint8_t completion_code; |
| 497 | uint8_t comp_compatability_resp; |
| 498 | uint8_t comp_compatability_resp_code; |
| 499 | bitfield32_t update_option_flags_enabled; |
| 500 | uint16_t time_before_req_fw_data; |
| 501 | } __attribute__((packed)); |
| 502 | |
| 503 | /** @struct pldm_request_firmware_data_req |
| 504 | * |
| 505 | * Structure representing RequestFirmwareData request. |
| 506 | */ |
| 507 | struct pldm_request_firmware_data_req { |
| 508 | uint32_t offset; |
| 509 | uint32_t length; |
| 510 | } __attribute__((packed)); |
| 511 | |
| 512 | /** @struct pldm_apply_complete_req |
| 513 | * |
| 514 | * Structure representing ApplyComplete request. |
| 515 | */ |
| 516 | struct pldm_apply_complete_req { |
| 517 | uint8_t apply_result; |
| 518 | bitfield16_t comp_activation_methods_modification; |
| 519 | } __attribute__((packed)); |
| 520 | |
| 521 | /** @struct pldm_activate_firmware_req |
| 522 | * |
| 523 | * Structure representing ActivateFirmware request |
| 524 | */ |
| 525 | struct pldm_activate_firmware_req { |
| 526 | bool8_t self_contained_activation_req; |
| 527 | } __attribute__((packed)); |
| 528 | |
| 529 | /** @struct activate_firmware_resp |
| 530 | * |
| 531 | * Structure representing Activate Firmware response |
| 532 | */ |
| 533 | struct pldm_activate_firmware_resp { |
| 534 | uint8_t completion_code; |
| 535 | uint16_t estimated_time_activation; |
| 536 | } __attribute__((packed)); |
| 537 | |
| 538 | /** @struct pldm_get_status_resp |
| 539 | * |
| 540 | * Structure representing GetStatus response. |
| 541 | */ |
| 542 | struct pldm_get_status_resp { |
| 543 | uint8_t completion_code; |
| 544 | uint8_t current_state; |
| 545 | uint8_t previous_state; |
| 546 | uint8_t aux_state; |
| 547 | uint8_t aux_state_status; |
| 548 | uint8_t progress_percent; |
| 549 | uint8_t reason_code; |
| 550 | bitfield32_t update_option_flags_enabled; |
| 551 | } __attribute__((packed)); |
| 552 | |
| 553 | /** @struct pldm_cancel_update_resp |
| 554 | * |
| 555 | * Structure representing CancelUpdate response. |
| 556 | */ |
| 557 | struct pldm_cancel_update_resp { |
| 558 | uint8_t completion_code; |
| 559 | bool8_t non_functioning_component_indication; |
| 560 | uint64_t non_functioning_component_bitmap; |
| 561 | } __attribute__((packed)); |
| 562 | |
| 563 | /** @brief Decode the PLDM package header information |
| 564 | * |
| 565 | * @param[in] data - pointer to package header information |
| 566 | * @param[in] length - available length in the firmware update package |
| 567 | * @param[out] package_header_info - pointer to fixed part of PLDM package |
| 568 | * header information |
| 569 | * @param[out] package_version_str - pointer to package version string |
| 570 | * |
| 571 | * @return pldm_completion_codes |
| 572 | */ |
| 573 | int decode_pldm_package_header_info( |
| 574 | const uint8_t *data, size_t length, |
| 575 | struct pldm_package_header_information *package_header_info, |
| 576 | struct variable_field *package_version_str); |
| 577 | |
| 578 | /** @brief Decode individual firmware device ID record |
| 579 | * |
| 580 | * @param[in] data - pointer to firmware device ID record |
| 581 | * @param[in] length - available length in the firmware update package |
| 582 | * @param[in] component_bitmap_bit_length - ComponentBitmapBitLengthfield |
| 583 | * parsed from the package header info |
| 584 | * @param[out] fw_device_id_record - pointer to fixed part of firmware device |
| 585 | * id record |
| 586 | * @param[out] applicable_components - pointer to ApplicableComponents |
| 587 | * @param[out] comp_image_set_version_str - pointer to |
| 588 | * ComponentImageSetVersionString |
| 589 | * @param[out] record_descriptors - pointer to RecordDescriptors |
| 590 | * @param[out] fw_device_pkg_data - pointer to FirmwareDevicePackageData |
| 591 | * |
| 592 | * @return pldm_completion_codes |
| 593 | */ |
| 594 | int decode_firmware_device_id_record( |
| 595 | const uint8_t *data, size_t length, uint16_t component_bitmap_bit_length, |
| 596 | struct pldm_firmware_device_id_record *fw_device_id_record, |
| 597 | struct variable_field *applicable_components, |
| 598 | struct variable_field *comp_image_set_version_str, |
| 599 | struct variable_field *record_descriptors, |
| 600 | struct variable_field *fw_device_pkg_data); |
| 601 | |
| 602 | /** @brief Decode the record descriptor entries in the firmware update package |
| 603 | * and the Descriptors in the QueryDeviceIDentifiers command |
| 604 | * |
| 605 | * @param[in] data - pointer to descriptor entry |
| 606 | * @param[in] length - remaining length of the descriptor data |
| 607 | * @param[out] descriptor_type - pointer to descriptor type |
| 608 | * @param[out] descriptor_data - pointer to descriptor data |
| 609 | * |
| 610 | * @return pldm_completion_codes |
| 611 | */ |
| 612 | int decode_descriptor_type_length_value(const uint8_t *data, size_t length, |
| 613 | uint16_t *descriptor_type, |
| 614 | struct variable_field *descriptor_data); |
| 615 | |
| 616 | /** @brief Decode the vendor defined descriptor value |
| 617 | * |
| 618 | * @param[in] data - pointer to vendor defined descriptor value |
| 619 | * @param[in] length - length of the vendor defined descriptor value |
| 620 | * @param[out] descriptor_title_str_type - pointer to vendor defined descriptor |
| 621 | * title string type |
| 622 | * @param[out] descriptor_title_str - pointer to vendor defined descriptor |
| 623 | * title string |
| 624 | * @param[out] descriptor_data - pointer to vendor defined descriptor data |
| 625 | * |
| 626 | * @return pldm_completion_codes |
| 627 | */ |
| 628 | int decode_vendor_defined_descriptor_value( |
| 629 | const uint8_t *data, size_t length, uint8_t *descriptor_title_str_type, |
| 630 | struct variable_field *descriptor_title_str, |
| 631 | struct variable_field *descriptor_data); |
| 632 | |
| 633 | /** @brief Decode individual component image information |
| 634 | * |
| 635 | * @param[in] data - pointer to component image information |
| 636 | * @param[in] length - available length in the firmware update package |
| 637 | * @param[out] pldm_comp_image_info - pointer to fixed part of component image |
| 638 | * information |
| 639 | * @param[out] comp_version_str - pointer to component version string |
| 640 | * |
| 641 | * @return pldm_completion_codes |
| 642 | */ |
| 643 | int decode_pldm_comp_image_info( |
| 644 | const uint8_t *data, size_t length, |
| 645 | struct pldm_component_image_information *pldm_comp_image_info, |
| 646 | struct variable_field *comp_version_str); |
| 647 | |
| 648 | /** @brief Create a PLDM request message for QueryDeviceIdentifiers |
| 649 | * |
| 650 | * @param[in] instance_id - Message's instance id |
| 651 | * @param[in] payload_length - Length of the request message payload |
| 652 | * @param[in,out] msg - Message will be written to this |
| 653 | * |
| 654 | * @return pldm_completion_codes |
| 655 | * |
| 656 | * @note Caller is responsible for memory alloc and dealloc of param |
| 657 | * 'msg.payload' |
| 658 | */ |
| 659 | int encode_query_device_identifiers_req(uint8_t instance_id, |
| 660 | size_t payload_length, |
| 661 | struct pldm_msg *msg); |
| 662 | |
| 663 | /** @brief Decode QueryDeviceIdentifiers response message |
| 664 | * |
| 665 | * @param[in] msg - Response message |
| 666 | * @param[in] payload_length - Length of response message payload |
| 667 | * @param[out] completion_code - Pointer to response msg's PLDM completion code |
| 668 | * @param[out] device_identifiers_len - Pointer to device identifiers length |
| 669 | * @param[out] descriptor_count - Pointer to descriptor count |
| 670 | * @param[out] descriptor_data - Pointer to descriptor data |
| 671 | * |
| 672 | * @return pldm_completion_codes |
| 673 | */ |
| 674 | int decode_query_device_identifiers_resp(const struct pldm_msg *msg, |
| 675 | size_t payload_length, |
| 676 | uint8_t *completion_code, |
| 677 | uint32_t *device_identifiers_len, |
| 678 | uint8_t *descriptor_count, |
| 679 | uint8_t **descriptor_data); |
| 680 | |
| 681 | /** @brief Create a PLDM request message for GetFirmwareParameters |
| 682 | * |
| 683 | * @param[in] instance_id - Message's instance id |
| 684 | * @param[in] payload_length - Length of the request message payload |
| 685 | * @param[in,out] msg - Message will be written to this |
| 686 | * |
| 687 | * @return pldm_completion_codes |
| 688 | * |
| 689 | * @note Caller is responsible for memory alloc and dealloc of param |
| 690 | * 'msg.payload' |
| 691 | */ |
| 692 | int encode_get_firmware_parameters_req(uint8_t instance_id, |
| 693 | size_t payload_length, |
| 694 | struct pldm_msg *msg); |
| 695 | |
| 696 | /** @brief Decode GetFirmwareParameters response |
| 697 | * |
| 698 | * @param[in] msg - Response message |
| 699 | * @param[in] payload_length - Length of response message payload |
| 700 | * @param[out] resp_data - Pointer to get firmware parameters response |
| 701 | * @param[out] active_comp_image_set_ver_str - Pointer to active component |
| 702 | * image set version string |
| 703 | * @param[out] pending_comp_image_set_ver_str - Pointer to pending component |
| 704 | * image set version string |
| 705 | * @param[out] comp_parameter_table - Pointer to component parameter table |
| 706 | * |
| 707 | * @return pldm_completion_codes |
| 708 | */ |
| 709 | int decode_get_firmware_parameters_resp( |
| 710 | const struct pldm_msg *msg, size_t payload_length, |
| 711 | struct pldm_get_firmware_parameters_resp *resp_data, |
| 712 | struct variable_field *active_comp_image_set_ver_str, |
| 713 | struct variable_field *pending_comp_image_set_ver_str, |
| 714 | struct variable_field *comp_parameter_table); |
| 715 | |
| 716 | /** @brief Decode component entries in the component parameter table which is |
| 717 | * part of the response of GetFirmwareParameters command |
| 718 | * |
| 719 | * @param[in] data - Component entry |
| 720 | * @param[in] length - Length of component entry |
| 721 | * @param[out] component_data - Pointer to component parameter table |
| 722 | * @param[out] active_comp_ver_str - Pointer to active component version string |
| 723 | * @param[out] pending_comp_ver_str - Pointer to pending component version |
| 724 | * string |
| 725 | * |
| 726 | * @return pldm_completion_codes |
| 727 | */ |
| 728 | int decode_get_firmware_parameters_resp_comp_entry( |
| 729 | const uint8_t *data, size_t length, |
| 730 | struct pldm_component_parameter_entry *component_data, |
| 731 | struct variable_field *active_comp_ver_str, |
| 732 | struct variable_field *pending_comp_ver_str); |
| 733 | |
| 734 | /** @brief Create PLDM request message for RequestUpdate |
| 735 | * |
| 736 | * @param[in] instance_id - Message's instance id |
| 737 | * @param[in] max_transfer_size - Maximum size of the variable payload allowed |
| 738 | * to be requested via RequestFirmwareData |
| 739 | * command |
| 740 | * @param[in] num_of_comp - Total number of components that will be passed to |
| 741 | * the FD during the update |
| 742 | * @param[in] max_outstanding_transfer_req - Total number of outstanding |
| 743 | * RequestFirmwareData |
| 744 | * commands that can be sent by the FD |
| 745 | * @param[in] pkg_data_len - Value of the FirmwareDevicePackageDataLength field |
| 746 | * present in firmware package header |
| 747 | * @param[in] comp_image_set_ver_str_type - StringType of |
| 748 | * ComponentImageSetVersionString |
| 749 | * @param[in] comp_image_set_ver_str_len - The length of the |
| 750 | * ComponentImageSetVersionString |
| 751 | * @param[in] comp_img_set_ver_str - Component Image Set version information |
| 752 | * @param[in,out] msg - Message will be written to this |
| 753 | * @param[in] payload_length - Length of request message payload |
| 754 | * |
| 755 | * @return pldm_completion_codes |
| 756 | * |
| 757 | * @note Caller is responsible for memory alloc and dealloc of param |
| 758 | * 'msg.payload' |
| 759 | */ |
| 760 | int encode_request_update_req(uint8_t instance_id, uint32_t max_transfer_size, |
| 761 | uint16_t num_of_comp, |
| 762 | uint8_t max_outstanding_transfer_req, |
| 763 | uint16_t pkg_data_len, |
| 764 | uint8_t comp_image_set_ver_str_type, |
| 765 | uint8_t comp_image_set_ver_str_len, |
| 766 | const struct variable_field *comp_img_set_ver_str, |
| 767 | struct pldm_msg *msg, size_t payload_length); |
| 768 | |
| 769 | /** @brief Decode a RequestUpdate response message |
| 770 | * |
| 771 | * @param[in] msg - Response message |
| 772 | * @param[in] payload_length - Length of response message payload |
| 773 | * @param[out] completion_code - Pointer to hold the completion code |
| 774 | * @param[out] fd_meta_data_len - Pointer to hold the length of FD metadata |
| 775 | * @param[out] fd_will_send_pkg_data - Pointer to hold information whether FD |
| 776 | * will send GetPackageData command |
| 777 | * @return pldm_completion_codes |
| 778 | */ |
| 779 | int decode_request_update_resp(const struct pldm_msg *msg, |
| 780 | size_t payload_length, uint8_t *completion_code, |
| 781 | uint16_t *fd_meta_data_len, |
| 782 | uint8_t *fd_will_send_pkg_data); |
| 783 | |
| 784 | /** @brief Create PLDM request message for PassComponentTable |
| 785 | * |
| 786 | * @param[in] instance_id - Message's instance id |
| 787 | * @param[in] transfer_flag - TransferFlag |
| 788 | * @param[in] comp_classification - ComponentClassification |
| 789 | * @param[in] comp_identifier - ComponentIdentifier |
| 790 | * @param[in] comp_classification_index - ComponentClassificationIndex |
| 791 | * @param[in] comp_comparison_stamp - ComponentComparisonStamp |
| 792 | * @param[in] comp_ver_str_type - ComponentVersionStringType |
| 793 | * @param[in] comp_ver_str_len - ComponentVersionStringLength |
| 794 | * @param[in] comp_ver_str - ComponentVersionString |
| 795 | * @param[in,out] msg - Message will be written to this |
| 796 | * @param[in] payload_length - Length of request message payload |
| 797 | * information |
| 798 | * |
| 799 | * @return pldm_completion_codes |
| 800 | * |
| 801 | * @note Caller is responsible for memory alloc and dealloc of param |
| 802 | * 'msg.payload' |
| 803 | */ |
| 804 | int encode_pass_component_table_req( |
| 805 | uint8_t instance_id, uint8_t transfer_flag, uint16_t comp_classification, |
| 806 | uint16_t comp_identifier, uint8_t comp_classification_index, |
| 807 | uint32_t comp_comparison_stamp, uint8_t comp_ver_str_type, |
| 808 | uint8_t comp_ver_str_len, const struct variable_field *comp_ver_str, |
| 809 | struct pldm_msg *msg, size_t payload_length); |
| 810 | |
| 811 | /** @brief Decode PassComponentTable response message |
| 812 | * |
| 813 | * @param[in] msg - Response message |
| 814 | * @param[in] payload_length - Length of response message payload |
| 815 | * @param[out] completion_code - Pointer to hold completion code |
| 816 | * @param[out] comp_resp - Pointer to hold component response |
| 817 | * @param[out] comp_resp_code - Pointer to hold component response code |
| 818 | * |
| 819 | * @return pldm_completion_codes |
| 820 | */ |
| 821 | int decode_pass_component_table_resp(const struct pldm_msg *msg, |
| 822 | size_t payload_length, |
| 823 | uint8_t *completion_code, |
| 824 | uint8_t *comp_resp, |
| 825 | uint8_t *comp_resp_code); |
| 826 | |
| 827 | /** @brief Create PLDM request message for UpdateComponent |
| 828 | * |
| 829 | * @param[in] instance_id - Message's instance id |
| 830 | * @param[in] comp_classification - ComponentClassification |
| 831 | * @param[in] comp_identifier - ComponentIdentifier |
| 832 | * @param[in] comp_classification_index - ComponentClassificationIndex |
| 833 | * @param[in] comp_comparison_stamp - ComponentComparisonStamp |
| 834 | * @param[in] comp_image_size - ComponentImageSize |
| 835 | * @param[in] update_option_flags - UpdateOptionFlags |
| 836 | * @param[in] comp_ver_str_type - ComponentVersionStringType |
| 837 | * @param[in] comp_ver_str_len - ComponentVersionStringLength |
| 838 | * @param[in] comp_ver_str - ComponentVersionString |
| 839 | * @param[in,out] msg - Message will be written to this |
| 840 | * @param[in] payload_length - Length of request message payload |
| 841 | * information |
| 842 | * |
| 843 | * @return pldm_completion_codes |
| 844 | * |
| 845 | * @note Caller is responsible for memory alloc and dealloc of param |
| 846 | * 'msg.payload' |
| 847 | */ |
| 848 | int encode_update_component_req( |
| 849 | uint8_t instance_id, uint16_t comp_classification, uint16_t comp_identifier, |
| 850 | uint8_t comp_classification_index, uint32_t comp_comparison_stamp, |
| 851 | uint32_t comp_image_size, bitfield32_t update_option_flags, |
| 852 | uint8_t comp_ver_str_type, uint8_t comp_ver_str_len, |
| 853 | const struct variable_field *comp_ver_str, struct pldm_msg *msg, |
| 854 | size_t payload_length); |
| 855 | |
| 856 | /** @brief Decode UpdateComponent response message |
| 857 | * |
| 858 | * @param[in] msg - Response message |
| 859 | * @param[in] payload_length - Length of response message payload |
| 860 | * @param[out] completion_code - Pointer to hold completion code |
| 861 | * @param[out] comp_compatability_resp - Pointer to hold component |
| 862 | * compatibility response |
| 863 | * @param[out] comp_compatability_resp_code - Pointer to hold component |
| 864 | * compatibility response code |
| 865 | * @param[out] update_option_flags_enabled - Pointer to hold |
| 866 | * UpdateOptionsFlagEnabled |
| 867 | * @param[out] time_before_req_fw_data - Pointer to hold the estimated time |
| 868 | * before sending RequestFirmwareData |
| 869 | * |
| 870 | * @return pldm_completion_codes |
| 871 | */ |
| 872 | int decode_update_component_resp(const struct pldm_msg *msg, |
| 873 | size_t payload_length, |
| 874 | uint8_t *completion_code, |
| 875 | uint8_t *comp_compatability_resp, |
| 876 | uint8_t *comp_compatability_resp_code, |
| 877 | bitfield32_t *update_option_flags_enabled, |
| 878 | uint16_t *time_before_req_fw_data); |
| 879 | |
| 880 | /** @brief Decode RequestFirmwareData request message |
| 881 | * |
| 882 | * @param[in] msg - Request message |
| 883 | * @param[in] payload_length - Length of request message payload |
| 884 | * @param[out] offset - Pointer to hold offset |
| 885 | * @param[out] length - Pointer to hold the size of the component image |
| 886 | * segment requested by the FD/FDP |
| 887 | * |
| 888 | * @return pldm_completion_codes |
| 889 | */ |
| 890 | int decode_request_firmware_data_req(const struct pldm_msg *msg, |
| 891 | size_t payload_length, uint32_t *offset, |
| 892 | uint32_t *length); |
| 893 | |
| 894 | /** @brief Create PLDM response message for RequestFirmwareData |
| 895 | * |
| 896 | * The ComponentImagePortion is not encoded in the PLDM response message |
| 897 | * by encode_request_firmware_data_resp to avoid an additional copy. Populating |
| 898 | * ComponentImagePortion in the PLDM response message is handled by the user |
| 899 | * of this API. The payload_length validation considers only the |
| 900 | * CompletionCode. |
| 901 | * |
| 902 | * @param[in] instance_id - Message's instance id |
| 903 | * @param[in] completion_code - CompletionCode |
| 904 | * @param[in,out] msg - Message will be written to this |
| 905 | * @param[in] payload_length - Length of response message payload |
| 906 | * |
| 907 | * @return pldm_completion_codes |
| 908 | * |
| 909 | * @note Caller is responsible for memory alloc and dealloc of param |
| 910 | * 'msg.payload' |
| 911 | */ |
| 912 | int encode_request_firmware_data_resp(uint8_t instance_id, |
| 913 | uint8_t completion_code, |
| 914 | struct pldm_msg *msg, |
| 915 | size_t payload_length); |
| 916 | |
| 917 | /** @brief Decode TransferComplete request message |
| 918 | * |
| 919 | * @param[in] msg - Request message |
| 920 | * @param[in] payload_length - Length of request message payload |
| 921 | * @param[out] transfer_result - Pointer to hold TransferResult |
| 922 | * |
| 923 | * @return pldm_completion_codes |
| 924 | */ |
| 925 | int decode_transfer_complete_req(const struct pldm_msg *msg, |
| 926 | size_t payload_length, |
| 927 | uint8_t *transfer_result); |
| 928 | |
| 929 | /** @brief Create PLDM response message for TransferComplete |
| 930 | * |
| 931 | * @param[in] instance_id - Message's instance id |
| 932 | * @param[in] completion_code - CompletionCode |
| 933 | * @param[in,out] msg - Message will be written to this |
| 934 | * @param[in] payload_length - Length of response message payload |
| 935 | * |
| 936 | * @return pldm_completion_codes |
| 937 | * |
| 938 | * @note Caller is responsible for memory alloc and dealloc of param |
| 939 | * 'msg.payload' |
| 940 | */ |
| 941 | int encode_transfer_complete_resp(uint8_t instance_id, uint8_t completion_code, |
| 942 | struct pldm_msg *msg, size_t payload_length); |
| 943 | |
| 944 | /** @brief Decode VerifyComplete request message |
| 945 | * |
| 946 | * @param[in] msg - Request message |
| 947 | * @param[in] payload_length - Length of request message payload |
| 948 | * @param[in] verify_result - Pointer to hold VerifyResult |
| 949 | * |
| 950 | * @return pldm_completion_codes |
| 951 | */ |
| 952 | int decode_verify_complete_req(const struct pldm_msg *msg, |
| 953 | size_t payload_length, uint8_t *verify_result); |
| 954 | |
| 955 | /** @brief Create PLDM response message for VerifyComplete |
| 956 | * |
| 957 | * @param[in] instance_id - Message's instance id |
| 958 | * @param[in] completion_code - CompletionCode |
| 959 | * @param[in,out] msg - Message will be written to this |
| 960 | * @param[in] payload_length - Length of response message payload |
| 961 | * |
| 962 | * @return pldm_completion_codes |
| 963 | * |
| 964 | * @note Caller is responsible for memory alloc and dealloc of param |
| 965 | * 'msg.payload' |
| 966 | */ |
| 967 | int encode_verify_complete_resp(uint8_t instance_id, uint8_t completion_code, |
| 968 | struct pldm_msg *msg, size_t payload_length); |
| 969 | |
| 970 | /** @brief Decode ApplyComplete request message |
| 971 | * |
| 972 | * @param[in] msg - Request message |
| 973 | * @param[in] payload_length - Length of request message payload |
| 974 | * @param[in] apply_result - Pointer to hold ApplyResult |
| 975 | * @param[in] comp_activation_methods_modification - Pointer to hold the |
| 976 | * ComponentActivationMethodsModification |
| 977 | * |
| 978 | * @return pldm_completion_codes |
| 979 | */ |
| 980 | int decode_apply_complete_req( |
| 981 | const struct pldm_msg *msg, size_t payload_length, uint8_t *apply_result, |
| 982 | bitfield16_t *comp_activation_methods_modification); |
| 983 | |
| 984 | /** @brief Create PLDM response message for ApplyComplete |
| 985 | * |
| 986 | * @param[in] instance_id - Message's instance id |
| 987 | * @param[in] completion_code - CompletionCode |
| 988 | * @param[in,out] msg - Message will be written to this |
| 989 | * @param[in] payload_length - Length of response message payload |
| 990 | * |
| 991 | * @return pldm_completion_codes |
| 992 | * |
| 993 | * @note Caller is responsible for memory alloc and dealloc of param |
| 994 | * 'msg.payload' |
| 995 | */ |
| 996 | int encode_apply_complete_resp(uint8_t instance_id, uint8_t completion_code, |
| 997 | struct pldm_msg *msg, size_t payload_length); |
| 998 | |
| 999 | /** @brief Create PLDM request message for ActivateFirmware |
| 1000 | * |
| 1001 | * @param[in] instance_id - Message's instance id |
| 1002 | * @param[in] self_contained_activation_req SelfContainedActivationRequest |
| 1003 | * @param[in,out] msg - Message will be written to this |
| 1004 | * @param[in] payload_length - Length of request message payload |
| 1005 | * |
| 1006 | * @return pldm_completion_codes |
| 1007 | * |
| 1008 | * @note Caller is responsible for memory alloc and dealloc of param |
| 1009 | * 'msg.payload' |
| 1010 | */ |
| 1011 | int encode_activate_firmware_req(uint8_t instance_id, |
| 1012 | bool8_t self_contained_activation_req, |
| 1013 | struct pldm_msg *msg, size_t payload_length); |
| 1014 | |
| 1015 | /** @brief Decode ActivateFirmware response message |
| 1016 | * |
| 1017 | * @param[in] msg - Response message |
| 1018 | * @param[in] payload_length - Length of response message payload |
| 1019 | * @param[out] completion_code - Pointer to hold CompletionCode |
| 1020 | * @param[out] estimated_time_activation - Pointer to hold |
| 1021 | * EstimatedTimeForSelfContainedActivation |
| 1022 | * |
| 1023 | * @return pldm_completion_codes |
| 1024 | */ |
| 1025 | int decode_activate_firmware_resp(const struct pldm_msg *msg, |
| 1026 | size_t payload_length, |
| 1027 | uint8_t *completion_code, |
| 1028 | uint16_t *estimated_time_activation); |
| 1029 | |
| 1030 | /** @brief Create PLDM request message for GetStatus |
| 1031 | * |
| 1032 | * @param[in] instance_id - Message's instance id |
| 1033 | * @param[in,out] msg - Message will be written to this |
| 1034 | * @param[in] payload_length - Length of request message payload |
| 1035 | * |
| 1036 | * @return pldm_completion_codes |
| 1037 | * |
| 1038 | * @note Caller is responsible for memory alloc and dealloc of param |
| 1039 | * 'msg.payload' |
| 1040 | */ |
| 1041 | int encode_get_status_req(uint8_t instance_id, struct pldm_msg *msg, |
| 1042 | size_t payload_length); |
| 1043 | |
| 1044 | /** @brief Decode GetStatus response message |
| 1045 | * |
| 1046 | * @param[in] msg - Response message |
| 1047 | * @param[in] payload_length - Length of response message payload |
| 1048 | * @param[out] completion_code - Pointer to completion code |
| 1049 | * @param[out] current_state - Pointer to current state machine state |
| 1050 | * @param[out] previous_state - Pointer to previous different state machine |
| 1051 | * state |
| 1052 | * @param[out] aux_state - Pointer to current operation state of FD/FDP |
| 1053 | * @param[out] aux_state_status - Pointer to aux state status |
| 1054 | * @param[out] progress_percent - Pointer to progress percentage |
| 1055 | * @param[out] reason_code - Pointer to reason for entering current state |
| 1056 | * @param[out] update_option_flags_enabled - Pointer to update option flags |
| 1057 | * enabled |
| 1058 | * |
| 1059 | * @return pldm_completion_codes |
| 1060 | */ |
| 1061 | int decode_get_status_resp(const struct pldm_msg *msg, size_t payload_length, |
| 1062 | uint8_t *completion_code, uint8_t *current_state, |
| 1063 | uint8_t *previous_state, uint8_t *aux_state, |
| 1064 | uint8_t *aux_state_status, uint8_t *progress_percent, |
| 1065 | uint8_t *reason_code, |
| 1066 | bitfield32_t *update_option_flags_enabled); |
| 1067 | |
| 1068 | /** @brief Create PLDM request message for CancelUpdateComponent |
| 1069 | * |
| 1070 | * @param[in] instance_id - Message's instance id |
| 1071 | * @param[in,out] msg - Message will be written to this |
| 1072 | * @param[in] payload_length - Length of request message payload |
| 1073 | * |
| 1074 | * @return pldm_completion_codes |
| 1075 | * |
| 1076 | * @note Caller is responsible for memory alloc and dealloc of param |
| 1077 | * 'msg.payload' |
| 1078 | */ |
| 1079 | int encode_cancel_update_component_req(uint8_t instance_id, |
| 1080 | struct pldm_msg *msg, |
| 1081 | size_t payload_length); |
| 1082 | |
| 1083 | /** @brief Decode CancelUpdateComponent response message |
| 1084 | * |
| 1085 | * @param[in] msg - Response message |
| 1086 | * @param[in] payload_length - Length of response message payload |
| 1087 | * @param[out] completion_code - Pointer to the completion code |
| 1088 | * |
| 1089 | * @return pldm_completion_codes |
| 1090 | */ |
| 1091 | int decode_cancel_update_component_resp(const struct pldm_msg *msg, |
| 1092 | size_t payload_length, |
| 1093 | uint8_t *completion_code); |
| 1094 | |
| 1095 | /** @brief Create PLDM request message for CancelUpdate |
| 1096 | * |
| 1097 | * @param[in] instance_id - Message's instance id |
| 1098 | * @param[in,out] msg - Message will be written to this |
| 1099 | * @param[in] payload_length - Length of request message payload |
| 1100 | * |
| 1101 | * @return pldm_completion_codes |
| 1102 | * |
| 1103 | * @note Caller is responsible for memory alloc and dealloc of param |
| 1104 | * 'msg.payload' |
| 1105 | */ |
| 1106 | int encode_cancel_update_req(uint8_t instance_id, struct pldm_msg *msg, |
| 1107 | size_t payload_length); |
| 1108 | |
| 1109 | /** @brief Decode CancelUpdate response message |
| 1110 | * |
| 1111 | * @param[in] msg - Response message |
| 1112 | * @param[in] payload_length - Length of response message payload |
| 1113 | * @param[out] completion_code - Pointer to completion code |
| 1114 | * @param[out] non_functioning_component_indication - Pointer to non |
| 1115 | functioning |
| 1116 | * component indication |
| 1117 | * @param[out] non_functioning_component_bitmap - Pointer to non |
| 1118 | functioning |
| 1119 | * component bitmap |
| 1120 | * |
| 1121 | * @return pldm_completion_codes |
| 1122 | */ |
| 1123 | int decode_cancel_update_resp(const struct pldm_msg *msg, size_t payload_length, |
| 1124 | uint8_t *completion_code, |
| 1125 | bool8_t *non_functioning_component_indication, |
| 1126 | bitfield64_t *non_functioning_component_bitmap); |
| 1127 | |
| 1128 | #ifdef __cplusplus |
| 1129 | } |
| 1130 | #endif |
| 1131 | |
| 1132 | #endif // End of FW_UPDATE_H |