You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

103 lines
4.4 KiB

  1. /***************************************************************************
  2. * Copyright (C) 2009 by Simon Qian <SimonQian@SimonQian.com> *
  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 as published by *
  6. * the Free Software Foundation; either version 2 of the License, or *
  7. * (at your option) any later version. *
  8. * *
  9. * This program is distributed in the hope that it will be useful, *
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  12. * GNU General Public License for more details. *
  13. * *
  14. * You should have received a copy of the GNU General Public License *
  15. * along with this program. If not, see <http://www.gnu.org/licenses/>. *
  16. ***************************************************************************/
  17. #ifndef OPENOCD_JTAG_DRIVERS_VERSALOON_VERSALOON_INCLUDE_H
  18. #define OPENOCD_JTAG_DRIVERS_VERSALOON_VERSALOON_INCLUDE_H
  19. /* This file is used to include different header and macros */
  20. /* according to different platform */
  21. #include <jtag/interface.h>
  22. #include <jtag/commands.h>
  23. #define PARAM_CHECK 1
  24. #define sleep_ms(ms) jtag_sleep((ms) * 1000)
  25. #define dimof(arr) (sizeof(arr) / sizeof((arr)[0]))
  26. #define TO_STR(name) #name
  27. #define RESULT int
  28. #define LOG_BUG LOG_ERROR
  29. /* Common error messages */
  30. #define ERRMSG_NOT_ENOUGH_MEMORY "Lack of memory."
  31. #define ERRCODE_NOT_ENOUGH_MEMORY ERROR_FAIL
  32. #define ERRMSG_INVALID_VALUE "%d is invalid for %s."
  33. #define ERRMSG_INVALID_INDEX "Index %d is invalid for %s."
  34. #define ERRMSG_INVALID_USAGE "Invalid usage of %s"
  35. #define ERRMSG_INVALID_TARGET "Invalid %s"
  36. #define ERRMSG_INVALID_PARAMETER "Invalid parameter of %s."
  37. #define ERRMSG_INVALID_INTERFACE_NUM "invalid inteface %d"
  38. #define ERRMSG_INVALID_BUFFER "Buffer %s is not valid."
  39. #define ERRCODE_INVALID_BUFFER ERROR_FAIL
  40. #define ERRCODE_INVALID_PARAMETER ERROR_FAIL
  41. #define ERRMSG_NOT_SUPPORT_BY "%s is not supported by %s."
  42. #define ERRMSG_FAILURE_OPERATION "Fail to %s."
  43. #define ERRMSG_FAILURE_OPERATION_MESSAGE "Fail to %s, %s"
  44. #define ERRCODE_FAILURE_OPERATION ERROR_FAIL
  45. #define GET_U16_MSBFIRST(p) (((*((uint8_t *)(p) + 0)) << 8) | \
  46. ((*((uint8_t *)(p) + 1)) << 0))
  47. #define GET_U32_MSBFIRST(p) (((*((uint8_t *)(p) + 0)) << 24) | \
  48. ((*((uint8_t *)(p) + 1)) << 16) | \
  49. ((*((uint8_t *)(p) + 2)) << 8) | \
  50. ((*((uint8_t *)(p) + 3)) << 0))
  51. #define GET_U16_LSBFIRST(p) (((*((uint8_t *)(p) + 0)) << 0) | \
  52. ((*((uint8_t *)(p) + 1)) << 8))
  53. #define GET_U32_LSBFIRST(p) (((*((uint8_t *)(p) + 0)) << 0) | \
  54. ((*((uint8_t *)(p) + 1)) << 8) | \
  55. ((*((uint8_t *)(p) + 2)) << 16) | \
  56. ((*((uint8_t *)(p) + 3)) << 24))
  57. #define SET_U16_MSBFIRST(p, v) \
  58. do {\
  59. *((uint8_t *)(p) + 0) = (((uint16_t)(v)) >> 8) & 0xFF;\
  60. *((uint8_t *)(p) + 1) = (((uint16_t)(v)) >> 0) & 0xFF;\
  61. } while (0)
  62. #define SET_U32_MSBFIRST(p, v) \
  63. do {\
  64. *((uint8_t *)(p) + 0) = (((uint32_t)(v)) >> 24) & 0xFF;\
  65. *((uint8_t *)(p) + 1) = (((uint32_t)(v)) >> 16) & 0xFF;\
  66. *((uint8_t *)(p) + 2) = (((uint32_t)(v)) >> 8) & 0xFF;\
  67. *((uint8_t *)(p) + 3) = (((uint32_t)(v)) >> 0) & 0xFF;\
  68. } while (0)
  69. #define SET_U16_LSBFIRST(p, v) \
  70. do {\
  71. *((uint8_t *)(p) + 0) = (((uint16_t)(v)) >> 0) & 0xFF;\
  72. *((uint8_t *)(p) + 1) = (((uint16_t)(v)) >> 8) & 0xFF;\
  73. } while (0)
  74. #define SET_U32_LSBFIRST(p, v) \
  75. do {\
  76. *((uint8_t *)(p) + 0) = (((uint32_t)(v)) >> 0) & 0xFF;\
  77. *((uint8_t *)(p) + 1) = (((uint32_t)(v)) >> 8) & 0xFF;\
  78. *((uint8_t *)(p) + 2) = (((uint32_t)(v)) >> 16) & 0xFF;\
  79. *((uint8_t *)(p) + 3) = (((uint32_t)(v)) >> 24) & 0xFF;\
  80. } while (0)
  81. #define GET_LE_U16(p) GET_U16_LSBFIRST(p)
  82. #define GET_LE_U32(p) GET_U32_LSBFIRST(p)
  83. #define GET_BE_U16(p) GET_U16_MSBFIRST(p)
  84. #define GET_BE_U32(p) GET_U32_MSBFIRST(p)
  85. #define SET_LE_U16(p, v) SET_U16_LSBFIRST(p, v)
  86. #define SET_LE_U32(p, v) SET_U32_LSBFIRST(p, v)
  87. #define SET_BE_U16(p, v) SET_U16_MSBFIRST(p, v)
  88. #define SET_BE_U32(p, v) SET_U32_MSBFIRST(p, v)
  89. #endif /* OPENOCD_JTAG_DRIVERS_VERSALOON_VERSALOON_INCLUDE_H */