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 typedef struct statemove_command_s
62 /// state in which JTAG commands should finish
63 tap_state_t end_state;
64 } statemove_command_t;
66 typedef struct pathmove_command_s
68 /// number of states in *path
70 /// states that have to be passed
74 typedef struct runtest_command_s
76 /// number of cycles to spend in Run-Test/Idle state
78 /// state in which JTAG commands should finish
79 tap_state_t end_state;
83 typedef struct stableclocks_command_s
85 /// number of clock cycles that should be sent
87 } stableclocks_command_t;
90 typedef struct reset_command_s
92 /// Set TRST output: 0 = deassert, 1 = assert, -1 = no change
94 /// Set SRST output: 0 = deassert, 1 = assert, -1 = no change
98 typedef struct end_state_command_s
100 /// state in which JTAG commands should finish
101 tap_state_t end_state;
102 } end_state_command_t;
104 typedef struct sleep_command_s
106 /// number of microseconds to sleep
111 * Defines a container type that hold a pointer to a JTAG command
112 * structure of any defined type.
114 typedef union jtag_command_container_u
116 struct scan_command* scan;
117 statemove_command_t* statemove;
118 pathmove_command_t* pathmove;
119 runtest_command_t* runtest;
120 stableclocks_command_t* stableclocks;
121 reset_command_t* reset;
122 end_state_command_t* end_state;
123 sleep_command_t* sleep;
124 } jtag_command_container_t;
127 * The type of the @c jtag_command_container_u contained by a
128 * @c jtag_command_s structure.
130 enum jtag_command_type {
137 JTAG_STABLECLOCKS = 8
140 typedef struct jtag_command_s
142 jtag_command_container_t cmd;
143 enum jtag_command_type type;
144 struct jtag_command_s* next;
147 /// The current queue of jtag_command_s structures.
148 extern jtag_command_t* jtag_command_queue;
150 void* cmd_queue_alloc(size_t size);
151 void cmd_queue_free(void);
153 void jtag_queue_command(jtag_command_t *cmd);
154 void jtag_command_queue_reset(void);
156 enum scan_type jtag_scan_type(const struct scan_command* cmd);
157 int jtag_scan_size(const struct scan_command* cmd);
158 int jtag_read_buffer(uint8_t* buffer, const struct scan_command* cmd);
159 int jtag_build_buffer(const struct scan_command* cmd, uint8_t** buffer);
161 #endif // JTAG_COMMANDS_H