1/* 2 * Copyright (c) 2009-2022 Huawei Technologies Co., Ltd. All rights reserved. 3 * 4 * UniProton is licensed under Mulan PSL v2. 5 * You can use this software according to the terms and conditions of the Mulan PSL v2. 6 * You may obtain a copy of Mulan PSL v2 at: 7 * http://license.coscl.org.cn/MulanPSL2 8 * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, 9 * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, 10 * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. 11 * See the Mulan PSL v2 for more details. 12 * Create: 2009-12-22 13 * Description: 异常模块的对外头文件。 14 */ 15#ifndef PRT_EXC_H 16#define PRT_EXC_H 17 18#include "prt_buildef.h" 19#include "prt_module.h" 20#include "prt_errno.h" 21#if (OS_HARDWARE_PLATFORM == OS_CORTEX_M4) 22#include "./hw/armv7-m/prt_exc.h" 23#endif 24 25#ifdef __cplusplus 26#if __cplusplus 27extern "C" { 28#endif /* __cpluscplus */ 29#endif /* __cpluscplus */ 30 31/* 32 * 异常错误码: 异常模块注册异常钩子函数为空。 33 * 34 * 值: 0x02000a01 35 * 36 * 解决方案:查看注册异常钩子函数是否为空。 37 */ 38#define OS_ERRNO_EXC_REG_HOOK_PTR_NULL OS_ERRNO_BUILD_ERROR(OS_MID_EXC, 0x01) 39 40/* 41 * @brief 异常处理函数类型定义。 42 * 43 * @par 描述 44 * 通过异常处理函数类型定义异常处理函数钩子,记录异常信息。 45 * @attention 46 * 47 * @param excInfo [IN] 类型#struct ExcInfo *,异常时寄存器信息。 48 * 49 * @retval OS_EXC_PROC_TYPE_RETURN,系统在发生异常后(并做完相关处理后)继续运行。 50 * @retval OS_EXC_PROC_TYPE_NO_RETURN,系统在发生异常后(并做完相关处理后)进入死循环,等待重启。 51 * @retval OS_EXC_PROC_TYPE_RETURN_SKIP_INST,系统在发生异常后(并做完相关处理后)跳过异常指令继续运行。 52 * 53 * @par 依赖 54 * <li>prt_exc.h:该接口声明所在的头文件。</li> 55 * @see 无 56 */ 57typedef U32 (*ExcProcFunc)(struct ExcInfo *excInfo); 58 59/* 60 * 模块配置信息结构体。 61 */ 62struct ExcModInfo { 63 /* 异常时用户注册的函数钩子 */ 64 ExcProcFunc excepHook; 65}; 66 67/* 68 * @brief 用户注册异常处理钩子。 69 * 70 * @par 描述 71 * 注册异常处理钩子。 72 * @attention 73 * <ul> 74 * <li>当多次注册该钩子时,最后一次注册的钩子生效。 75 * <li>注册的钩子函数不能为空,即一旦注册钩子函数,不能通过注册空函数将其取消。 76 * </ul> 77 * 78 * @param hook [IN] 类型#ExcProcFunc,钩子函数。 79 * 80 * @retval #OS_OK 0x00000000,注册失败。 81 * @retval #其它值,注册失败。 82 * 83 * @par 依赖 84 * <li>prt_exc.h:该接口声明所在的头文件。</li> 85 * @see 无 86 */ 87extern U32 PRT_ExcRegHook(ExcProcFunc hook); 88 89#ifdef __cplusplus 90#if __cplusplus 91} 92#endif /* __cpluscplus */ 93#endif /* __cpluscplus */ 94 95#endif /* PRT_EXC_H */ 96