blob: 9163f96b008dee3132301aed64d53e07aa258997 [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"
gokulsanker22fbb342021-04-05 15:55:06 +05308#include "utils.h"
gokulsanker138ceba2021-04-05 13:25:25 +05309
Tom Joseph568e4702021-06-07 22:15:49 -070010#define PLDM_FWUP_COMPONENT_BITMAP_MULTIPLE 8
Tom Joseph58cc1722021-06-09 07:15:49 -070011#define PLDM_FWUP_INVALID_COMPONENT_COMPARISON_TIMESTAMP 0xFFFFFFFF
gokulsanker138ceba2021-04-05 13:25:25 +053012#define PLDM_QUERY_DEVICE_IDENTIFIERS_REQ_BYTES 0
gokulsankereca3e192021-04-05 14:57:41 +053013/** @brief Minimum length of device descriptor, 2 bytes for descriptor type,
14 * 2 bytes for descriptor length and atleast 1 byte of descriptor data
15 */
16#define PLDM_FWUP_DEVICE_DESCRIPTOR_MIN_LEN 5
gokulsanker981fbfb2021-04-05 15:17:25 +053017#define PLDM_GET_FIRMWARE_PARAMETERS_REQ_BYTES 0
gokulsankerd434edc2021-04-05 16:36:04 +053018#define PLDM_FWUP_BASELINE_TRANSFER_SIZE 32
19#define PLDM_FWUP_MIN_OUTSTANDING_REQ 1
gokulsanker138ceba2021-04-05 13:25:25 +053020
21/** @brief PLDM Firmware update commands
22 */
gokulsanker981fbfb2021-04-05 15:17:25 +053023enum pldm_firmware_update_commands {
24 PLDM_QUERY_DEVICE_IDENTIFIERS = 0x01,
gokulsankerd434edc2021-04-05 16:36:04 +053025 PLDM_GET_FIRMWARE_PARAMETERS = 0x02,
gokulsanker1b909d82021-04-05 17:26:02 +053026 PLDM_REQUEST_UPDATE = 0x10,
gokulsankeraa3a5cd2021-04-22 11:06:42 +053027 PLDM_PASS_COMPONENT_TABLE = 0x13,
gokulsanker9c440d02021-06-03 09:54:02 +053028 PLDM_UPDATE_COMPONENT = 0x14,
gokulsanker50107cf2021-06-27 09:44:12 +053029 PLDM_REQUEST_FIRMWARE_DATA = 0x15,
gokulsanker9a693582021-06-27 11:35:09 +053030 PLDM_TRANSFER_COMPLETE = 0x16,
31 PLDM_VERIFY_COMPLETE = 0x17
gokulsanker981fbfb2021-04-05 15:17:25 +053032};
gokulsanker138ceba2021-04-05 13:25:25 +053033
gokulsanker611238c2021-04-05 16:50:44 +053034/** @brief PLDM Firmware update completion codes
35 */
36enum pldm_firmware_update_completion_codes {
37 PLDM_FWUP_NOT_IN_UPDATE_MODE = 0x80,
38 PLDM_FWUP_ALREADY_IN_UPDATE_MODE = 0x81,
39 PLDM_FWUP_DATA_OUT_OF_RANGE = 0x82,
40 PLDM_FWUP_INVALID_TRANSFER_LENGTH = 0x83,
41 PLDM_FWUP_INVALID_STATE_FOR_COMMAND = 0x84,
42 PLDM_FWUP_INCOMPLETE_UPDATE = 0x85,
43 PLDM_FWUP_BUSY_IN_BACKGROUND = 0x86,
44 PLDM_FWUP_CANCEL_PENDING = 0x87,
45 PLDM_FWUP_COMMAND_NOT_EXPECTED = 0x87,
46 PLDM_FWUP_RETRY_REQUEST_FW_DATA = 0x89,
47 PLDM_FWUP_UNABLE_TO_INITIATE_UPDATE = 0x8A,
48 PLDM_FWUP_ACTIVATION_NOT_REQUIRED = 0x8B,
49 PLDM_FWUP_SELF_CONTAINED_ACTIVATION_NOT_PERMITTED = 0x8C,
50 PLDM_FWUP_NO_DEVICE_METADATA = 0x8D,
51 PLDM_FWUP_RETRY_REQUEST_UPDATE = 0x8E,
52 PLDM_FWUP_NO_PACKAGE_DATA = 0x8F,
53 PLDM_FWUP_INVALID_TRANSFER_HANDLE = 0x90,
54 PLDM_FWUP_INVALID_TRANSFER_OPERATION_FLAG = 0x91,
55 PLDM_FWUP_ACTIVATE_PENDING_IMAGE_NOT_PERMITTED = 0x92,
56 PLDM_FWUP_PACKAGE_DATA_ERROR = 0x93
57};
58
Tom Joseph763b51e2021-06-05 04:50:47 -070059/** @brief String type values defined in the PLDM firmware update specification
60 */
61enum pldm_firmware_update_string_type {
62 PLDM_STR_TYPE_UNKNOWN = 0,
63 PLDM_STR_TYPE_ASCII = 1,
64 PLDM_STR_TYPE_UTF_8 = 2,
65 PLDM_STR_TYPE_UTF_16 = 3,
66 PLDM_STR_TYPE_UTF_16LE = 4,
67 PLDM_STR_TYPE_UTF_16BE = 5
68};
69
70/** @brief Descriptor types defined in PLDM firmware update specification
71 */
72enum pldm_firmware_update_descriptor_types {
73 PLDM_FWUP_PCI_VENDOR_ID = 0x0000,
74 PLDM_FWUP_IANA_ENTERPRISE_ID = 0x0001,
75 PLDM_FWUP_UUID = 0x0002,
76 PLDM_FWUP_PNP_VENDOR_ID = 0x0003,
77 PLDM_FWUP_ACPI_VENDOR_ID = 0x0004,
78 PLDM_FWUP_IEEE_ASSIGNED_COMPANY_ID = 0x0005,
79 PLDM_FWUP_SCSI_VENDOR_ID = 0x0006,
80 PLDM_FWUP_PCI_DEVICE_ID = 0x0100,
81 PLDM_FWUP_PCI_SUBSYSTEM_VENDOR_ID = 0x0101,
82 PLDM_FWUP_PCI_SUBSYSTEM_ID = 0x0102,
83 PLDM_FWUP_PCI_REVISION_ID = 0x0103,
84 PLDM_FWUP_PNP_PRODUCT_IDENTIFIER = 0x0104,
85 PLDM_FWUP_ACPI_PRODUCT_IDENTIFIER = 0x0105,
86 PLDM_FWUP_ASCII_MODEL_NUMBER_LONG_STRING = 0x0106,
87 PLDM_FWUP_ASCII_MODEL_NUMBER_SHORT_STRING = 0x0107,
88 PLDM_FWUP_SCSI_PRODUCT_ID = 0x0108,
89 PLDM_FWUP_UBM_CONTROLLER_DEVICE_CODE = 0x0109,
90 PLDM_FWUP_VENDOR_DEFINED = 0xFFFF
91};
92
93/** @brief Descriptor types length defined in PLDM firmware update specification
94 */
95enum pldm_firmware_update_descriptor_types_length {
96 PLDM_FWUP_PCI_VENDOR_ID_LENGTH = 2,
97 PLDM_FWUP_IANA_ENTERPRISE_ID_LENGTH = 4,
98 PLDM_FWUP_UUID_LENGTH = 16,
99 PLDM_FWUP_PNP_VENDOR_ID_LENGTH = 3,
100 PLDM_FWUP_ACPI_VENDOR_ID_LENGTH = 4,
101 PLDM_FWUP_IEEE_ASSIGNED_COMPANY_ID_LENGTH = 3,
102 PLDM_FWUP_SCSI_VENDOR_ID_LENGTH = 8,
103 PLDM_FWUP_PCI_DEVICE_ID_LENGTH = 2,
104 PLDM_FWUP_PCI_SUBSYSTEM_VENDOR_ID_LENGTH = 2,
105 PLDM_FWUP_PCI_SUBSYSTEM_ID_LENGTH = 2,
106 PLDM_FWUP_PCI_REVISION_ID_LENGTH = 1,
107 PLDM_FWUP_PNP_PRODUCT_IDENTIFIER_LENGTH = 4,
108 PLDM_FWUP_ACPI_PRODUCT_IDENTIFIER_LENGTH = 4,
109 PLDM_FWUP_ASCII_MODEL_NUMBER_LONG_STRING_LENGTH = 40,
110 PLDM_FWUP_ASCII_MODEL_NUMBER_SHORT_STRING_LENGTH = 10,
111 PLDM_FWUP_SCSI_PRODUCT_ID_LENGTH = 16,
112 PLDM_FWUP_UBM_CONTROLLER_DEVICE_CODE_LENGTH = 4
113};
114
gokulsanker1b909d82021-04-05 17:26:02 +0530115/** @brief ComponentClassification values defined in firmware update
116 * specification
117 */
118enum pldm_component_classification_values {
119 PLDM_COMP_UNKNOWN = 0x0000,
120 PLDM_COMP_OTHER = 0x0001,
121 PLDM_COMP_DRIVER = 0x0002,
122 PLDM_COMP_CONFIGURATION_SOFTWARE = 0x0003,
123 PLDM_COMP_APPLICATION_SOFTWARE = 0x0004,
124 PLDM_COMP_INSTRUMENTATION = 0x0005,
125 PLDM_COMP_FIRMWARE_OR_BIOS = 0x0006,
126 PLDM_COMP_DIAGNOSTIC_SOFTWARE = 0x0007,
127 PLDM_COMP_OPERATING_SYSTEM = 0x0008,
128 PLDM_COMP_MIDDLEWARE = 0x0009,
129 PLDM_COMP_FIRMWARE = 0x000A,
130 PLDM_COMP_BIOS_OR_FCODE = 0x000B,
131 PLDM_COMP_SUPPORT_OR_SERVICEPACK = 0x000C,
132 PLDM_COMP_SOFTWARE_BUNDLE = 0x000D,
133 PLDM_COMP_DOWNSTREAM_DEVICE = 0xFFFF
134};
135
gokulsanker566784b2021-04-05 17:47:04 +0530136/** @brief ComponentResponse values in the response of PassComponentTable
137 */
138enum pldm_component_responses {
139 PLDM_CR_COMP_CAN_BE_UPDATED = 0,
140 PLDM_CR_COMP_MAY_BE_UPDATEABLE = 1
141};
142
143/** @brief ComponentResponseCode values in the response of PassComponentTable
144 */
145enum pldm_component_response_codes {
146 PLDM_CRC_COMP_CAN_BE_UPDATED = 0x00,
147 PLDM_CRC_COMP_COMPARISON_STAMP_IDENTICAL = 0x01,
148 PLDM_CRC_COMP_COMPARISON_STAMP_LOWER = 0x02,
149 PLDM_CRC_INVALID_COMP_COMPARISON_STAMP = 0x03,
150 PLDM_CRC_COMP_CONFLICT = 0x04,
151 PLDM_CRC_COMP_PREREQUISITES_NOT_MET = 0x05,
152 PLDM_CRC_COMP_NOT_SUPPORTED = 0x06,
153 PLDM_CRC_COMP_SECURITY_RESTRICTIONS = 0x07,
154 PLDM_CRC_INCOMPLETE_COMP_IMAGE_SET = 0x08,
155 PLDM_CRC_ACTIVE_IMAGE_NOT_UPDATEABLE_SUBSEQUENTLY = 0x09,
156 PLDM_CRC_COMP_VER_STR_IDENTICAL = 0x0A,
157 PLDM_CRC_COMP_VER_STR_LOWER = 0x0B,
158 PLDM_CRC_VENDOR_COMP_RESP_CODE_RANGE_MIN = 0xD0,
159 PLDM_CRC_VENDOR_COMP_RESP_CODE_RANGE_MAX = 0xEF
160};
161
gokulsanker4b533f22021-04-22 12:53:00 +0530162/** @brief ComponentCompatibilityResponse values in the response of
163 * UpdateComponent
164 */
165enum pldm_component_compatability_responses {
166 PLDM_CCR_COMP_CAN_BE_UPDATED = 0,
167 PLDM_CCR_COMP_CANNOT_BE_UPDATED = 1
168};
169
170/** @brief ComponentCompatibilityResponse Code values in the response of
171 * UpdateComponent
172 */
173enum pldm_component_compatability_response_codes {
174 PLDM_CCRC_NO_RESPONSE_CODE = 0x00,
175 PLDM_CCRC_COMP_COMPARISON_STAMP_IDENTICAL = 0x01,
176 PLDM_CCRC_COMP_COMPARISON_STAMP_LOWER = 0x02,
177 PLDM_CCRC_INVALID_COMP_COMPARISON_STAMP = 0x03,
178 PLDM_CCRC_COMP_CONFLICT = 0x04,
179 PLDM_CCRC_COMP_PREREQUISITES_NOT_MET = 0x05,
180 PLDM_CCRC_COMP_NOT_SUPPORTED = 0x06,
181 PLDM_CCRC_COMP_SECURITY_RESTRICTIONS = 0x07,
182 PLDM_CCRC_INCOMPLETE_COMP_IMAGE_SET = 0x08,
183 PLDM_CCRC_COMP_INFO_NO_MATCH = 0x09,
184 PLDM_CCRC_COMP_VER_STR_IDENTICAL = 0x0A,
185 PLDM_CCRC_COMP_VER_STR_LOWER = 0x0B,
186 PLDM_CCRC_VENDOR_COMP_RESP_CODE_RANGE_MIN = 0xD0,
187 PLDM_CCRC_VENDOR_COMP_RESP_CODE_RANGE_MAX = 0xEF
188};
189
gokulsankere3807022021-06-26 19:12:01 +0530190/** @brief Common error codes in TransferComplete, VerifyComplete and
191 * ApplyComplete request
192 */
193enum pldm_firmware_update_common_error_codes {
194 PLDM_FWUP_TIME_OUT = 0x09,
195 PLDM_FWUP_GENERIC_ERROR = 0x0A
196};
197
gokulsanker50107cf2021-06-27 09:44:12 +0530198/** @brief TransferResult values in the request of TransferComplete
gokulsankere3807022021-06-26 19:12:01 +0530199 */
gokulsanker50107cf2021-06-27 09:44:12 +0530200enum pldm_firmware_update_transfer_result_values {
gokulsankere3807022021-06-26 19:12:01 +0530201 PLDM_FWUP_TRANSFER_SUCCESS = 0x00,
202 PLDM_FWUP_TRANSFER_ERROR_IMAGE_CORRUPT = 0x02,
203 PLDM_FWUP_TRANSFER_ERROR_VERSION_MISMATCH = 0x02,
204 PLDM_FWUP_FD_ABORTED_TRANSFER = 0x03,
205 PLDM_FWUP_FD_ABORTED_TRANSFER_LOW_POWER_STATE = 0x0B,
206 PLDM_FWUP_FD_ABORTED_TRANSFER_RESET_NEEDED = 0x0C,
207 PLDM_FWUP_FD_ABORTED_TRANSFER_STORAGE_ISSUE = 0x0D,
208 PLDM_FWUP_VENDOR_TRANSFER_RESULT_RANGE_MIN = 0x70,
209 PLDM_FWUP_VENDOR_TRANSFER_RESULT_RANGE_MAX = 0x8F
210};
211
gokulsanker9a693582021-06-27 11:35:09 +0530212/**@brief VerifyResult values in the request of VerifyComplete
gokulsankerb79b91a2021-06-27 11:26:36 +0530213 */
214enum pldm_firmware_update_verify_result_values {
215 PLDM_FWUP_VERIFY_SUCCESS = 0x00,
216 PLDM_FWUP_VERIFY_ERROR_VERIFICATION_FAILURE = 0x01,
217 PLDM_FWUP_VERIFY_ERROR_VERSION_MISMATCH = 0x02,
218 PLDM_FWUP_VERIFY_FAILED_FD_SECURITY_CHECKS = 0x03,
219 PLDM_FWUP_VERIFY_ERROR_IMAGE_INCOMPLETE = 0x04,
220 PLDM_FWUP_VENDOR_VERIFY_RESULT_RANGE_MIN = 0x90,
221 PLDM_FWUP_VENDOR_VERIFY_RESULT_RANGE_MAX = 0xAF
222};
223
Tom Joseph568e4702021-06-07 22:15:49 -0700224/** @struct pldm_package_header_information
225 *
226 * Structure representing fixed part of package header information
227 */
228struct pldm_package_header_information {
229 uint8_t uuid[PLDM_FWUP_UUID_LENGTH];
230 uint8_t package_header_format_version;
231 uint16_t package_header_size;
232 uint8_t timestamp104[PLDM_TIMESTAMP104_SIZE];
233 uint16_t component_bitmap_bit_length;
234 uint8_t package_version_string_type;
235 uint8_t package_version_string_length;
236} __attribute__((packed));
237
Tom Joseph64af3452021-06-08 04:05:28 -0700238/** @struct pldm_firmware_device_id_record
239 *
240 * Structure representing firmware device ID record
241 */
242struct pldm_firmware_device_id_record {
243 uint16_t record_length;
244 uint8_t descriptor_count;
245 bitfield32_t device_update_option_flags;
246 uint8_t comp_image_set_version_string_type;
247 uint8_t comp_image_set_version_string_length;
248 uint16_t fw_device_pkg_data_length;
249} __attribute__((packed));
250
Tom Joseph763b51e2021-06-05 04:50:47 -0700251/** @struct pldm_descriptor_tlv
252 *
253 * Structure representing descriptor type, length and value
254 */
255struct pldm_descriptor_tlv {
256 uint16_t descriptor_type;
257 uint16_t descriptor_length;
258 uint8_t descriptor_data[1];
259} __attribute__((packed));
260
261/** @struct pldm_vendor_defined_descriptor_title_data
262 *
263 * Structure representing vendor defined descriptor title sections
264 */
265struct pldm_vendor_defined_descriptor_title_data {
266 uint8_t vendor_defined_descriptor_title_str_type;
267 uint8_t vendor_defined_descriptor_title_str_len;
268 uint8_t vendor_defined_descriptor_title_str[1];
269} __attribute__((packed));
270
Tom Joseph58cc1722021-06-09 07:15:49 -0700271/** @struct pldm_component_image_information
272 *
273 * Structure representing fixed part of individual component information in
274 * PLDM firmware update package
275 */
276struct pldm_component_image_information {
277 uint16_t comp_classification;
278 uint16_t comp_identifier;
279 uint32_t comp_comparison_stamp;
280 bitfield16_t comp_options;
281 bitfield16_t requested_comp_activation_method;
282 uint32_t comp_location_offset;
283 uint32_t comp_size;
284 uint8_t comp_version_string_type;
285 uint8_t comp_version_string_length;
286} __attribute__((packed));
287
gokulsankereca3e192021-04-05 14:57:41 +0530288/** @struct pldm_query_device_identifiers_resp
289 *
290 * Structure representing query device identifiers response.
291 */
292struct pldm_query_device_identifiers_resp {
293 uint8_t completion_code;
294 uint32_t device_identifiers_len;
295 uint8_t descriptor_count;
296} __attribute__((packed));
297
gokulsanker22fbb342021-04-05 15:55:06 +0530298/** @struct pldm_get_firmware_parameters_resp
299 *
Tom Joseph3fd3eb82021-06-18 04:13:29 -0700300 * Structure representing the fixed part of GetFirmwareParameters response
gokulsanker22fbb342021-04-05 15:55:06 +0530301 */
302struct pldm_get_firmware_parameters_resp {
303 uint8_t completion_code;
304 bitfield32_t capabilities_during_update;
305 uint16_t comp_count;
306 uint8_t active_comp_image_set_ver_str_type;
307 uint8_t active_comp_image_set_ver_str_len;
308 uint8_t pending_comp_image_set_ver_str_type;
309 uint8_t pending_comp_image_set_ver_str_len;
310} __attribute__((packed));
311
gokulsankere1fb7a82021-04-05 16:09:29 +0530312/** @struct pldm_component_parameter_entry
313 *
314 * Structure representing component parameter table entry.
315 */
316struct pldm_component_parameter_entry {
317 uint16_t comp_classification;
318 uint16_t comp_identifier;
319 uint8_t comp_classification_index;
320 uint32_t active_comp_comparison_stamp;
321 uint8_t active_comp_ver_str_type;
322 uint8_t active_comp_ver_str_len;
323 uint8_t active_comp_release_date[8];
324 uint32_t pending_comp_comparison_stamp;
325 uint8_t pending_comp_ver_str_type;
326 uint8_t pending_comp_ver_str_len;
327 uint8_t pending_comp_release_date[8];
328 bitfield16_t comp_activation_methods;
329 bitfield32_t capabilities_during_update;
330} __attribute__((packed));
331
gokulsankerd434edc2021-04-05 16:36:04 +0530332/** @struct pldm_request_update_req
333 *
334 * Structure representing fixed part of Request Update request
335 */
336struct pldm_request_update_req {
337 uint32_t max_transfer_size;
338 uint16_t num_of_comp;
339 uint8_t max_outstanding_transfer_req;
340 uint16_t pkg_data_len;
341 uint8_t comp_image_set_ver_str_type;
342 uint8_t comp_image_set_ver_str_len;
343} __attribute__((packed));
344
gokulsanker611238c2021-04-05 16:50:44 +0530345/** @struct pldm_request_update_resp
346 *
347 * Structure representing Request Update response
348 */
349struct pldm_request_update_resp {
350 uint8_t completion_code;
351 uint16_t fd_meta_data_len;
352 uint8_t fd_will_send_pkg_data;
353} __attribute__((packed));
354
gokulsanker1b909d82021-04-05 17:26:02 +0530355/** @struct pldm_pass_component_table_req
356 *
357 * Structure representing PassComponentTable request
358 */
359struct pldm_pass_component_table_req {
360 uint8_t transfer_flag;
361 uint16_t comp_classification;
362 uint16_t comp_identifier;
363 uint8_t comp_classification_index;
364 uint32_t comp_comparison_stamp;
365 uint8_t comp_ver_str_type;
366 uint8_t comp_ver_str_len;
367} __attribute__((packed));
368
gokulsanker566784b2021-04-05 17:47:04 +0530369/** @struct pldm_pass_component_table_resp
370 *
371 * Structure representing PassComponentTable response
372 */
373struct pldm_pass_component_table_resp {
374 uint8_t completion_code;
375 uint8_t comp_resp;
376 uint8_t comp_resp_code;
377} __attribute__((packed));
378
gokulsankeraa3a5cd2021-04-22 11:06:42 +0530379/** @struct pldm_update_component_req
380 *
381 * Structure representing UpdateComponent request
382 */
383struct pldm_update_component_req {
384 uint16_t comp_classification;
385 uint16_t comp_identifier;
386 uint8_t comp_classification_index;
387 uint32_t comp_comparison_stamp;
388 uint32_t comp_image_size;
389 bitfield32_t update_option_flags;
390 uint8_t comp_ver_str_type;
391 uint8_t comp_ver_str_len;
392} __attribute__((packed));
393
gokulsanker4b533f22021-04-22 12:53:00 +0530394/** @struct pldm_update_component_resp
395 *
396 * Structure representing UpdateComponent response
397 */
398struct pldm_update_component_resp {
399 uint8_t completion_code;
400 uint8_t comp_compatability_resp;
401 uint8_t comp_compatability_resp_code;
402 bitfield32_t update_option_flags_enabled;
403 uint16_t time_before_req_fw_data;
404} __attribute__((packed));
405
gokulsankera4e6b292021-06-02 16:35:39 +0530406/** @struct pldm_request_firmware_data_req
407 *
408 * Structure representing RequestFirmwareData request.
409 */
410struct pldm_request_firmware_data_req {
411 uint32_t offset;
412 uint32_t length;
413} __attribute__((packed));
414
Tom Joseph568e4702021-06-07 22:15:49 -0700415/** @brief Decode the PLDM package header information
416 *
417 * @param[in] data - pointer to package header information
418 * @param[in] length - available length in the firmware update package
419 * @param[out] package_header_info - pointer to fixed part of PLDM package
420 * header information
421 * @param[out] package_version_str - pointer to package version string
422 *
423 * @return pldm_completion_codes
424 */
425int decode_pldm_package_header_info(
426 const uint8_t *data, size_t length,
427 struct pldm_package_header_information *package_header_info,
428 struct variable_field *package_version_str);
429
Tom Joseph64af3452021-06-08 04:05:28 -0700430/** @brief Decode individual firmware device ID record
431 *
432 * @param[in] data - pointer to firmware device ID record
433 * @param[in] length - available length in the firmware update package
434 * @param[in] component_bitmap_bit_length - ComponentBitmapBitLengthfield
435 * parsed from the package header info
436 * @param[out] fw_device_id_record - pointer to fixed part of firmware device
437 * id record
438 * @param[out] applicable_components - pointer to ApplicableComponents
439 * @param[out] comp_image_set_version_str - pointer to
440 * ComponentImageSetVersionString
441 * @param[out] record_descriptors - pointer to RecordDescriptors
442 * @param[out] fw_device_pkg_data - pointer to FirmwareDevicePackageData
443 *
444 * @return pldm_completion_codes
445 */
446int decode_firmware_device_id_record(
447 const uint8_t *data, size_t length, uint16_t component_bitmap_bit_length,
448 struct pldm_firmware_device_id_record *fw_device_id_record,
449 struct variable_field *applicable_components,
450 struct variable_field *comp_image_set_version_str,
451 struct variable_field *record_descriptors,
452 struct variable_field *fw_device_pkg_data);
453
Tom Joseph763b51e2021-06-05 04:50:47 -0700454/** @brief Decode the record descriptor entries in the firmware update package
455 * and the Descriptors in the QueryDeviceIDentifiers command
456 *
457 * @param[in] data - pointer to descriptor entry
458 * @param[in] length - remaining length of the descriptor data
459 * @param[out] descriptor_type - pointer to descriptor type
460 * @param[out] descriptor_data - pointer to descriptor data
461 *
462 * @return pldm_completion_codes
463 */
464int decode_descriptor_type_length_value(const uint8_t *data, size_t length,
465 uint16_t *descriptor_type,
466 struct variable_field *descriptor_data);
467
468/** @brief Decode the vendor defined descriptor value
469 *
470 * @param[in] data - pointer to vendor defined descriptor value
471 * @param[in] length - length of the vendor defined descriptor value
472 * @param[out] descriptor_title_str_type - pointer to vendor defined descriptor
473 * title string type
474 * @param[out] descriptor_title_str - pointer to vendor defined descriptor
475 * title string
476 * @param[out] descriptor_data - pointer to vendor defined descriptor data
477 *
478 * @return pldm_completion_codes
479 */
480int decode_vendor_defined_descriptor_value(
481 const uint8_t *data, size_t length, uint8_t *descriptor_title_str_type,
482 struct variable_field *descriptor_title_str,
483 struct variable_field *descriptor_data);
484
Tom Joseph58cc1722021-06-09 07:15:49 -0700485/** @brief Decode individual component image information
486 *
487 * @param[in] data - pointer to component image information
488 * @param[in] length - available length in the firmware update package
489 * @param[out] pldm_comp_image_info - pointer to fixed part of component image
490 * information
491 * @param[out] comp_version_str - pointer to component version string
492 *
493 * @return pldm_completion_codes
494 */
495int decode_pldm_comp_image_info(
496 const uint8_t *data, size_t length,
497 struct pldm_component_image_information *pldm_comp_image_info,
498 struct variable_field *comp_version_str);
499
gokulsanker138ceba2021-04-05 13:25:25 +0530500/** @brief Create a PLDM request message for QueryDeviceIdentifiers
501 *
502 * @param[in] instance_id - Message's instance id
503 * @param[in] payload_length - Length of the request message payload
504 * @param[in,out] msg - Message will be written to this
505 *
506 * @return pldm_completion_codes
507 *
508 * @note Caller is responsible for memory alloc and dealloc of param
509 * 'msg.payload'
510 */
511int encode_query_device_identifiers_req(uint8_t instance_id,
512 size_t payload_length,
513 struct pldm_msg *msg);
gokulsankereca3e192021-04-05 14:57:41 +0530514
515/** @brief Decode QueryDeviceIdentifiers response message
516 *
517 * @param[in] msg - Response message
518 * @param[in] payload_length - Length of response message payload
519 * @param[out] completion_code - Pointer to response msg's PLDM completion code
520 * @param[out] device_identifiers_len - Pointer to device identifiers length
521 * @param[out] descriptor_count - Pointer to descriptor count
522 * @param[out] descriptor_data - Pointer to descriptor data
523 *
524 * @return pldm_completion_codes
525 */
526int decode_query_device_identifiers_resp(const struct pldm_msg *msg,
527 size_t payload_length,
528 uint8_t *completion_code,
529 uint32_t *device_identifiers_len,
530 uint8_t *descriptor_count,
531 uint8_t **descriptor_data);
gokulsanker981fbfb2021-04-05 15:17:25 +0530532
533/** @brief Create a PLDM request message for GetFirmwareParameters
534 *
535 * @param[in] instance_id - Message's instance id
536 * @param[in] payload_length - Length of the request message payload
537 * @param[in,out] msg - Message will be written to this
538 *
539 * @return pldm_completion_codes
540 *
541 * @note Caller is responsible for memory alloc and dealloc of param
542 * 'msg.payload'
543 */
544int encode_get_firmware_parameters_req(uint8_t instance_id,
545 size_t payload_length,
546 struct pldm_msg *msg);
gokulsanker22fbb342021-04-05 15:55:06 +0530547
Tom Joseph3fd3eb82021-06-18 04:13:29 -0700548/** @brief Decode GetFirmwareParameters response
gokulsanker22fbb342021-04-05 15:55:06 +0530549 *
550 * @param[in] msg - Response message
551 * @param[in] payload_length - Length of response message payload
552 * @param[out] resp_data - Pointer to get firmware parameters response
553 * @param[out] active_comp_image_set_ver_str - Pointer to active component
Tom Joseph3fd3eb82021-06-18 04:13:29 -0700554 * image set version string
gokulsanker22fbb342021-04-05 15:55:06 +0530555 * @param[out] pending_comp_image_set_ver_str - Pointer to pending component
Tom Joseph3fd3eb82021-06-18 04:13:29 -0700556 * image set version string
557 * @param[out] comp_parameter_table - Pointer to component parameter table
gokulsanker22fbb342021-04-05 15:55:06 +0530558 *
559 * @return pldm_completion_codes
560 */
Tom Joseph3fd3eb82021-06-18 04:13:29 -0700561int decode_get_firmware_parameters_resp(
gokulsanker22fbb342021-04-05 15:55:06 +0530562 const struct pldm_msg *msg, size_t payload_length,
563 struct pldm_get_firmware_parameters_resp *resp_data,
564 struct variable_field *active_comp_image_set_ver_str,
Tom Joseph3fd3eb82021-06-18 04:13:29 -0700565 struct variable_field *pending_comp_image_set_ver_str,
566 struct variable_field *comp_parameter_table);
gokulsanker22fbb342021-04-05 15:55:06 +0530567
gokulsankere1fb7a82021-04-05 16:09:29 +0530568/** @brief Decode component entries in the component parameter table which is
569 * part of the response of GetFirmwareParameters command
570 *
571 * @param[in] data - Component entry
572 * @param[in] length - Length of component entry
573 * @param[out] component_data - Pointer to component parameter table
574 * @param[out] active_comp_ver_str - Pointer to active component version string
575 * @param[out] pending_comp_ver_str - Pointer to pending component version
576 * string
577 *
578 * @return pldm_completion_codes
579 */
580int decode_get_firmware_parameters_resp_comp_entry(
581 const uint8_t *data, size_t length,
582 struct pldm_component_parameter_entry *component_data,
583 struct variable_field *active_comp_ver_str,
584 struct variable_field *pending_comp_ver_str);
585
gokulsankerd434edc2021-04-05 16:36:04 +0530586/** @brief Create PLDM request message for RequestUpdate
587 *
588 * @param[in] instance_id - Message's instance id
589 * @param[in] max_transfer_size - Maximum size of the variable payload allowed
590 * to be requested via RequestFirmwareData
591 * command
592 * @param[in] num_of_comp - Total number of components that will be passed to
593 * the FD during the update
594 * @param[in] max_outstanding_transfer_req - Total number of outstanding
595 * RequestFirmwareData
596 * commands that can be sent by the FD
597 * @param[in] pkg_data_len - Value of the FirmwareDevicePackageDataLength field
598 * present in firmware package header
599 * @param[in] comp_image_set_ver_str_type - StringType of
600 * ComponentImageSetVersionString
601 * @param[in] comp_image_set_ver_str_len - The length of the
602 * ComponentImageSetVersionString
603 * @param[in] comp_img_set_ver_str - Component Image Set version information
604 * @param[in,out] msg - Message will be written to this
605 * @param[in] payload_length - Length of request message payload
606 *
607 * @return pldm_completion_codes
608 *
609 * @note Caller is responsible for memory alloc and dealloc of param
610 * 'msg.payload'
611 */
612int encode_request_update_req(uint8_t instance_id, uint32_t max_transfer_size,
613 uint16_t num_of_comp,
614 uint8_t max_outstanding_transfer_req,
615 uint16_t pkg_data_len,
616 uint8_t comp_image_set_ver_str_type,
617 uint8_t comp_image_set_ver_str_len,
618 const struct variable_field *comp_img_set_ver_str,
619 struct pldm_msg *msg, size_t payload_length);
gokulsanker611238c2021-04-05 16:50:44 +0530620
621/** @brief Decode a RequestUpdate response message
622 *
623 * @param[in] msg - Response message
624 * @param[in] payload_length - Length of response message payload
625 * @param[out] completion_code - Pointer to hold the completion code
626 * @param[out] fd_meta_data_len - Pointer to hold the length of FD metadata
627 * @param[out] fd_will_send_pkg_data - Pointer to hold information whether FD
628 * will send GetPackageData command
629 * @return pldm_completion_codes
630 */
631int decode_request_update_resp(const struct pldm_msg *msg,
632 size_t payload_length, uint8_t *completion_code,
633 uint16_t *fd_meta_data_len,
634 uint8_t *fd_will_send_pkg_data);
635
gokulsanker1b909d82021-04-05 17:26:02 +0530636/** @brief Create PLDM request message for PassComponentTable
637 *
638 * @param[in] instance_id - Message's instance id
639 * @param[in] transfer_flag - TransferFlag
640 * @param[in] comp_classification - ComponentClassification
641 * @param[in] comp_identifier - ComponentIdentifier
642 * @param[in] comp_classification_index - ComponentClassificationIndex
643 * @param[in] comp_comparison_stamp - ComponentComparisonStamp
644 * @param[in] comp_ver_str_type - ComponentVersionStringType
645 * @param[in] comp_ver_str_len - ComponentVersionStringLength
646 * @param[in] comp_ver_str - ComponentVersionString
647 * @param[in,out] msg - Message will be written to this
648 * @param[in] payload_length - Length of request message payload
649 * information
650 *
651 * @return pldm_completion_codes
652 *
653 * @note Caller is responsible for memory alloc and dealloc of param
654 * 'msg.payload'
655 */
656int encode_pass_component_table_req(
657 uint8_t instance_id, uint8_t transfer_flag, uint16_t comp_classification,
658 uint16_t comp_identifier, uint8_t comp_classification_index,
659 uint32_t comp_comparison_stamp, uint8_t comp_ver_str_type,
660 uint8_t comp_ver_str_len, const struct variable_field *comp_ver_str,
661 struct pldm_msg *msg, size_t payload_length);
662
gokulsanker566784b2021-04-05 17:47:04 +0530663/** @brief Decode PassComponentTable response message
664 *
665 * @param[in] msg - Response message
666 * @param[in] payload_length - Length of response message payload
667 * @param[out] completion_code - Pointer to hold completion code
668 * @param[out] comp_resp - Pointer to hold component response
669 * @param[out] comp_resp_code - Pointer to hold component response code
670 *
671 * @return pldm_completion_codes
672 */
673int decode_pass_component_table_resp(const struct pldm_msg *msg,
674 size_t payload_length,
675 uint8_t *completion_code,
676 uint8_t *comp_resp,
677 uint8_t *comp_resp_code);
678
gokulsankeraa3a5cd2021-04-22 11:06:42 +0530679/** @brief Create PLDM request message for UpdateComponent
680 *
681 * @param[in] instance_id - Message's instance id
682 * @param[in] comp_classification - ComponentClassification
683 * @param[in] comp_identifier - ComponentIdentifier
684 * @param[in] comp_classification_index - ComponentClassificationIndex
685 * @param[in] comp_comparison_stamp - ComponentComparisonStamp
686 * @param[in] comp_image_size - ComponentImageSize
687 * @param[in] update_option_flags - UpdateOptionFlags
688 * @param[in] comp_ver_str_type - ComponentVersionStringType
689 * @param[in] comp_ver_str_len - ComponentVersionStringLength
690 * @param[in] comp_ver_str - ComponentVersionString
691 * @param[in,out] msg - Message will be written to this
692 * @param[in] payload_length - Length of request message payload
693 * information
694 *
695 * @return pldm_completion_codes
696 *
697 * @note Caller is responsible for memory alloc and dealloc of param
698 * 'msg.payload'
699 */
700int encode_update_component_req(
701 uint8_t instance_id, uint16_t comp_classification, uint16_t comp_identifier,
702 uint8_t comp_classification_index, uint32_t comp_comparison_stamp,
703 uint32_t comp_image_size, bitfield32_t update_option_flags,
704 uint8_t comp_ver_str_type, uint8_t comp_ver_str_len,
705 const struct variable_field *comp_ver_str, struct pldm_msg *msg,
706 size_t payload_length);
707
gokulsanker4b533f22021-04-22 12:53:00 +0530708/** @brief Decode UpdateComponent response message
709 *
710 * @param[in] msg - Response message
711 * @param[in] payload_length - Length of response message payload
712 * @param[out] completion_code - Pointer to hold completion code
713 * @param[out] comp_compatability_resp - Pointer to hold component
714 * compatibility response
715 * @param[out] comp_compatability_resp_code - Pointer to hold component
716 * compatibility response code
717 * @param[out] update_option_flags_enabled - Pointer to hold
718 * UpdateOptionsFlagEnabled
719 * @param[out] time_before_req_fw_data - Pointer to hold the estimated time
720 * before sending RequestFirmwareData
721 *
722 * @return pldm_completion_codes
723 */
724int decode_update_component_resp(const struct pldm_msg *msg,
725 size_t payload_length,
726 uint8_t *completion_code,
727 uint8_t *comp_compatability_resp,
728 uint8_t *comp_compatability_resp_code,
729 bitfield32_t *update_option_flags_enabled,
730 uint16_t *time_before_req_fw_data);
gokulsankera4e6b292021-06-02 16:35:39 +0530731
732/** @brief Decode RequestFirmwareData request message
733 *
734 * @param[in] msg - Request message
735 * @param[in] payload_length - Length of request message payload
736 * @param[out] offset - Pointer to hold offset
737 * @param[out] length - Pointer to hold the size of the component image
738 * segment requested by the FD/FDP
739 *
740 * @return pldm_completion_codes
741 */
742int decode_request_firmware_data_req(const struct pldm_msg *msg,
743 size_t payload_length, uint32_t *offset,
744 uint32_t *length);
gokulsanker9c440d02021-06-03 09:54:02 +0530745
746/** @brief Create PLDM response message for RequestFirmwareData
747 *
748 * The ComponentImagePortion is not encoded in the PLDM response message
749 * by encode_request_firmware_data_resp to avoid an additional copy. Populating
750 * ComponentImagePortion in the PLDM response message is handled by the user
751 * of this API. The payload_length validation considers only the
752 * CompletionCode.
753 *
754 * @param[in] instance_id - Message's instance id
755 * @param[in] completion_code - CompletionCode
756 * @param[in,out] msg - Message will be written to this
757 * @param[in] payload_length - Length of response message payload
758 *
759 * @return pldm_completion_codes
760 *
761 * @note Caller is responsible for memory alloc and dealloc of param
762 * 'msg.payload'
763 */
764int encode_request_firmware_data_resp(uint8_t instance_id,
765 uint8_t completion_code,
766 struct pldm_msg *msg,
767 size_t payload_length);
768
gokulsankere3807022021-06-26 19:12:01 +0530769/** @brief Decode TransferComplete request message
770 *
771 * @param[in] msg - Request message
772 * @param[in] payload_length - Length of request message payload
773 * @param[out] transfer_result - Pointer to hold TransferResult
774 *
775 * @return pldm_completion_codes
776 */
777int decode_transfer_complete_req(const struct pldm_msg *msg,
778 size_t payload_length,
779 uint8_t *transfer_result);
gokulsanker50107cf2021-06-27 09:44:12 +0530780
781/** @brief Create PLDM response message for TransferComplete
782 *
783 * @param[in] instance_id - Message's instance id
784 * @param[in] completion_code - CompletionCode
785 * @param[in,out] msg - Message will be written to this
786 * @param[in] payload_length - Length of response message payload
787 *
788 * @return pldm_completion_codes
789 *
790 * @note Caller is responsible for memory alloc and dealloc of param
791 * 'msg.payload'
792 */
793int encode_transfer_complete_resp(uint8_t instance_id, uint8_t completion_code,
794 struct pldm_msg *msg, size_t payload_length);
gokulsankerb79b91a2021-06-27 11:26:36 +0530795
796/** @brief Decode VerifyComplete request message
797 *
798 * @param[in] msg - Request message
799 * @param[in] payload_length - Length of request message payload
800 * @param[in] verify_result - Pointer to hold VerifyResult
801 *
802 * @return pldm_completion_codes
803 */
804int decode_verify_complete_req(const struct pldm_msg *msg,
805 size_t payload_length, uint8_t *verify_result);
806
gokulsanker9a693582021-06-27 11:35:09 +0530807/** @brief Create PLDM response message for VerifyComplete
808 *
809 * @param[in] instance_id - Message's instance id
810 * @param[in] completion_code - CompletionCode
811 * @param[in,out] msg - Message will be written to this
812 * @param[in] payload_length - Length of response message payload
813 *
814 * @return pldm_completion_codes
815 *
816 * @note Caller is responsible for memory alloc and dealloc of param
817 * 'msg.payload'
818 */
819int encode_verify_complete_resp(uint8_t instance_id, uint8_t completion_code,
820 struct pldm_msg *msg, size_t payload_length);
821
gokulsanker138ceba2021-04-05 13:25:25 +0530822#ifdef __cplusplus
823}
824#endif
825
826#endif // End of FW_UPDATE_H