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