11bd4fe43Sopenharmony_ci/** 21bd4fe43Sopenharmony_ci* @file hi_crash.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/** @defgroup iot_crash_info Crash Log Management 191bd4fe43Sopenharmony_ci * @ingroup system 201bd4fe43Sopenharmony_ci */ 211bd4fe43Sopenharmony_ci 221bd4fe43Sopenharmony_ci#ifndef __HI_CRASH_H__ 231bd4fe43Sopenharmony_ci#define __HI_CRASH_H__ 241bd4fe43Sopenharmony_ci#include <hi_types.h> 251bd4fe43Sopenharmony_ci#include <hi_mdm_types.h> 261bd4fe43Sopenharmony_ci#include <hi_os_stat.h> 271bd4fe43Sopenharmony_ci#include <hi_mem.h> 281bd4fe43Sopenharmony_ci#include <hi_isr.h> 291bd4fe43Sopenharmony_ci 301bd4fe43Sopenharmony_ci#ifdef __cplusplus 311bd4fe43Sopenharmony_ciextern "C" { 321bd4fe43Sopenharmony_ci#endif 331bd4fe43Sopenharmony_ci 341bd4fe43Sopenharmony_ci/** 351bd4fe43Sopenharmony_ci* @ingroup iot_crash_info 361bd4fe43Sopenharmony_ci* 371bd4fe43Sopenharmony_ci* Version of the crash log module. CNcomment:死机存储模块版本号。CNend 381bd4fe43Sopenharmony_ci*/ 391bd4fe43Sopenharmony_ci#define HI_SYSERR_VERSION 1 401bd4fe43Sopenharmony_ci 411bd4fe43Sopenharmony_ci/** 421bd4fe43Sopenharmony_ci* @ingroup iot_crash_info 431bd4fe43Sopenharmony_ci* 441bd4fe43Sopenharmony_ci* Power down flag. CNcomment:下电标识。CNend 451bd4fe43Sopenharmony_ci*/ 461bd4fe43Sopenharmony_ci#define HI_SYSERR_POWER_DOWN 0x646F776E /* 下电标志 */ 471bd4fe43Sopenharmony_ci 481bd4fe43Sopenharmony_ci/** 491bd4fe43Sopenharmony_ci* @ingroup iot_crash_info 501bd4fe43Sopenharmony_ci* 511bd4fe43Sopenharmony_ci* No power down flag. CNcomment:未下电标识。CNend 521bd4fe43Sopenharmony_ci*/ 531bd4fe43Sopenharmony_ci#define HI_SYSERR_NO_POWER_DOWN 0xFFFFFFFF 541bd4fe43Sopenharmony_ci 551bd4fe43Sopenharmony_ci/** 561bd4fe43Sopenharmony_ci* @ingroup iot_crash_info 571bd4fe43Sopenharmony_ci* 581bd4fe43Sopenharmony_ci* Length of the name string of an exception type. CNcomment:异常类型的名字字符串长度限制。CNend 591bd4fe43Sopenharmony_ci*/ 601bd4fe43Sopenharmony_ci#define HI_SYSERR_EXC_TYPE_NAME_SIZE 8 611bd4fe43Sopenharmony_ci 621bd4fe43Sopenharmony_ci/** 631bd4fe43Sopenharmony_ci* @ingroup iot_crash_info 641bd4fe43Sopenharmony_ci* 651bd4fe43Sopenharmony_ci* Length of the task name string of a logged exception. 661bd4fe43Sopenharmony_ciCNcomment:异常存储的任务名字字符串长度限制。CNend 671bd4fe43Sopenharmony_ci*/ 681bd4fe43Sopenharmony_ci#define HI_SYSERR_EXC_TASK_NAME_SIZE 8 691bd4fe43Sopenharmony_ci 701bd4fe43Sopenharmony_ci/** 711bd4fe43Sopenharmony_ci* @ingroup iot_crash_info 721bd4fe43Sopenharmony_ci* 731bd4fe43Sopenharmony_ci* Depth of the scheduling track before an exception. CNcomment:异常前调度轨迹深度。CNend 741bd4fe43Sopenharmony_ci*/ 751bd4fe43Sopenharmony_ci#define HI_SYSERR_EXC_TRACE_DEPTH 10 761bd4fe43Sopenharmony_ci 771bd4fe43Sopenharmony_ci/** 781bd4fe43Sopenharmony_ci* @ingroup iot_crash_info 791bd4fe43Sopenharmony_ci* 801bd4fe43Sopenharmony_ci* Exception stack information depth (unit: word). CNcomment:异常栈信息深度(word为单位)CNend 811bd4fe43Sopenharmony_ci*/ 821bd4fe43Sopenharmony_ci#define HI_SYSERR_ESP_DATA_MAX_NUM 36 831bd4fe43Sopenharmony_ci 841bd4fe43Sopenharmony_ci/** 851bd4fe43Sopenharmony_ci* @ingroup iot_crash_info 861bd4fe43Sopenharmony_ci* 871bd4fe43Sopenharmony_ci* Extended depth of the exception stack SP to the stack bottom (unit: word). 881bd4fe43Sopenharmony_ciCNcomment:异常栈sp向栈底扩展深度(word为单位)CNend 891bd4fe43Sopenharmony_ci*/ 901bd4fe43Sopenharmony_ci#define HI_SYSERR_ESP_PRE_DATA_MAX_NUM 8 911bd4fe43Sopenharmony_ci 921bd4fe43Sopenharmony_ci/** 931bd4fe43Sopenharmony_ci* @ingroup iot_crash_info 941bd4fe43Sopenharmony_ci* 951bd4fe43Sopenharmony_ci* Version of the running kernel when the exception occurs. CNcomment:异常时对应的运行版本的版本号CNend 961bd4fe43Sopenharmony_ci*/ 971bd4fe43Sopenharmony_ci#define HI_SYSERR_EXC_KERNEL_VER_LEN_MAX 60 981bd4fe43Sopenharmony_ci#if !defined(PRODUCT_CFG_HSO) 991bd4fe43Sopenharmony_ci#if (HI_SYSERR_EXC_KERNEL_VER_LEN_MAX < HI_BUILD_VER_PRODUCT_LEN_MAX) 1001bd4fe43Sopenharmony_ci#error "HI_SYSERR_EXC_KERNEL_VER_LEN_MAX != HI_BUILD_VER_PRODUCT_LEN_MAX" 1011bd4fe43Sopenharmony_ci#endif 1021bd4fe43Sopenharmony_ci#endif 1031bd4fe43Sopenharmony_ci 1041bd4fe43Sopenharmony_ci/** 1051bd4fe43Sopenharmony_ci* @ingroup iot_crash_info 1061bd4fe43Sopenharmony_ci* Crash type eid.CNcomment:死机类型eid.CNend 1071bd4fe43Sopenharmony_ci*/ 1081bd4fe43Sopenharmony_citypedef enum { 1091bd4fe43Sopenharmony_ci HI_SYSERR_EID_POWER_DOWN, /**< Power Down or first Power on.CNcomment:下电重启或首次上电.CNend */ 1101bd4fe43Sopenharmony_ci HI_SYSERR_EID_FAULT_IN_TASK, /**< fault in task.CNcomment:任务中死机.CNend */ 1111bd4fe43Sopenharmony_ci HI_SYSERR_EID_FAULT_IN_ISR, /**< fault in isr.CNcomment:中断中死机.CNend */ 1121bd4fe43Sopenharmony_ci HI_SYSERR_EID_WATCHDOG_TSK, /**< watchdog reset(in task).CNcomment:看门狗死机(任务中).CNend */ 1131bd4fe43Sopenharmony_ci HI_SYSERR_EID_WATCHDOG_ISR, /**< watchdog reset(in isr).CNcomment:看门狗死机(中断中).CNend */ 1141bd4fe43Sopenharmony_ci HI_SYSERR_EID_SYS_SOFT_REBOOT, /**< system soft reboot.CNcomment:系统软复位.CNend */ 1151bd4fe43Sopenharmony_ci HI_SYSERR_EID_RESERVE, 1161bd4fe43Sopenharmony_ci HI_SYSERR_EID_MAX = 0xFF, 1171bd4fe43Sopenharmony_ci} hi_syserr_eid; 1181bd4fe43Sopenharmony_ci 1191bd4fe43Sopenharmony_ci/* cpu registers */ 1201bd4fe43Sopenharmony_citypedef struct { 1211bd4fe43Sopenharmony_ci hi_u32 mepc; 1221bd4fe43Sopenharmony_ci hi_u32 ra; 1231bd4fe43Sopenharmony_ci hi_u32 sp; 1241bd4fe43Sopenharmony_ci hi_u32 gp; 1251bd4fe43Sopenharmony_ci hi_u32 tp; 1261bd4fe43Sopenharmony_ci hi_u32 t0; 1271bd4fe43Sopenharmony_ci hi_u32 t1; 1281bd4fe43Sopenharmony_ci hi_u32 t2; 1291bd4fe43Sopenharmony_ci hi_u32 s0; 1301bd4fe43Sopenharmony_ci hi_u32 s1; 1311bd4fe43Sopenharmony_ci hi_u32 a0; 1321bd4fe43Sopenharmony_ci hi_u32 a1; 1331bd4fe43Sopenharmony_ci hi_u32 a2; 1341bd4fe43Sopenharmony_ci hi_u32 a3; 1351bd4fe43Sopenharmony_ci hi_u32 a4; 1361bd4fe43Sopenharmony_ci hi_u32 a5; 1371bd4fe43Sopenharmony_ci hi_u32 a6; 1381bd4fe43Sopenharmony_ci hi_u32 a7; 1391bd4fe43Sopenharmony_ci hi_u32 s2; 1401bd4fe43Sopenharmony_ci hi_u32 s3; 1411bd4fe43Sopenharmony_ci hi_u32 s4; 1421bd4fe43Sopenharmony_ci hi_u32 s5; 1431bd4fe43Sopenharmony_ci hi_u32 s6; 1441bd4fe43Sopenharmony_ci hi_u32 s7; 1451bd4fe43Sopenharmony_ci hi_u32 s8; 1461bd4fe43Sopenharmony_ci hi_u32 s9; 1471bd4fe43Sopenharmony_ci hi_u32 s10; 1481bd4fe43Sopenharmony_ci hi_u32 s11; 1491bd4fe43Sopenharmony_ci hi_u32 t3; 1501bd4fe43Sopenharmony_ci hi_u32 t4; 1511bd4fe43Sopenharmony_ci hi_u32 t5; 1521bd4fe43Sopenharmony_ci hi_u32 t6; 1531bd4fe43Sopenharmony_ci} syserr_reg_info; 1541bd4fe43Sopenharmony_ci 1551bd4fe43Sopenharmony_ci/** 1561bd4fe43Sopenharmony_ci* @ingroup iot_crash_info 1571bd4fe43Sopenharmony_ci* Task information.CNcomment:任务信息.CNend 1581bd4fe43Sopenharmony_ci*/ 1591bd4fe43Sopenharmony_citypedef struct { 1601bd4fe43Sopenharmony_ci hi_char name[HI_SYSERR_EXC_TASK_NAME_SIZE]; 1611bd4fe43Sopenharmony_ci hi_u32 id; /**< task id.CNcomment:任务ID.CNend */ 1621bd4fe43Sopenharmony_ci hi_u32 status; /**< task status.CNcomment:任务运行状态.CNend */ 1631bd4fe43Sopenharmony_ci hi_u8 reserve[3]; /* reserve's size 3 */ 1641bd4fe43Sopenharmony_ci hi_u8 stack_data_index; /**< extended stack information index from stack bottom.CNcomment: 1651bd4fe43Sopenharmony_ci 向栈底扩展的栈信息个数.CNend */ 1661bd4fe43Sopenharmony_ci hi_u16 stack_peak; /**< stack peak.CNcomment:栈使用峰值.CNend */ 1671bd4fe43Sopenharmony_ci hi_u16 stack_size; /**< stack size.CNcomment:任务栈大小.CNend */ 1681bd4fe43Sopenharmony_ci hi_u32 sp; /**< stack point.CNcomment:栈指针.CNend */ 1691bd4fe43Sopenharmony_ci hi_u32 stack[2]; /**< stack[2] is stack top and end address.CNcomment:栈顶和栈底地址.CNend */ 1701bd4fe43Sopenharmony_ci hi_u32 real_sp; /**< real stack point.CNcomment:真实栈指针.CNend */ 1711bd4fe43Sopenharmony_ci hi_u32 stack_pre_data[HI_SYSERR_ESP_PRE_DATA_MAX_NUM]; /**< extended stack information from stack bottom.CNcomment: 1721bd4fe43Sopenharmony_ci 向栈底扩展的栈信息,用于回退栈类错误参考.CNend */ 1731bd4fe43Sopenharmony_ci hi_u32 stack_data[HI_SYSERR_ESP_DATA_MAX_NUM]; /**< stack data.CNcomment:栈数据.CNend */ 1741bd4fe43Sopenharmony_ci hi_u32 overflow_flag; /**< stack overflow flag.CNcomment:栈溢出标识.CNend */ 1751bd4fe43Sopenharmony_ci} syserr_task_info; 1761bd4fe43Sopenharmony_ci 1771bd4fe43Sopenharmony_ci/** 1781bd4fe43Sopenharmony_ci* @ingroup iot_crash_info 1791bd4fe43Sopenharmony_ci* OS information.CNcomment:操作系统信息.CNend 1801bd4fe43Sopenharmony_ci*/ 1811bd4fe43Sopenharmony_citypedef struct { 1821bd4fe43Sopenharmony_ci hi_os_resource_use_stat usage; /**< os resource used count.CNcomment:系统资源使用个数.CNend */ 1831bd4fe43Sopenharmony_ci syserr_task_info task; /**< task information.CNcomment:任务信息.CNend */ 1841bd4fe43Sopenharmony_ci hi_mem_pool_crash_info mem; /**< memory pool information.CNcomment:动态内存池信息.CNend */ 1851bd4fe43Sopenharmony_ci} syserr_os_info; 1861bd4fe43Sopenharmony_ci 1871bd4fe43Sopenharmony_ci/** 1881bd4fe43Sopenharmony_ci* @ingroup iot_crash_info 1891bd4fe43Sopenharmony_ci* Basic information.CNcomment:基础信息.CNend 1901bd4fe43Sopenharmony_ci*/ 1911bd4fe43Sopenharmony_citypedef struct { 1921bd4fe43Sopenharmony_ci hi_u16 log_ver; /**< log version.CNcomment:Log版本号.CNend */ 1931bd4fe43Sopenharmony_ci hi_u16 eid; /**< reset reason id.CNcomment:复位类型.CNend */ 1941bd4fe43Sopenharmony_ci hi_u32 rid; /**< exception id.CNcomment:异常类型.CNend */ 1951bd4fe43Sopenharmony_ci hi_u32 now_tsec; /**< current time relative start time.CNcomment:当前运行相对启动时间.CNend */ 1961bd4fe43Sopenharmony_ci hi_u32 crash_tsec; /**< crash time relative start time.CNcomment:异常时相对当次启动时间.CNend */ 1971bd4fe43Sopenharmony_ci hi_u32 boot_ver; 1981bd4fe43Sopenharmony_ci hi_char kernel_ver[HI_SYSERR_EXC_KERNEL_VER_LEN_MAX]; /**< kernel version.CNcomment:异常时运行版本的版本号.CNend */ 1991bd4fe43Sopenharmony_ci hi_char type_name[HI_SYSERR_EXC_TYPE_NAME_SIZE]; /**< reset reason name.CNcomment:类型名:与eid对应.CNend */ 2001bd4fe43Sopenharmony_ci} syserr_basic_info; 2011bd4fe43Sopenharmony_ci 2021bd4fe43Sopenharmony_ci/** 2031bd4fe43Sopenharmony_ci* @ingroup iot_crash_info 2041bd4fe43Sopenharmony_ci* Watchdog information.CNcomment:看门狗信息.CNend 2051bd4fe43Sopenharmony_ci*/ 2061bd4fe43Sopenharmony_citypedef struct { 2071bd4fe43Sopenharmony_ci hi_u32 wdg_reset_pc; /**< watchdog reset reserved PC.CNcomment:看门狗复位PC.CNend */ 2081bd4fe43Sopenharmony_ci hi_u32 time_ms : 31; /**< watchdog timeout.CNcomment:看门狗超时时间.CNend */ 2091bd4fe43Sopenharmony_ci hi_u32 enable : 1; /**< watchdog enable.CNcomment:看门狗使能状态.CNend */ 2101bd4fe43Sopenharmony_ci} syserr_wdg_info; 2111bd4fe43Sopenharmony_ci 2121bd4fe43Sopenharmony_ci/** 2131bd4fe43Sopenharmony_ci* @ingroup iot_crash_info 2141bd4fe43Sopenharmony_ci* Flash protect information.CNcomment:Flash保护信息.CNend 2151bd4fe43Sopenharmony_ci*/ 2161bd4fe43Sopenharmony_citypedef struct { 2171bd4fe43Sopenharmony_ci hi_u32 current_block : 13; /**< flash protect current block.CNcomment:Flash保护当前block.CNend */ 2181bd4fe43Sopenharmony_ci hi_u32 reserve : 18; 2191bd4fe43Sopenharmony_ci hi_u32 enable : 1; /**< flash protect enable.CNcomment:Flash保护使能状态.CNend */ 2201bd4fe43Sopenharmony_ci hi_u32 status_reg; /**< flash protect status.CNcomment:Flash保护状态寄存器.CNend */ 2211bd4fe43Sopenharmony_ci} syserr_fp_info; 2221bd4fe43Sopenharmony_ci 2231bd4fe43Sopenharmony_ci/** 2241bd4fe43Sopenharmony_ci* @ingroup iot_crash_info 2251bd4fe43Sopenharmony_ci* Track item information.CNcomment:调度项信息.CNend 2261bd4fe43Sopenharmony_ci*/ 2271bd4fe43Sopenharmony_citypedef struct { 2281bd4fe43Sopenharmony_ci hi_u16 type; /**< track type.CNcomment:调度类型.CNend */ 2291bd4fe43Sopenharmony_ci hi_u16 id; /**< track ID.CNcomment:调度项id.CNend */ 2301bd4fe43Sopenharmony_ci hi_u32 data; /**< track userdata.CNcomment:调度用户数据.CNend */ 2311bd4fe43Sopenharmony_ci hi_u32 entry; /**< track Hook function Entry.CNcomment:调度回调勾子函数.CNend */ 2321bd4fe43Sopenharmony_ci hi_u32 timestamp; /**< The low 32 bit of the current time,us.CNcomment:调度时间戳.CNend */ 2331bd4fe43Sopenharmony_ci} syserr_track_item; 2341bd4fe43Sopenharmony_ci 2351bd4fe43Sopenharmony_ci/** 2361bd4fe43Sopenharmony_ci* @ingroup iot_crash_info 2371bd4fe43Sopenharmony_ci* Track information.CNcomment:调度轨迹信息.CNend 2381bd4fe43Sopenharmony_ci*/ 2391bd4fe43Sopenharmony_citypedef struct { 2401bd4fe43Sopenharmony_ci hi_u16 current_item; /**< current track item.CNcomment:当前调度项.CNend */ 2411bd4fe43Sopenharmony_ci hi_u16 item_cnt; /**< track count of track information.CNcomment:调度项记录个数.CNend */ 2421bd4fe43Sopenharmony_ci syserr_track_item item[HI_SYSERR_EXC_TRACE_DEPTH]; /**< track item data.CNcomment:调度项数据.CNend */ 2431bd4fe43Sopenharmony_ci} syserr_track_info; 2441bd4fe43Sopenharmony_ci 2451bd4fe43Sopenharmony_ci/** 2461bd4fe43Sopenharmony_ci* @ingroup iot_crash_info 2471bd4fe43Sopenharmony_ci* CPU csr registers information.CNcomment:CPU CSR寄存器信息.CNend 2481bd4fe43Sopenharmony_ci*/ 2491bd4fe43Sopenharmony_citypedef struct { 2501bd4fe43Sopenharmony_ci hi_u32 mstatus; /**< CPU mstatus register value.CNcomment:CPU mstatus寄存器值.CNend */ 2511bd4fe43Sopenharmony_ci hi_u32 mtval; /**< CPU mtval register value.CNcomment:CPU mtval寄存器值.CNend */ 2521bd4fe43Sopenharmony_ci hi_u32 mcause; /**< CPU mcause register value.CNcomment:CPU mcause寄存器值.CNend */ 2531bd4fe43Sopenharmony_ci hi_u32 ccause; /**< CPU ccause register value.CNcomment:CPU ccause寄存器值.CNend */ 2541bd4fe43Sopenharmony_ci hi_u16 cur_task_id; /**< current task id.CNcomment:当前任务ID.CNend */ 2551bd4fe43Sopenharmony_ci} syserr_core_info; 2561bd4fe43Sopenharmony_ci 2571bd4fe43Sopenharmony_ci/** 2581bd4fe43Sopenharmony_ci* @ingroup iot_crash_info 2591bd4fe43Sopenharmony_ci* Saved exception information.CNcomment:异常时对应存储信息。CNend 2601bd4fe43Sopenharmony_ci*/ 2611bd4fe43Sopenharmony_citypedef struct { 2621bd4fe43Sopenharmony_ci hi_u32 sig_s; /**< header flag of crash information.CNcomment:异常信息前标识.CNend */ 2631bd4fe43Sopenharmony_ci hi_u32 power_down : 1; /**< power down flag.CNcomment:下电标识.CNend */ 2641bd4fe43Sopenharmony_ci hi_u32 crc_usable : 1; /**< CRC check enable of crash information.CNcomment:死机信息CRC校验使能.CNend */ 2651bd4fe43Sopenharmony_ci hi_u32 info_len : 14; /**< crash information length.CNcomment:死机信息长度.CNend */ 2661bd4fe43Sopenharmony_ci hi_u32 crc_val : 16; /**< CRC16 calue of crash information.CNcomment:CRC16校验值.CNend */ 2671bd4fe43Sopenharmony_ci 2681bd4fe43Sopenharmony_ci syserr_basic_info basic_info; /**< basic data of crash information.CNcomment:死机基础信息.CNend */ 2691bd4fe43Sopenharmony_ci syserr_os_info os_info; /**< OS data of crash information.CNcomment:死机OS信息.CNend */ 2701bd4fe43Sopenharmony_ci syserr_reg_info reg_info; /**< CPU registers of crash information.CNcomment:死机CPU寄存器信息.CNend */ 2711bd4fe43Sopenharmony_ci syserr_wdg_info wdg_info; /**< watchdog data of crash information.CNcomment:死机看门狗.CNend */ 2721bd4fe43Sopenharmony_ci syserr_fp_info protect_info; /**< flash protect data of crash information.CNcomment:死机Flash保护信息.CNend */ 2731bd4fe43Sopenharmony_ci syserr_track_info track_info; /**< track data of crash information.CNcomment:死机调度信息.CNend */ 2741bd4fe43Sopenharmony_ci syserr_core_info core_info; /**< CPU CSR registers of crash information.CNcomment:死机CPU状态寄存器信息.CNend */ 2751bd4fe43Sopenharmony_ci hi_u32 sig_e; /**< end flag of crash information.CNcomment:异常信息后标识.CNend */ 2761bd4fe43Sopenharmony_ci} hi_syserr_info; 2771bd4fe43Sopenharmony_ci 2781bd4fe43Sopenharmony_citypedef hi_void (*hi_syserr_exc_callback)(hi_void); 2791bd4fe43Sopenharmony_ci 2801bd4fe43Sopenharmony_ci/** 2811bd4fe43Sopenharmony_ci* @ingroup iot_crash_info 2821bd4fe43Sopenharmony_ci* @brief Initializes the exception information module. CNcomment:异常信息模块初始化。CNend 2831bd4fe43Sopenharmony_ci* 2841bd4fe43Sopenharmony_ci* @par 描述: 2851bd4fe43Sopenharmony_ci* Initializes the exception information module. CNcomment:异常信息模块初始化。CNend 2861bd4fe43Sopenharmony_ci* 2871bd4fe43Sopenharmony_ci* @attention s API can be called only once. Repeated initialization and multi-task calling are not supported. 2881bd4fe43Sopenharmony_ciCNcomment:仅初始化一次,未考虑多次初始化及多任务调用场景。CNend 2891bd4fe43Sopenharmony_ci* @param None 2901bd4fe43Sopenharmony_ci* 2911bd4fe43Sopenharmony_ci* @retval None 2921bd4fe43Sopenharmony_ci* @par 依赖: 2931bd4fe43Sopenharmony_ci* @li hi_crash.h:Describes Crash log APIs. CNcomment:文件用于描述死机相关接口。CNend 2941bd4fe43Sopenharmony_ci* @see None 2951bd4fe43Sopenharmony_ci*/ 2961bd4fe43Sopenharmony_cihi_void hi_syserr_init(hi_void); 2971bd4fe43Sopenharmony_ci 2981bd4fe43Sopenharmony_ci/** 2991bd4fe43Sopenharmony_ci* @ingroup iot_crash_info 3001bd4fe43Sopenharmony_ci* @brief Obtains the system exception information pointer (in the memory). 3011bd4fe43Sopenharmony_ciCNcomment:获取系统异常信息指针(内存中)。CNend 3021bd4fe43Sopenharmony_ci* 3031bd4fe43Sopenharmony_ci* @par 描述: 3041bd4fe43Sopenharmony_ci* Obtains the system exception information pointer (in the memory). 3051bd4fe43Sopenharmony_ciCNcomment:获取系统异常信息指针(内存中)。CNend 3061bd4fe43Sopenharmony_ci* 3071bd4fe43Sopenharmony_ci* @attention None 3081bd4fe43Sopenharmony_ci* @param None 3091bd4fe43Sopenharmony_ci* 3101bd4fe43Sopenharmony_ci* @retval Pointer to the hi_syserr_info structure. CNcomment:hi_syserr_info结构体指针。CNend 3111bd4fe43Sopenharmony_ci* @par 依赖: 3121bd4fe43Sopenharmony_ci* @li hi_crash.h:Describes Crash log APIs. CNcomment:文件用于描述死机相关接口。CNend 3131bd4fe43Sopenharmony_ci* @see None 3141bd4fe43Sopenharmony_ci*/ 3151bd4fe43Sopenharmony_cihi_syserr_info *hi_syserr_ptr(hi_void); 3161bd4fe43Sopenharmony_ci 3171bd4fe43Sopenharmony_ci/** 3181bd4fe43Sopenharmony_ci* @ingroup iot_crash_info 3191bd4fe43Sopenharmony_ci* @brief Obtains the system exception information pointer (in the flash). 3201bd4fe43Sopenharmony_ciCNcomment:获取系统异常信息指针(flash中)。CNend 3211bd4fe43Sopenharmony_ci* 3221bd4fe43Sopenharmony_ci* @par 描述: 3231bd4fe43Sopenharmony_ci* Obtains the system exception information pointer (in the flash). 3241bd4fe43Sopenharmony_ciCNcomment:获取系统异常信息指针(flash中)。CNend 3251bd4fe43Sopenharmony_ci* 3261bd4fe43Sopenharmony_ci* @attention None 3271bd4fe43Sopenharmony_ci* @param info [OUT] type #hi_syserr_info* ,Pointer to the hi_syserr_info structure. 3281bd4fe43Sopenharmony_ciCNcomment:异常信息读出后存放地址。CNend 3291bd4fe43Sopenharmony_ci* 3301bd4fe43Sopenharmony_ci* @retval #HI_ERR_SUCCESS Success. 3311bd4fe43Sopenharmony_ci* @retval #Other values Failure. For details, see hi_errno.h. 3321bd4fe43Sopenharmony_ci* @par 依赖: 3331bd4fe43Sopenharmony_ci* @li hi_crash.h:Describes Crash log APIs. CNcomment:文件用于描述死机相关接口。CNend 3341bd4fe43Sopenharmony_ci* @see None 3351bd4fe43Sopenharmony_ci*/ 3361bd4fe43Sopenharmony_cihi_u32 hi_syserr_get(hi_syserr_info *info); 3371bd4fe43Sopenharmony_ci 3381bd4fe43Sopenharmony_ci/** 3391bd4fe43Sopenharmony_ci* @ingroup iot_crash_info 3401bd4fe43Sopenharmony_ci* @brief Register exception handling callback. CNcomment:注册异常死机处理回调函数。CNend 3411bd4fe43Sopenharmony_ci* 3421bd4fe43Sopenharmony_ci* @par 描述: 3431bd4fe43Sopenharmony_ci* Register exception handling callback. CNcomment:注册异常死机处理回调函数。CNend 3441bd4fe43Sopenharmony_ci* 3451bd4fe43Sopenharmony_ci* @attention None 3461bd4fe43Sopenharmony_ci* @param func [IN] type #hi_syserr_exc_callback ,Callback function of exception happens 3471bd4fe43Sopenharmony_ciCNcoment:异常回调函数。CNend 3481bd4fe43Sopenharmony_ci* 3491bd4fe43Sopenharmony_ci* @retval None 3501bd4fe43Sopenharmony_ci* @par 依赖: 3511bd4fe43Sopenharmony_ci* @li hi_crash.h:Describes Crash log APIs. CNcomment:文件用于描述死机相关接口。CNend 3521bd4fe43Sopenharmony_ci* @see None 3531bd4fe43Sopenharmony_ci*/ 3541bd4fe43Sopenharmony_cihi_void hi_syserr_exc_register(hi_syserr_exc_callback func); 3551bd4fe43Sopenharmony_ci 3561bd4fe43Sopenharmony_ci/** 3571bd4fe43Sopenharmony_ci* @ingroup iot_crash_info 3581bd4fe43Sopenharmony_ci* @brief Retains the PC pointer when the watchdog reset in interrupt. CNcomment:中断中看门狗复位时记录PC值。CNend 3591bd4fe43Sopenharmony_ci* 3601bd4fe43Sopenharmony_ci* @par 描述: 3611bd4fe43Sopenharmony_ci* Retains the PC pointer when the watchdog reset in interrupt. 3621bd4fe43Sopenharmony_ciCNcomment:中断中看门狗复位时记录PC值,打开此功能后看门狗复位有复位不完全的风险,量产版本请务必关闭。CNend 3631bd4fe43Sopenharmony_ci* 3641bd4fe43Sopenharmony_ci* @attention None 3651bd4fe43Sopenharmony_ci* @param enable [IN] type #hi_bool ,Enable/Disable retains reset PC pointer function. 3661bd4fe43Sopenharmony_ciCNcoment:打开/关闭记录中断中看门狗复位PC值功能。CNend 3671bd4fe43Sopenharmony_ci* 3681bd4fe43Sopenharmony_ci* @retval None 3691bd4fe43Sopenharmony_ci* @par 依赖: 3701bd4fe43Sopenharmony_ci* @li hi_crash.h:Describes Crash log APIs. CNcomment:文件用于描述死机相关接口。CNend 3711bd4fe43Sopenharmony_ci* @see None 3721bd4fe43Sopenharmony_ci*/ 3731bd4fe43Sopenharmony_cihi_void hi_syserr_watchdog_debug(hi_bool enable); 3741bd4fe43Sopenharmony_ci 3751bd4fe43Sopenharmony_ci/** 3761bd4fe43Sopenharmony_ci* @ingroup iot_crash_info 3771bd4fe43Sopenharmony_ci* @brief Whether reset after watchdog in task, default yes. CNcomment: 任务中触发看门狗时是否主动复位,默认复位。CNend 3781bd4fe43Sopenharmony_ci* 3791bd4fe43Sopenharmony_ci* @par 描述: 3801bd4fe43Sopenharmony_ci* Whether reset after wdt in task, default yes. 3811bd4fe43Sopenharmony_ciCNcomment: 任务中触发看门狗时是否主动复位,默认复位。CNend 3821bd4fe43Sopenharmony_ci* 3831bd4fe43Sopenharmony_ci* @attention None 3841bd4fe43Sopenharmony_ci* @param reset [IN] type #hi_bool ,Reset/Not reset after watchdog in task. 3851bd4fe43Sopenharmony_ciCNcoment:任务中触发看门狗时是否主动复位。CNend 3861bd4fe43Sopenharmony_ci* 3871bd4fe43Sopenharmony_ci* @retval None 3881bd4fe43Sopenharmony_ci* @par 依赖: 3891bd4fe43Sopenharmony_ci* @li hi_crash.h:Describes Crash log APIs. CNcomment:文件用于描述死机相关接口。CNend 3901bd4fe43Sopenharmony_ci* @see None 3911bd4fe43Sopenharmony_ci*/ 3921bd4fe43Sopenharmony_cihi_void hi_syserr_reset_after_wdg(hi_bool reset); 3931bd4fe43Sopenharmony_ci 3941bd4fe43Sopenharmony_ci/** 3951bd4fe43Sopenharmony_ci* @ingroup iot_crash_info 3961bd4fe43Sopenharmony_ci* @brief Whether record crash info in flash, default no. CNcomment: 是否记录宕机信息到FLASH,默认不记录。CNend 3971bd4fe43Sopenharmony_ci* 3981bd4fe43Sopenharmony_ci* @par 描述: 3991bd4fe43Sopenharmony_ci* Whether record crash info in flash, default no. 4001bd4fe43Sopenharmony_ciCNcomment: 是否记录宕机信息到FLASH,默认不记录。CNend 4011bd4fe43Sopenharmony_ci* 4021bd4fe43Sopenharmony_ci* @attention None 4031bd4fe43Sopenharmony_ci* @param record [IN] type #hi_bool ,Record/Not record crash info in flash. 4041bd4fe43Sopenharmony_ciCNcoment:宕机时是否记录宕机信息到FLASH。CNend 4051bd4fe43Sopenharmony_ci* 4061bd4fe43Sopenharmony_ci* @retval None 4071bd4fe43Sopenharmony_ci* @par 依赖: 4081bd4fe43Sopenharmony_ci* @li hi_crash.h:Describes Crash log APIs. CNcomment:文件用于描述死机相关接口。CNend 4091bd4fe43Sopenharmony_ci* @see None 4101bd4fe43Sopenharmony_ci*/ 4111bd4fe43Sopenharmony_cihi_void hi_syserr_record_crash_info(hi_bool record); 4121bd4fe43Sopenharmony_ci 4131bd4fe43Sopenharmony_ci/** 4141bd4fe43Sopenharmony_ci* @ingroup iot_crash_info 4151bd4fe43Sopenharmony_ci* @brief Retains the latest reboot reason. CNcomment:获取最近一次重启原因。CNend 4161bd4fe43Sopenharmony_ci* 4171bd4fe43Sopenharmony_ci* @par 描述: 4181bd4fe43Sopenharmony_ci* Retains the latest reboot reason. 4191bd4fe43Sopenharmony_ciCNcomment:获取最近一次重启原因。CNend 4201bd4fe43Sopenharmony_ci* 4211bd4fe43Sopenharmony_ci* @attention None 4221bd4fe43Sopenharmony_ci* @param err_id [OUT] type #hi_u16 * , error id, see hi_syserr_eid. 4231bd4fe43Sopenharmony_cipower_down or hard rebootwould always be 0. 4241bd4fe43Sopenharmony_ciCNcomment:重启原因ID,取值含义参见hi_syserr_eid,掉电重启和硬复位值均为0。CNend 4251bd4fe43Sopenharmony_ci* @param reboot_cause [OUT] type #hi_u32* , when err_id is soft reboot, see hi_sys_reboot_cause; 4261bd4fe43Sopenharmony_ciwhen err_id is fault in task or isr, reboot_cause would be mcause of cpu regs. Otherwise, reboot_cause would be 0. 4271bd4fe43Sopenharmony_ciCNcomment:当重启原因ID 为软复位时,取值含义见hi_sys_reboot_cause; 4281bd4fe43Sopenharmony_ci当为任务或中断中异常时,取值为cpu mcause寄存器,否则为0。 4291bd4fe43Sopenharmony_ciCNend 4301bd4fe43Sopenharmony_ci* 4311bd4fe43Sopenharmony_ci* @retval #HI_ERR_SUCCESS Success. 4321bd4fe43Sopenharmony_ci* @retval #Other Failure. See hi_errno.h for details. 4331bd4fe43Sopenharmony_ci* @par 依赖: 4341bd4fe43Sopenharmony_ci* @li hi_crash.h:Describes Crash log APIs. CNcomment:文件用于描述死机相关接口。CNend 4351bd4fe43Sopenharmony_ci* @see None 4361bd4fe43Sopenharmony_ci*/ 4371bd4fe43Sopenharmony_cihi_u32 hi_syserr_get_reboot_reason(hi_u16 *err_id, hi_u32 *reboot_cause); 4381bd4fe43Sopenharmony_ci 4391bd4fe43Sopenharmony_ci 4401bd4fe43Sopenharmony_ci#ifdef __cplusplus 4411bd4fe43Sopenharmony_ci} 4421bd4fe43Sopenharmony_ci#endif 4431bd4fe43Sopenharmony_ci 4441bd4fe43Sopenharmony_ci#endif /* __HI_CRASH_H__ */ 445