tcl/interface: support for Raspberry Pi 5
[openocd.git] / src / jtag / commands.h
blob825907733fd93c7cbbd6f1970525fdb81c51ed31
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
3 /***************************************************************************
4 * Copyright (C) 2005 by Dominic Rath *
5 * Dominic.Rath@gmx.de *
6 * *
7 * Copyright (C) 2007,2008 Øyvind Harboe *
8 * oyvind.harboe@zylin.com *
9 * *
10 * Copyright (C) 2009 Zachary T Welch *
11 * zw@superlucidity.net *
12 ***************************************************************************/
14 #ifndef OPENOCD_JTAG_COMMANDS_H
15 #define OPENOCD_JTAG_COMMANDS_H
17 /**
18 * The inferred type of a scan_command structure, indicating whether
19 * the command has the host scan in from the device, the host scan out
20 * to the device, or both.
22 enum scan_type {
23 /** From device to host, */
24 SCAN_IN = 1,
25 /** From host to device, */
26 SCAN_OUT = 2,
27 /** Full-duplex scan. */
28 SCAN_IO = 3
31 /**
32 * The scan_command provide a means of encapsulating a set of scan_field
33 * structures that should be scanned in/out to the device.
35 struct scan_command {
36 /** instruction/not data scan */
37 bool ir_scan;
38 /** number of fields in *fields array */
39 int num_fields;
40 /** pointer to an array of data scan fields */
41 struct scan_field *fields;
42 /** state in which JTAG commands should finish */
43 tap_state_t end_state;
46 struct statemove_command {
47 /** state in which JTAG commands should finish */
48 tap_state_t end_state;
51 struct pathmove_command {
52 /** number of states in *path */
53 int num_states;
54 /** states that have to be passed */
55 tap_state_t *path;
58 struct runtest_command {
59 /** number of cycles to spend in Run-Test/Idle state */
60 int num_cycles;
61 /** state in which JTAG commands should finish */
62 tap_state_t end_state;
66 struct stableclocks_command {
67 /** number of clock cycles that should be sent */
68 int num_cycles;
72 struct reset_command {
73 /** Set TRST output: 0 = deassert, 1 = assert, -1 = no change */
74 int trst;
75 /** Set SRST output: 0 = deassert, 1 = assert, -1 = no change */
76 int srst;
79 struct end_state_command {
80 /** state in which JTAG commands should finish */
81 tap_state_t end_state;
84 struct sleep_command {
85 /** number of microseconds to sleep */
86 uint32_t us;
89 /**
90 * Encapsulates a series of bits to be clocked out, affecting state
91 * and mode of the interface.
93 * In JTAG mode these are clocked out on TMS, using TCK. They may be
94 * used for link resets, transitioning between JTAG and SWD modes, or
95 * to implement JTAG state machine transitions (implementing pathmove
96 * or statemove operations).
98 * In SWD mode these are clocked out on SWDIO, using SWCLK, and are
99 * used for link resets and transitioning between SWD and JTAG modes.
101 struct tms_command {
102 /** How many bits should be clocked out. */
103 unsigned num_bits;
104 /** The bits to clock out; the LSB is bit 0 of bits[0]. */
105 const uint8_t *bits;
109 * Defines a container type that hold a pointer to a JTAG command
110 * structure of any defined type.
112 union jtag_command_container {
113 struct scan_command *scan;
114 struct statemove_command *statemove;
115 struct pathmove_command *pathmove;
116 struct runtest_command *runtest;
117 struct stableclocks_command *stableclocks;
118 struct reset_command *reset;
119 struct end_state_command *end_state;
120 struct sleep_command *sleep;
121 struct tms_command *tms;
125 * The type of the @c jtag_command_container contained by a
126 * @c jtag_command structure.
128 enum jtag_command_type {
129 JTAG_SCAN = 1,
130 /* JTAG_TLR_RESET's non-minidriver implementation is a
131 * vestige from a statemove cmd. The statemove command
132 * is obsolete and replaced by pathmove.
134 * pathmove does not support reset as one of it's states,
135 * hence the need for an explicit statemove command.
137 JTAG_TLR_RESET = 2,
138 JTAG_RUNTEST = 3,
139 JTAG_RESET = 4,
140 JTAG_PATHMOVE = 6,
141 JTAG_SLEEP = 7,
142 JTAG_STABLECLOCKS = 8,
143 JTAG_TMS = 9,
146 struct jtag_command {
147 union jtag_command_container cmd;
148 enum jtag_command_type type;
149 struct jtag_command *next;
152 void *cmd_queue_alloc(size_t size);
154 void jtag_queue_command(struct jtag_command *cmd);
155 void jtag_command_queue_reset(void);
156 struct jtag_command *jtag_command_queue_get(void);
158 void jtag_scan_field_clone(struct scan_field *dst, const struct scan_field *src);
159 enum scan_type jtag_scan_type(const struct scan_command *cmd);
160 int jtag_scan_size(const struct scan_command *cmd);
161 int jtag_read_buffer(uint8_t *buffer, const struct scan_command *cmd);
162 int jtag_build_buffer(const struct scan_command *cmd, uint8_t **buffer);
164 #endif /* OPENOCD_JTAG_COMMANDS_H */