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