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