target: Remove write_memory_imp
[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
27 #ifndef JTAG_COMMANDS_H
28 #define JTAG_COMMANDS_H
29
30 /**
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.
34 */
35 enum scan_type {
36 /** From device to host, */
37 SCAN_IN = 1,
38 /** From host to device, */
39 SCAN_OUT = 2,
40 /** Full-duplex scan. */
41 SCAN_IO = 3
42 };
43
44 /**
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.
47 */
48 struct scan_command {
49 /** instruction/not data scan */
50 bool ir_scan;
51 /** number of fields in *fields array */
52 int num_fields;
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;
57 };
58
59 struct statemove_command {
60 /** state in which JTAG commands should finish */
61 tap_state_t end_state;
62 };
63
64 struct pathmove_command {
65 /** number of states in *path */
66 int num_states;
67 /** states that have to be passed */
68 tap_state_t *path;
69 };
70
71 struct runtest_command {
72 /** number of cycles to spend in Run-Test/Idle state */
73 int num_cycles;
74 /** state in which JTAG commands should finish */
75 tap_state_t end_state;
76 };
77
78
79 struct stableclocks_command {
80 /** number of clock cycles that should be sent */
81 int num_cycles;
82 };
83
84
85 struct reset_command {
86 /** Set TRST output: 0 = deassert, 1 = assert, -1 = no change */
87 int trst;
88 /** Set SRST output: 0 = deassert, 1 = assert, -1 = no change */
89 int srst;
90 };
91
92 struct end_state_command {
93 /** state in which JTAG commands should finish */
94 tap_state_t end_state;
95 };
96
97 struct sleep_command {
98 /** number of microseconds to sleep */
99 uint32_t us;
100 };
101
102 /**
103 * Encapsulates a series of bits to be clocked out, affecting state
104 * and mode of the interface.
105 *
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).
110 *
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.
113 */
114 struct tms_command {
115 /** How many bits should be clocked out. */
116 unsigned num_bits;
117 /** The bits to clock out; the LSB is bit 0 of bits[0]. */
118 const uint8_t *bits;
119 };
120
121 /**
122 * Defines a container type that hold a pointer to a JTAG command
123 * structure of any defined type.
124 */
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;
135 };
136
137 /**
138 * The type of the @c jtag_command_container contained by a
139 * @c jtag_command_s structure.
140 */
141 enum jtag_command_type {
142 JTAG_SCAN = 1,
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.
146 *
147 * pathmove does not support reset as one of it's states,
148 * hence the need for an explicit statemove command.
149 */
150 JTAG_TLR_RESET = 2,
151 JTAG_RUNTEST = 3,
152 JTAG_RESET = 4,
153 JTAG_PATHMOVE = 6,
154 JTAG_SLEEP = 7,
155 JTAG_STABLECLOCKS = 8,
156 JTAG_TMS = 9,
157 };
158
159 struct jtag_command {
160 union jtag_command_container cmd;
161 enum jtag_command_type type;
162 struct jtag_command *next;
163 };
164
165 /** The current queue of jtag_command_s structures. */
166 extern struct jtag_command *jtag_command_queue;
167
168 void *cmd_queue_alloc(size_t size);
169
170 void jtag_queue_command(struct jtag_command *cmd);
171 void jtag_command_queue_reset(void);
172
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);
177
178 #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)