11bd4fe43Sopenharmony_ci/* 21bd4fe43Sopenharmony_ci * @file hi_upg_api.h 31bd4fe43Sopenharmony_ci * 41bd4fe43Sopenharmony_ci * Copyright (c) 2020 HiSilicon (Shanghai) Technologies CO., LIMITED. 51bd4fe43Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 61bd4fe43Sopenharmony_ci * you may not use this file except in compliance with the License. 71bd4fe43Sopenharmony_ci * You may obtain a copy of the License at 81bd4fe43Sopenharmony_ci * 91bd4fe43Sopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 101bd4fe43Sopenharmony_ci * 111bd4fe43Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software 121bd4fe43Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 131bd4fe43Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 141bd4fe43Sopenharmony_ci * See the License for the specific language governing permissions and 151bd4fe43Sopenharmony_ci * limitations under the License. 161bd4fe43Sopenharmony_ci */ 171bd4fe43Sopenharmony_ci 181bd4fe43Sopenharmony_ci/** 191bd4fe43Sopenharmony_ci * @defgroup upg Upgrade 201bd4fe43Sopenharmony_ci * @ingroup system 211bd4fe43Sopenharmony_ci*/ 221bd4fe43Sopenharmony_ci 231bd4fe43Sopenharmony_ci#ifndef __HI_UPG_API_H__ 241bd4fe43Sopenharmony_ci#define __HI_UPG_API_H__ 251bd4fe43Sopenharmony_ci#include "hi_upg_file.h" 261bd4fe43Sopenharmony_ci#include <hi_types.h> 271bd4fe43Sopenharmony_ci 281bd4fe43Sopenharmony_ci/** 291bd4fe43Sopenharmony_ci * @ingroup upg 301bd4fe43Sopenharmony_ci * Kernel upgrade file. CNcomment:Kernel升级文件。CNend 311bd4fe43Sopenharmony_ci */ 321bd4fe43Sopenharmony_ci#define HI_UPG_FILE_KERNEL 0xF0 331bd4fe43Sopenharmony_ci 341bd4fe43Sopenharmony_ci/** 351bd4fe43Sopenharmony_ci * @ingroup upg 361bd4fe43Sopenharmony_ci * FlashBoot upgrade file. CNcomment:FlashBoot升级文件。CNend 371bd4fe43Sopenharmony_ci */ 381bd4fe43Sopenharmony_ci#define HI_UPG_FILE_BOOT 0xE1 391bd4fe43Sopenharmony_ci 401bd4fe43Sopenharmony_ci/** 411bd4fe43Sopenharmony_ci * @ingroup upg 421bd4fe43Sopenharmony_ci * Kernel upgrade file of area A. CNcomment:A区升级文件。CNend 431bd4fe43Sopenharmony_ci */ 441bd4fe43Sopenharmony_ci#define HI_UPG_FILE_FOR_AREA_A 1 451bd4fe43Sopenharmony_ci 461bd4fe43Sopenharmony_ci/** 471bd4fe43Sopenharmony_ci * @ingroup upg 481bd4fe43Sopenharmony_ci * Kernel upgrade file of area B/Compress kernel upgrade file. CNcomment:B区升级文件/压缩升级文件。CNend 491bd4fe43Sopenharmony_ci */ 501bd4fe43Sopenharmony_ci#define HI_UPG_FILE_FOR_AREA_B 2 511bd4fe43Sopenharmony_ci 521bd4fe43Sopenharmony_ci/** 531bd4fe43Sopenharmony_ci * @ingroup upg 541bd4fe43Sopenharmony_ci * Kernel upgrade file magic number. CNcomment:Kernel升级文件魔术字。CNend 551bd4fe43Sopenharmony_ci */ 561bd4fe43Sopenharmony_ci#define HI_UPG_FILE_IMAGE_ID 0x3C78961E 571bd4fe43Sopenharmony_ci 581bd4fe43Sopenharmony_ci/** 591bd4fe43Sopenharmony_ci* @ingroup upg 601bd4fe43Sopenharmony_ci* @brief Upgrade module initialization.CNcomment:升级模块初始化。CNend 611bd4fe43Sopenharmony_ci* 621bd4fe43Sopenharmony_ci* @par 描述: 631bd4fe43Sopenharmony_ci Upgrade module initialization.CNcomment:升级模块初始化。CNend 641bd4fe43Sopenharmony_ci* @attention 651bd4fe43Sopenharmony_ci* @li Must be called immediately after NV initialization. CNcomment:必须紧跟NV初始化后调用。CNend 661bd4fe43Sopenharmony_ci* @li This interface does not support multiple calls. CNcomment:该接口不支持多次调用。CNend 671bd4fe43Sopenharmony_ci* @param None. 681bd4fe43Sopenharmony_ci* @retval #HI_ERR_SUCCESS Success.CNcomment:升级模块初始化成功。CNend 691bd4fe43Sopenharmony_ci* @retval #Other Failure.CNcomment:其他值 升级模块初始化失败。CNend 701bd4fe43Sopenharmony_ci* @par 依赖: 711bd4fe43Sopenharmony_ci* @li hi_upg_api.h:Describe Upgrade usage APIs.CNcomment:文件用于描述升级对外接口。CNend 721bd4fe43Sopenharmony_ci* @see None.CNcomment:无。CNend 731bd4fe43Sopenharmony_ci*/ 741bd4fe43Sopenharmony_cihi_u32 hi_upg_init(hi_void); 751bd4fe43Sopenharmony_ci 761bd4fe43Sopenharmony_ci/** 771bd4fe43Sopenharmony_ci* @ingroup upg 781bd4fe43Sopenharmony_ci* @brief Get upgrade file from the backup flash.CNcomment:从备份区读取升级文件。CNend 791bd4fe43Sopenharmony_ci* 801bd4fe43Sopenharmony_ci* @par 描述: 811bd4fe43Sopenharmony_ci Used to get upgrade data from the backup flash.CNcomment:该函数从备份区读升级文件。CNend 821bd4fe43Sopenharmony_ci* @attention 831bd4fe43Sopenharmony_ci* @li Ensure that the actual buffer size is the same as the value of buf_len. 841bd4fe43Sopenharmony_ci* CNcomment:用户需保证buf实际大小与buf_len相等。CNend 851bd4fe43Sopenharmony_ci* @li Must be called after calling interface hi_upg_transmit or hi_upg_transmit_finish_save_cache. 861bd4fe43Sopenharmony_ciCNcomment:必须在调用升级文件传输接口之后调用。CNend 871bd4fe43Sopenharmony_ci* @li Must be called before calling interface hi_upg_transmit_finish in non-power-off upgrade scenario. 881bd4fe43Sopenharmony_ciCNcomment:非断电升级场景必须在调用升级文件传输完成之前调用。CNend 891bd4fe43Sopenharmony_ci* @li Must be called before calling interface hi_upg_finish_with_cache in power-off upgrade scenario. 901bd4fe43Sopenharmony_ciCNcomment:断电升级场景必须在调用升级结束完成之前调用。CNend 911bd4fe43Sopenharmony_ci* @param offset [IN] type #hi_u32 Offset relative to the start address of the upgrade cache. 921bd4fe43Sopenharmony_ci* CNcomment:相对升级备份区起始地址的偏移地址。CNend 931bd4fe43Sopenharmony_ci* @param buf [IN/OUT] type #hi_u8* Pointer to the upgrade data package.CNcomment:升级数据包指针。CNend 941bd4fe43Sopenharmony_ci* @param buf_len [IN] type #hi_u32 Length of the upgrade data package.Unit: byte. 951bd4fe43Sopenharmony_ci* CNcomment:升级数据包长度,单位:byte。CNend 961bd4fe43Sopenharmony_ci* @retval #HI_ERR_SUCCESS Success.CNcomment:读成功。CNend 971bd4fe43Sopenharmony_ci* @retval #Other Failure.CNcomment:其他值 读失败。CNend 981bd4fe43Sopenharmony_ci* @par 依赖: 991bd4fe43Sopenharmony_ci* @li hi_upg_api.h:Describe Upgrade usage APIs.CNcomment:文件用于描述升级对外接口。CNend 1001bd4fe43Sopenharmony_ci* @see hi_upg_transmit_finish_save_cache; hi_upg_finish_with_cache; hi_upg_transmit; hi_upg_transmit_finish. 1011bd4fe43Sopenharmony_ci*/ 1021bd4fe43Sopenharmony_cihi_u32 hi_upg_get_content(hi_u32 offset, hi_u8* buf, hi_u32 buf_len); 1031bd4fe43Sopenharmony_ci 1041bd4fe43Sopenharmony_ci/** 1051bd4fe43Sopenharmony_ci* @ingroup upg 1061bd4fe43Sopenharmony_ci* @brief Transmit upgrade file.CNcomment:传输升级文件。CNend 1071bd4fe43Sopenharmony_ci* 1081bd4fe43Sopenharmony_ci* @par 描述: 1091bd4fe43Sopenharmony_ci Transmit upgrade file.CNcomment:传输升级文件。CNend 1101bd4fe43Sopenharmony_ci* @attention 1111bd4fe43Sopenharmony_ci* @li The first packet transmitted is not less than 96 bytes.CNcomment:传输的第1包不小于96字节。CNend 1121bd4fe43Sopenharmony_ci* @param offset [IN] type #hi_u32 Offset relative to the head of the upgrade file.CNcomment:相对升级文件头的偏移地址。CNend 1131bd4fe43Sopenharmony_ci* @param buf [IN] type #hi_u8* Upgrade file data.CNcomment:升级数据包。CNend 1141bd4fe43Sopenharmony_ci* @param buf_len [IN] type #hi_u32 Length of the upgrade file data.Unit:byte.CNcomment:升级数据包长度,单位:byte。CNend 1151bd4fe43Sopenharmony_ci* @retval #HI_ERR_SUCCESS Success.CNcomment:成功。CNend 1161bd4fe43Sopenharmony_ci* @retval #Other Failure.CNcomment:其他值 失败。CNend 1171bd4fe43Sopenharmony_ci* @par 依赖: 1181bd4fe43Sopenharmony_ci* @li hi_upg_api.h:Describe Upgrade usage APIs.CNcomment:文件用于描述升级对外接口。CNend 1191bd4fe43Sopenharmony_ci* @see None.CNcomment:无。CNend 1201bd4fe43Sopenharmony_ci*/ 1211bd4fe43Sopenharmony_cihi_u32 hi_upg_transmit(hi_u32 offset, hi_u8* buf, hi_u32 buf_len); 1221bd4fe43Sopenharmony_ci 1231bd4fe43Sopenharmony_ci/** 1241bd4fe43Sopenharmony_ci* @ingroup upg 1251bd4fe43Sopenharmony_ci* @brief Upgrade restart.CNcomment:升级重启。CNend 1261bd4fe43Sopenharmony_ci* 1271bd4fe43Sopenharmony_ci* @par 描述: 1281bd4fe43Sopenharmony_ci This interface is used to restart.CNcomment:该接口实现升级重启。CNend 1291bd4fe43Sopenharmony_ci* @attention None. 1301bd4fe43Sopenharmony_ci* @param None. 1311bd4fe43Sopenharmony_ci* @retval None. 1321bd4fe43Sopenharmony_ci* @par 依赖: 1331bd4fe43Sopenharmony_ci* @li hi_upg_api.h:Describe Upgrade usage APIs.CNcomment:文件用于描述升级对外接口。CNend 1341bd4fe43Sopenharmony_ci* @see None.CNcomment:无。CNend 1351bd4fe43Sopenharmony_ci*/ 1361bd4fe43Sopenharmony_cihi_void hi_upg_finish(hi_void); 1371bd4fe43Sopenharmony_ci 1381bd4fe43Sopenharmony_ci/** 1391bd4fe43Sopenharmony_ci* @ingroup upg 1401bd4fe43Sopenharmony_ci* @brief Notify file transfer end.CNcomment:文件传输结束。CNend 1411bd4fe43Sopenharmony_ci* 1421bd4fe43Sopenharmony_ci* @par 描述: 1431bd4fe43Sopenharmony_ci Used to notify file transfer end.CNcomment:文件传输结束。CNend 1441bd4fe43Sopenharmony_ci* @attention None. 1451bd4fe43Sopenharmony_ci* @param None. 1461bd4fe43Sopenharmony_ci* @retval #HI_ERR_SUCCESS Success.CNcomment:成功。CNend 1471bd4fe43Sopenharmony_ci* @retval #Other Failure.CNcomment:其他值 失败。CNend 1481bd4fe43Sopenharmony_ci* @par 依赖: 1491bd4fe43Sopenharmony_ci* @li hi_upg_api.h:Describe Upgrade usage APIs.CNcomment:文件用于描述升级对外接口。CNend 1501bd4fe43Sopenharmony_ci* @see None.CNcomment:无。CNend 1511bd4fe43Sopenharmony_ci*/ 1521bd4fe43Sopenharmony_cihi_u32 hi_upg_transmit_finish(hi_void); 1531bd4fe43Sopenharmony_ci 1541bd4fe43Sopenharmony_ci/** 1551bd4fe43Sopenharmony_ci* @ingroup upg 1561bd4fe43Sopenharmony_ci* @brief Upgrade restart. The power-off or restart operation is allowed before upgrade restart. 1571bd4fe43Sopenharmony_ci CNcomment:升级重启,支持断电后执行升级重启操作。CNend 1581bd4fe43Sopenharmony_ci* 1591bd4fe43Sopenharmony_ci* @par 描述: 1601bd4fe43Sopenharmony_ci This interface is used to restart. It works with hi_upg_transmit_finish_save_cache and applies to scenarios 1611bd4fe43Sopenharmony_ci where the upgrade is not required immediately. 1621bd4fe43Sopenharmony_ci CNcomment:该接口实现升级重启,与hi_upg_transmit_finish_save_cache配合使用,适用于不需要立即进行升级的场景。CNend 1631bd4fe43Sopenharmony_ci* @attention 1641bd4fe43Sopenharmony_ci* @li The power-off or restart operation is allowed between hi_upg_transmit_finish_save_cache and 1651bd4fe43Sopenharmony_ci hi_upg_finish_with_cache. 1661bd4fe43Sopenharmony_ciCNcomment:允许在hi_upg_transmit_finish_save_cache和hi_upg_finish_with_cache的调用之间存在掉电或重启操作。CNend. 1671bd4fe43Sopenharmony_ci* @param None. 1681bd4fe43Sopenharmony_ci* @retval #HI_ERR_SUCCESS Success.CNcomment:成功。CNend 1691bd4fe43Sopenharmony_ci* @retval #Other Failure.CNcomment:其他值 失败。CNend 1701bd4fe43Sopenharmony_ci* @par 依赖: 1711bd4fe43Sopenharmony_ci* @li hi_upg_api.h:Describe Upgrade usage APIs.CNcomment:文件用于描述升级对外接口。CNend 1721bd4fe43Sopenharmony_ci* @see None.CNcomment:无。CNend 1731bd4fe43Sopenharmony_ci*/ 1741bd4fe43Sopenharmony_cihi_u32 hi_upg_finish_with_cache(hi_void); 1751bd4fe43Sopenharmony_ci 1761bd4fe43Sopenharmony_ci/** 1771bd4fe43Sopenharmony_ci* @ingroup upg 1781bd4fe43Sopenharmony_ci* @brief Notify file transfer is complete and save some key parameters of the transfer process. 1791bd4fe43Sopenharmony_ci CNcomment:文件传输结束,保存传输流程的关键参数。CNend 1801bd4fe43Sopenharmony_ci* 1811bd4fe43Sopenharmony_ci* @par 描述: 1821bd4fe43Sopenharmony_ci Used to notify file transfer end and save some key parameters of the transfer process. It works with 1831bd4fe43Sopenharmony_ci hi_upg_finish_with_cache and applies to scenarios where the upgrade is not required immediately. 1841bd4fe43Sopenharmony_ci CNcomment:文件传输结束,保存传输流程的关键参数。与hi_upg_finish_with_cache配合使用,适用于不需要立即 1851bd4fe43Sopenharmony_ci 进行升级的场景。CNend 1861bd4fe43Sopenharmony_ci* @attention 1871bd4fe43Sopenharmony_ci* @li The power-off or restart operation is allowed between hi_upg_transmit_finish_save_cache and 1881bd4fe43Sopenharmony_ci hi_upg_finish_with_cache. 1891bd4fe43Sopenharmony_ciCNcomment:允许在hi_upg_transmit_finish_save_cache和hi_upg_finish_with_cache的调用之间存在掉电或重启操作。CNend. 1901bd4fe43Sopenharmony_ci* @param None. 1911bd4fe43Sopenharmony_ci* @retval #HI_ERR_SUCCESS Success.CNcomment:成功。CNend 1921bd4fe43Sopenharmony_ci* @retval #Other Failure.CNcomment:其他值 失败。CNend 1931bd4fe43Sopenharmony_ci* @par 依赖: 1941bd4fe43Sopenharmony_ci* @li hi_upg_api.h:Describe Upgrade usage APIs.CNcomment:文件用于描述升级对外接口。CNend 1951bd4fe43Sopenharmony_ci* @see None.CNcomment:无。CNend 1961bd4fe43Sopenharmony_ci*/ 1971bd4fe43Sopenharmony_cihi_u32 hi_upg_transmit_finish_save_cache(hi_void); 1981bd4fe43Sopenharmony_ci 1991bd4fe43Sopenharmony_ci/** 2001bd4fe43Sopenharmony_ci* @ingroup upg 2011bd4fe43Sopenharmony_ci* @brief Get the maximum upgrade file length.CNcomment:获取最大升级文件长度。CNend 2021bd4fe43Sopenharmony_ci* 2031bd4fe43Sopenharmony_ci* @par 描述: 2041bd4fe43Sopenharmony_ci Used to get the maximum upgrade file length.CNcomment:获取最大升级文件长度。CNend 2051bd4fe43Sopenharmony_ci* @attention None. 2061bd4fe43Sopenharmony_ci* @param file_type [IN] type #hi_u8 Upgrade file type.CNcomment:升级文件类型。CNend 2071bd4fe43Sopenharmony_ci* @param file_len [IN/OUT] type #hi_u32* Max file length.CNcomment:最大升级文件大小。CNend 2081bd4fe43Sopenharmony_ci* @retval #HI_ERR_SUCCESS Success.CNcomment:成功。CNend 2091bd4fe43Sopenharmony_ci* @retval #Other Failure.CNcomment:其他值 失败。CNend 2101bd4fe43Sopenharmony_ci* @par 依赖: 2111bd4fe43Sopenharmony_ci* @li hi_upg_api.h:Describe Upgrade usage APIs.CNcomment:文件用于描述升级对外接口。CNend 2121bd4fe43Sopenharmony_ci* @see None.CNcomment:无。CNend 2131bd4fe43Sopenharmony_ci*/ 2141bd4fe43Sopenharmony_cihi_u32 hi_upg_get_max_file_len(hi_u8 file_type, hi_u32 *file_len); 2151bd4fe43Sopenharmony_ci 2161bd4fe43Sopenharmony_ci/** 2171bd4fe43Sopenharmony_ci* @ingroup upg 2181bd4fe43Sopenharmony_ci* @brief Get the upgrade file index.CNcomment:获取升级文件编号。CNend 2191bd4fe43Sopenharmony_ci* 2201bd4fe43Sopenharmony_ci* @par 描述: 2211bd4fe43Sopenharmony_ci Get the upgrade file index.CNcomment:获取升级文件编号。CNend 2221bd4fe43Sopenharmony_ci* @attention None.CNcomment:无。CNend 2231bd4fe43Sopenharmony_ci* @param index [IN/OUT] type #hi_u8* Upgrade file index.CNcomment:升级文件编号。CNend 2241bd4fe43Sopenharmony_ci* @retval #1 Upg file for area A.CNcomment:1 A区升级文件。CNend 2251bd4fe43Sopenharmony_ci* @retval #2 Upg file for area B.CNcomment:2 B区升级文件。CNend 2261bd4fe43Sopenharmony_ci* @par 依赖: 2271bd4fe43Sopenharmony_ci* @li hi_upg_api.h:Describe Upgrade usage APIs.CNcomment:文件用于描述升级对外接口。CNend 2281bd4fe43Sopenharmony_ci* @see None.CNcomment:无。CNend 2291bd4fe43Sopenharmony_ci*/ 2301bd4fe43Sopenharmony_cihi_u32 hi_upg_get_file_index(hi_u8 *index); 2311bd4fe43Sopenharmony_ci 2321bd4fe43Sopenharmony_ci/** 2331bd4fe43Sopenharmony_ci* @ingroup upg 2341bd4fe43Sopenharmony_ci* @brief Stop the upgrade process.CNcomment:停止升级。CNend 2351bd4fe43Sopenharmony_ci* 2361bd4fe43Sopenharmony_ci* @par 描述: 2371bd4fe43Sopenharmony_ci Used to stop the upgrade process.CNcomment:停止升级。CNend 2381bd4fe43Sopenharmony_ci* @attention None. 2391bd4fe43Sopenharmony_ci* @param None. 2401bd4fe43Sopenharmony_ci* @retval #HI_ERR_SUCCESS Success.CNcomment:成功。CNend 2411bd4fe43Sopenharmony_ci* @retval #Other Failure.CNcomment:其他值 失败。CNend 2421bd4fe43Sopenharmony_ci* @par 依赖: 2431bd4fe43Sopenharmony_ci* @li hi_upg_api.h:Describe Upgrade usage APIs.CNcomment:文件用于描述升级对外接口。CNend 2441bd4fe43Sopenharmony_ci* @see None.CNcomment:无。CNend 2451bd4fe43Sopenharmony_ci*/ 2461bd4fe43Sopenharmony_cihi_u32 hi_upg_stop(hi_void); 2471bd4fe43Sopenharmony_ci 2481bd4fe43Sopenharmony_ci/** 2491bd4fe43Sopenharmony_ci* @ingroup upg 2501bd4fe43Sopenharmony_ci* @brief Register upgrade file validity check interface.CNcomment:注册升级文件合法性校验接口。CNend 2511bd4fe43Sopenharmony_ci* 2521bd4fe43Sopenharmony_ci* @par 描述: 2531bd4fe43Sopenharmony_ci Register upgrade file validity check interface.CNcomment:注册升级文件合法性校验接口。CNend 2541bd4fe43Sopenharmony_ci* @attention Called during the initialization process.CNcomment:初始化流程中调用。CNend 2551bd4fe43Sopenharmony_ci* @param upg_file_check_fn [IN]User-defined upgrade file verification interface.CNcomment:用户自定义接口。CNend 2561bd4fe43Sopenharmony_ci* @param param [IN]Passed back to callback function when callback.CNcomment:用户自定义接口参数。CNend 2571bd4fe43Sopenharmony_ci* @retval #HI_ERR_SUCCESS Success.CNcomment:成功。CNend 2581bd4fe43Sopenharmony_ci* @retval #Other Failure.CNcomment:其他值 失败。CNend 2591bd4fe43Sopenharmony_ci* @par 依赖: 2601bd4fe43Sopenharmony_ci* @li hi_upg_api.h:Describe Upgrade usage APIs.CNcomment:文件用于描述升级对外接口。CNend 2611bd4fe43Sopenharmony_ci* @see None.CNcomment:无。CNend 2621bd4fe43Sopenharmony_ci*/ 2631bd4fe43Sopenharmony_cihi_u32 hi_upg_register_file_verify_fn( 2641bd4fe43Sopenharmony_ci hi_u32 (*upg_file_check_fn)(const hi_upg_user_info *info, hi_void *param), 2651bd4fe43Sopenharmony_ci hi_void *param); 2661bd4fe43Sopenharmony_ci 2671bd4fe43Sopenharmony_ci#endif