• 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_ERR_EXTERNAL_H
16 #define PRT_ERR_EXTERNAL_H
17 
18 #include "prt_err.h"
19 
20 extern void OsErrHandle(const char *fileName, U32 lineNo, U32 errorNo, U32 paraLen, void *para);
21 /*
22  * 模块间宏定义
23  */
24 #define OS_ERR_RECORD_N 3  // 表示保留二进制低n位,计算OS_ERR_RECORD_NUM用,OS_ERR_RECORD_NUM为2的n次方+1
25 
26 #define OS_ERR_RECORD_NUM \
27     ((1U << OS_ERR_RECORD_N) + 1)  // 2的n次方+1,目前n取3,NUM为9,第一次错误固定记录,后面8个循环记录。
28 
29 #define OS_ERR_MAGIC_WORD 0xa1b2d4f8
30 
31 #define OS_ERR_LEVEL_HIGH 0
32 #define OS_ERR_LEVEL_LOW 2
33 #define OS_LOG_LEVEL_FORCE 0xFF
34 
35 #define OS_REPORT_ERROR(errNo)                                       \
36     do {                                                             \
37         OsErrHandle("os_file", OS_ERR_MAGIC_WORD, (errNo), 0, NULL); \
38     } while (0)
39 
40 /* 用于OS_OPTION_NFTL_ERR_POST_PROC */
41 #define OS_ERROR_TYPE_NUM (ERRTYPE_FATAL >> 24) /* 中断中需要延后处理的错误类型(所有低于FATAL等级的类型)数 */
42 
43 /* errno中错误大类的类型掩码 */
44 #define OS_ERROR_TYPE_MASK (0xffU << 24)
45 
46 #define OS_ERROR_LOG_REPORT(traceLevel, format, ...)
47 
48 #if defined(OS_DBG)
49 #define LOG_ADDR_DBG(addr) (addr)
50 #define OS_LOG_REPORT_DBG(format, ...) OS_ERROR_LOG_REPORT(OS_ERR_LEVEL_HIGH, (format), ##__VA_ARGS__)
51 #else
52 #define LOG_ADDR_DBG(addr) ((void)(addr), 0x0U)
53 #define OS_LOG_REPORT_DBG(format, ...)
54 #endif
55 
56 extern void OsErrRecordInCda(U32 errorNo);
57 
58 // 函数返回值void的,都通过此接口记录返回值到cda
59 #define OS_ERR_RECORD(errorNo)          \
60     do {                                \
61         U32 errorNo_ = (errorNo);       \
62         if (errorNo_ != OS_OK) {       \
63             OsErrRecordInCda(errorNo_); \
64         }                               \
65     } while (0)
66 
67 #endif /* PRT_ERR_EXTERNAL_H */
68