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.
 
 
 
 
 
 

163 lines
5.1 KiB

  1. /***************************************************************************
  2. * Copyright (C) 2005 by Dominic Rath *
  3. * Dominic.Rath@gmx.de *
  4. * *
  5. * Copyright (C) 2007,2008 Øyvind Harboe *
  6. * oyvind.harboe@zylin.com *
  7. * *
  8. * Copyright (C) 2009 Zachary T Welch *
  9. * zw@superlucidity.net *
  10. * *
  11. * This program is free software; you can redistribute it and/or modify *
  12. * it under the terms of the GNU General Public License as published by *
  13. * the Free Software Foundation; either version 2 of the License, or *
  14. * (at your option) any later version. *
  15. * *
  16. * This program is distributed in the hope that it will be useful, *
  17. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  18. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  19. * GNU General Public License for more details. *
  20. * *
  21. * You should have received a copy of the GNU General Public License *
  22. * along with this program; if not, write to the *
  23. * Free Software Foundation, Inc., *
  24. * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
  25. ***************************************************************************/
  26. #ifndef JTAG_COMMANDS_H
  27. #define JTAG_COMMANDS_H
  28. #include "jtag.h"
  29. /**
  30. * The inferred type of a scan_command_s structure, indicating whether
  31. * the command has the host scan in from the device, the host scan out
  32. * to the device, or both.
  33. */
  34. enum scan_type {
  35. /// From device to host,
  36. SCAN_IN = 1,
  37. /// From host to device,
  38. SCAN_OUT = 2,
  39. /// Full-duplex scan.
  40. SCAN_IO = 3
  41. };
  42. /**
  43. * The scan_command provide a means of encapsulating a set of scan_field_s
  44. * structures that should be scanned in/out to the device.
  45. */
  46. typedef struct scan_command_s
  47. {
  48. /// instruction/not data scan
  49. bool ir_scan;
  50. /// number of fields in *fields array
  51. int num_fields;
  52. /// pointer to an array of data scan fields
  53. struct scan_field* fields;
  54. /// state in which JTAG commands should finish
  55. tap_state_t end_state;
  56. } scan_command_t;
  57. typedef struct statemove_command_s
  58. {
  59. /// state in which JTAG commands should finish
  60. tap_state_t end_state;
  61. } statemove_command_t;
  62. typedef struct pathmove_command_s
  63. {
  64. /// number of states in *path
  65. int num_states;
  66. /// states that have to be passed
  67. tap_state_t* path;
  68. } pathmove_command_t;
  69. typedef struct runtest_command_s
  70. {
  71. /// number of cycles to spend in Run-Test/Idle state
  72. int num_cycles;
  73. /// state in which JTAG commands should finish
  74. tap_state_t end_state;
  75. } runtest_command_t;
  76. typedef struct stableclocks_command_s
  77. {
  78. /// number of clock cycles that should be sent
  79. int num_cycles;
  80. } stableclocks_command_t;
  81. typedef struct reset_command_s
  82. {
  83. /// Set TRST output: 0 = deassert, 1 = assert, -1 = no change
  84. int trst;
  85. /// Set SRST output: 0 = deassert, 1 = assert, -1 = no change
  86. int srst;
  87. } reset_command_t;
  88. typedef struct end_state_command_s
  89. {
  90. /// state in which JTAG commands should finish
  91. tap_state_t end_state;
  92. } end_state_command_t;
  93. typedef struct sleep_command_s
  94. {
  95. /// number of microseconds to sleep
  96. uint32_t us;
  97. } sleep_command_t;
  98. /**
  99. * Defines a container type that hold a pointer to a JTAG command
  100. * structure of any defined type.
  101. */
  102. typedef union jtag_command_container_u
  103. {
  104. scan_command_t* scan;
  105. statemove_command_t* statemove;
  106. pathmove_command_t* pathmove;
  107. runtest_command_t* runtest;
  108. stableclocks_command_t* stableclocks;
  109. reset_command_t* reset;
  110. end_state_command_t* end_state;
  111. sleep_command_t* sleep;
  112. } jtag_command_container_t;
  113. /**
  114. * The type of the @c jtag_command_container_u contained by a
  115. * @c jtag_command_s structure.
  116. */
  117. enum jtag_command_type {
  118. JTAG_SCAN = 1,
  119. JTAG_STATEMOVE = 2,
  120. JTAG_RUNTEST = 3,
  121. JTAG_RESET = 4,
  122. JTAG_PATHMOVE = 6,
  123. JTAG_SLEEP = 7,
  124. JTAG_STABLECLOCKS = 8
  125. };
  126. typedef struct jtag_command_s
  127. {
  128. jtag_command_container_t cmd;
  129. enum jtag_command_type type;
  130. struct jtag_command_s* next;
  131. } jtag_command_t;
  132. /// The current queue of jtag_command_s structures.
  133. extern jtag_command_t* jtag_command_queue;
  134. void* cmd_queue_alloc(size_t size);
  135. void cmd_queue_free(void);
  136. void jtag_queue_command(jtag_command_t *cmd);
  137. void jtag_command_queue_reset(void);
  138. enum scan_type jtag_scan_type(const scan_command_t* cmd);
  139. int jtag_scan_size(const scan_command_t* cmd);
  140. int jtag_read_buffer(uint8_t* buffer, const scan_command_t* cmd);
  141. int jtag_build_buffer(const scan_command_t* cmd, uint8_t** buffer);
  142. #endif // JTAG_COMMANDS_H