1 /* SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later */ 2 #pragma once 3 4 #include <stdint.h> 5 #include <stdbool.h> 6 #include <string.h> 7 8 #include <libpldm/pldm.h> 9 #include <libpldm/firmware_update.h> 10 #include <libpldm/firmware_fd.h> 11 12 typedef uint64_t pldm_fd_time_t; 13 14 struct pldm_fd_req { 15 enum pldm_fd_req_state { 16 // pldm_fd_req instance is unused 17 PLDM_FD_REQ_UNUSED = 0, 18 // Ready to send a request 19 PLDM_FD_REQ_READY, 20 // Waiting for a response 21 PLDM_FD_REQ_SENT, 22 // Completed and failed, will not send more requests. 23 // Waiting for a cancel from the UA. 24 PLDM_FD_REQ_FAILED, 25 } state; 26 27 /* Set once when ready to move to next state, will return 28 * this result for TransferComplete/VerifyComplete/ApplyComplete request. */ 29 bool complete; 30 /* Only valid when complete is set */ 31 uint8_t result; 32 33 /* Only valid in SENT state */ 34 uint8_t instance_id; 35 uint8_t command; 36 pldm_fd_time_t sent_time; 37 }; 38 39 struct pldm_fd_download { 40 uint32_t offset; 41 }; 42 43 struct pldm_fd_verify { 44 uint8_t progress_percent; 45 }; 46 47 struct pldm_fd_apply { 48 uint8_t progress_percent; 49 }; 50 51 struct pldm_fd { 52 enum pldm_firmware_device_states state; 53 enum pldm_firmware_device_states prev_state; 54 55 /* Reason for last transition to idle state, 56 * only valid when state == PLDM_FD_STATE_IDLE */ 57 enum pldm_get_status_reason_code_values reason; 58 59 /* State-specific content */ 60 union { 61 struct pldm_fd_download download; 62 struct pldm_fd_verify verify; 63 struct pldm_fd_apply apply; 64 } specific; 65 /* Details of the component currently being updated. 66 * Set by UpdateComponent, available during download/verify/apply. 67 * Also used as temporary storage for PassComponentTable */ 68 struct pldm_firmware_update_component update_comp; 69 bitfield32_t update_flags; 70 71 /* Used for download/verify/apply requests */ 72 struct pldm_fd_req req; 73 74 /* Address of the UA */ 75 pldm_tid_t ua_address; 76 bool ua_address_set; 77 78 /* Maximum size allowed by the UA or platform implementation */ 79 uint32_t max_transfer; 80 81 /* Timestamp for FD T1 timeout, milliseconds */ 82 pldm_fd_time_t update_timestamp_fd_t1; 83 84 pldm_fd_time_t fd_t1_timeout; 85 pldm_fd_time_t fd_t2_retry_time; 86 87 const struct pldm_fd_ops *ops; 88 void *ops_ctx; 89 }; 90