• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #if (OS_HARDWARE_PLATFORM == OS_ARMV8)
26 #include "./hw/armv8/os_exc_armv8.h"
27 #endif
28 
29 #ifdef __cplusplus
30 #if __cplusplus
31 extern "C" {
32 #endif /* __cpluscplus */
33 #endif /* __cpluscplus */
34 
35 /*
36  * 异常错误码: 异常模块注册异常钩子函数为空。
37  *
38  * 值: 0x02000a01
39  *
40  * 解决方案:查看注册异常钩子函数是否为空。
41  */
42 #define OS_ERRNO_EXC_REG_HOOK_PTR_NULL OS_ERRNO_BUILD_ERROR(OS_MID_EXC, 0x01)
43 
44 /*
45  * @brief 异常处理函数类型定义。
46  *
47  * @par 描述
48  * 通过异常处理函数类型定义异常处理函数钩子,记录异常信息。
49  * @attention
50  *
51  * @param excInfo [IN]  类型#struct ExcInfo *,异常时寄存器信息。
52  *
53  * @retval OS_EXC_PROC_TYPE_RETURN,系统在发生异常后(并做完相关处理后)继续运行。
54  * @retval OS_EXC_PROC_TYPE_NO_RETURN,系统在发生异常后(并做完相关处理后)进入死循环,等待重启。
55  * @retval OS_EXC_PROC_TYPE_RETURN_SKIP_INST,系统在发生异常后(并做完相关处理后)跳过异常指令继续运行。
56  *
57  * @par 依赖
58  * <li>prt_exc.h:该接口声明所在的头文件。</li>
59  * @see 无
60  */
61 typedef U32 (*ExcProcFunc)(struct ExcInfo *excInfo);
62 
63 /*
64  * 模块配置信息结构体。
65  */
66 struct ExcModInfo {
67     /* 异常时用户注册的函数钩子 */
68     ExcProcFunc excepHook;
69 };
70 
71 /*
72  * @brief 用户注册异常处理钩子。
73  *
74  * @par 描述
75  * 注册异常处理钩子。
76  * @attention
77  * <ul>
78  * <li>当多次注册该钩子时,最后一次注册的钩子生效。
79  * <li>注册的钩子函数不能为空,即一旦注册钩子函数,不能通过注册空函数将其取消。
80  * </ul>
81  *
82  * @param hook [IN]  类型#ExcProcFunc,钩子函数。
83  *
84  * @retval #OS_OK  0x00000000,注册成功。
85  * @retval #其它值,注册失败。
86  *
87  * @par 依赖
88  * <li>prt_exc.h:该接口声明所在的头文件。</li>
89  * @see 无
90  */
91 extern U32 PRT_ExcRegHook(ExcProcFunc hook);
92 
93 #ifdef __cplusplus
94 #if __cplusplus
95 }
96 #endif /* __cpluscplus */
97 #endif /* __cpluscplus */
98 
99 #endif /* PRT_EXC_H */
100