ferror_code.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. /*
  2. * Copyright : (C) 2022 Phytium Information Technology, Inc.
  3. * All Rights Reserved.
  4. *
  5. * This program is OPEN SOURCE software: you can redistribute it and/or modify it
  6. * under the terms of the Phytium Public License as published by the Phytium Technology Co.,Ltd,
  7. * either version 1.0 of the License, or (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY;
  10. * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  11. * See the Phytium Public License for more details.
  12. *
  13. *
  14. * FilePath: ferror_code.h
  15. * Date: 2021-04-07 09:53:30
  16. * LastEditTime: 2022-02-17 18:05:27
  17. * Description:  This file is for error code functions
  18. *
  19. * Modify History:
  20. * Ver   Who        Date         Changes
  21. * ----- ------     --------    --------------------------------------
  22. */
  23. #ifndef FERROR_CODE_H
  24. #define FERROR_CODE_H
  25. #include "ftypes.h"
  26. #ifdef __cplusplus
  27. extern "C"
  28. {
  29. #endif
  30. typedef u32 FError;
  31. #define FT_SUCCESS 0
  32. /* 系统错误码模块定义 */
  33. typedef enum
  34. {
  35. ErrorModGeneral = 0,
  36. ErrModBsp,
  37. ErrModAssert,
  38. ErrModPort,
  39. StatusModBsp,
  40. ErrModMaxMask = 255,
  41. } FtErrorCodeModuleMask;
  42. /* COMMON组件的错误码子模块定义 */
  43. typedef enum
  44. {
  45. ErrCommGeneral = 0,
  46. ErrCommMemp,
  47. ErrInterrupt,
  48. ErrElf,
  49. } FtErrCodeCommMask;
  50. /* BSP模块的错误子模块定义 */
  51. typedef enum
  52. {
  53. ErrBspGeneral = 0,
  54. ErrBspClk,
  55. ErrBspScmi,
  56. ErrBspRtc,
  57. ErrBspTimer,
  58. ErrBspUart,
  59. ErrBspGpio,
  60. ErrBspSpi,
  61. ErrBspEth,
  62. ErrBspCan,
  63. ErrPcie,
  64. ErrBspQSpi,
  65. ErrBspMio,
  66. ErrBspI2c,
  67. ErrBspMmc,
  68. ErrBspWdt,
  69. ErrGic,
  70. ErrGdma,
  71. ErrNand,
  72. ErrIoMux,
  73. ErrBspSata,
  74. ErrUsb,
  75. ErrEthPhy,
  76. ErrDdma,
  77. ErrBspAdc,
  78. ErrBspPwm,
  79. ErrSema,
  80. ErrBspMEDIA,
  81. ErrBspMhu,
  82. ErrBspIOPad,
  83. ErrBspModMaxMask = 255
  84. } FtErrCodeBspMask;
  85. #define FT_ERRCODE_SYS_MODULE_OFFSET (u32)24
  86. #define FT_ERRCODE_SUB_MODULE_OFFSET (u32)16
  87. #define FT_ERRCODE_SYS_MODULE_MASK ((u32)0xff << FT_ERRCODE_SYS_MODULE_OFFSET) /* bit 24 .. 31 */
  88. #define FT_ERRCODE_SUB_MODULE_MASK ((u32)0xff << FT_ERRCODE_SUB_MODULE_OFFSET) /* bit 16 .. 23 */
  89. #define FT_ERRCODE_TAIL_VALUE_MASK ((u32)0xffff) /* bit 1 .. 15 */
  90. /* Offset error code */
  91. #define FT_ERRCODE_OFFSET(code, offset, mask) \
  92. (((code) << (offset)) & (mask))
  93. /* Assembly error code */
  94. #define FT_MAKE_ERRCODE(sys_mode, sub_mode, tail) \
  95. ((FT_ERRCODE_OFFSET((u32)sys_mode, FT_ERRCODE_SYS_MODULE_OFFSET, FT_ERRCODE_SYS_MODULE_MASK)) | \
  96. (FT_ERRCODE_OFFSET((u32)sub_mode, FT_ERRCODE_SUB_MODULE_OFFSET, FT_ERRCODE_SUB_MODULE_MASK)) | \
  97. ((u32)tail & FT_ERRCODE_TAIL_VALUE_MASK))
  98. #define FT_CODE_ERR FT_MAKE_ERRCODE
  99. #define ERR_SUCCESS FT_MAKE_ERRCODE(ErrorModGeneral, ErrBspGeneral, 0) /* 成功 */
  100. #define ERR_GENERAL FT_MAKE_ERRCODE(ErrorModGeneral, ErrBspGeneral, 1) /* 一般错误 */
  101. #ifdef __cplusplus
  102. }
  103. #endif
  104. #endif