1 /* 2 * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved. 3 * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without modification, 6 * are permitted provided that the following conditions are met: 7 * 8 * 1. Redistributions of source code must retain the above copyright notice, this list of 9 * conditions and the following disclaimer. 10 * 11 * 2. Redistributions in binary form must reproduce the above copyright notice, this list 12 * of conditions and the following disclaimer in the documentation and/or other materials 13 * provided with the distribution. 14 * 15 * 3. Neither the name of the copyright holder nor the names of its contributors may be used 16 * to endorse or promote products derived from this software without specific prior written 17 * permission. 18 * 19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 21 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 26 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 27 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 28 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 29 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 */ 31 32 /** 33 * @defgroup los_err Error handling 34 * @ingroup kernel 35 */ 36 37 #ifndef _LOS_ERR_H 38 #define _LOS_ERR_H 39 40 #include "los_typedef.h" 41 42 #ifdef __cplusplus 43 #if __cplusplus 44 extern "C" { 45 #endif /* __cplusplus */ 46 #endif /* __cplusplus */ 47 48 /** 49 * @ingroup los_err 50 * @brief Define the pointer to the error handling function. 51 * 52 * @par Description: 53 * This API is used to define the pointer to the error handling function. 54 * @attention 55 * <ul> 56 * <li>None.</li> 57 * </ul> 58 * 59 * @param fileName [IN] Log file that stores error information. 60 * @param lineNo [IN] Line number of the erroneous line. 61 * @param errorNo [IN] Error code. 62 * @param paraLen [IN] Length of the input parameter pPara. 63 * @param para [IN] User label of the error. 64 * 65 * @retval None. 66 * @par Dependency: 67 * <ul><li>los_err.h: the header file that contains the API declaration.</li></ul> 68 * @see None. 69 */ 70 typedef VOID (*LOS_ERRORHANDLE_FUNC)(CHAR *fileName, 71 UINT32 lineNo, 72 UINT32 errorNo, 73 UINT32 paraLen, 74 VOID *para); 75 76 /** 77 * @ingroup los_err 78 * @brief Error handling function. 79 * 80 * @par Description: 81 * This API is used to perform different operations according to error types. 82 * @attention 83 * <ul> 84 * <li>None</li> 85 * </ul> 86 * 87 * @param fileName [IN] Log file that stores error information. 88 * @param lineNo [IN] Line number of the erroneous line which should not be OS_ERR_MAGIC_WORD. 89 * @param errorNo [IN] Error code. 90 * @param paraLen [IN] Length of the input parameter pPara. 91 * @param para [IN] User label of the error. 92 * 93 * @retval LOS_OK The error is successfully processed. 94 * @par Dependency: 95 * <ul><li>los_err.h: the header file that contains the API declaration.</li></ul> 96 * @see None 97 */ 98 extern UINT32 LOS_ErrHandle(CHAR *fileName, UINT32 lineNo, 99 UINT32 errorNo, UINT32 paraLen, 100 VOID *para); 101 102 /** 103 * @ingroup los_err 104 * @brief set Error handling function. 105 * 106 * @param fun [IN] the error handle function. 107 */ 108 extern VOID LOS_SetErrHandleHook(LOS_ERRORHANDLE_FUNC fun); 109 110 enum LOS_MOUDLE_ID { 111 LOS_MOD_SYS = 0x0, 112 LOS_MOD_MEM = 0x1, 113 LOS_MOD_TSK = 0x2, 114 LOS_MOD_SWTMR = 0x3, 115 LOS_MOD_TICK = 0x4, 116 LOS_MOD_MSG = 0x5, 117 LOS_MOD_QUE = 0x6, 118 LOS_MOD_SEM = 0x7, 119 LOS_MOD_MBOX = 0x8, 120 LOS_MOD_HWI = 0x9, 121 LOS_MOD_HWWDG = 0xa, 122 LOS_MOD_CACHE = 0xb, 123 LOS_MOD_HWTMR = 0xc, 124 LOS_MOD_MMU = 0xd, 125 126 LOS_MOD_LOG = 0xe, 127 LOS_MOD_ERR = 0xf, 128 129 LOS_MOD_EXC = 0x10, 130 LOS_MOD_CSTK = 0x11, 131 132 LOS_MOD_MPU = 0x12, 133 LOS_MOD_NMHWI = 0x13, 134 LOS_MOD_TRACE = 0x14, 135 LOS_MOD_KNLSTAT = 0x15, 136 LOS_MOD_EVTTIME = 0x16, 137 LOS_MOD_THRDCPUP = 0x17, 138 LOS_MOD_IPC = 0x18, 139 LOS_MOD_STKMON = 0x19, 140 LOS_MOD_TIMER = 0x1a, 141 LOS_MOD_RESLEAKMON = 0x1b, 142 LOS_MOD_EVENT = 0x1c, 143 LOS_MOD_MUX = 0X1d, 144 LOS_MOD_CPUP = 0x1e, 145 LOS_MOD_HOOK = 0x1f, 146 LOS_MOD_PERF = 0x20, 147 LOS_MOD_PM = 0x21, 148 LOS_MOD_SHELL = 0x31, 149 LOS_MOD_DRIVER = 0x41, 150 LOS_MOD_BUTT 151 }; 152 153 #ifdef __cplusplus 154 #if __cplusplus 155 } 156 #endif /* __cplusplus */ 157 #endif /* __cplusplus */ 158 159 #endif /* _LOS_ERR_H */ 160