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 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. *
25 ***************************************************************************/
27 #ifndef JTAG_COMMANDS_H
28 #define JTAG_COMMANDS_H
31 * The inferred type of a scan_command_s structure, indicating whether
32 * the command has the host scan in from the device, the host scan out
33 * to the device, or both.
36 /** From device to host, */
38 /** From host to device, */
40 /** Full-duplex scan. */
45 * The scan_command provide a means of encapsulating a set of scan_field_s
46 * structures that should be scanned in/out to the device.
49 /** instruction/not data scan */
51 /** number of fields in *fields array */
53 /** pointer to an array of data scan fields */
54 struct scan_field
*fields
;
55 /** state in which JTAG commands should finish */
56 tap_state_t end_state
;
59 struct statemove_command
{
60 /** state in which JTAG commands should finish */
61 tap_state_t end_state
;
64 struct pathmove_command
{
65 /** number of states in *path */
67 /** states that have to be passed */
71 struct runtest_command
{
72 /** number of cycles to spend in Run-Test/Idle state */
74 /** state in which JTAG commands should finish */
75 tap_state_t end_state
;
79 struct stableclocks_command
{
80 /** number of clock cycles that should be sent */
85 struct reset_command
{
86 /** Set TRST output: 0 = deassert, 1 = assert, -1 = no change */
88 /** Set SRST output: 0 = deassert, 1 = assert, -1 = no change */
92 struct end_state_command
{
93 /** state in which JTAG commands should finish */
94 tap_state_t end_state
;
97 struct sleep_command
{
98 /** number of microseconds to sleep */
103 * Encapsulates a series of bits to be clocked out, affecting state
104 * and mode of the interface.
106 * In JTAG mode these are clocked out on TMS, using TCK. They may be
107 * used for link resets, transitioning between JTAG and SWD modes, or
108 * to implement JTAG state machine transitions (implementing pathmove
109 * or statemove operations).
111 * In SWD mode these are clocked out on SWDIO, using SWCLK, and are
112 * used for link resets and transitioning between SWD and JTAG modes.
115 /** How many bits should be clocked out. */
117 /** The bits to clock out; the LSB is bit 0 of bits[0]. */
122 * Defines a container type that hold a pointer to a JTAG command
123 * structure of any defined type.
125 union jtag_command_container
{
126 struct scan_command
*scan
;
127 struct statemove_command
*statemove
;
128 struct pathmove_command
*pathmove
;
129 struct runtest_command
*runtest
;
130 struct stableclocks_command
*stableclocks
;
131 struct reset_command
*reset
;
132 struct end_state_command
*end_state
;
133 struct sleep_command
*sleep
;
134 struct tms_command
*tms
;
138 * The type of the @c jtag_command_container contained by a
139 * @c jtag_command_s structure.
141 enum jtag_command_type
{
143 /* JTAG_TLR_RESET's non-minidriver implementation is a
144 * vestige from a statemove cmd. The statemove command
145 * is obsolete and replaced by pathmove.
147 * pathmove does not support reset as one of it's states,
148 * hence the need for an explicit statemove command.
155 JTAG_STABLECLOCKS
= 8,
159 struct jtag_command
{
160 union jtag_command_container cmd
;
161 enum jtag_command_type type
;
162 struct jtag_command
*next
;
165 /** The current queue of jtag_command_s structures. */
166 extern struct jtag_command
*jtag_command_queue
;
168 void *cmd_queue_alloc(size_t size
);
170 void jtag_queue_command(struct jtag_command
*cmd
);
171 void jtag_command_queue_reset(void);
173 enum scan_type
jtag_scan_type(const struct scan_command
*cmd
);
174 int jtag_scan_size(const struct scan_command
*cmd
);
175 int jtag_read_buffer(uint8_t *buffer
, const struct scan_command
*cmd
);
176 int jtag_build_buffer(const struct scan_command
*cmd
, uint8_t **buffer
);
178 #endif /* JTAG_COMMANDS_H */