1 /* 2 * Copyright (c) 2021-2023, Arm Limited. All rights reserved. 3 * 4 * SPDX-License-Identifier: BSD-3-Clause 5 * 6 */ 7 8 #ifndef FWU_AGENT_H 9 #define FWU_AGENT_H 10 11 #ifdef ENABLE_FWU_AGENT_DEBUG_LOGS 12 #include <stdio.h> 13 #define FWU_LOG_MSG(f_, ...) printf((f_), ##__VA_ARGS__) 14 #else 15 #define FWU_LOG_MSG(f_, ...) 16 #endif 17 18 enum fwu_agent_error_t { 19 FWU_AGENT_SUCCESS = 0, 20 FWU_AGENT_ERROR = (-1) 21 }; 22 23 #define FWU_ASSERT(_c_) \ 24 if (!(_c_)) { \ 25 FWU_LOG_MSG("%s:%d assert hit\n\r", __func__, __LINE__); \ 26 while(1) {}; \ 27 } \ 28 29 30 /* Version used for the very first image of the device. */ 31 #define FWU_IMAGE_INITIAL_VERSION 0 32 33 enum fwu_agent_error_t fwu_metadata_provision(void); 34 enum fwu_agent_error_t fwu_metadata_init(void); 35 36 /* host to secure enclave: 37 * firwmare update image is sent accross 38 */ 39 enum fwu_agent_error_t corstone1000_fwu_flash_image(void); 40 41 /* host to secure enclave: 42 * host responds with this api to acknowledge its successful 43 * boot. 44 */ 45 enum fwu_agent_error_t corstone1000_fwu_host_ack(void); 46 47 void bl1_get_active_bl2_image(uint32_t *bank_offset); 48 uint8_t bl2_get_boot_bank(void); 49 50 /* When in trial state, start the timer for host to respond. 51 * Diable timer when host responds back either by calling 52 * corstone1000_fwu_accept_image or corstone1000_fwu_select_previous. 53 * Otherwise, resets the system. 54 */ 55 void host_acknowledgement_timer_to_reset(void); 56 57 enum fwu_nv_counter_index_t { 58 FWU_BL2_NV_COUNTER = 0, 59 FWU_TFM_NV_COUNTER, 60 FWU_TFA_NV_COUNTER, 61 FWU_MAX_NV_COUNTER_INDEX = FWU_TFA_NV_COUNTER 62 }; 63 64 /* stage nv counter into private metadata section of the flash. 65 * staged nv counters are written to the otp when firmware update 66 * is successful 67 * the function assumes that the api is called in the boot loading 68 * stage 69 */ 70 enum fwu_agent_error_t fwu_stage_nv_counter(enum fwu_nv_counter_index_t index, 71 uint32_t img_security_cnt); 72 73 #endif /* FWU_AGENT_H */ 74