• 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: 提供公共的异常处理机制(如PRT_SysReboot)
14  */
15 #include "prt_kexc_external.h"
16 #include "prt_exc_external.h"
17 #include "prt_sys_external.h"
18 #include "prt_cpu_external.h"
19 #include "prt_err_external.h"
20 
21 OS_SEC_L4_BSS struct ExcModInfo g_excModInfo;
22 
23 // 若作为KOS异常使用,因为UOS异常可恢复异常直接清除该变量值,而不可恢复异常直接Kill该进程了之前也会清除该变量。
24 OS_SEC_DATA U32 g_curNestCount = 0;
25 OS_SEC_BSS struct TagExcInfoInternal g_excInfoInternal;
26 
27 /*
28  * 描述:异常处理用户钩子函数注册
29  */
PRT_ExcRegHook(ExcProcFunc hook)30 OS_SEC_L4_TEXT U32 PRT_ExcRegHook(ExcProcFunc hook)
31 {
32     uintptr_t intSave;
33 
34     if (hook == NULL) {
35         return OS_ERRNO_EXC_REG_HOOK_PTR_NULL;
36     }
37 
38     intSave = OsIntLock();
39 
40     g_excModInfo.excepHook = hook;
41 
42     OsIntRestore(intSave);
43 
44     return OS_OK;
45 }
46 
PRT_SysReboot(void)47 OS_SEC_L4_TEXT void PRT_SysReboot(void)
48 {
49     while (1) {
50         /* Wait for HWWDG to reboot board. */
51     }
52 }
53