blob: bffd296fa1b5f21ec25c16028d8ab983418d733d [file] [log] [blame]
gokulsanker138ceba2021-04-05 13:25:25 +05301#ifndef FW_UPDATE_H
2#define FW_UPDATE_H
3
4#ifdef __cplusplus
5extern "C" {
6#endif
7#include "base.h"
gokulsanker773cd1f2021-04-27 17:59:15 +05308#include "stdbool.h"
gokulsanker22fbb342021-04-05 15:55:06 +05309#include "utils.h"
gokulsanker138ceba2021-04-05 13:25:25 +053010
Tom Joseph568e4702021-06-07 22:15:49 -070011#define PLDM_FWUP_COMPONENT_BITMAP_MULTIPLE 8
Tom Joseph58cc1722021-06-09 07:15:49 -070012#define PLDM_FWUP_INVALID_COMPONENT_COMPARISON_TIMESTAMP 0xFFFFFFFF
gokulsanker138ceba2021-04-05 13:25:25 +053013#define PLDM_QUERY_DEVICE_IDENTIFIERS_REQ_BYTES 0
gokulsankereca3e192021-04-05 14:57:41 +053014/** @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
gokulsanker981fbfb2021-04-05 15:17:25 +053018#define PLDM_GET_FIRMWARE_PARAMETERS_REQ_BYTES 0
gokulsankerd434edc2021-04-05 16:36:04 +053019#define PLDM_FWUP_BASELINE_TRANSFER_SIZE 32
20#define PLDM_FWUP_MIN_OUTSTANDING_REQ 1
gokulsanker138ceba2021-04-05 13:25:25 +053021
22/** @brief PLDM Firmware update commands
23 */
gokulsanker981fbfb2021-04-05 15:17:25 +053024enum pldm_firmware_update_commands {
25 PLDM_QUERY_DEVICE_IDENTIFIERS = 0x01,
gokulsankerd434edc2021-04-05 16:36:04 +053026 PLDM_GET_FIRMWARE_PARAMETERS = 0x02,
gokulsanker1b909d82021-04-05 17:26:02 +053027 PLDM_REQUEST_UPDATE = 0x10,
gokulsankeraa3a5cd2021-04-22 11:06:42 +053028 PLDM_PASS_COMPONENT_TABLE = 0x13,
gokulsanker9c440d02021-06-03 09:54:02 +053029 PLDM_UPDATE_COMPONENT = 0x14,
gokulsanker50107cf2021-06-27 09:44:12 +053030 PLDM_REQUEST_FIRMWARE_DATA = 0x15,
gokulsanker9a693582021-06-27 11:35:09 +053031 PLDM_TRANSFER_COMPLETE = 0x16,
gokulsankerd6f79b82021-06-27 12:00:25 +053032 PLDM_VERIFY_COMPLETE = 0x17,
gokulsanker773cd1f2021-04-27 17:59:15 +053033 PLDM_APPLY_COMPLETE = 0x18,
34 PLDM_ACTIVATE_FIRMWARE = 0x1A
gokulsanker981fbfb2021-04-05 15:17:25 +053035};
gokulsanker138ceba2021-04-05 13:25:25 +053036
gokulsanker611238c2021-04-05 16:50:44 +053037/** @brief PLDM Firmware update completion codes
38 */
39enum pldm_firmware_update_completion_codes {
40 PLDM_FWUP_NOT_IN_UPDATE_MODE = 0x80,
41 PLDM_FWUP_ALREADY_IN_UPDATE_MODE = 0x81,
42 PLDM_FWUP_DATA_OUT_OF_RANGE = 0x82,
43 PLDM_FWUP_INVALID_TRANSFER_LENGTH = 0x83,
44 PLDM_FWUP_INVALID_STATE_FOR_COMMAND = 0x84,
45 PLDM_FWUP_INCOMPLETE_UPDATE = 0x85,
46 PLDM_FWUP_BUSY_IN_BACKGROUND = 0x86,
47 PLDM_FWUP_CANCEL_PENDING = 0x87,
48 PLDM_FWUP_COMMAND_NOT_EXPECTED = 0x87,
49 PLDM_FWUP_RETRY_REQUEST_FW_DATA = 0x89,
50 PLDM_FWUP_UNABLE_TO_INITIATE_UPDATE = 0x8A,
51 PLDM_FWUP_ACTIVATION_NOT_REQUIRED = 0x8B,
52 PLDM_FWUP_SELF_CONTAINED_ACTIVATION_NOT_PERMITTED = 0x8C,
53 PLDM_FWUP_NO_DEVICE_METADATA = 0x8D,
54 PLDM_FWUP_RETRY_REQUEST_UPDATE = 0x8E,
55 PLDM_FWUP_NO_PACKAGE_DATA = 0x8F,
56 PLDM_FWUP_INVALID_TRANSFER_HANDLE = 0x90,
57 PLDM_FWUP_INVALID_TRANSFER_OPERATION_FLAG = 0x91,
58 PLDM_FWUP_ACTIVATE_PENDING_IMAGE_NOT_PERMITTED = 0x92,
59 PLDM_FWUP_PACKAGE_DATA_ERROR = 0x93
60};
61
Tom Joseph763b51e2021-06-05 04:50:47 -070062/** @brief String type values defined in the PLDM firmware update specification
63 */
64enum pldm_firmware_update_string_type {
65 PLDM_STR_TYPE_UNKNOWN = 0,
66 PLDM_STR_TYPE_ASCII = 1,
67 PLDM_STR_TYPE_UTF_8 = 2,
68 PLDM_STR_TYPE_UTF_16 = 3,
69 PLDM_STR_TYPE_UTF_16LE = 4,
70 PLDM_STR_TYPE_UTF_16BE = 5
71};
72
73/** @brief Descriptor types defined in PLDM firmware update specification
74 */
75enum pldm_firmware_update_descriptor_types {
76 PLDM_FWUP_PCI_VENDOR_ID = 0x0000,
77 PLDM_FWUP_IANA_ENTERPRISE_ID = 0x0001,
78 PLDM_FWUP_UUID = 0x0002,
79 PLDM_FWUP_PNP_VENDOR_ID = 0x0003,
80 PLDM_FWUP_ACPI_VENDOR_ID = 0x0004,
81 PLDM_FWUP_IEEE_ASSIGNED_COMPANY_ID = 0x0005,
82 PLDM_FWUP_SCSI_VENDOR_ID = 0x0006,
83 PLDM_FWUP_PCI_DEVICE_ID = 0x0100,
84 PLDM_FWUP_PCI_SUBSYSTEM_VENDOR_ID = 0x0101,
85 PLDM_FWUP_PCI_SUBSYSTEM_ID = 0x0102,
86 PLDM_FWUP_PCI_REVISION_ID = 0x0103,
87 PLDM_FWUP_PNP_PRODUCT_IDENTIFIER = 0x0104,
88 PLDM_FWUP_ACPI_PRODUCT_IDENTIFIER = 0x0105,
89 PLDM_FWUP_ASCII_MODEL_NUMBER_LONG_STRING = 0x0106,
90 PLDM_FWUP_ASCII_MODEL_NUMBER_SHORT_STRING = 0x0107,
91 PLDM_FWUP_SCSI_PRODUCT_ID = 0x0108,
92 PLDM_FWUP_UBM_CONTROLLER_DEVICE_CODE = 0x0109,
93 PLDM_FWUP_VENDOR_DEFINED = 0xFFFF
94};
95
96/** @brief Descriptor types length defined in PLDM firmware update specification
97 */
98enum pldm_firmware_update_descriptor_types_length {
99 PLDM_FWUP_PCI_VENDOR_ID_LENGTH = 2,
100 PLDM_FWUP_IANA_ENTERPRISE_ID_LENGTH = 4,
101 PLDM_FWUP_UUID_LENGTH = 16,
102 PLDM_FWUP_PNP_VENDOR_ID_LENGTH = 3,
103 PLDM_FWUP_ACPI_VENDOR_ID_LENGTH = 4,
104 PLDM_FWUP_IEEE_ASSIGNED_COMPANY_ID_LENGTH = 3,
105 PLDM_FWUP_SCSI_VENDOR_ID_LENGTH = 8,
106 PLDM_FWUP_PCI_DEVICE_ID_LENGTH = 2,
107 PLDM_FWUP_PCI_SUBSYSTEM_VENDOR_ID_LENGTH = 2,
108 PLDM_FWUP_PCI_SUBSYSTEM_ID_LENGTH = 2,
109 PLDM_FWUP_PCI_REVISION_ID_LENGTH = 1,
110 PLDM_FWUP_PNP_PRODUCT_IDENTIFIER_LENGTH = 4,
111 PLDM_FWUP_ACPI_PRODUCT_IDENTIFIER_LENGTH = 4,
112 PLDM_FWUP_ASCII_MODEL_NUMBER_LONG_STRING_LENGTH = 40,
113 PLDM_FWUP_ASCII_MODEL_NUMBER_SHORT_STRING_LENGTH = 10,
114 PLDM_FWUP_SCSI_PRODUCT_ID_LENGTH = 16,
115 PLDM_FWUP_UBM_CONTROLLER_DEVICE_CODE_LENGTH = 4
116};
117
gokulsanker1b909d82021-04-05 17:26:02 +0530118/** @brief ComponentClassification values defined in firmware update
119 * specification
120 */
121enum pldm_component_classification_values {
122 PLDM_COMP_UNKNOWN = 0x0000,
123 PLDM_COMP_OTHER = 0x0001,
124 PLDM_COMP_DRIVER = 0x0002,
125 PLDM_COMP_CONFIGURATION_SOFTWARE = 0x0003,
126 PLDM_COMP_APPLICATION_SOFTWARE = 0x0004,
127 PLDM_COMP_INSTRUMENTATION = 0x0005,
128 PLDM_COMP_FIRMWARE_OR_BIOS = 0x0006,
129 PLDM_COMP_DIAGNOSTIC_SOFTWARE = 0x0007,
130 PLDM_COMP_OPERATING_SYSTEM = 0x0008,
131 PLDM_COMP_MIDDLEWARE = 0x0009,
132 PLDM_COMP_FIRMWARE = 0x000A,
133 PLDM_COMP_BIOS_OR_FCODE = 0x000B,
134 PLDM_COMP_SUPPORT_OR_SERVICEPACK = 0x000C,
135 PLDM_COMP_SOFTWARE_BUNDLE = 0x000D,
136 PLDM_COMP_DOWNSTREAM_DEVICE = 0xFFFF
137};
138
gokulsanker4687f242021-06-27 11:50:26 +0530139/** @brief ComponentActivationMethods is the bit position in the bitfield that
140 * provides the capability of the FD for firmware activation. Multiple
141 * activation methods can be supported.
142 */
143enum pldm_comp_activation_methods {
144 PLDM_ACTIVATION_AUTOMATIC = 0,
145 PLDM_ACTIVATION_SELF_CONTAINED = 1,
146 PLDM_ACTIVATION_MEDIUM_SPECIFIC_RESET = 2,
147 PLDM_ACTIVATION_SYSTEM_REBOOT = 3,
148 PLDM_ACTIVATION_DC_POWER_CYCLE = 4,
149 PLDM_ACTIVATION_AC_POWER_CYCLE = 5,
150 PLDM_SUPPORTS_ACTIVATE_PENDING_IMAGE = 6,
151 PLDM_SUPPORTS_ACTIVATE_PENDING_IMAGE_SET = 7
152};
153
gokulsanker566784b2021-04-05 17:47:04 +0530154/** @brief ComponentResponse values in the response of PassComponentTable
155 */
156enum pldm_component_responses {
157 PLDM_CR_COMP_CAN_BE_UPDATED = 0,
158 PLDM_CR_COMP_MAY_BE_UPDATEABLE = 1
159};
160
161/** @brief ComponentResponseCode values in the response of PassComponentTable
162 */
163enum pldm_component_response_codes {
164 PLDM_CRC_COMP_CAN_BE_UPDATED = 0x00,
165 PLDM_CRC_COMP_COMPARISON_STAMP_IDENTICAL = 0x01,
166 PLDM_CRC_COMP_COMPARISON_STAMP_LOWER = 0x02,
167 PLDM_CRC_INVALID_COMP_COMPARISON_STAMP = 0x03,
168 PLDM_CRC_COMP_CONFLICT = 0x04,
169 PLDM_CRC_COMP_PREREQUISITES_NOT_MET = 0x05,
170 PLDM_CRC_COMP_NOT_SUPPORTED = 0x06,
171 PLDM_CRC_COMP_SECURITY_RESTRICTIONS = 0x07,
172 PLDM_CRC_INCOMPLETE_COMP_IMAGE_SET = 0x08,
173 PLDM_CRC_ACTIVE_IMAGE_NOT_UPDATEABLE_SUBSEQUENTLY = 0x09,
174 PLDM_CRC_COMP_VER_STR_IDENTICAL = 0x0A,
175 PLDM_CRC_COMP_VER_STR_LOWER = 0x0B,
176 PLDM_CRC_VENDOR_COMP_RESP_CODE_RANGE_MIN = 0xD0,
177 PLDM_CRC_VENDOR_COMP_RESP_CODE_RANGE_MAX = 0xEF
178};
179
gokulsanker4b533f22021-04-22 12:53:00 +0530180/** @brief ComponentCompatibilityResponse values in the response of
181 * UpdateComponent
182 */
183enum pldm_component_compatability_responses {
184 PLDM_CCR_COMP_CAN_BE_UPDATED = 0,
185 PLDM_CCR_COMP_CANNOT_BE_UPDATED = 1
186};
187
188/** @brief ComponentCompatibilityResponse Code values in the response of
189 * UpdateComponent
190 */
191enum pldm_component_compatability_response_codes {
192 PLDM_CCRC_NO_RESPONSE_CODE = 0x00,
193 PLDM_CCRC_COMP_COMPARISON_STAMP_IDENTICAL = 0x01,
194 PLDM_CCRC_COMP_COMPARISON_STAMP_LOWER = 0x02,
195 PLDM_CCRC_INVALID_COMP_COMPARISON_STAMP = 0x03,
196 PLDM_CCRC_COMP_CONFLICT = 0x04,
197 PLDM_CCRC_COMP_PREREQUISITES_NOT_MET = 0x05,
198 PLDM_CCRC_COMP_NOT_SUPPORTED = 0x06,
199 PLDM_CCRC_COMP_SECURITY_RESTRICTIONS = 0x07,
200 PLDM_CCRC_INCOMPLETE_COMP_IMAGE_SET = 0x08,
201 PLDM_CCRC_COMP_INFO_NO_MATCH = 0x09,
202 PLDM_CCRC_COMP_VER_STR_IDENTICAL = 0x0A,
203 PLDM_CCRC_COMP_VER_STR_LOWER = 0x0B,
204 PLDM_CCRC_VENDOR_COMP_RESP_CODE_RANGE_MIN = 0xD0,
205 PLDM_CCRC_VENDOR_COMP_RESP_CODE_RANGE_MAX = 0xEF
206};
207
gokulsankere3807022021-06-26 19:12:01 +0530208/** @brief Common error codes in TransferComplete, VerifyComplete and
209 * ApplyComplete request
210 */
211enum pldm_firmware_update_common_error_codes {
212 PLDM_FWUP_TIME_OUT = 0x09,
213 PLDM_FWUP_GENERIC_ERROR = 0x0A
214};
215
gokulsanker50107cf2021-06-27 09:44:12 +0530216/** @brief TransferResult values in the request of TransferComplete
gokulsankere3807022021-06-26 19:12:01 +0530217 */
gokulsanker50107cf2021-06-27 09:44:12 +0530218enum pldm_firmware_update_transfer_result_values {
gokulsankere3807022021-06-26 19:12:01 +0530219 PLDM_FWUP_TRANSFER_SUCCESS = 0x00,
220 PLDM_FWUP_TRANSFER_ERROR_IMAGE_CORRUPT = 0x02,
221 PLDM_FWUP_TRANSFER_ERROR_VERSION_MISMATCH = 0x02,
222 PLDM_FWUP_FD_ABORTED_TRANSFER = 0x03,
223 PLDM_FWUP_FD_ABORTED_TRANSFER_LOW_POWER_STATE = 0x0B,
224 PLDM_FWUP_FD_ABORTED_TRANSFER_RESET_NEEDED = 0x0C,
225 PLDM_FWUP_FD_ABORTED_TRANSFER_STORAGE_ISSUE = 0x0D,
226 PLDM_FWUP_VENDOR_TRANSFER_RESULT_RANGE_MIN = 0x70,
227 PLDM_FWUP_VENDOR_TRANSFER_RESULT_RANGE_MAX = 0x8F
228};
229
gokulsanker9a693582021-06-27 11:35:09 +0530230/**@brief VerifyResult values in the request of VerifyComplete
gokulsankerb79b91a2021-06-27 11:26:36 +0530231 */
232enum pldm_firmware_update_verify_result_values {
233 PLDM_FWUP_VERIFY_SUCCESS = 0x00,
234 PLDM_FWUP_VERIFY_ERROR_VERIFICATION_FAILURE = 0x01,
235 PLDM_FWUP_VERIFY_ERROR_VERSION_MISMATCH = 0x02,
236 PLDM_FWUP_VERIFY_FAILED_FD_SECURITY_CHECKS = 0x03,
237 PLDM_FWUP_VERIFY_ERROR_IMAGE_INCOMPLETE = 0x04,
238 PLDM_FWUP_VENDOR_VERIFY_RESULT_RANGE_MIN = 0x90,
239 PLDM_FWUP_VENDOR_VERIFY_RESULT_RANGE_MAX = 0xAF
240};
241
gokulsankerd6f79b82021-06-27 12:00:25 +0530242/**@brief ApplyResult values in the request of ApplyComplete
gokulsanker4687f242021-06-27 11:50:26 +0530243 */
244enum pldm_firmware_update_apply_result_values {
245 PLDM_FWUP_APPLY_SUCCESS = 0x00,
246 PLDM_FWUP_APPLY_SUCCESS_WITH_ACTIVATION_METHOD = 0x01,
247 PLDM_FWUP_APPLY_FAILURE_MEMORY_ISSUE = 0x02,
248 PLDM_FWUP_VENDOR_APPLY_RESULT_RANGE_MIN = 0xB0,
249 PLDM_FWUP_VENDOR_APPLY_RESULT_RANGE_MAX = 0xCF
250};
251
gokulsanker773cd1f2021-04-27 17:59:15 +0530252/** @brief SelfContainedActivationRequest in the request of ActivateFirmware
253 */
254enum pldm_self_contained_activation_req {
255 PLDM_NOT_ACTIVATE_SELF_CONTAINED_COMPONENTS = false,
256 PLDM_ACTIVATE_SELF_CONTAINED_COMPONENTS = true
257};
258
Tom Joseph568e4702021-06-07 22:15:49 -0700259/** @struct pldm_package_header_information
260 *
261 * Structure representing fixed part of package header information
262 */
263struct pldm_package_header_information {
264 uint8_t uuid[PLDM_FWUP_UUID_LENGTH];
265 uint8_t package_header_format_version;
266 uint16_t package_header_size;
267 uint8_t timestamp104[PLDM_TIMESTAMP104_SIZE];
268 uint16_t component_bitmap_bit_length;
269 uint8_t package_version_string_type;
270 uint8_t package_version_string_length;
271} __attribute__((packed));
272
Tom Joseph64af3452021-06-08 04:05:28 -0700273/** @struct pldm_firmware_device_id_record
274 *
275 * Structure representing firmware device ID record
276 */
277struct pldm_firmware_device_id_record {
278 uint16_t record_length;
279 uint8_t descriptor_count;
280 bitfield32_t device_update_option_flags;
281 uint8_t comp_image_set_version_string_type;
282 uint8_t comp_image_set_version_string_length;
283 uint16_t fw_device_pkg_data_length;
284} __attribute__((packed));
285
Tom Joseph763b51e2021-06-05 04:50:47 -0700286/** @struct pldm_descriptor_tlv
287 *
288 * Structure representing descriptor type, length and value
289 */
290struct pldm_descriptor_tlv {
291 uint16_t descriptor_type;
292 uint16_t descriptor_length;
293 uint8_t descriptor_data[1];
294} __attribute__((packed));
295
296/** @struct pldm_vendor_defined_descriptor_title_data
297 *
298 * Structure representing vendor defined descriptor title sections
299 */
300struct pldm_vendor_defined_descriptor_title_data {
301 uint8_t vendor_defined_descriptor_title_str_type;
302 uint8_t vendor_defined_descriptor_title_str_len;
303 uint8_t vendor_defined_descriptor_title_str[1];
304} __attribute__((packed));
305
Tom Joseph58cc1722021-06-09 07:15:49 -0700306/** @struct pldm_component_image_information
307 *
308 * Structure representing fixed part of individual component information in
309 * PLDM firmware update package
310 */
311struct pldm_component_image_information {
312 uint16_t comp_classification;
313 uint16_t comp_identifier;
314 uint32_t comp_comparison_stamp;
315 bitfield16_t comp_options;
316 bitfield16_t requested_comp_activation_method;
317 uint32_t comp_location_offset;
318 uint32_t comp_size;
319 uint8_t comp_version_string_type;
320 uint8_t comp_version_string_length;
321} __attribute__((packed));
322
gokulsankereca3e192021-04-05 14:57:41 +0530323/** @struct pldm_query_device_identifiers_resp
324 *
325 * Structure representing query device identifiers response.
326 */
327struct pldm_query_device_identifiers_resp {
328 uint8_t completion_code;
329 uint32_t device_identifiers_len;
330 uint8_t descriptor_count;
331} __attribute__((packed));
332
gokulsanker22fbb342021-04-05 15:55:06 +0530333/** @struct pldm_get_firmware_parameters_resp
334 *
Tom Joseph3fd3eb82021-06-18 04:13:29 -0700335 * Structure representing the fixed part of GetFirmwareParameters response
gokulsanker22fbb342021-04-05 15:55:06 +0530336 */
337struct pldm_get_firmware_parameters_resp {
338 uint8_t completion_code;
339 bitfield32_t capabilities_during_update;
340 uint16_t comp_count;
341 uint8_t active_comp_image_set_ver_str_type;
342 uint8_t active_comp_image_set_ver_str_len;
343 uint8_t pending_comp_image_set_ver_str_type;
344 uint8_t pending_comp_image_set_ver_str_len;
345} __attribute__((packed));
346
gokulsankere1fb7a82021-04-05 16:09:29 +0530347/** @struct pldm_component_parameter_entry
348 *
349 * Structure representing component parameter table entry.
350 */
351struct pldm_component_parameter_entry {
352 uint16_t comp_classification;
353 uint16_t comp_identifier;
354 uint8_t comp_classification_index;
355 uint32_t active_comp_comparison_stamp;
356 uint8_t active_comp_ver_str_type;
357 uint8_t active_comp_ver_str_len;
358 uint8_t active_comp_release_date[8];
359 uint32_t pending_comp_comparison_stamp;
360 uint8_t pending_comp_ver_str_type;
361 uint8_t pending_comp_ver_str_len;
362 uint8_t pending_comp_release_date[8];
363 bitfield16_t comp_activation_methods;
364 bitfield32_t capabilities_during_update;
365} __attribute__((packed));
366
gokulsankerd434edc2021-04-05 16:36:04 +0530367/** @struct pldm_request_update_req
368 *
369 * Structure representing fixed part of Request Update request
370 */
371struct pldm_request_update_req {
372 uint32_t max_transfer_size;
373 uint16_t num_of_comp;
374 uint8_t max_outstanding_transfer_req;
375 uint16_t pkg_data_len;
376 uint8_t comp_image_set_ver_str_type;
377 uint8_t comp_image_set_ver_str_len;
378} __attribute__((packed));
379
gokulsanker611238c2021-04-05 16:50:44 +0530380/** @struct pldm_request_update_resp
381 *
382 * Structure representing Request Update response
383 */
384struct pldm_request_update_resp {
385 uint8_t completion_code;
386 uint16_t fd_meta_data_len;
387 uint8_t fd_will_send_pkg_data;
388} __attribute__((packed));
389
gokulsanker1b909d82021-04-05 17:26:02 +0530390/** @struct pldm_pass_component_table_req
391 *
392 * Structure representing PassComponentTable request
393 */
394struct pldm_pass_component_table_req {
395 uint8_t transfer_flag;
396 uint16_t comp_classification;
397 uint16_t comp_identifier;
398 uint8_t comp_classification_index;
399 uint32_t comp_comparison_stamp;
400 uint8_t comp_ver_str_type;
401 uint8_t comp_ver_str_len;
402} __attribute__((packed));
403
gokulsanker566784b2021-04-05 17:47:04 +0530404/** @struct pldm_pass_component_table_resp
405 *
406 * Structure representing PassComponentTable response
407 */
408struct pldm_pass_component_table_resp {
409 uint8_t completion_code;
410 uint8_t comp_resp;
411 uint8_t comp_resp_code;
412} __attribute__((packed));
413
gokulsankeraa3a5cd2021-04-22 11:06:42 +0530414/** @struct pldm_update_component_req
415 *
416 * Structure representing UpdateComponent request
417 */
418struct pldm_update_component_req {
419 uint16_t comp_classification;
420 uint16_t comp_identifier;
421 uint8_t comp_classification_index;
422 uint32_t comp_comparison_stamp;
423 uint32_t comp_image_size;
424 bitfield32_t update_option_flags;
425 uint8_t comp_ver_str_type;
426 uint8_t comp_ver_str_len;
427} __attribute__((packed));
428
gokulsanker4b533f22021-04-22 12:53:00 +0530429/** @struct pldm_update_component_resp
430 *
431 * Structure representing UpdateComponent response
432 */
433struct pldm_update_component_resp {
434 uint8_t completion_code;
435 uint8_t comp_compatability_resp;
436 uint8_t comp_compatability_resp_code;
437 bitfield32_t update_option_flags_enabled;
438 uint16_t time_before_req_fw_data;
439} __attribute__((packed));
440
gokulsankera4e6b292021-06-02 16:35:39 +0530441/** @struct pldm_request_firmware_data_req
442 *
443 * Structure representing RequestFirmwareData request.
444 */
445struct pldm_request_firmware_data_req {
446 uint32_t offset;
447 uint32_t length;
448} __attribute__((packed));
449
gokulsanker4687f242021-06-27 11:50:26 +0530450/** @struct pldm_apply_complete_req
451 *
452 * Structure representing ApplyComplete request.
453 */
454struct pldm_apply_complete_req {
455 uint8_t apply_result;
456 bitfield16_t comp_activation_methods_modification;
457} __attribute__((packed));
458
gokulsanker773cd1f2021-04-27 17:59:15 +0530459/** @struct pldm_activate_firmware_req
460 *
461 * Structure representing ActivateFirmware request
462 */
463struct pldm_activate_firmware_req {
464 bool8_t self_contained_activation_req;
465} __attribute__((packed));
466
Tom Joseph568e4702021-06-07 22:15:49 -0700467/** @brief Decode the PLDM package header information
468 *
469 * @param[in] data - pointer to package header information
470 * @param[in] length - available length in the firmware update package
471 * @param[out] package_header_info - pointer to fixed part of PLDM package
472 * header information
473 * @param[out] package_version_str - pointer to package version string
474 *
475 * @return pldm_completion_codes
476 */
477int decode_pldm_package_header_info(
478 const uint8_t *data, size_t length,
479 struct pldm_package_header_information *package_header_info,
480 struct variable_field *package_version_str);
481
Tom Joseph64af3452021-06-08 04:05:28 -0700482/** @brief Decode individual firmware device ID record
483 *
484 * @param[in] data - pointer to firmware device ID record
485 * @param[in] length - available length in the firmware update package
486 * @param[in] component_bitmap_bit_length - ComponentBitmapBitLengthfield
487 * parsed from the package header info
488 * @param[out] fw_device_id_record - pointer to fixed part of firmware device
489 * id record
490 * @param[out] applicable_components - pointer to ApplicableComponents
491 * @param[out] comp_image_set_version_str - pointer to
492 * ComponentImageSetVersionString
493 * @param[out] record_descriptors - pointer to RecordDescriptors
494 * @param[out] fw_device_pkg_data - pointer to FirmwareDevicePackageData
495 *
496 * @return pldm_completion_codes
497 */
498int decode_firmware_device_id_record(
499 const uint8_t *data, size_t length, uint16_t component_bitmap_bit_length,
500 struct pldm_firmware_device_id_record *fw_device_id_record,
501 struct variable_field *applicable_components,
502 struct variable_field *comp_image_set_version_str,
503 struct variable_field *record_descriptors,
504 struct variable_field *fw_device_pkg_data);
505
Tom Joseph763b51e2021-06-05 04:50:47 -0700506/** @brief Decode the record descriptor entries in the firmware update package
507 * and the Descriptors in the QueryDeviceIDentifiers command
508 *
509 * @param[in] data - pointer to descriptor entry
510 * @param[in] length - remaining length of the descriptor data
511 * @param[out] descriptor_type - pointer to descriptor type
512 * @param[out] descriptor_data - pointer to descriptor data
513 *
514 * @return pldm_completion_codes
515 */
516int decode_descriptor_type_length_value(const uint8_t *data, size_t length,
517 uint16_t *descriptor_type,
518 struct variable_field *descriptor_data);
519
520/** @brief Decode the vendor defined descriptor value
521 *
522 * @param[in] data - pointer to vendor defined descriptor value
523 * @param[in] length - length of the vendor defined descriptor value
524 * @param[out] descriptor_title_str_type - pointer to vendor defined descriptor
525 * title string type
526 * @param[out] descriptor_title_str - pointer to vendor defined descriptor
527 * title string
528 * @param[out] descriptor_data - pointer to vendor defined descriptor data
529 *
530 * @return pldm_completion_codes
531 */
532int decode_vendor_defined_descriptor_value(
533 const uint8_t *data, size_t length, uint8_t *descriptor_title_str_type,
534 struct variable_field *descriptor_title_str,
535 struct variable_field *descriptor_data);
536
Tom Joseph58cc1722021-06-09 07:15:49 -0700537/** @brief Decode individual component image information
538 *
539 * @param[in] data - pointer to component image information
540 * @param[in] length - available length in the firmware update package
541 * @param[out] pldm_comp_image_info - pointer to fixed part of component image
542 * information
543 * @param[out] comp_version_str - pointer to component version string
544 *
545 * @return pldm_completion_codes
546 */
547int decode_pldm_comp_image_info(
548 const uint8_t *data, size_t length,
549 struct pldm_component_image_information *pldm_comp_image_info,
550 struct variable_field *comp_version_str);
551
gokulsanker138ceba2021-04-05 13:25:25 +0530552/** @brief Create a PLDM request message for QueryDeviceIdentifiers
553 *
554 * @param[in] instance_id - Message's instance id
555 * @param[in] payload_length - Length of the request message payload
556 * @param[in,out] msg - Message will be written to this
557 *
558 * @return pldm_completion_codes
559 *
560 * @note Caller is responsible for memory alloc and dealloc of param
561 * 'msg.payload'
562 */
563int encode_query_device_identifiers_req(uint8_t instance_id,
564 size_t payload_length,
565 struct pldm_msg *msg);
gokulsankereca3e192021-04-05 14:57:41 +0530566
567/** @brief Decode QueryDeviceIdentifiers response message
568 *
569 * @param[in] msg - Response message
570 * @param[in] payload_length - Length of response message payload
571 * @param[out] completion_code - Pointer to response msg's PLDM completion code
572 * @param[out] device_identifiers_len - Pointer to device identifiers length
573 * @param[out] descriptor_count - Pointer to descriptor count
574 * @param[out] descriptor_data - Pointer to descriptor data
575 *
576 * @return pldm_completion_codes
577 */
578int decode_query_device_identifiers_resp(const struct pldm_msg *msg,
579 size_t payload_length,
580 uint8_t *completion_code,
581 uint32_t *device_identifiers_len,
582 uint8_t *descriptor_count,
583 uint8_t **descriptor_data);
gokulsanker981fbfb2021-04-05 15:17:25 +0530584
585/** @brief Create a PLDM request message for GetFirmwareParameters
586 *
587 * @param[in] instance_id - Message's instance id
588 * @param[in] payload_length - Length of the request message payload
589 * @param[in,out] msg - Message will be written to this
590 *
591 * @return pldm_completion_codes
592 *
593 * @note Caller is responsible for memory alloc and dealloc of param
594 * 'msg.payload'
595 */
596int encode_get_firmware_parameters_req(uint8_t instance_id,
597 size_t payload_length,
598 struct pldm_msg *msg);
gokulsanker22fbb342021-04-05 15:55:06 +0530599
Tom Joseph3fd3eb82021-06-18 04:13:29 -0700600/** @brief Decode GetFirmwareParameters response
gokulsanker22fbb342021-04-05 15:55:06 +0530601 *
602 * @param[in] msg - Response message
603 * @param[in] payload_length - Length of response message payload
604 * @param[out] resp_data - Pointer to get firmware parameters response
605 * @param[out] active_comp_image_set_ver_str - Pointer to active component
Tom Joseph3fd3eb82021-06-18 04:13:29 -0700606 * image set version string
gokulsanker22fbb342021-04-05 15:55:06 +0530607 * @param[out] pending_comp_image_set_ver_str - Pointer to pending component
Tom Joseph3fd3eb82021-06-18 04:13:29 -0700608 * image set version string
609 * @param[out] comp_parameter_table - Pointer to component parameter table
gokulsanker22fbb342021-04-05 15:55:06 +0530610 *
611 * @return pldm_completion_codes
612 */
Tom Joseph3fd3eb82021-06-18 04:13:29 -0700613int decode_get_firmware_parameters_resp(
gokulsanker22fbb342021-04-05 15:55:06 +0530614 const struct pldm_msg *msg, size_t payload_length,
615 struct pldm_get_firmware_parameters_resp *resp_data,
616 struct variable_field *active_comp_image_set_ver_str,
Tom Joseph3fd3eb82021-06-18 04:13:29 -0700617 struct variable_field *pending_comp_image_set_ver_str,
618 struct variable_field *comp_parameter_table);
gokulsanker22fbb342021-04-05 15:55:06 +0530619
gokulsankere1fb7a82021-04-05 16:09:29 +0530620/** @brief Decode component entries in the component parameter table which is
621 * part of the response of GetFirmwareParameters command
622 *
623 * @param[in] data - Component entry
624 * @param[in] length - Length of component entry
625 * @param[out] component_data - Pointer to component parameter table
626 * @param[out] active_comp_ver_str - Pointer to active component version string
627 * @param[out] pending_comp_ver_str - Pointer to pending component version
628 * string
629 *
630 * @return pldm_completion_codes
631 */
632int decode_get_firmware_parameters_resp_comp_entry(
633 const uint8_t *data, size_t length,
634 struct pldm_component_parameter_entry *component_data,
635 struct variable_field *active_comp_ver_str,
636 struct variable_field *pending_comp_ver_str);
637
gokulsankerd434edc2021-04-05 16:36:04 +0530638/** @brief Create PLDM request message for RequestUpdate
639 *
640 * @param[in] instance_id - Message's instance id
641 * @param[in] max_transfer_size - Maximum size of the variable payload allowed
642 * to be requested via RequestFirmwareData
643 * command
644 * @param[in] num_of_comp - Total number of components that will be passed to
645 * the FD during the update
646 * @param[in] max_outstanding_transfer_req - Total number of outstanding
647 * RequestFirmwareData
648 * commands that can be sent by the FD
649 * @param[in] pkg_data_len - Value of the FirmwareDevicePackageDataLength field
650 * present in firmware package header
651 * @param[in] comp_image_set_ver_str_type - StringType of
652 * ComponentImageSetVersionString
653 * @param[in] comp_image_set_ver_str_len - The length of the
654 * ComponentImageSetVersionString
655 * @param[in] comp_img_set_ver_str - Component Image Set version information
656 * @param[in,out] msg - Message will be written to this
657 * @param[in] payload_length - Length of request message payload
658 *
659 * @return pldm_completion_codes
660 *
661 * @note Caller is responsible for memory alloc and dealloc of param
662 * 'msg.payload'
663 */
664int encode_request_update_req(uint8_t instance_id, uint32_t max_transfer_size,
665 uint16_t num_of_comp,
666 uint8_t max_outstanding_transfer_req,
667 uint16_t pkg_data_len,
668 uint8_t comp_image_set_ver_str_type,
669 uint8_t comp_image_set_ver_str_len,
670 const struct variable_field *comp_img_set_ver_str,
671 struct pldm_msg *msg, size_t payload_length);
gokulsanker611238c2021-04-05 16:50:44 +0530672
673/** @brief Decode a RequestUpdate response message
674 *
675 * @param[in] msg - Response message
676 * @param[in] payload_length - Length of response message payload
677 * @param[out] completion_code - Pointer to hold the completion code
678 * @param[out] fd_meta_data_len - Pointer to hold the length of FD metadata
679 * @param[out] fd_will_send_pkg_data - Pointer to hold information whether FD
680 * will send GetPackageData command
681 * @return pldm_completion_codes
682 */
683int decode_request_update_resp(const struct pldm_msg *msg,
684 size_t payload_length, uint8_t *completion_code,
685 uint16_t *fd_meta_data_len,
686 uint8_t *fd_will_send_pkg_data);
687
gokulsanker1b909d82021-04-05 17:26:02 +0530688/** @brief Create PLDM request message for PassComponentTable
689 *
690 * @param[in] instance_id - Message's instance id
691 * @param[in] transfer_flag - TransferFlag
692 * @param[in] comp_classification - ComponentClassification
693 * @param[in] comp_identifier - ComponentIdentifier
694 * @param[in] comp_classification_index - ComponentClassificationIndex
695 * @param[in] comp_comparison_stamp - ComponentComparisonStamp
696 * @param[in] comp_ver_str_type - ComponentVersionStringType
697 * @param[in] comp_ver_str_len - ComponentVersionStringLength
698 * @param[in] comp_ver_str - ComponentVersionString
699 * @param[in,out] msg - Message will be written to this
700 * @param[in] payload_length - Length of request message payload
701 * information
702 *
703 * @return pldm_completion_codes
704 *
705 * @note Caller is responsible for memory alloc and dealloc of param
706 * 'msg.payload'
707 */
708int encode_pass_component_table_req(
709 uint8_t instance_id, uint8_t transfer_flag, uint16_t comp_classification,
710 uint16_t comp_identifier, uint8_t comp_classification_index,
711 uint32_t comp_comparison_stamp, uint8_t comp_ver_str_type,
712 uint8_t comp_ver_str_len, const struct variable_field *comp_ver_str,
713 struct pldm_msg *msg, size_t payload_length);
714
gokulsanker566784b2021-04-05 17:47:04 +0530715/** @brief Decode PassComponentTable response message
716 *
717 * @param[in] msg - Response message
718 * @param[in] payload_length - Length of response message payload
719 * @param[out] completion_code - Pointer to hold completion code
720 * @param[out] comp_resp - Pointer to hold component response
721 * @param[out] comp_resp_code - Pointer to hold component response code
722 *
723 * @return pldm_completion_codes
724 */
725int decode_pass_component_table_resp(const struct pldm_msg *msg,
726 size_t payload_length,
727 uint8_t *completion_code,
728 uint8_t *comp_resp,
729 uint8_t *comp_resp_code);
730
gokulsankeraa3a5cd2021-04-22 11:06:42 +0530731/** @brief Create PLDM request message for UpdateComponent
732 *
733 * @param[in] instance_id - Message's instance id
734 * @param[in] comp_classification - ComponentClassification
735 * @param[in] comp_identifier - ComponentIdentifier
736 * @param[in] comp_classification_index - ComponentClassificationIndex
737 * @param[in] comp_comparison_stamp - ComponentComparisonStamp
738 * @param[in] comp_image_size - ComponentImageSize
739 * @param[in] update_option_flags - UpdateOptionFlags
740 * @param[in] comp_ver_str_type - ComponentVersionStringType
741 * @param[in] comp_ver_str_len - ComponentVersionStringLength
742 * @param[in] comp_ver_str - ComponentVersionString
743 * @param[in,out] msg - Message will be written to this
744 * @param[in] payload_length - Length of request message payload
745 * information
746 *
747 * @return pldm_completion_codes
748 *
749 * @note Caller is responsible for memory alloc and dealloc of param
750 * 'msg.payload'
751 */
752int encode_update_component_req(
753 uint8_t instance_id, uint16_t comp_classification, uint16_t comp_identifier,
754 uint8_t comp_classification_index, uint32_t comp_comparison_stamp,
755 uint32_t comp_image_size, bitfield32_t update_option_flags,
756 uint8_t comp_ver_str_type, uint8_t comp_ver_str_len,
757 const struct variable_field *comp_ver_str, struct pldm_msg *msg,
758 size_t payload_length);
759
gokulsanker4b533f22021-04-22 12:53:00 +0530760/** @brief Decode UpdateComponent response message
761 *
762 * @param[in] msg - Response message
763 * @param[in] payload_length - Length of response message payload
764 * @param[out] completion_code - Pointer to hold completion code
765 * @param[out] comp_compatability_resp - Pointer to hold component
766 * compatibility response
767 * @param[out] comp_compatability_resp_code - Pointer to hold component
768 * compatibility response code
769 * @param[out] update_option_flags_enabled - Pointer to hold
770 * UpdateOptionsFlagEnabled
771 * @param[out] time_before_req_fw_data - Pointer to hold the estimated time
772 * before sending RequestFirmwareData
773 *
774 * @return pldm_completion_codes
775 */
776int decode_update_component_resp(const struct pldm_msg *msg,
777 size_t payload_length,
778 uint8_t *completion_code,
779 uint8_t *comp_compatability_resp,
780 uint8_t *comp_compatability_resp_code,
781 bitfield32_t *update_option_flags_enabled,
782 uint16_t *time_before_req_fw_data);
gokulsankera4e6b292021-06-02 16:35:39 +0530783
784/** @brief Decode RequestFirmwareData request message
785 *
786 * @param[in] msg - Request message
787 * @param[in] payload_length - Length of request message payload
788 * @param[out] offset - Pointer to hold offset
789 * @param[out] length - Pointer to hold the size of the component image
790 * segment requested by the FD/FDP
791 *
792 * @return pldm_completion_codes
793 */
794int decode_request_firmware_data_req(const struct pldm_msg *msg,
795 size_t payload_length, uint32_t *offset,
796 uint32_t *length);
gokulsanker9c440d02021-06-03 09:54:02 +0530797
798/** @brief Create PLDM response message for RequestFirmwareData
799 *
800 * The ComponentImagePortion is not encoded in the PLDM response message
801 * by encode_request_firmware_data_resp to avoid an additional copy. Populating
802 * ComponentImagePortion in the PLDM response message is handled by the user
803 * of this API. The payload_length validation considers only the
804 * CompletionCode.
805 *
806 * @param[in] instance_id - Message's instance id
807 * @param[in] completion_code - CompletionCode
808 * @param[in,out] msg - Message will be written to this
809 * @param[in] payload_length - Length of response message payload
810 *
811 * @return pldm_completion_codes
812 *
813 * @note Caller is responsible for memory alloc and dealloc of param
814 * 'msg.payload'
815 */
816int encode_request_firmware_data_resp(uint8_t instance_id,
817 uint8_t completion_code,
818 struct pldm_msg *msg,
819 size_t payload_length);
820
gokulsankere3807022021-06-26 19:12:01 +0530821/** @brief Decode TransferComplete request message
822 *
823 * @param[in] msg - Request message
824 * @param[in] payload_length - Length of request message payload
825 * @param[out] transfer_result - Pointer to hold TransferResult
826 *
827 * @return pldm_completion_codes
828 */
829int decode_transfer_complete_req(const struct pldm_msg *msg,
830 size_t payload_length,
831 uint8_t *transfer_result);
gokulsanker50107cf2021-06-27 09:44:12 +0530832
833/** @brief Create PLDM response message for TransferComplete
834 *
835 * @param[in] instance_id - Message's instance id
836 * @param[in] completion_code - CompletionCode
837 * @param[in,out] msg - Message will be written to this
838 * @param[in] payload_length - Length of response message payload
839 *
840 * @return pldm_completion_codes
841 *
842 * @note Caller is responsible for memory alloc and dealloc of param
843 * 'msg.payload'
844 */
845int encode_transfer_complete_resp(uint8_t instance_id, uint8_t completion_code,
846 struct pldm_msg *msg, size_t payload_length);
gokulsankerb79b91a2021-06-27 11:26:36 +0530847
848/** @brief Decode VerifyComplete request message
849 *
850 * @param[in] msg - Request message
851 * @param[in] payload_length - Length of request message payload
852 * @param[in] verify_result - Pointer to hold VerifyResult
853 *
854 * @return pldm_completion_codes
855 */
856int decode_verify_complete_req(const struct pldm_msg *msg,
857 size_t payload_length, uint8_t *verify_result);
858
gokulsanker9a693582021-06-27 11:35:09 +0530859/** @brief Create PLDM response message for VerifyComplete
860 *
861 * @param[in] instance_id - Message's instance id
862 * @param[in] completion_code - CompletionCode
863 * @param[in,out] msg - Message will be written to this
864 * @param[in] payload_length - Length of response message payload
865 *
866 * @return pldm_completion_codes
867 *
868 * @note Caller is responsible for memory alloc and dealloc of param
869 * 'msg.payload'
870 */
871int encode_verify_complete_resp(uint8_t instance_id, uint8_t completion_code,
872 struct pldm_msg *msg, size_t payload_length);
873
gokulsanker4687f242021-06-27 11:50:26 +0530874/** @brief Decode ApplyComplete request message
875 *
876 * @param[in] msg - Request message
877 * @param[in] payload_length - Length of request message payload
878 * @param[in] apply_result - Pointer to hold ApplyResult
879 * @param[in] comp_activation_methods_modification - Pointer to hold the
880 * ComponentActivationMethodsModification
881 *
882 * @return pldm_completion_codes
883 */
884int decode_apply_complete_req(
885 const struct pldm_msg *msg, size_t payload_length, uint8_t *apply_result,
886 bitfield16_t *comp_activation_methods_modification);
887
gokulsankerd6f79b82021-06-27 12:00:25 +0530888/** @brief Create PLDM response message for ApplyComplete
889 *
890 * @param[in] instance_id - Message's instance id
891 * @param[in] completion_code - CompletionCode
892 * @param[in,out] msg - Message will be written to this
893 * @param[in] payload_length - Length of response message payload
894 *
895 * @return pldm_completion_codes
896 *
897 * @note Caller is responsible for memory alloc and dealloc of param
898 * 'msg.payload'
899 */
900int encode_apply_complete_resp(uint8_t instance_id, uint8_t completion_code,
901 struct pldm_msg *msg, size_t payload_length);
902
gokulsanker773cd1f2021-04-27 17:59:15 +0530903/** @brief Create PLDM request message for ActivateFirmware
904 *
905 * @param[in] instance_id - Message's instance id
906 * @param[in] self_contained_activation_req SelfContainedActivationRequest
907 * @param[in,out] msg - Message will be written to this
908 * @param[in] payload_length - Length of request message payload
909 *
910 * @return pldm_completion_codes
911 *
912 * @note Caller is responsible for memory alloc and dealloc of param
913 * 'msg.payload'
914 */
915int encode_activate_firmware_req(uint8_t instance_id,
916 bool8_t self_contained_activation_req,
917 struct pldm_msg *msg, size_t payload_length);
918
gokulsanker138ceba2021-04-05 13:25:25 +0530919#ifdef __cplusplus
920}
921#endif
922
923#endif // End of FW_UPDATE_H