xos_errors.h 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. /** @file */
  2. // xos_errors.h - XOS error codes.
  3. // Copyright (c) 2003-2015 Cadence Design Systems, Inc.
  4. //
  5. // Permission is hereby granted, free of charge, to any person obtaining
  6. // a copy of this software and associated documentation files (the
  7. // "Software"), to deal in the Software without restriction, including
  8. // without limitation the rights to use, copy, modify, merge, publish,
  9. // distribute, sublicense, and/or sell copies of the Software, and to
  10. // permit persons to whom the Software is furnished to do so, subject to
  11. // the following conditions:
  12. //
  13. // The above copyright notice and this permission notice shall be included
  14. // in all copies or substantial portions of the Software.
  15. //
  16. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  17. // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  18. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
  19. // IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
  20. // CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
  21. // TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
  22. // SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  23. // NOTE: Do not include this file directly in your application. Including
  24. // xos.h will automatically include this file.
  25. #ifndef __XOS_ERRORS_H__
  26. #define __XOS_ERRORS_H__
  27. #include "xos_types.h"
  28. #define _XOS_ERR_FIRST (-65536)
  29. #define _XOS_ERR_LAST (-1)
  30. //-----------------------------------------------------------------------------
  31. ///
  32. /// List of XOS error codes. All error codes are negative integers, except for
  33. /// XOS_OK which is zero.
  34. /// XOS error codes occupy the range from -65536 up to -1.
  35. /// The function IS_XOS_ERRCODE() can be used to check if a value lies within
  36. /// the error code range.
  37. ///
  38. //-----------------------------------------------------------------------------
  39. typedef enum xos_err_t {
  40. XOS_OK = 0,
  41. XOS_ERR_NOT_FOUND = _XOS_ERR_FIRST, ///< Object not found
  42. XOS_ERR_INVALID_PARAMETER, ///< Function parameter is invalid
  43. XOS_ERR_LIMIT, ///< Limit exceeded
  44. XOS_ERR_NOT_OWNED, ///< Object not owned by caller
  45. XOS_ERR_MUTEX_LOCKED, ///< Mutex is already locked
  46. XOS_ERR_MUTEX_NOT_OWNED, ///< Mutex not owned by caller
  47. XOS_ERR_MUTEX_ALREADY_OWNED, ///< Mutex already owned by caller
  48. XOS_ERR_MUTEX_DELETE, ///< Mutex being waited on has been deleted
  49. XOS_ERR_COND_DELETE, ///< Condition being waited on has been deleted
  50. XOS_ERR_SEM_DELETE, ///< Semaphore being waited on has been deleted
  51. XOS_ERR_SEM_BUSY, ///< Semaphore is not available
  52. XOS_ERR_EVENT_DELETE, ///< Event being waited on has been deleted
  53. XOS_ERR_MSGQ_FULL, ///< Message queue is full
  54. XOS_ERR_MSGQ_EMPTY, ///< Message queue is empty
  55. XOS_ERR_MSGQ_DELETE, ///< Message queue being waited on has been deleted
  56. XOS_ERR_TIMER_DELETE, ///< Timer being waited on has been deleted
  57. XOS_ERR_CONTAINER_NOT_RTC, ///< Containing thread not of RTC type
  58. XOS_ERR_CONTAINER_NOT_SAME_PRI, ///< Containing thread not at same priority
  59. XOS_ERR_STACK_TOO_SMALL, ///< Thread stack is too small
  60. XOS_ERR_CONTAINER_ILLEGAL, ///< Illegal container thread
  61. XOS_ERR_ILLEGAL_OPERATION, ///< This operation is not allowed
  62. XOS_ERR_THREAD_EXITED, ///< The thread has already exited
  63. XOS_ERR_NO_TIMER, ///< No suitable timer found
  64. XOS_ERR_FEATURE_NOT_PRESENT, ///< This feature is disabled or not implemented
  65. XOS_ERR_TIMEOUT, ///< Wait timed out
  66. XOS_ERR_UNHANDLED_INTERRUPT, ///< No handler for interrupt
  67. XOS_ERR_UNHANDLED_EXCEPTION, ///< No handler for exception
  68. XOS_ERR_INTERRUPT_CONTEXT, ///< Operation is illegal in interrupt context
  69. XOS_ERR_THREAD_BLOCKED, ///< Thread already blocked
  70. XOS_ERR_ASSERT_FAILED, ///< Runtime assertion failure
  71. XOS_ERR_CLIB_ERR, ///< Error in C library thread safety module
  72. XOS_ERR_INTERNAL_ERROR, ///< XOS internal error
  73. XOS_ERR_LAST = _XOS_ERR_LAST,
  74. } xos_err_t;
  75. //-----------------------------------------------------------------------------
  76. ///
  77. /// Check if a value is a valid XOS error code.
  78. ///
  79. /// \param val Value to check
  80. ///
  81. /// \return Returns nonzero if 'val' is in the XOS error code range.
  82. ///
  83. //-----------------------------------------------------------------------------
  84. static inline int32_t
  85. IS_XOS_ERRCODE(xos_err_t val)
  86. {
  87. return ((val >= _XOS_ERR_FIRST) && (val <= _XOS_ERR_LAST));
  88. }
  89. #endif // __XOS_ERRORS_H__