blob: bb09c5667b1c5206b2541278d13e7cd7a7bdd7dd [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
gokulsanker630f76a2021-04-27 18:41:28 +0530467/** @struct activate_firmware_resp
468 *
469 * Structure representing Activate Firmware response
470 */
471struct pldm_activate_firmware_resp {
472 uint8_t completion_code;
473 uint16_t estimated_time_activation;
474} __attribute__((packed));
475
Tom Joseph568e4702021-06-07 22:15:49 -0700476/** @brief Decode the PLDM package header information
477 *
478 * @param[in] data - pointer to package header information
479 * @param[in] length - available length in the firmware update package
480 * @param[out] package_header_info - pointer to fixed part of PLDM package
481 * header information
482 * @param[out] package_version_str - pointer to package version string
483 *
484 * @return pldm_completion_codes
485 */
486int decode_pldm_package_header_info(
487 const uint8_t *data, size_t length,
488 struct pldm_package_header_information *package_header_info,
489 struct variable_field *package_version_str);
490
Tom Joseph64af3452021-06-08 04:05:28 -0700491/** @brief Decode individual firmware device ID record
492 *
493 * @param[in] data - pointer to firmware device ID record
494 * @param[in] length - available length in the firmware update package
495 * @param[in] component_bitmap_bit_length - ComponentBitmapBitLengthfield
496 * parsed from the package header info
497 * @param[out] fw_device_id_record - pointer to fixed part of firmware device
498 * id record
499 * @param[out] applicable_components - pointer to ApplicableComponents
500 * @param[out] comp_image_set_version_str - pointer to
501 * ComponentImageSetVersionString
502 * @param[out] record_descriptors - pointer to RecordDescriptors
503 * @param[out] fw_device_pkg_data - pointer to FirmwareDevicePackageData
504 *
505 * @return pldm_completion_codes
506 */
507int decode_firmware_device_id_record(
508 const uint8_t *data, size_t length, uint16_t component_bitmap_bit_length,
509 struct pldm_firmware_device_id_record *fw_device_id_record,
510 struct variable_field *applicable_components,
511 struct variable_field *comp_image_set_version_str,
512 struct variable_field *record_descriptors,
513 struct variable_field *fw_device_pkg_data);
514
Tom Joseph763b51e2021-06-05 04:50:47 -0700515/** @brief Decode the record descriptor entries in the firmware update package
516 * and the Descriptors in the QueryDeviceIDentifiers command
517 *
518 * @param[in] data - pointer to descriptor entry
519 * @param[in] length - remaining length of the descriptor data
520 * @param[out] descriptor_type - pointer to descriptor type
521 * @param[out] descriptor_data - pointer to descriptor data
522 *
523 * @return pldm_completion_codes
524 */
525int decode_descriptor_type_length_value(const uint8_t *data, size_t length,
526 uint16_t *descriptor_type,
527 struct variable_field *descriptor_data);
528
529/** @brief Decode the vendor defined descriptor value
530 *
531 * @param[in] data - pointer to vendor defined descriptor value
532 * @param[in] length - length of the vendor defined descriptor value
533 * @param[out] descriptor_title_str_type - pointer to vendor defined descriptor
534 * title string type
535 * @param[out] descriptor_title_str - pointer to vendor defined descriptor
536 * title string
537 * @param[out] descriptor_data - pointer to vendor defined descriptor data
538 *
539 * @return pldm_completion_codes
540 */
541int decode_vendor_defined_descriptor_value(
542 const uint8_t *data, size_t length, uint8_t *descriptor_title_str_type,
543 struct variable_field *descriptor_title_str,
544 struct variable_field *descriptor_data);
545
Tom Joseph58cc1722021-06-09 07:15:49 -0700546/** @brief Decode individual component image information
547 *
548 * @param[in] data - pointer to component image information
549 * @param[in] length - available length in the firmware update package
550 * @param[out] pldm_comp_image_info - pointer to fixed part of component image
551 * information
552 * @param[out] comp_version_str - pointer to component version string
553 *
554 * @return pldm_completion_codes
555 */
556int decode_pldm_comp_image_info(
557 const uint8_t *data, size_t length,
558 struct pldm_component_image_information *pldm_comp_image_info,
559 struct variable_field *comp_version_str);
560
gokulsanker138ceba2021-04-05 13:25:25 +0530561/** @brief Create a PLDM request message for QueryDeviceIdentifiers
562 *
563 * @param[in] instance_id - Message's instance id
564 * @param[in] payload_length - Length of the request message payload
565 * @param[in,out] msg - Message will be written to this
566 *
567 * @return pldm_completion_codes
568 *
569 * @note Caller is responsible for memory alloc and dealloc of param
570 * 'msg.payload'
571 */
572int encode_query_device_identifiers_req(uint8_t instance_id,
573 size_t payload_length,
574 struct pldm_msg *msg);
gokulsankereca3e192021-04-05 14:57:41 +0530575
576/** @brief Decode QueryDeviceIdentifiers response message
577 *
578 * @param[in] msg - Response message
579 * @param[in] payload_length - Length of response message payload
580 * @param[out] completion_code - Pointer to response msg's PLDM completion code
581 * @param[out] device_identifiers_len - Pointer to device identifiers length
582 * @param[out] descriptor_count - Pointer to descriptor count
583 * @param[out] descriptor_data - Pointer to descriptor data
584 *
585 * @return pldm_completion_codes
586 */
587int decode_query_device_identifiers_resp(const struct pldm_msg *msg,
588 size_t payload_length,
589 uint8_t *completion_code,
590 uint32_t *device_identifiers_len,
591 uint8_t *descriptor_count,
592 uint8_t **descriptor_data);
gokulsanker981fbfb2021-04-05 15:17:25 +0530593
594/** @brief Create a PLDM request message for GetFirmwareParameters
595 *
596 * @param[in] instance_id - Message's instance id
597 * @param[in] payload_length - Length of the request message payload
598 * @param[in,out] msg - Message will be written to this
599 *
600 * @return pldm_completion_codes
601 *
602 * @note Caller is responsible for memory alloc and dealloc of param
603 * 'msg.payload'
604 */
605int encode_get_firmware_parameters_req(uint8_t instance_id,
606 size_t payload_length,
607 struct pldm_msg *msg);
gokulsanker22fbb342021-04-05 15:55:06 +0530608
Tom Joseph3fd3eb82021-06-18 04:13:29 -0700609/** @brief Decode GetFirmwareParameters response
gokulsanker22fbb342021-04-05 15:55:06 +0530610 *
611 * @param[in] msg - Response message
612 * @param[in] payload_length - Length of response message payload
613 * @param[out] resp_data - Pointer to get firmware parameters response
614 * @param[out] active_comp_image_set_ver_str - Pointer to active component
Tom Joseph3fd3eb82021-06-18 04:13:29 -0700615 * image set version string
gokulsanker22fbb342021-04-05 15:55:06 +0530616 * @param[out] pending_comp_image_set_ver_str - Pointer to pending component
Tom Joseph3fd3eb82021-06-18 04:13:29 -0700617 * image set version string
618 * @param[out] comp_parameter_table - Pointer to component parameter table
gokulsanker22fbb342021-04-05 15:55:06 +0530619 *
620 * @return pldm_completion_codes
621 */
Tom Joseph3fd3eb82021-06-18 04:13:29 -0700622int decode_get_firmware_parameters_resp(
gokulsanker22fbb342021-04-05 15:55:06 +0530623 const struct pldm_msg *msg, size_t payload_length,
624 struct pldm_get_firmware_parameters_resp *resp_data,
625 struct variable_field *active_comp_image_set_ver_str,
Tom Joseph3fd3eb82021-06-18 04:13:29 -0700626 struct variable_field *pending_comp_image_set_ver_str,
627 struct variable_field *comp_parameter_table);
gokulsanker22fbb342021-04-05 15:55:06 +0530628
gokulsankere1fb7a82021-04-05 16:09:29 +0530629/** @brief Decode component entries in the component parameter table which is
630 * part of the response of GetFirmwareParameters command
631 *
632 * @param[in] data - Component entry
633 * @param[in] length - Length of component entry
634 * @param[out] component_data - Pointer to component parameter table
635 * @param[out] active_comp_ver_str - Pointer to active component version string
636 * @param[out] pending_comp_ver_str - Pointer to pending component version
637 * string
638 *
639 * @return pldm_completion_codes
640 */
641int decode_get_firmware_parameters_resp_comp_entry(
642 const uint8_t *data, size_t length,
643 struct pldm_component_parameter_entry *component_data,
644 struct variable_field *active_comp_ver_str,
645 struct variable_field *pending_comp_ver_str);
646
gokulsankerd434edc2021-04-05 16:36:04 +0530647/** @brief Create PLDM request message for RequestUpdate
648 *
649 * @param[in] instance_id - Message's instance id
650 * @param[in] max_transfer_size - Maximum size of the variable payload allowed
651 * to be requested via RequestFirmwareData
652 * command
653 * @param[in] num_of_comp - Total number of components that will be passed to
654 * the FD during the update
655 * @param[in] max_outstanding_transfer_req - Total number of outstanding
656 * RequestFirmwareData
657 * commands that can be sent by the FD
658 * @param[in] pkg_data_len - Value of the FirmwareDevicePackageDataLength field
659 * present in firmware package header
660 * @param[in] comp_image_set_ver_str_type - StringType of
661 * ComponentImageSetVersionString
662 * @param[in] comp_image_set_ver_str_len - The length of the
663 * ComponentImageSetVersionString
664 * @param[in] comp_img_set_ver_str - Component Image Set version information
665 * @param[in,out] msg - Message will be written to this
666 * @param[in] payload_length - Length of request message payload
667 *
668 * @return pldm_completion_codes
669 *
670 * @note Caller is responsible for memory alloc and dealloc of param
671 * 'msg.payload'
672 */
673int encode_request_update_req(uint8_t instance_id, uint32_t max_transfer_size,
674 uint16_t num_of_comp,
675 uint8_t max_outstanding_transfer_req,
676 uint16_t pkg_data_len,
677 uint8_t comp_image_set_ver_str_type,
678 uint8_t comp_image_set_ver_str_len,
679 const struct variable_field *comp_img_set_ver_str,
680 struct pldm_msg *msg, size_t payload_length);
gokulsanker611238c2021-04-05 16:50:44 +0530681
682/** @brief Decode a RequestUpdate response message
683 *
684 * @param[in] msg - Response message
685 * @param[in] payload_length - Length of response message payload
686 * @param[out] completion_code - Pointer to hold the completion code
687 * @param[out] fd_meta_data_len - Pointer to hold the length of FD metadata
688 * @param[out] fd_will_send_pkg_data - Pointer to hold information whether FD
689 * will send GetPackageData command
690 * @return pldm_completion_codes
691 */
692int decode_request_update_resp(const struct pldm_msg *msg,
693 size_t payload_length, uint8_t *completion_code,
694 uint16_t *fd_meta_data_len,
695 uint8_t *fd_will_send_pkg_data);
696
gokulsanker1b909d82021-04-05 17:26:02 +0530697/** @brief Create PLDM request message for PassComponentTable
698 *
699 * @param[in] instance_id - Message's instance id
700 * @param[in] transfer_flag - TransferFlag
701 * @param[in] comp_classification - ComponentClassification
702 * @param[in] comp_identifier - ComponentIdentifier
703 * @param[in] comp_classification_index - ComponentClassificationIndex
704 * @param[in] comp_comparison_stamp - ComponentComparisonStamp
705 * @param[in] comp_ver_str_type - ComponentVersionStringType
706 * @param[in] comp_ver_str_len - ComponentVersionStringLength
707 * @param[in] comp_ver_str - ComponentVersionString
708 * @param[in,out] msg - Message will be written to this
709 * @param[in] payload_length - Length of request message payload
710 * information
711 *
712 * @return pldm_completion_codes
713 *
714 * @note Caller is responsible for memory alloc and dealloc of param
715 * 'msg.payload'
716 */
717int encode_pass_component_table_req(
718 uint8_t instance_id, uint8_t transfer_flag, uint16_t comp_classification,
719 uint16_t comp_identifier, uint8_t comp_classification_index,
720 uint32_t comp_comparison_stamp, uint8_t comp_ver_str_type,
721 uint8_t comp_ver_str_len, const struct variable_field *comp_ver_str,
722 struct pldm_msg *msg, size_t payload_length);
723
gokulsanker566784b2021-04-05 17:47:04 +0530724/** @brief Decode PassComponentTable response message
725 *
726 * @param[in] msg - Response message
727 * @param[in] payload_length - Length of response message payload
728 * @param[out] completion_code - Pointer to hold completion code
729 * @param[out] comp_resp - Pointer to hold component response
730 * @param[out] comp_resp_code - Pointer to hold component response code
731 *
732 * @return pldm_completion_codes
733 */
734int decode_pass_component_table_resp(const struct pldm_msg *msg,
735 size_t payload_length,
736 uint8_t *completion_code,
737 uint8_t *comp_resp,
738 uint8_t *comp_resp_code);
739
gokulsankeraa3a5cd2021-04-22 11:06:42 +0530740/** @brief Create PLDM request message for UpdateComponent
741 *
742 * @param[in] instance_id - Message's instance id
743 * @param[in] comp_classification - ComponentClassification
744 * @param[in] comp_identifier - ComponentIdentifier
745 * @param[in] comp_classification_index - ComponentClassificationIndex
746 * @param[in] comp_comparison_stamp - ComponentComparisonStamp
747 * @param[in] comp_image_size - ComponentImageSize
748 * @param[in] update_option_flags - UpdateOptionFlags
749 * @param[in] comp_ver_str_type - ComponentVersionStringType
750 * @param[in] comp_ver_str_len - ComponentVersionStringLength
751 * @param[in] comp_ver_str - ComponentVersionString
752 * @param[in,out] msg - Message will be written to this
753 * @param[in] payload_length - Length of request message payload
754 * information
755 *
756 * @return pldm_completion_codes
757 *
758 * @note Caller is responsible for memory alloc and dealloc of param
759 * 'msg.payload'
760 */
761int encode_update_component_req(
762 uint8_t instance_id, uint16_t comp_classification, uint16_t comp_identifier,
763 uint8_t comp_classification_index, uint32_t comp_comparison_stamp,
764 uint32_t comp_image_size, bitfield32_t update_option_flags,
765 uint8_t comp_ver_str_type, uint8_t comp_ver_str_len,
766 const struct variable_field *comp_ver_str, struct pldm_msg *msg,
767 size_t payload_length);
768
gokulsanker4b533f22021-04-22 12:53:00 +0530769/** @brief Decode UpdateComponent 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 completion code
774 * @param[out] comp_compatability_resp - Pointer to hold component
775 * compatibility response
776 * @param[out] comp_compatability_resp_code - Pointer to hold component
777 * compatibility response code
778 * @param[out] update_option_flags_enabled - Pointer to hold
779 * UpdateOptionsFlagEnabled
780 * @param[out] time_before_req_fw_data - Pointer to hold the estimated time
781 * before sending RequestFirmwareData
782 *
783 * @return pldm_completion_codes
784 */
785int decode_update_component_resp(const struct pldm_msg *msg,
786 size_t payload_length,
787 uint8_t *completion_code,
788 uint8_t *comp_compatability_resp,
789 uint8_t *comp_compatability_resp_code,
790 bitfield32_t *update_option_flags_enabled,
791 uint16_t *time_before_req_fw_data);
gokulsankera4e6b292021-06-02 16:35:39 +0530792
793/** @brief Decode RequestFirmwareData request message
794 *
795 * @param[in] msg - Request message
796 * @param[in] payload_length - Length of request message payload
797 * @param[out] offset - Pointer to hold offset
798 * @param[out] length - Pointer to hold the size of the component image
799 * segment requested by the FD/FDP
800 *
801 * @return pldm_completion_codes
802 */
803int decode_request_firmware_data_req(const struct pldm_msg *msg,
804 size_t payload_length, uint32_t *offset,
805 uint32_t *length);
gokulsanker9c440d02021-06-03 09:54:02 +0530806
807/** @brief Create PLDM response message for RequestFirmwareData
808 *
809 * The ComponentImagePortion is not encoded in the PLDM response message
810 * by encode_request_firmware_data_resp to avoid an additional copy. Populating
811 * ComponentImagePortion in the PLDM response message is handled by the user
812 * of this API. The payload_length validation considers only the
813 * CompletionCode.
814 *
815 * @param[in] instance_id - Message's instance id
816 * @param[in] completion_code - CompletionCode
817 * @param[in,out] msg - Message will be written to this
818 * @param[in] payload_length - Length of response message payload
819 *
820 * @return pldm_completion_codes
821 *
822 * @note Caller is responsible for memory alloc and dealloc of param
823 * 'msg.payload'
824 */
825int encode_request_firmware_data_resp(uint8_t instance_id,
826 uint8_t completion_code,
827 struct pldm_msg *msg,
828 size_t payload_length);
829
gokulsankere3807022021-06-26 19:12:01 +0530830/** @brief Decode TransferComplete request message
831 *
832 * @param[in] msg - Request message
833 * @param[in] payload_length - Length of request message payload
834 * @param[out] transfer_result - Pointer to hold TransferResult
835 *
836 * @return pldm_completion_codes
837 */
838int decode_transfer_complete_req(const struct pldm_msg *msg,
839 size_t payload_length,
840 uint8_t *transfer_result);
gokulsanker50107cf2021-06-27 09:44:12 +0530841
842/** @brief Create PLDM response message for TransferComplete
843 *
844 * @param[in] instance_id - Message's instance id
845 * @param[in] completion_code - CompletionCode
846 * @param[in,out] msg - Message will be written to this
847 * @param[in] payload_length - Length of response message payload
848 *
849 * @return pldm_completion_codes
850 *
851 * @note Caller is responsible for memory alloc and dealloc of param
852 * 'msg.payload'
853 */
854int encode_transfer_complete_resp(uint8_t instance_id, uint8_t completion_code,
855 struct pldm_msg *msg, size_t payload_length);
gokulsankerb79b91a2021-06-27 11:26:36 +0530856
857/** @brief Decode VerifyComplete request message
858 *
859 * @param[in] msg - Request message
860 * @param[in] payload_length - Length of request message payload
861 * @param[in] verify_result - Pointer to hold VerifyResult
862 *
863 * @return pldm_completion_codes
864 */
865int decode_verify_complete_req(const struct pldm_msg *msg,
866 size_t payload_length, uint8_t *verify_result);
867
gokulsanker9a693582021-06-27 11:35:09 +0530868/** @brief Create PLDM response message for VerifyComplete
869 *
870 * @param[in] instance_id - Message's instance id
871 * @param[in] completion_code - CompletionCode
872 * @param[in,out] msg - Message will be written to this
873 * @param[in] payload_length - Length of response message payload
874 *
875 * @return pldm_completion_codes
876 *
877 * @note Caller is responsible for memory alloc and dealloc of param
878 * 'msg.payload'
879 */
880int encode_verify_complete_resp(uint8_t instance_id, uint8_t completion_code,
881 struct pldm_msg *msg, size_t payload_length);
882
gokulsanker4687f242021-06-27 11:50:26 +0530883/** @brief Decode ApplyComplete request message
884 *
885 * @param[in] msg - Request message
886 * @param[in] payload_length - Length of request message payload
887 * @param[in] apply_result - Pointer to hold ApplyResult
888 * @param[in] comp_activation_methods_modification - Pointer to hold the
889 * ComponentActivationMethodsModification
890 *
891 * @return pldm_completion_codes
892 */
893int decode_apply_complete_req(
894 const struct pldm_msg *msg, size_t payload_length, uint8_t *apply_result,
895 bitfield16_t *comp_activation_methods_modification);
896
gokulsankerd6f79b82021-06-27 12:00:25 +0530897/** @brief Create PLDM response message for ApplyComplete
898 *
899 * @param[in] instance_id - Message's instance id
900 * @param[in] completion_code - CompletionCode
901 * @param[in,out] msg - Message will be written to this
902 * @param[in] payload_length - Length of response message payload
903 *
904 * @return pldm_completion_codes
905 *
906 * @note Caller is responsible for memory alloc and dealloc of param
907 * 'msg.payload'
908 */
909int encode_apply_complete_resp(uint8_t instance_id, uint8_t completion_code,
910 struct pldm_msg *msg, size_t payload_length);
911
gokulsanker773cd1f2021-04-27 17:59:15 +0530912/** @brief Create PLDM request message for ActivateFirmware
913 *
914 * @param[in] instance_id - Message's instance id
915 * @param[in] self_contained_activation_req SelfContainedActivationRequest
916 * @param[in,out] msg - Message will be written to this
917 * @param[in] payload_length - Length of request message payload
918 *
919 * @return pldm_completion_codes
920 *
921 * @note Caller is responsible for memory alloc and dealloc of param
922 * 'msg.payload'
923 */
924int encode_activate_firmware_req(uint8_t instance_id,
925 bool8_t self_contained_activation_req,
926 struct pldm_msg *msg, size_t payload_length);
927
gokulsanker630f76a2021-04-27 18:41:28 +0530928/** @brief Decode ActivateFirmware response message
929 *
930 * @param[in] msg - Response message
931 * @param[in] payload_length - Length of response message payload
932 * @param[out] completion_code - Pointer to hold CompletionCode
933 * @param[out] estimated_time_activation - Pointer to hold
934 * EstimatedTimeForSelfContainedActivation
935 *
936 * @return pldm_completion_codes
937 */
938int decode_activate_firmware_resp(const struct pldm_msg *msg,
939 size_t payload_length,
940 uint8_t *completion_code,
941 uint16_t *estimated_time_activation);
942
gokulsanker138ceba2021-04-05 13:25:25 +0530943#ifdef __cplusplus
944}
945#endif
946
947#endif // End of FW_UPDATE_H