cpe_err.h 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. /*
  2. * Copyright (c) 2015, 2017, The Linux Foundation. All rights reserved.
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License version 2 and
  6. * only version 2 as published by the Free Software Foundation.
  7. *
  8. * This program is distributed in the hope that it will be useful,
  9. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. * GNU General Public License for more details.
  12. */
  13. #ifndef __CPE_ERR__
  14. #define __CPE_ERR__
  15. #include <linux/errno.h>
  16. /* ERROR CODES */
  17. /* Success. The operation completed with no errors. */
  18. #define CPE_EOK 0x00000000
  19. /* General failure. */
  20. #define CPE_EFAILED 0x00000001
  21. /* Bad operation parameter. */
  22. #define CPE_EBADPARAM 0x00000002
  23. /* Unsupported routine or operation. */
  24. #define CPE_EUNSUPPORTED 0x00000003
  25. /* Unsupported version. */
  26. #define CPE_EVERSION 0x00000004
  27. /* Unexpected problem encountered. */
  28. #define CPE_EUNEXPECTED 0x00000005
  29. /* Unhandled problem occurred. */
  30. #define CPE_EPANIC 0x00000006
  31. /* Unable to allocate resource. */
  32. #define CPE_ENORESOURCE 0x00000007
  33. /* Invalid handle. */
  34. #define CPE_EHANDLE 0x00000008
  35. /* Operation is already processed. */
  36. #define CPE_EALREADY 0x00000009
  37. /* Operation is not ready to be processed. */
  38. #define CPE_ENOTREADY 0x0000000A
  39. /* Operation is pending completion. */
  40. #define CPE_EPENDING 0x0000000B
  41. /* Operation could not be accepted or processed. */
  42. #define CPE_EBUSY 0x0000000C
  43. /* Operation aborted due to an error. */
  44. #define CPE_EABORTED 0x0000000D
  45. /* Operation preempted by a higher priority. */
  46. #define CPE_EPREEMPTED 0x0000000E
  47. /* Operation requests intervention to complete. */
  48. #define CPE_ECONTINUE 0x0000000F
  49. /* Operation requests immediate intervention to complete. */
  50. #define CPE_EIMMEDIATE 0x00000010
  51. /* Operation is not implemented. */
  52. #define CPE_ENOTIMPL 0x00000011
  53. /* Operation needs more data or resources. */
  54. #define CPE_ENEEDMORE 0x00000012
  55. /* Operation does not have memory. */
  56. #define CPE_ENOMEMORY 0x00000014
  57. /* Item does not exist. */
  58. #define CPE_ENOTEXIST 0x00000015
  59. /* Operation is finished. */
  60. #define CPE_ETERMINATED 0x00000016
  61. /* Max count for adsp error code sent to HLOS*/
  62. #define CPE_ERR_MAX (CPE_ETERMINATED + 1)
  63. /* ERROR STRING */
  64. /* Success. The operation completed with no errors. */
  65. #define CPE_EOK_STR "CPE_EOK"
  66. /* General failure. */
  67. #define CPE_EFAILED_STR "CPE_EFAILED"
  68. /* Bad operation parameter. */
  69. #define CPE_EBADPARAM_STR "CPE_EBADPARAM"
  70. /* Unsupported routine or operation. */
  71. #define CPE_EUNSUPPORTED_STR "CPE_EUNSUPPORTED"
  72. /* Unsupported version. */
  73. #define CPE_EVERSION_STR "CPE_EVERSION"
  74. /* Unexpected problem encountered. */
  75. #define CPE_EUNEXPECTED_STR "CPE_EUNEXPECTED"
  76. /* Unhandled problem occurred. */
  77. #define CPE_EPANIC_STR "CPE_EPANIC"
  78. /* Unable to allocate resource. */
  79. #define CPE_ENORESOURCE_STR "CPE_ENORESOURCE"
  80. /* Invalid handle. */
  81. #define CPE_EHANDLE_STR "CPE_EHANDLE"
  82. /* Operation is already processed. */
  83. #define CPE_EALREADY_STR "CPE_EALREADY"
  84. /* Operation is not ready to be processed. */
  85. #define CPE_ENOTREADY_STR "CPE_ENOTREADY"
  86. /* Operation is pending completion. */
  87. #define CPE_EPENDING_STR "CPE_EPENDING"
  88. /* Operation could not be accepted or processed. */
  89. #define CPE_EBUSY_STR "CPE_EBUSY"
  90. /* Operation aborted due to an error. */
  91. #define CPE_EABORTED_STR "CPE_EABORTED"
  92. /* Operation preempted by a higher priority. */
  93. #define CPE_EPREEMPTED_STR "CPE_EPREEMPTED"
  94. /* Operation requests intervention to complete. */
  95. #define CPE_ECONTINUE_STR "CPE_ECONTINUE"
  96. /* Operation requests immediate intervention to complete. */
  97. #define CPE_EIMMEDIATE_STR "CPE_EIMMEDIATE"
  98. /* Operation is not implemented. */
  99. #define CPE_ENOTIMPL_STR "CPE_ENOTIMPL"
  100. /* Operation needs more data or resources. */
  101. #define CPE_ENEEDMORE_STR "CPE_ENEEDMORE"
  102. /* Operation does not have memory. */
  103. #define CPE_ENOMEMORY_STR "CPE_ENOMEMORY"
  104. /* Item does not exist. */
  105. #define CPE_ENOTEXIST_STR "CPE_ENOTEXIST"
  106. /* Operation is finished. */
  107. #define CPE_ETERMINATED_STR "CPE_ETERMINATED"
  108. /* Unexpected error code. */
  109. #define CPE_ERR_MAX_STR "CPE_ERR_MAX"
  110. struct cpe_err_code {
  111. int lnx_err_code;
  112. char *cpe_err_str;
  113. };
  114. static struct cpe_err_code cpe_err_code_info[CPE_ERR_MAX+1] = {
  115. { 0, CPE_EOK_STR},
  116. { -ENOTRECOVERABLE, CPE_EFAILED_STR},
  117. { -EINVAL, CPE_EBADPARAM_STR},
  118. { -EOPNOTSUPP, CPE_EUNSUPPORTED_STR},
  119. { -ENOPROTOOPT, CPE_EVERSION_STR},
  120. { -ENOTRECOVERABLE, CPE_EUNEXPECTED_STR},
  121. { -ENOTRECOVERABLE, CPE_EPANIC_STR},
  122. { -ENOSPC, CPE_ENORESOURCE_STR},
  123. { -EBADR, CPE_EHANDLE_STR},
  124. { -EALREADY, CPE_EALREADY_STR},
  125. { -EPERM, CPE_ENOTREADY_STR},
  126. { -EINPROGRESS, CPE_EPENDING_STR},
  127. { -EBUSY, CPE_EBUSY_STR},
  128. { -ECANCELED, CPE_EABORTED_STR},
  129. { -EAGAIN, CPE_EPREEMPTED_STR},
  130. { -EAGAIN, CPE_ECONTINUE_STR},
  131. { -EAGAIN, CPE_EIMMEDIATE_STR},
  132. { -EAGAIN, CPE_ENOTIMPL_STR},
  133. { -ENODATA, CPE_ENEEDMORE_STR},
  134. { -EADV, CPE_ERR_MAX_STR},
  135. { -ENOMEM, CPE_ENOMEMORY_STR},
  136. { -ENODEV, CPE_ENOTEXIST_STR},
  137. { -EADV, CPE_ETERMINATED_STR},
  138. { -EADV, CPE_ERR_MAX_STR},
  139. };
  140. static inline int cpe_err_get_lnx_err_code(u32 cpe_error)
  141. {
  142. if (cpe_error > CPE_ERR_MAX)
  143. return cpe_err_code_info[CPE_ERR_MAX].lnx_err_code;
  144. else
  145. return cpe_err_code_info[cpe_error].lnx_err_code;
  146. }
  147. static inline char *cpe_err_get_err_str(u32 cpe_error)
  148. {
  149. if (cpe_error > CPE_ERR_MAX)
  150. return cpe_err_code_info[CPE_ERR_MAX].cpe_err_str;
  151. else
  152. return cpe_err_code_info[cpe_error].cpe_err_str;
  153. }
  154. #endif