jtag: rename JTAG_MOVESTATE to JTAG_TLR_RESET
[openocd.git] / src / jtag / commands.h
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
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 /**
44 * The scan_command provide a means of encapsulating a set of scan_field_s
45 * structures that should be scanned in/out to the device.
46 */
47 struct scan_command {
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 };
57
58 struct statemove_command {
59 /// state in which JTAG commands should finish
60 tap_state_t end_state;
61 };
62
63 struct pathmove_command {
64 /// number of states in *path
65 int num_states;
66 /// states that have to be passed
67 tap_state_t* path;
68 };
69
70 struct runtest_command {
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 };
76
77
78 struct stableclocks_command {
79 /// number of clock cycles that should be sent
80 int num_cycles;
81 };
82
83
84 struct reset_command {
85 /// Set TRST output: 0 = deassert, 1 = assert, -1 = no change
86 int trst;
87 /// Set SRST output: 0 = deassert, 1 = assert, -1 = no change
88 int srst;
89 };
90
91 struct end_state_command {
92 /// state in which JTAG commands should finish
93 tap_state_t end_state;
94 };
95
96 struct sleep_command {
97 /// number of microseconds to sleep
98 uint32_t us;
99 };
100
101 /**
102 * Encapsulates a series of bits to be clocked out, affecting state
103 * and mode of the interface.
104 *
105 * In JTAG mode these are clocked out on TMS, using TCK. They may be
106 * used for link resets, transitioning between JTAG and SWD modes, or
107 * to implement JTAG state machine transitions (implementing pathmove
108 * or statemove operations).
109 *
110 * In SWD mode these are clocked out on SWDIO, using SWCLK, and are
111 * used for link resets and transitioning between SWD and JTAG modes.
112 */
113 struct tms_command {
114 /** How many bits should be clocked out. */
115 unsigned num_bits;
116 /** The bits to clock out; the LSB is bit 0 of bits[0]. */
117 const uint8_t *bits;
118 };
119
120 /**
121 * Defines a container type that hold a pointer to a JTAG command
122 * structure of any defined type.
123 */
124 union jtag_command_container {
125 struct scan_command *scan;
126 struct statemove_command *statemove;
127 struct pathmove_command *pathmove;
128 struct runtest_command *runtest;
129 struct stableclocks_command *stableclocks;
130 struct reset_command *reset;
131 struct end_state_command *end_state;
132 struct sleep_command *sleep;
133 struct tms_command *tms;
134 };
135
136 /**
137 * The type of the @c jtag_command_container contained by a
138 * @c jtag_command_s structure.
139 */
140 enum jtag_command_type {
141 JTAG_SCAN = 1,
142 /* JTAG_TLR_RESET's non-minidriver implementation is a
143 * vestige from a statemove cmd. The statemove command
144 * is obsolete and replaced by pathmove.
145 *
146 * pathmove does not support reset as one of it's states,
147 * hence the need for an explicit statemove command.
148 */
149 JTAG_TLR_RESET = 2,
150 JTAG_RUNTEST = 3,
151 JTAG_RESET = 4,
152 JTAG_PATHMOVE = 6,
153 JTAG_SLEEP = 7,
154 JTAG_STABLECLOCKS = 8,
155 JTAG_TMS = 9,
156 };
157
158 struct jtag_command {
159 union jtag_command_container cmd;
160 enum jtag_command_type type;
161 struct jtag_command *next;
162 };
163
164 /// The current queue of jtag_command_s structures.
165 extern struct jtag_command* jtag_command_queue;
166
167 void* cmd_queue_alloc(size_t size);
168
169 void jtag_queue_command(struct jtag_command *cmd);
170 void jtag_command_queue_reset(void);
171
172 enum scan_type jtag_scan_type(const struct scan_command* cmd);
173 int jtag_scan_size(const struct scan_command* cmd);
174 int jtag_read_buffer(uint8_t* buffer, const struct scan_command* cmd);
175 int jtag_build_buffer(const struct scan_command* cmd, uint8_t** buffer);
176
177 #endif // JTAG_COMMANDS_H

Linking to existing account procedure

If you already have an account and want to add another login method you MUST first sign in with your existing account and then change URL to read https://review.openocd.org/login/?link to get to this page again but this time it'll work for linking. Thank you.

SSH host keys fingerprints

1024 SHA256:YKx8b7u5ZWdcbp7/4AeXNaqElP49m6QrwfXaqQGJAOk gerrit-code-review@openocd.zylin.com (DSA)
384 SHA256:jHIbSQa4REvwCFG4cq5LBlBLxmxSqelQPem/EXIrxjk gerrit-code-review@openocd.org (ECDSA)
521 SHA256:UAOPYkU9Fjtcao0Ul/Rrlnj/OsQvt+pgdYSZ4jOYdgs gerrit-code-review@openocd.org (ECDSA)
256 SHA256:A13M5QlnozFOvTllybRZH6vm7iSt0XLxbA48yfc2yfY gerrit-code-review@openocd.org (ECDSA)
256 SHA256:spYMBqEYoAOtK7yZBrcwE8ZpYt6b68Cfh9yEVetvbXg gerrit-code-review@openocd.org (ED25519)
+--[ED25519 256]--+
|=..              |
|+o..   .         |
|*.o   . .        |
|+B . . .         |
|Bo. = o S        |
|Oo.+ + =         |
|oB=.* = . o      |
| =+=.+   + E     |
|. .=o   . o      |
+----[SHA256]-----+
2048 SHA256:0Onrb7/PHjpo6iVZ7xQX2riKN83FJ3KGU0TvI0TaFG4 gerrit-code-review@openocd.zylin.com (RSA)