| /*-----------------------------------------------------------------------------------------------*/ | 
 | /** | 
 |   @file ql_absys.h | 
 |   @brief | 
 |        This file declare absys interface | 
 | */ | 
 | /*-----------------------------------------------------------------------------------------------*/ | 
 |  | 
 | /*------------------------------------------------------------------------------------------------- | 
 |   Copyright (c) 2018 Quectel Wireless Solution, Co., Ltd. All Rights Reserved. | 
 |   Quectel Wireless Solution Proprietary and Confidential. | 
 | -------------------------------------------------------------------------------------------------*/ | 
 |  | 
 | /*------------------------------------------------------------------------------------------------- | 
 |   EDIT HISTORY | 
 |   This section contains comments describing changes made to the file. | 
 |   Notice that changes are listed in reverse chronological order. | 
 |   $Header: $ | 
 |   when       who          what, where, why | 
 |   --------   ---          ---------------------------------------------------------- | 
 |   2021.12.20   jessie.lei     Created . | 
 | -------------------------------------------------------------------------------------------------*/ | 
 |  | 
 |  | 
 | #ifndef QL_ABSYS_H_ | 
 | #define QL_ABSYS_H_ | 
 |  | 
 | #include <stdbool.h> | 
 | #include <stdint.h> | 
 | #include <errno.h> | 
 | #include "fota_info.h" | 
 |  | 
 | #ifdef __cplusplus | 
 | extern "C" { | 
 | #endif | 
 |  | 
 | #define PARTITION_NAME_SIZE 16 | 
 |  | 
 |  | 
 |  | 
 | //-------------------------------------------------------------------------------------------------- | 
 | /** | 
 |  * System ID: The dual system platforms have 2 systems: A and B. | 
 |  * | 
 |  */ | 
 | //-------------------------------------------------------------------------------------------------- | 
 | typedef enum absystem | 
 | { | 
 |     SYSTEM_A = 0, | 
 |     SYSTEM_B = 1 | 
 | } absystem_t; | 
 |  | 
 | //-------------------------------------------------------------------------------------------------- | 
 | /** | 
 |  * system status | 
 |  */ | 
 | //-------------------------------------------------------------------------------------------------- | 
 | typedef struct | 
 | { | 
 |     fota_state_t ota_state;        ///< the device ota upgrade status | 
 |     bool is_damaged;               ///< whether the device have damaged partition | 
 |     uint8_t damaged_partname[PARTITION_NAME_SIZE];  ///< which partition damaged, and tiggered the device A/B system switch | 
 | } sysstatus_t; | 
 |  | 
 | //-------------------------------------------------------------------------------------------------- | 
 | /** | 
 |  * @brief | 
 |  * 		get current system status, fota status & A/B partition status. | 
 |  * @Parameter | 
 |         [OUT] sys_state, store the status to this struct for the caller could read current system status. | 
 |  * @return | 
 |  *      - On success               0 | 
 |  *      - On failure              -1 | 
 |  */ | 
 | //-------------------------------------------------------------------------------------------------- | 
 | int ql_absys_getstatus(sysstatus_t *sys_state); | 
 |  | 
 | //-------------------------------------------------------------------------------------------------- | 
 | /** | 
 |  * @brief | 
 |  * 		get current active system is A or B. | 
 |  * @Parameter | 
 |         [InOut] cur_system, store the current active system info to this enmu. | 
 |  * @return | 
 |  *      - On success               0, success to get current active system | 
 |  *      - On failure              -1, failed to get current active system | 
 |  */ | 
 | //-------------------------------------------------------------------------------------------------- | 
 | int ql_absys_get_cur_active_part(absystem_t *cur_system); | 
 |  | 
 |  | 
 | //-------------------------------------------------------------------------------------------------- | 
 | /** | 
 |  * @brief | 
 |  *      Set flags in fota state file, need the caller do reboot system action atfer this api return 0, then A/B system will be switch atfer reboot. | 
 |  *      If fota state is SUCCEED or NEEDSYNC (A/B system is sync), it is okay to switch A/B system, API will be return 0. | 
 |  *      If fota state is WRITEDONE (A/B system is not sync), it is okay to switch A/B system and will be set fota state to NEEDSYNC, API will be return 0. | 
 |  *      If fota state is UPDATE or BACKUP (A/B system is not sync), indicate the inactive partition is being updated and can not switch A/B, API will be return -2 | 
 |  *      If fota state is FAILED (A/B system is not sync), indicate the inactive partition was damaged and can not switch A/B, API will be return -3 | 
 |  * @Parameter | 
 |  *     No parameter | 
 |  * @return | 
 |  *      - On success   0  indicate the switch flag was set succeed | 
 |  *      - On failure   -1 get or set fota state and absys info failed; | 
 |  *                     -2 indicate the inactive partition was damaged by ota upgrade, could not switch; | 
 |  *                     -3 indicate the inactive partition is being upgraded or backup is in progress. | 
 |  */ | 
 | //-------------------------------------------------------------------------------------------------- | 
 | int ql_absys_switch(void); | 
 |  | 
 |  | 
 | //-------------------------------------------------------------------------------------------------- | 
 | /** | 
 |  * @brief | 
 |  * 		Program a synchronization active slot partition data to non-active partition | 
 |  * @Parameter | 
 |  *      No parameter | 
 |  * @return | 
 |  *      - On success             0 | 
 |  *      - On failure            -1 | 
 |  */ | 
 | //-------------------------------------------------------------------------------------------------- | 
 | int ql_absys_sync(void); | 
 |  | 
 |  | 
 | //-------------------------------------------------------------------------------------------------- | 
 | /** | 
 |  * @brief | 
 |  * 		Program a synchronization active slot partition data to non-inactive partition | 
 |  * @Parameter | 
 |  *  [IN] cpu_loading_level       0   ql_otad cpuloading 98% | 
 |  *                               1   ql_otad cpuloading 55% | 
 |  *                               2   ql_otad cpuloading 38% | 
 |  *                               3   ql_otad cpuloading 30% | 
 |  *                               4   ql_otad cpuloading 25% | 
 |  *                               5   ql_otad cpuloading 20% | 
 |  * @return | 
 |  *      - On success             0 | 
 |  *      - On failure            -1 | 
 |  */ | 
 | //-------------------------------------------------------------------------------------------------- | 
 | int ql_absys_sync_control(int cpu_loading_level); | 
 |  | 
 |  | 
 | #ifdef __cplusplus | 
 | } | 
 | #endif | 
 |  | 
 | #endif //QL_ABSYS_H_ |