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