OpenOCD
esirisc_jtag.c
Go to the documentation of this file.
1 // SPDX-License-Identifier: GPL-2.0-or-later
2 
3 /***************************************************************************
4  * Copyright (C) 2018 by Square, Inc. *
5  * Steven Stallion <stallion@squareup.com> *
6  * James Zhao <hjz@squareup.com> *
7  ***************************************************************************/
8 
9 #ifdef HAVE_CONFIG_H
10 #include "config.h"
11 #endif
12 
13 #include <helper/binarybuffer.h>
14 #include <helper/log.h>
15 #include <helper/types.h>
16 #include <jtag/jtag.h>
17 #include <jtag/commands.h>
18 #include <jtag/interface.h>
19 
20 #include "esirisc_jtag.h"
21 
22 static void esirisc_jtag_set_instr(struct esirisc_jtag *jtag_info, uint32_t new_instr)
23 {
24  struct jtag_tap *tap = jtag_info->tap;
25 
26  if (buf_get_u32(tap->cur_instr, 0, tap->ir_length) != new_instr) {
27  struct scan_field field;
28  uint8_t t[4] = { 0 };
29 
30  field.num_bits = tap->ir_length;
31  field.out_value = t;
32  buf_set_u32(t, 0, field.num_bits, new_instr);
33  field.in_value = NULL;
34 
35  jtag_add_ir_scan(tap, &field, TAP_IDLE);
36  }
37 }
38 
39 /*
40  * The data register is latched every 8 bits while in the Shift-DR state
41  * (Update-DR is not supported). This necessitates prepending padding
42  * bits to ensure data is aligned when multiple TAPs are present.
43  */
44 static int esirisc_jtag_get_padding(void)
45 {
46  int padding = 0;
47  int bypass_devices = 0;
48 
49  for (struct jtag_tap *tap = jtag_tap_next_enabled(NULL); tap;
50  tap = jtag_tap_next_enabled(tap))
51  if (tap->bypass)
52  bypass_devices++;
53 
54  int num_bits = bypass_devices % 8;
55  if (num_bits > 0)
56  padding = 8 - num_bits;
57 
58  return padding;
59 }
60 
61 static int esirisc_jtag_count_bits(unsigned int num_fields,
62  struct scan_field *fields)
63 {
64  int bit_count = 0;
65 
66  for (unsigned int i = 0; i < num_fields; ++i)
67  bit_count += fields[i].num_bits;
68 
69  return bit_count;
70 }
71 
72 /*
73  * Data received from the target will be byte-stuffed if it contains
74  * either the pad byte (0xAA) or stuffing marker (0x55). Buffers should
75  * be sized twice the expected length to account for stuffing overhead.
76  */
77 static void esirisc_jtag_unstuff(uint8_t *data, size_t len)
78 {
79  uint8_t *r, *w;
80  uint8_t *end;
81 
82  r = w = data;
83  end = data + len;
84  while (r < end) {
85  if (*r == STUFF_MARKER) {
86  r++; /* skip stuffing marker */
87  assert(r < end);
88  *w++ = *r++ ^ STUFF_MARKER;
89  } else
90  *w++ = *r++;
91  }
92 }
93 
94 /*
95  * The eSi-Debug protocol defines a byte-oriented command/response
96  * channel that operates over serial or JTAG. While not strictly
97  * required, separate DR scans are used for sending and receiving data.
98  * This allows the TAP to recover gracefully if the byte stream is
99  * corrupted at the expense of sending additional padding bits.
100  */
101 
102 static int esirisc_jtag_send(struct esirisc_jtag *jtag_info, uint8_t command,
103  int num_out_fields, struct scan_field *out_fields)
104 {
105  int num_fields = 2 + num_out_fields;
106  struct scan_field *fields = cmd_queue_alloc(num_fields * sizeof(struct scan_field));
107 
109 
110  fields[0].num_bits = esirisc_jtag_get_padding();
111  fields[0].out_value = NULL;
112  fields[0].in_value = NULL;
113 
114  fields[1].num_bits = 8;
115  fields[1].out_value = &command;
116  fields[1].in_value = NULL;
117 
118  /* append command data */
119  for (int i = 0; i < num_out_fields; ++i)
120  jtag_scan_field_clone(&fields[2+i], &out_fields[i]);
121 
122  jtag_add_dr_scan(jtag_info->tap, num_fields, fields, TAP_IDLE);
123 
124  return jtag_execute_queue();
125 }
126 
127 static int esirisc_jtag_recv(struct esirisc_jtag *jtag_info,
128  int num_in_fields, struct scan_field *in_fields)
129 {
130  int num_in_bits = esirisc_jtag_count_bits(num_in_fields, in_fields);
131  int num_in_bytes = DIV_ROUND_UP(num_in_bits, 8);
132 
133  struct scan_field fields[3];
134  /* prevent zero-size variable length array */
135  int r_size = num_in_bytes ? num_in_bytes * 2 : 1;
136  uint8_t r[r_size];
137 
139 
140  fields[0].num_bits = esirisc_jtag_get_padding() + 1;
141  fields[0].out_value = NULL;
142  fields[0].in_value = NULL;
143 
144  fields[1].num_bits = 8;
145  fields[1].out_value = NULL;
146  fields[1].in_value = &jtag_info->status;
147 
148  fields[2].num_bits = num_in_bits * 2;
149  fields[2].out_value = NULL;
150  fields[2].in_value = r;
151 
152  jtag_add_dr_scan(jtag_info->tap, ARRAY_SIZE(fields), fields, TAP_IDLE);
153 
154  int retval = jtag_execute_queue();
155  if (retval != ERROR_OK)
156  return retval;
157 
158  /* unstuff response data and write back to caller */
159  if (num_in_fields > 0) {
161 
162  int bit_count = 0;
163  for (int i = 0; i < num_in_fields; ++i) {
164  buf_set_buf(r, bit_count, in_fields[i].in_value, 0, in_fields[i].num_bits);
165  bit_count += in_fields[i].num_bits;
166  }
167  }
168 
169  return ERROR_OK;
170 }
171 
172 static int esirisc_jtag_check_status(struct esirisc_jtag *jtag_info)
173 {
174  uint8_t eid = esirisc_jtag_get_eid(jtag_info);
175  if (eid != EID_NONE) {
176  LOG_ERROR("esirisc_jtag: bad status: 0x%02" PRIx8 " (DA: %" PRId32 ", "
177  "S: %" PRId32 ", EID: 0x%02" PRIx8 ")",
178  jtag_info->status, esirisc_jtag_is_debug_active(jtag_info),
179  esirisc_jtag_is_stopped(jtag_info), eid);
180  return ERROR_FAIL;
181  }
182 
183  return ERROR_OK;
184 }
185 
186 static int esirisc_jtag_send_and_recv(struct esirisc_jtag *jtag_info, uint8_t command,
187  int num_out_fields, struct scan_field *out_fields,
188  int num_in_fields, struct scan_field *in_fields)
189 {
190  int retval;
191 
192  jtag_info->status = 0; /* clear status */
193 
194  retval = esirisc_jtag_send(jtag_info, command, num_out_fields, out_fields);
195  if (retval != ERROR_OK) {
196  LOG_ERROR("esirisc_jtag: send failed (command: 0x%02" PRIx8 ")", command);
197  return ERROR_FAIL;
198  }
199 
200  retval = esirisc_jtag_recv(jtag_info, num_in_fields, in_fields);
201  if (retval != ERROR_OK) {
202  LOG_ERROR("esirisc_jtag: recv failed (command: 0x%02" PRIx8 ")", command);
203  return ERROR_FAIL;
204  }
205 
206  return esirisc_jtag_check_status(jtag_info);
207 }
208 
209 /*
210  * Status is automatically updated after each command completes;
211  * these functions make each field available to the caller.
212  */
213 
215 {
216  return !!(jtag_info->status & 1<<7); /* DA */
217 }
218 
219 bool esirisc_jtag_is_stopped(struct esirisc_jtag *jtag_info)
220 {
221  return !!(jtag_info->status & 1<<6); /* S */
222 }
223 
224 uint8_t esirisc_jtag_get_eid(struct esirisc_jtag *jtag_info)
225 {
226  return jtag_info->status & 0x3f; /* EID */
227 }
228 
229 /*
230  * Most commands manipulate target data (eg. memory and registers); each
231  * command returns a status byte that indicates success. Commands must
232  * transmit multibyte values in big-endian order, however response
233  * values are in little-endian order. Target endianness does not have an
234  * effect on this ordering.
235  */
236 
237 int esirisc_jtag_read_byte(struct esirisc_jtag *jtag_info, uint32_t address, uint8_t *data)
238 {
239  struct scan_field out_fields[1];
240  uint8_t a[4];
241 
242  out_fields[0].num_bits = 32;
243  out_fields[0].out_value = a;
244  h_u32_to_be(a, address);
245  out_fields[0].in_value = NULL;
246 
247  struct scan_field in_fields[1];
248  uint8_t d[1];
249 
250  in_fields[0].num_bits = 8;
251  in_fields[0].out_value = NULL;
252  in_fields[0].in_value = d;
253 
254  int retval = esirisc_jtag_send_and_recv(jtag_info, DEBUG_READ_BYTE,
255  ARRAY_SIZE(out_fields), out_fields, ARRAY_SIZE(in_fields), in_fields);
256  if (retval != ERROR_OK)
257  return retval;
258 
259  *data = *d;
260  LOG_DEBUG("address: 0x%" PRIx32 ", data: 0x%" PRIx8, address, *data);
261 
262  return ERROR_OK;
263 }
264 
265 int esirisc_jtag_read_hword(struct esirisc_jtag *jtag_info, uint32_t address, uint16_t *data)
266 {
267  struct scan_field out_fields[1];
268  uint8_t a[4];
269 
270  out_fields[0].num_bits = 32;
271  out_fields[0].out_value = a;
272  h_u32_to_be(a, address);
273  out_fields[0].in_value = NULL;
274 
275  struct scan_field in_fields[1];
276  uint8_t d[2];
277 
278  in_fields[0].num_bits = 16;
279  in_fields[0].out_value = NULL;
280  in_fields[0].in_value = d;
281 
282  int retval = esirisc_jtag_send_and_recv(jtag_info, DEBUG_READ_HWORD,
283  ARRAY_SIZE(out_fields), out_fields, ARRAY_SIZE(in_fields), in_fields);
284  if (retval != ERROR_OK)
285  return retval;
286 
287  *data = le_to_h_u16(d);
288  LOG_DEBUG("address: 0x%" PRIx32 ", data: 0x%" PRIx16, address, *data);
289 
290  return ERROR_OK;
291 }
292 
293 int esirisc_jtag_read_word(struct esirisc_jtag *jtag_info, uint32_t address, uint32_t *data)
294 {
295  struct scan_field out_fields[1];
296  uint8_t a[4];
297 
298  out_fields[0].num_bits = 32;
299  out_fields[0].out_value = a;
300  h_u32_to_be(a, address);
301  out_fields[0].in_value = NULL;
302 
303  struct scan_field in_fields[1];
304  uint8_t d[4];
305 
306  in_fields[0].num_bits = 32;
307  in_fields[0].out_value = NULL;
308  in_fields[0].in_value = d;
309 
310  int retval = esirisc_jtag_send_and_recv(jtag_info, DEBUG_READ_WORD,
311  ARRAY_SIZE(out_fields), out_fields, ARRAY_SIZE(in_fields), in_fields);
312  if (retval != ERROR_OK)
313  return retval;
314 
315  *data = le_to_h_u32(d);
316  LOG_DEBUG("address: 0x%" PRIx32 ", data: 0x%" PRIx32, address, *data);
317 
318  return ERROR_OK;
319 }
320 
321 int esirisc_jtag_write_byte(struct esirisc_jtag *jtag_info, uint32_t address, uint8_t data)
322 {
323  struct scan_field out_fields[2];
324  uint8_t a[4];
325 
326  LOG_DEBUG("address: 0x%" PRIx32 ", data: 0x%" PRIx8, address, data);
327 
328  out_fields[0].num_bits = 32;
329  out_fields[0].out_value = a;
330  h_u32_to_be(a, address);
331  out_fields[0].in_value = NULL;
332 
333  out_fields[1].num_bits = 8;
334  out_fields[1].out_value = &data;
335  out_fields[1].in_value = NULL;
336 
338  ARRAY_SIZE(out_fields), out_fields, 0, NULL);
339 }
340 
341 int esirisc_jtag_write_hword(struct esirisc_jtag *jtag_info, uint32_t address, uint16_t data)
342 {
343  struct scan_field out_fields[2];
344  uint8_t a[4], d[2];
345 
346  LOG_DEBUG("address: 0x%" PRIx32 ", data: 0x%" PRIx16, address, data);
347 
348  out_fields[0].num_bits = 32;
349  out_fields[0].out_value = a;
350  h_u32_to_be(a, address);
351  out_fields[0].in_value = NULL;
352 
353  out_fields[1].num_bits = 16;
354  out_fields[1].out_value = d;
355  h_u16_to_be(d, data);
356  out_fields[1].in_value = NULL;
357 
359  ARRAY_SIZE(out_fields), out_fields, 0, NULL);
360 }
361 
362 int esirisc_jtag_write_word(struct esirisc_jtag *jtag_info, uint32_t address, uint32_t data)
363 {
364  struct scan_field out_fields[2];
365  uint8_t a[4], d[4];
366 
367  LOG_DEBUG("address: 0x%" PRIx32 ", data: 0x%" PRIx32, address, data);
368 
369  out_fields[0].num_bits = 32;
370  out_fields[0].out_value = a;
371  h_u32_to_be(a, address);
372  out_fields[0].in_value = NULL;
373 
374  out_fields[1].num_bits = 32;
375  out_fields[1].out_value = d;
376  h_u32_to_be(d, data);
377  out_fields[1].in_value = NULL;
378 
380  ARRAY_SIZE(out_fields), out_fields, 0, NULL);
381 }
382 
383 int esirisc_jtag_read_reg(struct esirisc_jtag *jtag_info, uint8_t reg, uint32_t *data)
384 {
385  struct scan_field out_fields[1];
386 
387  out_fields[0].num_bits = 8;
388  out_fields[0].out_value = &reg;
389  out_fields[0].in_value = NULL;
390 
391  struct scan_field in_fields[1];
392  uint8_t d[4];
393 
394  in_fields[0].num_bits = 32;
395  in_fields[0].out_value = NULL;
396  in_fields[0].in_value = d;
397 
398  int retval = esirisc_jtag_send_and_recv(jtag_info, DEBUG_READ_REG,
399  ARRAY_SIZE(out_fields), out_fields, ARRAY_SIZE(in_fields), in_fields);
400  if (retval != ERROR_OK)
401  return retval;
402 
403  *data = le_to_h_u32(d);
404  LOG_DEBUG("register: 0x%" PRIx8 ", data: 0x%" PRIx32, reg, *data);
405 
406  return ERROR_OK;
407 }
408 
409 int esirisc_jtag_write_reg(struct esirisc_jtag *jtag_info, uint8_t reg, uint32_t data)
410 {
411  struct scan_field out_fields[2];
412  uint8_t d[4];
413 
414  LOG_DEBUG("register: 0x%" PRIx8 ", data: 0x%" PRIx32, reg, data);
415 
416  out_fields[0].num_bits = 8;
417  out_fields[0].out_value = &reg;
418  out_fields[0].in_value = NULL;
419 
420  out_fields[1].num_bits = 32;
421  out_fields[1].out_value = d;
422  h_u32_to_be(d, data);
423  out_fields[1].in_value = NULL;
424 
426  ARRAY_SIZE(out_fields), out_fields, 0, NULL);
427 }
428 
429 int esirisc_jtag_read_csr(struct esirisc_jtag *jtag_info, uint8_t bank, uint8_t csr, uint32_t *data)
430 {
431  struct scan_field out_fields[1];
432  uint8_t c[2];
433 
434  out_fields[0].num_bits = 16;
435  out_fields[0].out_value = c;
436  h_u16_to_be(c, (csr << 5) | bank);
437  out_fields[0].in_value = NULL;
438 
439  struct scan_field in_fields[1];
440  uint8_t d[4];
441 
442  in_fields[0].num_bits = 32;
443  in_fields[0].out_value = NULL;
444  in_fields[0].in_value = d;
445 
446  int retval = esirisc_jtag_send_and_recv(jtag_info, DEBUG_READ_CSR,
447  ARRAY_SIZE(out_fields), out_fields, ARRAY_SIZE(in_fields), in_fields);
448  if (retval != ERROR_OK)
449  return retval;
450 
451  *data = le_to_h_u32(d);
452  LOG_DEBUG("bank: 0x%" PRIx8 ", csr: 0x%" PRIx8 ", data: 0x%" PRIx32, bank, csr, *data);
453 
454  return ERROR_OK;
455 }
456 
457 int esirisc_jtag_write_csr(struct esirisc_jtag *jtag_info, uint8_t bank, uint8_t csr, uint32_t data)
458 {
459  struct scan_field out_fields[2];
460  uint8_t c[2], d[4];
461 
462  LOG_DEBUG("bank: 0x%" PRIx8 ", csr: 0x%" PRIx8 ", data: 0x%" PRIx32, bank, csr, data);
463 
464  out_fields[0].num_bits = 16;
465  out_fields[0].out_value = c;
466  h_u16_to_be(c, (csr << 5) | bank);
467  out_fields[0].in_value = NULL;
468 
469  out_fields[1].num_bits = 32;
470  out_fields[1].out_value = d;
471  h_u32_to_be(d, data);
472  out_fields[1].in_value = NULL;
473 
475  ARRAY_SIZE(out_fields), out_fields, 0, NULL);
476 }
477 
478 /*
479  * Control commands affect CPU operation; these commands send no data
480  * and return a status byte.
481  */
482 
483 static inline int esirisc_jtag_send_ctrl(struct esirisc_jtag *jtag_info, uint8_t command)
484 {
485  return esirisc_jtag_send_and_recv(jtag_info, command, 0, NULL, 0, NULL);
486 }
487 
489 {
490  return esirisc_jtag_send_ctrl(jtag_info, DEBUG_ENABLE_DEBUG);
491 }
492 
494 {
495  return esirisc_jtag_send_ctrl(jtag_info, DEBUG_DISABLE_DEBUG);
496 }
497 
499 {
500  return esirisc_jtag_send_ctrl(jtag_info, DEBUG_ASSERT_RESET);
501 }
502 
504 {
505  return esirisc_jtag_send_ctrl(jtag_info, DEBUG_DEASSERT_RESET);
506 }
507 
508 int esirisc_jtag_break(struct esirisc_jtag *jtag_info)
509 {
510  return esirisc_jtag_send_ctrl(jtag_info, DEBUG_BREAK);
511 }
512 
513 int esirisc_jtag_continue(struct esirisc_jtag *jtag_info)
514 {
515  return esirisc_jtag_send_ctrl(jtag_info, DEBUG_CONTINUE);
516 }
517 
519 {
520  return esirisc_jtag_send_ctrl(jtag_info, DEBUG_FLUSH_CACHES);
521 }
void * buf_set_buf(const void *_src, unsigned int src_start, void *_dst, unsigned int dst_start, unsigned int len)
Definition: binarybuffer.c:120
Support functions to access arbitrary bits in a byte array.
static uint32_t buf_get_u32(const uint8_t *_buffer, unsigned int first, unsigned int num)
Retrieves num bits from _buffer, starting at the first bit, returning the bits in a 32-bit word.
Definition: binarybuffer.h:104
static void buf_set_u32(uint8_t *_buffer, unsigned int first, unsigned int num, uint32_t value)
Sets num bits in _buffer, starting at the first bit, using the bits in value.
Definition: binarybuffer.h:34
void jtag_scan_field_clone(struct scan_field *dst, const struct scan_field *src)
Copy a struct scan_field for insertion into the queue.
Definition: commands.c:160
void * cmd_queue_alloc(size_t size)
Definition: commands.c:66
uint8_t csr
Definition: esirisc.c:136
uint8_t bank
Definition: esirisc.c:135
int esirisc_jtag_read_hword(struct esirisc_jtag *jtag_info, uint32_t address, uint16_t *data)
Definition: esirisc_jtag.c:265
static int esirisc_jtag_get_padding(void)
Definition: esirisc_jtag.c:44
int esirisc_jtag_read_csr(struct esirisc_jtag *jtag_info, uint8_t bank, uint8_t csr, uint32_t *data)
Definition: esirisc_jtag.c:429
int esirisc_jtag_deassert_reset(struct esirisc_jtag *jtag_info)
Definition: esirisc_jtag.c:503
int esirisc_jtag_read_reg(struct esirisc_jtag *jtag_info, uint8_t reg, uint32_t *data)
Definition: esirisc_jtag.c:383
int esirisc_jtag_read_byte(struct esirisc_jtag *jtag_info, uint32_t address, uint8_t *data)
Definition: esirisc_jtag.c:237
int esirisc_jtag_write_byte(struct esirisc_jtag *jtag_info, uint32_t address, uint8_t data)
Definition: esirisc_jtag.c:321
static int esirisc_jtag_send_and_recv(struct esirisc_jtag *jtag_info, uint8_t command, int num_out_fields, struct scan_field *out_fields, int num_in_fields, struct scan_field *in_fields)
Definition: esirisc_jtag.c:186
int esirisc_jtag_continue(struct esirisc_jtag *jtag_info)
Definition: esirisc_jtag.c:513
uint8_t esirisc_jtag_get_eid(struct esirisc_jtag *jtag_info)
Definition: esirisc_jtag.c:224
static int esirisc_jtag_recv(struct esirisc_jtag *jtag_info, int num_in_fields, struct scan_field *in_fields)
Definition: esirisc_jtag.c:127
int esirisc_jtag_flush_caches(struct esirisc_jtag *jtag_info)
Definition: esirisc_jtag.c:518
static int esirisc_jtag_send(struct esirisc_jtag *jtag_info, uint8_t command, int num_out_fields, struct scan_field *out_fields)
Definition: esirisc_jtag.c:102
bool esirisc_jtag_is_debug_active(struct esirisc_jtag *jtag_info)
Definition: esirisc_jtag.c:214
static void esirisc_jtag_unstuff(uint8_t *data, size_t len)
Definition: esirisc_jtag.c:77
int esirisc_jtag_disable_debug(struct esirisc_jtag *jtag_info)
Definition: esirisc_jtag.c:493
int esirisc_jtag_write_csr(struct esirisc_jtag *jtag_info, uint8_t bank, uint8_t csr, uint32_t data)
Definition: esirisc_jtag.c:457
int esirisc_jtag_write_reg(struct esirisc_jtag *jtag_info, uint8_t reg, uint32_t data)
Definition: esirisc_jtag.c:409
static int esirisc_jtag_count_bits(unsigned int num_fields, struct scan_field *fields)
Definition: esirisc_jtag.c:61
static int esirisc_jtag_check_status(struct esirisc_jtag *jtag_info)
Definition: esirisc_jtag.c:172
int esirisc_jtag_read_word(struct esirisc_jtag *jtag_info, uint32_t address, uint32_t *data)
Definition: esirisc_jtag.c:293
bool esirisc_jtag_is_stopped(struct esirisc_jtag *jtag_info)
Definition: esirisc_jtag.c:219
int esirisc_jtag_assert_reset(struct esirisc_jtag *jtag_info)
Definition: esirisc_jtag.c:498
int esirisc_jtag_write_word(struct esirisc_jtag *jtag_info, uint32_t address, uint32_t data)
Definition: esirisc_jtag.c:362
static int esirisc_jtag_send_ctrl(struct esirisc_jtag *jtag_info, uint8_t command)
Definition: esirisc_jtag.c:483
static void esirisc_jtag_set_instr(struct esirisc_jtag *jtag_info, uint32_t new_instr)
Definition: esirisc_jtag.c:22
int esirisc_jtag_write_hword(struct esirisc_jtag *jtag_info, uint32_t address, uint16_t data)
Definition: esirisc_jtag.c:341
int esirisc_jtag_enable_debug(struct esirisc_jtag *jtag_info)
Definition: esirisc_jtag.c:488
int esirisc_jtag_break(struct esirisc_jtag *jtag_info)
Definition: esirisc_jtag.c:508
#define DEBUG_WRITE_CSR
Definition: esirisc_jtag.h:32
#define DEBUG_WRITE_BYTE
Definition: esirisc_jtag.h:26
#define DEBUG_WRITE_HWORD
Definition: esirisc_jtag.h:27
#define DEBUG_WRITE_WORD
Definition: esirisc_jtag.h:28
#define DEBUG_READ_REG
Definition: esirisc_jtag.h:29
#define DEBUG_ASSERT_RESET
Definition: esirisc_jtag.h:35
#define DEBUG_BREAK
Definition: esirisc_jtag.h:37
#define INSTR_DEBUG
Definition: esirisc_jtag.h:17
#define DEBUG_ENABLE_DEBUG
Definition: esirisc_jtag.h:33
#define DEBUG_DEASSERT_RESET
Definition: esirisc_jtag.h:36
#define STUFF_MARKER
Definition: esirisc_jtag.h:47
#define DEBUG_READ_HWORD
Definition: esirisc_jtag.h:24
#define DEBUG_CONTINUE
Definition: esirisc_jtag.h:38
#define EID_NONE
Definition: esirisc_jtag.h:44
#define DEBUG_DISABLE_DEBUG
Definition: esirisc_jtag.h:34
#define DEBUG_READ_BYTE
Definition: esirisc_jtag.h:23
#define DEBUG_FLUSH_CACHES
Definition: esirisc_jtag.h:39
#define DEBUG_READ_WORD
Definition: esirisc_jtag.h:25
#define DEBUG_READ_CSR
Definition: esirisc_jtag.h:31
#define DEBUG_WRITE_REG
Definition: esirisc_jtag.h:30
int jtag_execute_queue(void)
For software FIFO implementations, the queued commands can be executed during this call or earlier.
Definition: jtag/core.c:1037
struct jtag_tap * jtag_tap_next_enabled(struct jtag_tap *p)
Definition: jtag/core.c:265
void jtag_add_ir_scan(struct jtag_tap *active, struct scan_field *in_fields, tap_state_t state)
Generate an IR SCAN with a list of scan fields with one entry for each enabled TAP.
Definition: jtag/core.c:374
void jtag_add_dr_scan(struct jtag_tap *active, int in_num_fields, const struct scan_field *in_fields, tap_state_t state)
Generate a DR SCAN using the fields passed to the function.
Definition: jtag/core.c:451
The JTAG interface can be implemented with a software or hardware fifo.
@ TAP_IDLE
Definition: jtag.h:53
#define ERROR_FAIL
Definition: log.h:170
#define LOG_ERROR(expr ...)
Definition: log.h:132
#define LOG_DEBUG(expr ...)
Definition: log.h:109
#define ERROR_OK
Definition: log.h:164
struct jtag_tap * tap
Definition: esirisc_jtag.h:51
uint8_t status
Definition: esirisc_jtag.h:52
Definition: jtag.h:101
uint8_t * cur_instr
current instruction
Definition: jtag.h:132
unsigned int ir_length
size of instruction register
Definition: jtag.h:110
Definition: register.h:111
This structure defines a single scan field in the scan.
Definition: jtag.h:87
uint8_t * in_value
A pointer to a 32-bit memory location for data scanned out.
Definition: jtag.h:93
const uint8_t * out_value
A pointer to value to be scanned into the device.
Definition: jtag.h:91
unsigned int num_bits
The number of bits this field specifies.
Definition: jtag.h:89
static void h_u32_to_be(uint8_t *buf, uint32_t val)
Definition: types.h:186
static void h_u16_to_be(uint8_t *buf, uint16_t val)
Definition: types.h:214
static uint16_t le_to_h_u16(const uint8_t *buf)
Definition: types.h:122
#define ARRAY_SIZE(x)
Compute the number of elements of a variable length array.
Definition: types.h:57
#define DIV_ROUND_UP(m, n)
Rounds m up to the nearest multiple of n using division.
Definition: types.h:79
static uint32_t le_to_h_u32(const uint8_t *buf)
Definition: types.h:112
#define NULL
Definition: usb.h:16