1 /** ---------------------------------------------------------------------- 2 * 3 * Copyright (C) 2018 ST Microelectronics S.A. 4 * 5 * Licensed under the Apache License, Version 2.0 (the "License"); 6 * you may not use this file except in compliance with the License. 7 * You may obtain a copy of the License at 8 * 9 * http://www.apache.org/licenses/LICENSE-2.0 10 * 11 * Unless required by applicable law or agreed to in writing, software 12 * distributed under the License is distributed on an "AS IS" BASIS, 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 * See the License for the specific language governing permissions and 15 * limitations under the License. 16 * 17 * 18 ----------------------------------------------------------------------*/ 19 20 #ifndef HAL_FD_H_ 21 #define HAL_FD_H_ 22 23 #include "halcore.h" 24 25 #define STFLASHTOOL_VERSION 0x0503 26 /* 27 *Structure containing fw version info 28 */ 29 typedef struct FWInfo { 30 uint32_t patchVersion; 31 uint32_t fwVersion; 32 uint8_t hwVersion; 33 uint32_t loaderVersion; 34 uint16_t custVersion; 35 uint16_t confVersion; 36 bool hibernate_exited; 37 } FWInfo; 38 39 typedef enum { 40 // HAL_FD_STATE_GET_ATR, 41 HAL_FD_STATE_AUTHENTICATE, 42 HAL_FD_STATE_ERASE_FLASH, 43 HAL_FD_STATE_SEND_RAW_APDU, 44 HAL_FD_STATE_EXIT_APDU, 45 } hal_fd_state_e; 46 47 #define FT_CLF_MODE_ERROR 0 48 #define FT_CLF_MODE_LOADER 1 49 #define FT_CLF_MODE_ROUTER 2 50 51 #define FW_TIMER_DURATION 3000 52 53 #define FW_PATCH_AVAILABLE 1 54 #define FW_CUSTOM_PARAM_AVAILABLE 2 55 56 #define FW_UPDATE_NEEDED 1 57 #define CONF_UPDATE_NEEDED 2 58 59 #define MAX_BUFFER_SIZE 300 60 61 /* Function declarations */ 62 int hal_fd_init(); 63 void hal_fd_close(); 64 uint8_t ft_cmd_HwReset(uint8_t* pdata, uint8_t* clf_mode); 65 void ExitHibernateHandler(HALHANDLE mHalHandle, uint16_t data_len, 66 uint8_t* p_data); 67 void UpdateHandler(HALHANDLE mHalHandle, uint16_t data_len, uint8_t* p_data); 68 void ApplyCustomParamHandler(HALHANDLE mHalHandle, uint16_t data_len, 69 uint8_t* p_data); 70 void resetHandlerState(); 71 #endif /* HAL_FD_H_ */ 72