1 /***************************************************************************
2 * Copyright (C) 2005 by Dominic Rath *
3 * Dominic.Rath@gmx.de *
5 * Copyright (C) 2007,2008 Øyvind Harboe *
6 * oyvind.harboe@zylin.com *
8 * Copyright (C) 2009 Zachary T Welch *
9 * zw@superlucidity.net *
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. *
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. *
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
32 * The inferred type of a scan_command_s structure, indicating whether
33 * the command has the host scan in from the device, the host scan out
34 * to the device, or both.
37 /// From device to host,
39 /// From host to device,
46 * The scan_command provide a means of encapsulating a set of scan_field_s
47 * structures that should be scanned in/out to the device.
50 /// instruction/not data scan
52 /// number of fields in *fields array
54 /// pointer to an array of data scan fields
55 struct scan_field
* fields
;
56 /// state in which JTAG commands should finish
57 tap_state_t end_state
;
60 struct statemove_command
{
61 /// state in which JTAG commands should finish
62 tap_state_t end_state
;
65 struct pathmove_command
{
66 /// number of states in *path
68 /// states that have to be passed
72 struct runtest_command
{
73 /// number of cycles to spend in Run-Test/Idle state
75 /// state in which JTAG commands should finish
76 tap_state_t end_state
;
80 struct stableclocks_command
{
81 /// number of clock cycles that should be sent
86 struct reset_command
{
87 /// Set TRST output: 0 = deassert, 1 = assert, -1 = no change
89 /// Set SRST output: 0 = deassert, 1 = assert, -1 = no change
93 struct end_state_command
{
94 /// state in which JTAG commands should finish
95 tap_state_t end_state
;
98 struct sleep_command
{
99 /// number of microseconds to sleep
104 * Defines a container type that hold a pointer to a JTAG command
105 * structure of any defined type.
107 union jtag_command_container
{
108 struct scan_command
* scan
;
109 struct statemove_command
* statemove
;
110 struct pathmove_command
* pathmove
;
111 struct runtest_command
* runtest
;
112 struct stableclocks_command
* stableclocks
;
113 struct reset_command
* reset
;
114 struct end_state_command
* end_state
;
115 struct sleep_command
* sleep
;
119 * The type of the @c jtag_command_container contained by a
120 * @c jtag_command_s structure.
122 enum jtag_command_type
{
129 JTAG_STABLECLOCKS
= 8
132 struct jtag_command
{
133 union jtag_command_container cmd
;
134 enum jtag_command_type type
;
135 struct jtag_command
*next
;
138 /// The current queue of jtag_command_s structures.
139 extern struct jtag_command
* jtag_command_queue
;
141 void* cmd_queue_alloc(size_t size
);
142 void cmd_queue_free(void);
144 void jtag_queue_command(struct jtag_command
*cmd
);
145 void jtag_command_queue_reset(void);
147 enum scan_type
jtag_scan_type(const struct scan_command
* cmd
);
148 int jtag_scan_size(const struct scan_command
* cmd
);
149 int jtag_read_buffer(uint8_t* buffer
, const struct scan_command
* cmd
);
150 int jtag_build_buffer(const struct scan_command
* cmd
, uint8_t** buffer
);
152 #endif // JTAG_COMMANDS_H