mips: load code in buffer mode
[openocd.git] / src / jtag / commands.h
blob06ec24837af1a58fb7fb087ac6d1792c9608cd4c
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 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. *
25 ***************************************************************************/
27 #ifndef JTAG_COMMANDS_H
28 #define JTAG_COMMANDS_H
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.
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
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.
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;
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 */
66 int num_states;
67 /** states that have to be passed */
68 tap_state_t *path;
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;
79 struct stableclocks_command {
80 /** number of clock cycles that should be sent */
81 int num_cycles;
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;
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 */
99 uint32_t us;
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.
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;
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 {
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.
147 * pathmove does not support reset as one of it's states,
148 * hence the need for an explicit statemove command.
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,
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 */