los_errno.h 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. /* ----------------------------------------------------------------------------
  2. * Copyright (c) Huawei Technologies Co., Ltd. 2013-2019. All rights reserved.
  3. * Description: Errno
  4. * Author: Huawei LiteOS Team
  5. * Create: 2013-01-01
  6. * Redistribution and use in source and binary forms, with or without modification,
  7. * are permitted provided that the following conditions are met:
  8. * 1. Redistributions of source code must retain the above copyright notice, this list of
  9. * conditions and the following disclaimer.
  10. * 2. Redistributions in binary form must reproduce the above copyright notice, this list
  11. * of conditions and the following disclaimer in the documentation and/or other materials
  12. * provided with the distribution.
  13. * 3. Neither the name of the copyright holder nor the names of its contributors may be used
  14. * to endorse or promote products derived from this software without specific prior written
  15. * permission.
  16. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  17. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
  18. * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  19. * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
  20. * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
  21. * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  22. * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
  23. * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
  24. * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
  25. * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
  26. * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  27. * --------------------------------------------------------------------------- */
  28. /**
  29. * @defgroup los_errno Error code
  30. * @ingroup kernel
  31. */
  32. #ifndef _LOS_ERRNO_H
  33. #define _LOS_ERRNO_H
  34. #include "los_typedef.h"
  35. #ifdef __cplusplus
  36. #if __cplusplus
  37. extern "C" {
  38. #endif /* __cplusplus */
  39. #endif /* __cplusplus */
  40. /**
  41. * @ingroup los_errno
  42. * OS error code flag. It is a 24-bit unsigned integer. Its value is 0x000000U.
  43. */
  44. #define LOS_ERRNO_OS_ID (0x00U << 16)
  45. /**
  46. * @ingroup los_errno
  47. * Define the error level as informative. It is a 32-bit unsigned integer. Its value is 0x00000000U.
  48. */
  49. #define LOS_ERRTYPE_NORMAL (0x00U << 24)
  50. /**
  51. * @ingroup los_errno
  52. * Define the error level as warning. It is a 32-bit unsigned integer. Its value is 0x01000000U.
  53. */
  54. #define LOS_ERRTYPE_WARN (0x01U << 24)
  55. /**
  56. * @ingroup los_errno
  57. * Define the error level as critical. It is a 32-bit unsigned integer. Its value is 0x02000000U.
  58. */
  59. #define LOS_ERRTYPE_ERROR (0x02U << 24)
  60. /**
  61. * @ingroup los_errno
  62. * Define the error level as fatal. It is a 32-bit unsigned integer. Its value is 0x03000000U.
  63. */
  64. #define LOS_ERRTYPE_FATAL (0x03U << 24)
  65. /**
  66. * @ingroup los_errno
  67. * Define fatal OS errors. It is a 32-bit unsigned integer error code.
  68. * <ul>
  69. * <li>24-31 bits indicate the error level, here is #LOS_ERRTYPE_FATAL.</li>
  70. * <li>16-23 bits indicate the os error code flag, here is #LOS_ERRNO_OS_ID.</li>
  71. * <li>8-15 bits indicate the module which the error code belongs to. It is specified by MID.</li>
  72. * <li>0-7 bits indicate the error code number. It is specified by ERRNO.</li>
  73. * </ul>
  74. */
  75. #define LOS_ERRNO_OS_FATAL(MID, ERRNO) \
  76. (LOS_ERRTYPE_FATAL | LOS_ERRNO_OS_ID | ((UINT32)(MID) << 8) | ((UINT32)(ERRNO)))
  77. /**
  78. * @ingroup los_errno
  79. * Define critical OS errors. It is a 32-bit unsigned integer error code.
  80. * <ul>
  81. * <li>24-31 bits indicate the error level, here is #LOS_ERRTYPE_ERROR.</li>
  82. * <li>16-23 bits indicate the os error code flag, here is #LOS_ERRNO_OS_ID.</li>
  83. * <li>8-15 bits indicate the module which the error code belongs to. It is specified by MID.</li>
  84. * <li>0-7 bits indicate the error code number. It is specified by ERRNO.</li>
  85. * </ul>
  86. */
  87. #define LOS_ERRNO_OS_ERROR(MID, ERRNO) \
  88. (LOS_ERRTYPE_ERROR | LOS_ERRNO_OS_ID | ((UINT32)(MID) << 8) | ((UINT32)(ERRNO)))
  89. /**
  90. * @ingroup los_errno
  91. * Define warning OS errors. It is a 32-bit unsigned integer error code.
  92. * <ul>
  93. * <li>24-31 bits indicate the error level, here is #LOS_ERRTYPE_WARN.</li>
  94. * <li>16-23 bits indicate the os error code flag, here is #LOS_ERRNO_OS_ID.</li>
  95. * <li>8-15 bits indicate the module which the error code belongs to. It is specified by MID.</li>
  96. * <li>0-7 bits indicate the error code number. It is specified by ERRNO.</li>
  97. * </ul>
  98. */
  99. #define LOS_ERRNO_OS_WARN(MID, ERRNO) \
  100. (LOS_ERRTYPE_WARN | LOS_ERRNO_OS_ID | ((UINT32)(MID) << 8) | ((UINT32)(ERRNO)))
  101. /**
  102. * @ingroup los_errno
  103. * Define informative OS errors. It is a 32-bit unsigned integer error code.
  104. * <ul>
  105. * <li>24-31 bits indicate the error level, here is #LOS_ERRTYPE_NORMAL.</li>
  106. * <li>16-23 bits indicate the os error code flag, here is #LOS_ERRNO_OS_ID.</li>
  107. * <li>8-15 bits indicate the module which the error code belongs to. It is specified by MID.</li>
  108. * <li>0-7 bits indicate the error code number. It is specified by ERRNO.</li>
  109. * </ul>
  110. */
  111. #define LOS_ERRNO_OS_NORMAL(MID, ERRNO) \
  112. (LOS_ERRTYPE_NORMAL | LOS_ERRNO_OS_ID | ((UINT32)(MID) << 8) | ((UINT32)(ERRNO)))
  113. /**
  114. * @ingroup los_errno
  115. * Define the ID of each module in kernel. The ID is used in error code.
  116. */
  117. enum LOS_MOUDLE_ID {
  118. LOS_MOD_SYS = 0x0, /**< System ID. Its value is 0x0. */
  119. LOS_MOD_MEM = 0x1, /**< Dynamic memory module ID. Its value is 0x1. */
  120. LOS_MOD_TSK = 0x2, /**< Task module ID. Its value is 0x2. */
  121. LOS_MOD_SWTMR = 0x3, /**< Software timer module ID. Its value is 0x3. */
  122. LOS_MOD_TICK = 0x4, /**< Tick module ID. Its value is 0x4. */
  123. LOS_MOD_MSG = 0x5, /**< Message module ID. Its value is 0x5. */
  124. LOS_MOD_QUE = 0x6, /**< Queue module ID. Its value is 0x6. */
  125. LOS_MOD_SEM = 0x7, /**< Semaphore module ID. Its value is 0x7. */
  126. LOS_MOD_MBOX = 0x8, /**< Static memory module ID. Its value is 0x8. */
  127. LOS_MOD_HWI = 0x9, /**< Hardware interrupt module ID. Its value is 0x9. */
  128. LOS_MOD_HWWDG = 0xa, /**< Hardware watchdog module ID. Its value is 0xa. */
  129. LOS_MOD_CACHE = 0xb, /**< Cache module ID. Its value is 0xb. */
  130. LOS_MOD_HWTMR = 0xc, /**< Hardware timer module ID. Its value is 0xc. */
  131. LOS_MOD_MMU = 0xd, /**< MMU module ID. Its value is 0xd. */
  132. LOS_MOD_LOG = 0xe, /**< Log module ID. Its value is 0xe. */
  133. LOS_MOD_ERR = 0xf, /**< Error handling module ID. Its value is 0xf. */
  134. LOS_MOD_EXC = 0x10, /**< Exception handling module ID. Its value is 0x10. */
  135. LOS_MOD_CSTK = 0x11, /**< This module ID is reserved. Its value is 0x11. */
  136. LOS_MOD_MPU = 0x12, /**< MPU module ID. Its value is 0x12. */
  137. LOS_MOD_NMHWI = 0x13, /**< NMI module ID. It is reserved. Its value is 0x13. */
  138. LOS_MOD_TRACE = 0x14, /**< Trace module ID. Its value is 0x14. */
  139. LOS_MOD_KNLSTAT = 0x15, /**< This module ID is reserved. Its value is 0x15. */
  140. LOS_MOD_EVTTIME = 0x16, /**< This module ID is reserved. Its value is 0x16. */
  141. LOS_MOD_THRDCPUP = 0x17, /**< This module ID is reserved. Its value is 0x17. */
  142. LOS_MOD_IPC = 0x18, /**< This module ID is reserved. Its value is 0x18. */
  143. LOS_MOD_STKMON = 0x19, /**< This module ID is reserved. Its value is 0x19. */
  144. LOS_MOD_TIMER = 0x1a, /**< This module ID is reserved. Its value is 0x1a. */
  145. LOS_MOD_RESLEAKMON = 0x1b, /**< This module ID is reserved. Its value is 0x1b. */
  146. LOS_MOD_EVENT = 0x1c, /**< event module ID. Its value is 0x1c. */
  147. LOS_MOD_MUX = 0x1d, /**< mutex module ID. Its value is 0x1d. */
  148. LOS_MOD_CPUP = 0x1e, /**< CPU usage module ID. Its value is 0x1e. */
  149. LOS_MOD_FPB = 0x1f, /**< FPB module ID. Its value is 0x1f. */
  150. LOS_MOD_PERF = 0x20, /**< Perf module ID. Its value is 0x20. */
  151. LOS_MOD_SHELL = 0x31, /**< shell module ID. Its value is 0x31. */
  152. LOS_MOD_DRIVER = 0x41, /**< driver module ID. Its value is 0x41. */
  153. LOS_MOD_BUTT /**< It is end flag of this enumeration. */
  154. };
  155. #ifdef __cplusplus
  156. #if __cplusplus
  157. }
  158. #endif /* __cplusplus */
  159. #endif /* __cplusplus */
  160. #endif /* _LOS_ERRNO_H */