jtag: retire tap field
[openocd.git] / src / target / avrt.c
1 /***************************************************************************
2 * Copyright (C) 2009 by Simon Qian *
3 * SimonQian@SimonQian.com *
4 * *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 2 of the License, or *
8 * (at your option) any later version. *
9 * *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
14 * *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program; if not, write to the *
17 * Free Software Foundation, Inc., *
18 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
19 ***************************************************************************/
20 #ifdef HAVE_CONFIG_H
21 #include "config.h"
22 #endif
23
24 #include "avrt.h"
25 #include "target.h"
26 #include "target_type.h"
27
28
29 #define AVR_JTAG_INS_LEN 4
30
31 /* forward declarations */
32 int avr_target_create(struct target *target, Jim_Interp *interp);
33 int avr_init_target(struct command_context *cmd_ctx, struct target *target);
34
35 int avr_arch_state(struct target *target);
36 int avr_poll(struct target *target);
37 int avr_halt(struct target *target);
38 int avr_resume(struct target *target, int current, uint32_t address, int handle_breakpoints, int debug_execution);
39 int avr_step(struct target *target, int current, uint32_t address, int handle_breakpoints);
40
41 int avr_assert_reset(struct target *target);
42 int avr_deassert_reset(struct target *target);
43 int avr_soft_reset_halt(struct target *target);
44
45 /* IR and DR functions */
46 int avr_jtag_sendinstr(struct jtag_tap *tap, uint8_t *ir_in, uint8_t ir_out);
47 int avr_jtag_senddat(struct jtag_tap *tap, uint32_t *dr_in, uint32_t dr_out, int len);
48
49 int mcu_write_ir(struct jtag_tap *tap, uint8_t *ir_in, uint8_t *ir_out, int ir_len, int rti);
50 int mcu_write_dr(struct jtag_tap *tap, uint8_t *dr_in, uint8_t *dr_out, int dr_len, int rti);
51 int mcu_write_ir_u8(struct jtag_tap *tap, uint8_t *ir_in, uint8_t ir_out, int ir_len, int rti);
52 int mcu_write_dr_u8(struct jtag_tap *tap, uint8_t *ir_in, uint8_t ir_out, int dr_len, int rti);
53 int mcu_write_ir_u16(struct jtag_tap *tap, uint16_t *ir_in, uint16_t ir_out, int ir_len, int rti);
54 int mcu_write_dr_u16(struct jtag_tap *tap, uint16_t *ir_in, uint16_t ir_out, int dr_len, int rti);
55 int mcu_write_ir_u32(struct jtag_tap *tap, uint32_t *ir_in, uint32_t ir_out, int ir_len, int rti);
56 int mcu_write_dr_u32(struct jtag_tap *tap, uint32_t *ir_in, uint32_t ir_out, int dr_len, int rti);
57 int mcu_execute_queue(void);
58
59 struct target_type avr_target =
60 {
61 .name = "avr",
62
63 .poll = avr_poll,
64 .arch_state = avr_arch_state,
65
66 .target_request_data = NULL,
67
68 .halt = avr_halt,
69 .resume = avr_resume,
70 .step = avr_step,
71
72 .assert_reset = avr_assert_reset,
73 .deassert_reset = avr_deassert_reset,
74 .soft_reset_halt = avr_soft_reset_halt,
75 /*
76 .get_gdb_reg_list = avr_get_gdb_reg_list,
77
78 .read_memory = avr_read_memory,
79 .write_memory = avr_write_memory,
80 .bulk_write_memory = avr_bulk_write_memory,
81 .checksum_memory = avr_checksum_memory,
82 .blank_check_memory = avr_blank_check_memory,
83
84 .run_algorithm = avr_run_algorithm,
85
86 .add_breakpoint = avr_add_breakpoint,
87 .remove_breakpoint = avr_remove_breakpoint,
88 .add_watchpoint = avr_add_watchpoint,
89 .remove_watchpoint = avr_remove_watchpoint,
90 */
91 .target_create = avr_target_create,
92 .init_target = avr_init_target,
93 };
94
95 int avr_target_create(struct target *target, Jim_Interp *interp)
96 {
97 struct avr_common *avr = calloc(1, sizeof(struct avr_common));
98
99 avr->jtag_info.tap = target->tap;
100 target->arch_info = avr;
101
102 return ERROR_OK;
103 }
104
105 int avr_init_target(struct command_context *cmd_ctx, struct target *target)
106 {
107 LOG_DEBUG("%s", __FUNCTION__);
108 return ERROR_OK;
109 }
110
111 int avr_arch_state(struct target *target)
112 {
113 LOG_DEBUG("%s", __FUNCTION__);
114 return ERROR_OK;
115 }
116
117 int avr_poll(struct target *target)
118 {
119 if ((target->state == TARGET_RUNNING) || (target->state == TARGET_DEBUG_RUNNING))
120 {
121 target->state = TARGET_HALTED;
122 }
123
124 LOG_DEBUG("%s", __FUNCTION__);
125 return ERROR_OK;
126 }
127
128 int avr_halt(struct target *target)
129 {
130 LOG_DEBUG("%s", __FUNCTION__);
131 return ERROR_OK;
132 }
133
134 int avr_resume(struct target *target, int current, uint32_t address, int handle_breakpoints, int debug_execution)
135 {
136 LOG_DEBUG("%s", __FUNCTION__);
137 return ERROR_OK;
138 }
139
140 int avr_step(struct target *target, int current, uint32_t address, int handle_breakpoints)
141 {
142 LOG_DEBUG("%s", __FUNCTION__);
143 return ERROR_OK;
144 }
145
146 int avr_assert_reset(struct target *target)
147 {
148 target->state = TARGET_RESET;
149
150 LOG_DEBUG("%s", __FUNCTION__);
151 return ERROR_OK;
152 }
153
154 int avr_deassert_reset(struct target *target)
155 {
156 target->state = TARGET_RUNNING;
157
158 LOG_DEBUG("%s", __FUNCTION__);
159 return ERROR_OK;
160 }
161
162 int avr_soft_reset_halt(struct target *target)
163 {
164 LOG_DEBUG("%s", __FUNCTION__);
165 return ERROR_OK;
166 }
167
168 int avr_jtag_senddat(struct jtag_tap *tap, uint32_t* dr_in, uint32_t dr_out, int len)
169 {
170 return mcu_write_dr_u32(tap, dr_in, dr_out, len, 1);
171 }
172
173 int avr_jtag_sendinstr(struct jtag_tap *tap, uint8_t *ir_in, uint8_t ir_out)
174 {
175 return mcu_write_ir_u8(tap, ir_in, ir_out, AVR_JTAG_INS_LEN, 1);
176 }
177
178 /* IR and DR functions */
179 int mcu_write_ir(struct jtag_tap *tap, uint8_t *ir_in, uint8_t *ir_out, int ir_len, int rti)
180 {
181 if (NULL == tap)
182 {
183 LOG_ERROR("invalid tap");
184 return ERROR_FAIL;
185 }
186 if (ir_len != tap->ir_length)
187 {
188 LOG_ERROR("invalid ir_len");
189 return ERROR_FAIL;
190 }
191
192 {
193 struct scan_field field[1];
194
195 field[0].num_bits = tap->ir_length;
196 field[0].out_value = ir_out;
197 field[0].in_value = ir_in;
198 jtag_add_plain_ir_scan(ARRAY_SIZE(field), field, jtag_set_end_state(TAP_IDLE));
199 }
200
201 return ERROR_OK;
202 }
203
204 int mcu_write_dr(struct jtag_tap *tap, uint8_t *dr_in, uint8_t *dr_out, int dr_len, int rti)
205 {
206 if (NULL == tap)
207 {
208 LOG_ERROR("invalid tap");
209 return ERROR_FAIL;
210 }
211
212 {
213 struct scan_field field[1];
214
215 field[0].num_bits = dr_len;
216 field[0].out_value = dr_out;
217 field[0].in_value = dr_in;
218 jtag_add_plain_dr_scan(ARRAY_SIZE(field), field, jtag_set_end_state(TAP_IDLE));
219 }
220
221 return ERROR_OK;
222 }
223
224 int mcu_write_ir_u8(struct jtag_tap *tap, uint8_t *ir_in, uint8_t ir_out, int ir_len, int rti)
225 {
226 if (ir_len > 8)
227 {
228 LOG_ERROR("ir_len overflow, maxium is 8");
229 return ERROR_FAIL;
230 }
231
232 mcu_write_ir(tap, ir_in, &ir_out, ir_len, rti);
233
234 return ERROR_OK;
235 }
236
237 int mcu_write_dr_u8(struct jtag_tap *tap, uint8_t *dr_in, uint8_t dr_out, int dr_len, int rti)
238 {
239 if (dr_len > 8)
240 {
241 LOG_ERROR("dr_len overflow, maxium is 8");
242 return ERROR_FAIL;
243 }
244
245 mcu_write_dr(tap, dr_in, &dr_out, dr_len, rti);
246
247 return ERROR_OK;
248 }
249
250 int mcu_write_ir_u16(struct jtag_tap *tap, uint16_t *ir_in, uint16_t ir_out, int ir_len, int rti)
251 {
252 if (ir_len > 16)
253 {
254 LOG_ERROR("ir_len overflow, maxium is 16");
255 return ERROR_FAIL;
256 }
257
258 mcu_write_ir(tap, (uint8_t*)ir_in, (uint8_t*)&ir_out, ir_len, rti);
259
260 return ERROR_OK;
261 }
262
263 int mcu_write_dr_u16(struct jtag_tap *tap, uint16_t *dr_in, uint16_t dr_out, int dr_len, int rti)
264 {
265 if (dr_len > 16)
266 {
267 LOG_ERROR("dr_len overflow, maxium is 16");
268 return ERROR_FAIL;
269 }
270
271 mcu_write_dr(tap, (uint8_t*)dr_in, (uint8_t*)&dr_out, dr_len, rti);
272
273 return ERROR_OK;
274 }
275
276 int mcu_write_ir_u32(struct jtag_tap *tap, uint32_t *ir_in, uint32_t ir_out, int ir_len, int rti)
277 {
278 if (ir_len > 32)
279 {
280 LOG_ERROR("ir_len overflow, maxium is 32");
281 return ERROR_FAIL;
282 }
283
284 mcu_write_ir(tap, (uint8_t*)ir_in, (uint8_t*)&ir_out, ir_len, rti);
285
286 return ERROR_OK;
287 }
288
289 int mcu_write_dr_u32(struct jtag_tap *tap, uint32_t *dr_in, uint32_t dr_out, int dr_len, int rti)
290 {
291 if (dr_len > 32)
292 {
293 LOG_ERROR("dr_len overflow, maxium is 32");
294 return ERROR_FAIL;
295 }
296
297 mcu_write_dr(tap, (uint8_t*)dr_in, (uint8_t*)&dr_out, dr_len, rti);
298
299 return ERROR_OK;
300 }
301
302 int mcu_execute_queue(void)
303 {
304 return jtag_execute_queue();
305 }

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)