1 /* ---------------------------------------------------------------------------- 2 * Copyright (c) Huawei Technologies Co., Ltd. 2013-2015. All rights reserved. 3 * Description: los_errno error code 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_errno Error code 29 * @ingroup kernel 30 */ 31 32 #ifndef _LOS_ERRNO_H 33 #define _LOS_ERRNO_H 34 35 #include "los_err.h" 36 37 #ifdef __cplusplus 38 #if __cplusplus 39 extern "C" { 40 #endif /* __cplusplus */ 41 #endif /* __cplusplus */ 42 43 #ifdef LOS_SHORT_ERRNO 44 #define LOS_ERRNO_OS_ID ((UINT32)0x00 << 16) 45 46 /** 47 * @ingroup los_errno 48 * Define the error level as informative. 49 */ 50 #define LOS_ERRTYPE_NORMAL ((UINT32)0x00 << 0) 51 52 /** 53 * @ingroup los_errno 54 * Define the error level as warning. 55 */ 56 #define LOS_ERRTYPE_WARN ((UINT32)0x01 << 0) 57 58 /** 59 * @ingroup los_errno 60 * Define the error level as critical. 61 */ 62 #define LOS_ERRTYPE_ERROR ((UINT32)0x02 << 0) 63 64 /** 65 * @ingroup los_errno 66 * Define the error level as fatal. 67 */ 68 #define LOS_ERRTYPE_FATAL ((UINT32)0x03 << 0) 69 70 /** 71 * @ingroup los_errno 72 * Define fatal OS errors. 73 */ 74 #define LOS_ERRNO_OS_FATAL(moduleID, errno) \ 75 (LOS_ERRTYPE_FATAL | LOS_ERRNO_OS_ID | ((UINT32)(moduleID) << 2) | (errno << 7)) 76 77 /** 78 * @ingroup los_errno 79 * Define critical OS errors. 80 */ 81 #define LOS_ERRNO_OS_ERROR(moduleID, errno) \ 82 (LOS_ERRTYPE_ERROR | LOS_ERRNO_OS_ID | ((UINT32)(moduleID) << 2) | (errno << 7)) 83 84 /** 85 * @ingroup los_errno 86 * Define warning OS errors. 87 */ 88 #define LOS_ERRNO_OS_WARN(moduleID, errno) \ 89 (LOS_ERRTYPE_WARN | LOS_ERRNO_OS_ID | ((UINT32)(moduleID) << 2) | (errno << 7)) 90 91 /** 92 * @ingroup los_errno 93 * Define informative OS errors. 94 */ 95 #define LOS_ERRNO_OS_NORMAL(moduleID, errno) \ 96 (LOS_ERRTYPE_NORMAL | LOS_ERRNO_OS_ID | ((UINT32)(moduleID) << 2) | (errno << 7)) 97 98 #else 99 /** 100 * @ingroup los_errno 101 * OS error code flag. 102 */ 103 #define LOS_ERRNO_OS_ID ((UINT32)0x00 << 16) 104 105 /** 106 * @ingroup los_errno 107 * Define the error level as informative. 108 */ 109 #define LOS_ERRTYPE_NORMAL ((UINT32)0x00 << 24) 110 111 /** 112 * @ingroup los_errno 113 * Define the error level as warning. 114 */ 115 #define LOS_ERRTYPE_WARN ((UINT32)0x01 << 24) 116 117 /** 118 * @ingroup los_errno 119 * Define the error level as critical. 120 */ 121 #define LOS_ERRTYPE_ERROR ((UINT32)0x02 << 24) 122 123 /** 124 * @ingroup los_errno 125 * Define the error level as fatal. 126 */ 127 #define LOS_ERRTYPE_FATAL ((UINT32)0x03 << 24) 128 129 /** 130 * @ingroup los_errno 131 * Define fatal OS errors. 132 */ 133 #define LOS_ERRNO_OS_FATAL(moduleID, errno) \ 134 (LOS_ERRTYPE_FATAL | LOS_ERRNO_OS_ID | ((UINT32)(moduleID) << 8) | (errno)) 135 136 /** 137 * @ingroup los_errno 138 * Define critical OS errors. 139 */ 140 #define LOS_ERRNO_OS_ERROR(moduleID, errno) \ 141 (LOS_ERRTYPE_ERROR | LOS_ERRNO_OS_ID | ((UINT32)(moduleID) << 8) | (errno)) 142 143 /** 144 * @ingroup los_errno 145 * Define warning OS errors. 146 */ 147 #define LOS_ERRNO_OS_WARN(moduleID, errno) \ 148 (LOS_ERRTYPE_WARN | LOS_ERRNO_OS_ID | ((UINT32)(moduleID) << 8) | (errno)) 149 150 /** 151 * @ingroup los_errno 152 * Define informative OS errors. 153 */ 154 #define LOS_ERRNO_OS_NORMAL(moduleID, errno) \ 155 (LOS_ERRTYPE_NORMAL | LOS_ERRNO_OS_ID | ((UINT32)(moduleID) << 8) | (errno)) 156 #endif 157 158 #ifdef __cplusplus 159 #if __cplusplus 160 } 161 #endif /* __cplusplus */ 162 #endif /* __cplusplus */ 163 164 #endif /* _LOS_ERRNO_H */ 165