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