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