OpenOCD
esirisc_trace.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  ***************************************************************************/
7 
8 #ifdef HAVE_CONFIG_H
9 #include "config.h"
10 #endif
11 
12 #include <helper/binarybuffer.h>
13 #include <helper/command.h>
14 #include <helper/fileio.h>
15 #include <helper/log.h>
16 #include <helper/types.h>
17 #include <target/target.h>
18 
19 #include "esirisc.h"
20 
21 #define BIT_MASK(x) ((1 << (x)) - 1)
22 
23 /* Control Fields */
24 #define CONTROL_ST (1<<0) /* Start */
25 #define CONTROL_SP (1<<1) /* Stop */
26 #define CONTROL_W (1<<2) /* Wrap */
27 #define CONTROL_FC (1<<3) /* Flow Control */
28 #define CONTROL_FMT(x) (((x) << 4) & 0x30) /* Format */
29 #define CONTROL_PCB(x) (((x) << 10) & 0x7c00) /* PC Bits */
30 
31 /* Status Fields */
32 #define STATUS_T (1<<0) /* Trace Started */
33 #define STATUS_TD (1<<1) /* Trace Disabled */
34 #define STATUS_W (1<<2) /* Wrapped */
35 #define STATUS_O (1<<3) /* Overflow */
36 
37 /* Trigger Fields */
38 #define TRIGGER_TST(x) (((x) << 0) & 0xf) /* Trigger Start */
39 #define TRIGGER_DST (1<<7) /* Delay Start */
40 #define TRIGGER_TSP(x) (((x) << 8) & 0xf00) /* Trigger Stop */
41 #define TRIGGER_DSP (1<<15) /* Delay Start */
42 
43 static const char * const esirisc_trace_delay_strings[] = {
44  "none", "start", "stop", "both",
45 };
46 
47 static const char * const esirisc_trace_format_strings[] = {
48  "full", "branch", "icache",
49 };
50 
51 static const char * const esirisc_trace_id_strings[] = {
52  "sequential instruction",
53  "pipeline stall",
54  "direct branch",
55  "extended ID",
56 };
57 
58 static const char * const esirisc_trace_ext_id_strings[] = {
59  "", /* unused */
60  "exception",
61  "eret",
62  "stop instruction",
63  "wait instruction",
64  "multicycle instruction",
65  "count",
66  "initial",
67  "indirect branch",
68  "end of trace",
69  "final",
70 };
71 
72 static const char * const esirisc_trace_trigger_strings[] = {
73  "none", "pc", "load", "store", "exception", "eret", "wait", "stop",
74  "high", "low", /* start only */
75 };
76 
78 {
79  struct esirisc_common *esirisc = target_to_esirisc(target);
80  struct esirisc_jtag *jtag_info = &esirisc->jtag_info;
81  int retval;
82 
83  if (target->state != TARGET_HALTED)
85 
86  retval = esirisc_jtag_write_csr(jtag_info, CSR_TRACE, CSR_TRACE_STATUS, ~0);
87  if (retval != ERROR_OK) {
88  LOG_TARGET_ERROR(target, "failed to write Trace CSR: Status");
89  return retval;
90  }
91 
92  return ERROR_OK;
93 }
94 
95 static int esirisc_trace_get_status(struct target *target, uint32_t *status)
96 {
97  struct esirisc_common *esirisc = target_to_esirisc(target);
98  struct esirisc_jtag *jtag_info = &esirisc->jtag_info;
99 
100  if (target->state != TARGET_HALTED)
102 
103  int retval = esirisc_jtag_read_csr(jtag_info, CSR_TRACE, CSR_TRACE_STATUS, status);
104  if (retval != ERROR_OK) {
105  LOG_TARGET_ERROR(target, "failed to read Trace CSR: Status");
106  return retval;
107  }
108 
109  return ERROR_OK;
110 }
111 
112 static int esirisc_trace_start(struct target *target)
113 {
114  struct esirisc_common *esirisc = target_to_esirisc(target);
115  struct esirisc_jtag *jtag_info = &esirisc->jtag_info;
116  uint32_t control;
117  int retval;
118 
119  if (target->state != TARGET_HALTED)
121 
122  retval = esirisc_jtag_read_csr(jtag_info, CSR_TRACE, CSR_TRACE_CONTROL, &control);
123  if (retval != ERROR_OK) {
124  LOG_TARGET_ERROR(target, "failed to read Trace CSR: Control");
125  return retval;
126  }
127 
128  control |= CONTROL_ST;
129 
130  retval = esirisc_jtag_write_csr(jtag_info, CSR_TRACE, CSR_TRACE_CONTROL, control);
131  if (retval != ERROR_OK) {
132  LOG_TARGET_ERROR(target, "failed to write Trace CSR: Control");
133  return retval;
134  }
135 
136  return ERROR_OK;
137 }
138 
139 static int esirisc_trace_stop(struct target *target)
140 {
141  struct esirisc_common *esirisc = target_to_esirisc(target);
142  struct esirisc_jtag *jtag_info = &esirisc->jtag_info;
143  uint32_t control;
144  int retval;
145 
146  if (target->state != TARGET_HALTED)
148 
149  retval = esirisc_jtag_read_csr(jtag_info, CSR_TRACE, CSR_TRACE_CONTROL, &control);
150  if (retval != ERROR_OK) {
151  LOG_TARGET_ERROR(target, "failed to read Trace CSR: Control");
152  return retval;
153  }
154 
155  control |= CONTROL_SP;
156 
157  retval = esirisc_jtag_write_csr(jtag_info, CSR_TRACE, CSR_TRACE_CONTROL, control);
158  if (retval != ERROR_OK) {
159  LOG_TARGET_ERROR(target, "failed to write Trace CSR: Control");
160  return retval;
161  }
162 
163  return ERROR_OK;
164 }
165 
166 static int esirisc_trace_init(struct target *target)
167 {
168  struct esirisc_common *esirisc = target_to_esirisc(target);
169  struct esirisc_jtag *jtag_info = &esirisc->jtag_info;
170  struct esirisc_trace *trace_info = &esirisc->trace_info;
171  uint32_t control, trigger;
172  int retval;
173 
174  if (target->state != TARGET_HALTED)
176 
177  /* stop if running and clear status */
178  retval = esirisc_trace_stop(target);
179  if (retval != ERROR_OK)
180  return retval;
181 
183  if (retval != ERROR_OK)
184  return retval;
185 
186  /* initialize Control CSR */
187  control = CONTROL_FMT(trace_info->format)
188  | CONTROL_PCB(trace_info->pc_bits);
189 
190  if (trace_info->buffer_wrap)
191  control |= CONTROL_W;
192 
193  if (trace_info->flow_control)
194  control |= CONTROL_FC;
195 
196  retval = esirisc_jtag_write_csr(jtag_info, CSR_TRACE, CSR_TRACE_CONTROL, control);
197  if (retval != ERROR_OK) {
198  LOG_TARGET_ERROR(target, "failed to write Trace CSR: Control");
199  return retval;
200  }
201 
202  /* initialize buffer CSRs */
204  trace_info->buffer_start);
205  if (retval != ERROR_OK) {
206  LOG_TARGET_ERROR(target, "failed to write Trace CSR: BufferStart");
207  return retval;
208  }
209 
211  trace_info->buffer_end);
212  if (retval != ERROR_OK) {
213  LOG_TARGET_ERROR(target, "failed to write Trace CSR: BufferEnd");
214  return retval;
215  }
216 
217  /*
218  * The BufferCurrent CSR must be initialized to the same value as
219  * BufferStart before tracing can be enabled:
220  */
222  trace_info->buffer_start);
223  if (retval != ERROR_OK) {
224  LOG_TARGET_ERROR(target, "failed to write Trace CSR: BufferCurrent");
225  return retval;
226  }
227 
228  /* initialize Trigger CSR */
229  trigger = TRIGGER_TST(trace_info->start_trigger)
230  | TRIGGER_TSP(trace_info->stop_trigger);
231 
232  if (trace_info->delay == ESIRISC_TRACE_DELAY_START
233  || trace_info->delay == ESIRISC_TRACE_DELAY_BOTH) {
234  trigger |= TRIGGER_DST;
235  }
236 
237  if (trace_info->delay == ESIRISC_TRACE_DELAY_STOP
238  || trace_info->delay == ESIRISC_TRACE_DELAY_BOTH) {
239  trigger |= TRIGGER_DSP;
240  }
241 
243  if (retval != ERROR_OK) {
244  LOG_TARGET_ERROR(target, "failed to write Trace CSR: Trigger");
245  return retval;
246  }
247 
248  /* initialize StartData/StartMask CSRs */
250  trace_info->start_data);
251  if (retval != ERROR_OK) {
252  LOG_TARGET_ERROR(target, "failed to write Trace CSR: StartData");
253  return retval;
254  }
255 
257  trace_info->start_mask);
258  if (retval != ERROR_OK) {
259  LOG_TARGET_ERROR(target, "failed to write Trace CSR: StartMask");
260  return retval;
261  }
262 
263  /* initialize StopData/StopMask CSRs */
265  trace_info->stop_data);
266  if (retval != ERROR_OK) {
267  LOG_TARGET_ERROR(target, "failed to write Trace CSR: StopData");
268  return retval;
269  }
270 
272  trace_info->stop_mask);
273  if (retval != ERROR_OK) {
274  LOG_TARGET_ERROR(target, "failed to write Trace CSR: StopMask");
275  return retval;
276  }
277 
278  /* initialize Delay CSR */
279  retval = esirisc_jtag_write_csr(jtag_info, CSR_TRACE, CSR_TRACE_DELAY,
280  trace_info->delay_cycles);
281  if (retval != ERROR_OK) {
282  LOG_TARGET_ERROR(target, "failed to write Trace CSR: Delay");
283  return retval;
284  }
285 
286  return ERROR_OK;
287 }
288 
289 static int esirisc_trace_buf_get_u32(uint8_t *buffer, uint32_t size,
290  unsigned int *pos, unsigned int count, uint32_t *value)
291 {
292  const unsigned int num_bits = size * 8;
293 
294  if (*pos+count > num_bits)
295  return ERROR_FAIL;
296 
297  *value = buf_get_u32(buffer, *pos, count);
298  *pos += count;
299 
300  return ERROR_OK;
301 }
302 
303 static int esirisc_trace_buf_get_pc(struct target *target, uint8_t *buffer, uint32_t size,
304  unsigned int *pos, uint32_t *value)
305 {
306  struct esirisc_common *esirisc = target_to_esirisc(target);
307  struct esirisc_trace *trace_info = &esirisc->trace_info;
308  int retval;
309 
310  retval = esirisc_trace_buf_get_u32(buffer, size, pos, trace_info->pc_bits, value);
311  if (retval != ERROR_OK)
312  return retval;
313 
314  *value <<= esirisc->num_bits - trace_info->pc_bits;
315 
316  return ERROR_OK;
317 }
318 
320  uint8_t *buffer)
321 {
322  int retval;
323 
324  if (target->state != TARGET_HALTED)
326 
327  retval = target_read_memory(target, address, 1, size, buffer);
328  if (retval != ERROR_OK) {
329  LOG_TARGET_ERROR(target, "failed to read trace data");
330  return retval;
331  }
332 
333  return ERROR_OK;
334 }
335 
336 static int esirisc_trace_read_buffer(struct target *target, uint8_t *buffer)
337 {
338  struct esirisc_common *esirisc = target_to_esirisc(target);
339  struct esirisc_jtag *jtag_info = &esirisc->jtag_info;
340  struct esirisc_trace *trace_info = &esirisc->trace_info;
341  uint32_t buffer_cur, status;
342  int retval;
343 
344  if (target->state != TARGET_HALTED)
346 
347  retval = esirisc_jtag_read_csr(jtag_info, CSR_TRACE, CSR_TRACE_BUFFER_CUR, &buffer_cur);
348  if (retval != ERROR_OK) {
349  LOG_TARGET_ERROR(target, "failed to read Trace CSR: BufferCurrent");
350  return retval;
351  }
352 
353  /*
354  * If the buffer has wrapped, the BufferCurrent CSR indicates the
355  * next address to be written (ie. the start address). These bytes
356  * must be dumped first to maintain coherency when analyzing
357  * captured data.
358  */
360  if (retval != ERROR_OK)
361  return retval;
362 
363  if (status & STATUS_W) {
364  uint32_t size = trace_info->buffer_end - buffer_cur;
365 
366  retval = esirisc_trace_read_memory(target, buffer_cur, size, buffer);
367  if (retval != ERROR_OK)
368  return retval;
369 
370  buffer += size;
371  }
372 
373  return esirisc_trace_read_memory(target, trace_info->buffer_start,
374  buffer_cur - trace_info->buffer_start, buffer);
375 }
376 
377 static int esirisc_trace_analyze_full(struct command_invocation *cmd, uint8_t *buffer, uint32_t size)
378 {
379  struct target *target = get_current_target(cmd->ctx);
380  const uint32_t num_bits = size * 8;
381  int retval;
382 
383  unsigned int pos = 0;
384  while (pos < num_bits) {
385  uint32_t id;
386 
387  retval = esirisc_trace_buf_get_u32(buffer, size, &pos, 2, &id);
388  if (retval != ERROR_OK)
389  goto fail;
390 
391  switch (id) {
396  break;
397 
399  uint32_t ext_id;
400 
401  retval = esirisc_trace_buf_get_u32(buffer, size, &pos, 4, &ext_id);
402  if (retval != ERROR_OK)
403  goto fail;
404 
405  switch (ext_id) {
410  break;
411 
416  uint32_t pc;
417 
418  retval = esirisc_trace_buf_get_pc(target, buffer, size, &pos, &pc);
419  if (retval != ERROR_OK)
420  goto fail;
421 
422  command_print(cmd, "%s PC: 0x%" PRIx32,
423  esirisc_trace_ext_id_strings[ext_id], pc);
424 
425  if (ext_id == ESIRISC_TRACE_EXT_ID_END_PC) {
426  command_print(cmd, "--- end of trace ---");
427  return ERROR_OK;
428  }
429  break;
430  }
431 
433  uint32_t eid, epc;
434 
435  retval = esirisc_trace_buf_get_u32(buffer, size, &pos, 6, &eid);
436  if (retval != ERROR_OK)
437  goto fail;
438 
439  retval = esirisc_trace_buf_get_pc(target, buffer, size, &pos, &epc);
440  if (retval != ERROR_OK)
441  goto fail;
442 
443  command_print(cmd, "%s EID: 0x%" PRIx32 ", EPC: 0x%" PRIx32,
444  esirisc_trace_ext_id_strings[ext_id], eid, epc);
445  break;
446  }
447 
449  uint32_t count;
450 
451  retval = esirisc_trace_buf_get_u32(buffer, size, &pos, 6, &count);
452  if (retval != ERROR_OK)
453  goto fail;
454 
455  command_print(cmd, "repeats %" PRIu32 " %s", count,
456  (count == 1) ? "time" : "times");
457  break;
458  }
459 
461  command_print(cmd, "--- end of trace ---");
462  return ERROR_OK;
463 
464  default:
465  command_print(cmd, "invalid extended trace ID: %" PRIu32, ext_id);
466  return ERROR_FAIL;
467  }
468  break;
469  }
470  default:
471  command_print(cmd, "invalid trace ID: %" PRIu32, id);
472  return ERROR_FAIL;
473  }
474  }
475 
476 fail:
477  command_print(cmd, "trace buffer too small");
478  return ERROR_BUF_TOO_SMALL;
479 }
480 
481 static int esirisc_trace_analyze_simple(struct command_invocation *cmd, uint8_t *buffer, uint32_t size)
482 {
483  struct target *target = get_current_target(cmd->ctx);
484  struct esirisc_common *esirisc = target_to_esirisc(target);
485  struct esirisc_trace *trace_info = &esirisc->trace_info;
486  const uint32_t end_of_trace = BIT_MASK(trace_info->pc_bits) << 1;
487  const uint32_t num_bits = size * 8;
488  int retval;
489 
490  unsigned int pos = 0;
491  while (pos < num_bits) {
492  uint32_t pc;
493 
494  retval = esirisc_trace_buf_get_pc(target, buffer, size, &pos, &pc);
495  if (retval != ERROR_OK)
496  break;
497 
498  if (pc == end_of_trace) {
499  command_print(cmd, "--- end of trace ---");
500  return ERROR_OK;
501  }
502 
503  command_print(cmd, "PC: 0x%" PRIx32, pc);
504  }
505 
506  command_print(cmd, "trace buffer too small");
507  return ERROR_BUF_TOO_SMALL;
508 }
509 
510 static int esirisc_trace_analyze(struct command_invocation *cmd, uint8_t *buffer, uint32_t size)
511 {
512  struct target *target = get_current_target(cmd->ctx);
513  struct esirisc_common *esirisc = target_to_esirisc(target);
514  struct esirisc_trace *trace_info = &esirisc->trace_info;
515 
516  switch (trace_info->format) {
518  command_print(cmd, "--- full pipeline ---");
520 
522  command_print(cmd, "--- branches taken ---");
524 
526  command_print(cmd, "--- icache misses ---");
528 
529  default:
530  command_print(cmd, "invalid trace format: %i", trace_info->format);
531  return ERROR_FAIL;
532  }
533 }
534 
536 {
537  struct target *target = get_current_target(cmd->ctx);
538  struct esirisc_common *esirisc = target_to_esirisc(target);
539  struct esirisc_trace *trace_info = &esirisc->trace_info;
540  uint8_t *buffer;
541  uint32_t size;
542  int retval;
543 
544  size = esirisc_trace_buffer_size(trace_info);
545  buffer = calloc(1, size);
546  if (!buffer) {
547  command_print(cmd, "out of memory");
548  return ERROR_FAIL;
549  }
550 
552  if (retval != ERROR_OK)
553  goto done;
554 
555  retval = esirisc_trace_analyze(cmd, buffer, size);
556 
557 done:
558  free(buffer);
559 
560  return retval;
561 }
562 
564  target_addr_t address, uint32_t size)
565 {
566  struct target *target = get_current_target(cmd->ctx);
567  uint8_t *buffer;
568  int retval;
569 
570  buffer = calloc(1, size);
571  if (!buffer) {
572  command_print(cmd, "out of memory");
573  return ERROR_FAIL;
574  }
575 
577  if (retval != ERROR_OK)
578  goto done;
579 
580  retval = esirisc_trace_analyze(cmd, buffer, size);
581 
582 done:
583  free(buffer);
584 
585  return retval;
586 }
587 
588 static int esirisc_trace_dump(struct command_invocation *cmd, const char *filename,
589  uint8_t *buffer, uint32_t size)
590 {
591  struct fileio *fileio;
592  size_t size_written;
593  int retval;
594 
595  retval = fileio_open(&fileio, filename, FILEIO_WRITE, FILEIO_BINARY);
596  if (retval != ERROR_OK) {
597  command_print(cmd, "could not open dump file: %s", filename);
598  return retval;
599  }
600 
601  retval = fileio_write(fileio, size, buffer, &size_written);
602  if (retval == ERROR_OK)
603  command_print(cmd, "trace data dumped to: %s", filename);
604  else
605  command_print(cmd, "could not write dump file: %s", filename);
606 
608 
609  return retval;
610 }
611 
612 static int esirisc_trace_dump_buffer(struct command_invocation *cmd, const char *filename)
613 {
614  struct target *target = get_current_target(cmd->ctx);
615  struct esirisc_common *esirisc = target_to_esirisc(target);
616  struct esirisc_trace *trace_info = &esirisc->trace_info;
617  uint8_t *buffer;
618  uint32_t size;
619  int retval;
620 
621  size = esirisc_trace_buffer_size(trace_info);
622  buffer = calloc(1, size);
623  if (!buffer) {
624  command_print(cmd, "out of memory");
625  return ERROR_FAIL;
626  }
627 
629  if (retval != ERROR_OK)
630  goto done;
631 
632  retval = esirisc_trace_dump(cmd, filename, buffer, size);
633 
634 done:
635  free(buffer);
636 
637  return retval;
638 }
639 
640 static int esirisc_trace_dump_memory(struct command_invocation *cmd, const char *filename,
641  target_addr_t address, uint32_t size)
642 {
643  struct target *target = get_current_target(cmd->ctx);
644  uint8_t *buffer;
645  int retval;
646 
647  buffer = calloc(1, size);
648  if (!buffer) {
649  command_print(cmd, "out of memory");
650  return ERROR_FAIL;
651  }
652 
654  if (retval != ERROR_OK)
655  goto done;
656 
657  retval = esirisc_trace_dump(cmd, filename, buffer, size);
658 
659 done:
660  free(buffer);
661 
662  return retval;
663 }
664 
665 COMMAND_HANDLER(handle_esirisc_trace_init_command)
666 {
668  struct esirisc_common *esirisc = target_to_esirisc(target);
669 
670  if (!esirisc->has_trace) {
671  command_print(CMD, "target does not support trace");
672  return ERROR_FAIL;
673  }
674 
675  int retval = esirisc_trace_init(target);
676  if (retval == ERROR_OK)
677  command_print(CMD, "trace initialized");
678 
679  return retval;
680 }
681 
682 COMMAND_HANDLER(handle_esirisc_trace_info_command)
683 {
685  struct esirisc_common *esirisc = target_to_esirisc(target);
686  struct esirisc_trace *trace_info = &esirisc->trace_info;
687 
688  if (!esirisc->has_trace) {
689  command_print(CMD, "target does not support trace");
690  return ERROR_FAIL;
691  }
692 
693  if (esirisc_trace_is_fifo(trace_info))
694  command_print(CMD, "trace FIFO address: 0x%" TARGET_PRIxADDR,
695  trace_info->buffer_start);
696  else {
697  command_print(CMD, "trace buffer start: 0x%" TARGET_PRIxADDR,
698  trace_info->buffer_start);
699  command_print(CMD, "trace buffer end: 0x%" TARGET_PRIxADDR,
700  trace_info->buffer_end);
701  command_print(CMD, "trace buffer will %swrap",
702  trace_info->buffer_wrap ? "" : "not ");
703  }
704 
705  command_print(CMD, "flow control: %s",
706  trace_info->flow_control ? "enabled" : "disabled");
707 
708  command_print(CMD, "trace format: %s",
709  esirisc_trace_format_strings[trace_info->format]);
710  command_print(CMD, "number of PC bits: %i", trace_info->pc_bits);
711 
712  command_print(CMD, "start trigger: %s",
714  command_print(CMD, "start data: 0x%" PRIx32, trace_info->start_data);
715  command_print(CMD, "start mask: 0x%" PRIx32, trace_info->start_mask);
716 
717  command_print(CMD, "stop trigger: %s",
719  command_print(CMD, "stop data: 0x%" PRIx32, trace_info->stop_data);
720  command_print(CMD, "stop mask: 0x%" PRIx32, trace_info->stop_mask);
721 
722  command_print(CMD, "trigger delay: %s",
723  esirisc_trace_delay_strings[trace_info->delay]);
724  command_print(CMD, "trigger delay cycles: %" PRIu32, trace_info->delay_cycles);
725 
726  return ERROR_OK;
727 }
728 
729 COMMAND_HANDLER(handle_esirisc_trace_status_command)
730 {
732  struct esirisc_common *esirisc = target_to_esirisc(target);
733  uint32_t status;
734 
735  if (!esirisc->has_trace) {
736  command_print(CMD, "target does not support trace");
737  return ERROR_FAIL;
738  }
739 
740  int retval = esirisc_trace_get_status(target, &status);
741  if (retval != ERROR_OK)
742  return retval;
743 
744  command_print(CMD, "trace is %s%s%s%s",
745  (status & STATUS_T) ? "started" : "stopped",
746  (status & STATUS_TD) ? ", disabled" : "",
747  (status & STATUS_W) ? ", wrapped" : "",
748  (status & STATUS_O) ? ", overflowed" : "");
749 
750  return ERROR_OK;
751 }
752 
753 COMMAND_HANDLER(handle_esirisc_trace_start_command)
754 {
756  struct esirisc_common *esirisc = target_to_esirisc(target);
757 
758  if (!esirisc->has_trace) {
759  command_print(CMD, "target does not support trace");
760  return ERROR_FAIL;
761  }
762 
763  int retval = esirisc_trace_start(target);
764  if (retval == ERROR_OK)
765  command_print(CMD, "trace started");
766 
767  return retval;
768 }
769 
770 COMMAND_HANDLER(handle_esirisc_trace_stop_command)
771 {
773  struct esirisc_common *esirisc = target_to_esirisc(target);
774 
775  if (!esirisc->has_trace) {
776  command_print(CMD, "target does not support trace");
777  return ERROR_FAIL;
778  }
779 
780  int retval = esirisc_trace_stop(target);
781  if (retval == ERROR_OK)
782  command_print(CMD, "trace stopped");
783 
784  return retval;
785 }
786 
787 COMMAND_HANDLER(handle_esirisc_trace_analyze_command)
788 {
790  struct esirisc_common *esirisc = target_to_esirisc(target);
791  struct esirisc_trace *trace_info = &esirisc->trace_info;
793  uint32_t size;
794 
795  if (!esirisc->has_trace) {
796  command_print(CMD, "target does not support trace");
797  return ERROR_FAIL;
798  }
799 
800  if (CMD_ARGC != 0 && CMD_ARGC != 2)
802 
803  if (CMD_ARGC == 0) {
804  /*
805  * Use of the Trace FIFO typically involves DMA to a peripheral
806  * (eg. SPI) or a separately managed buffer in memory, neither
807  * of which may be under our control. If the destination address
808  * and size are known in the latter case, they may be specified
809  * as arguments as a workaround.
810  */
811  if (esirisc_trace_is_fifo(trace_info)) {
812  command_print(CMD, "analyze from FIFO not supported");
813  return ERROR_FAIL;
814  }
815 
817  } else {
820 
822  }
823 }
824 
825 COMMAND_HANDLER(handle_esirisc_trace_dump_command)
826 {
828  struct esirisc_common *esirisc = target_to_esirisc(target);
829  struct esirisc_trace *trace_info = &esirisc->trace_info;
831  uint32_t size;
832 
833  if (!esirisc->has_trace) {
834  command_print(CMD, "target does not support trace");
835  return ERROR_FAIL;
836  }
837 
838  if (CMD_ARGC != 1 && CMD_ARGC != 3)
840 
841  if (CMD_ARGC == 1) {
842  /* also see: handle_esirisc_trace_analyze_command() */
843  if (esirisc_trace_is_fifo(trace_info)) {
844  command_print(CMD, "dump from FIFO not supported");
845  return ERROR_FAIL;
846  }
847 
849  } else {
852 
854  }
855 }
856 
857 COMMAND_HANDLER(handle_esirisc_trace_buffer_command)
858 {
860  struct esirisc_common *esirisc = target_to_esirisc(target);
861  struct esirisc_trace *trace_info = &esirisc->trace_info;
862  uint32_t size;
863 
864  if (CMD_ARGC < 2 || CMD_ARGC > 3)
866 
869 
870  trace_info->buffer_end = trace_info->buffer_start + size;
871 
872  if (CMD_ARGC == 3) {
873  if (strcmp("wrap", CMD_ARGV[2]) == 0)
874  trace_info->buffer_wrap = true;
875  else
877  }
878 
879  return ERROR_OK;
880 }
881 
882 COMMAND_HANDLER(handle_esirisc_trace_fifo_command)
883 {
885  struct esirisc_common *esirisc = target_to_esirisc(target);
886  struct esirisc_trace *trace_info = &esirisc->trace_info;
887 
888  if (CMD_ARGC != 1)
890 
892 
893  /* FIFOs have the same start and end address */
894  trace_info->buffer_end = trace_info->buffer_start;
895  trace_info->buffer_wrap = true;
896 
897  return ERROR_OK;
898 }
899 
900 COMMAND_HANDLER(handle_esirisc_trace_flow_control_command)
901 {
903  struct esirisc_common *esirisc = target_to_esirisc(target);
904  struct esirisc_trace *trace_info = &esirisc->trace_info;
905 
906  if (CMD_ARGC != 1)
908 
909  if (strcmp(CMD_ARGV[0], "enable") == 0)
910  trace_info->flow_control = true;
911  else if (strcmp(CMD_ARGV[0], "disable") == 0)
912  trace_info->flow_control = false;
913  else
915 
916  return ERROR_OK;
917 }
918 
919 COMMAND_HANDLER(handle_esirisc_trace_format_command)
920 {
922  struct esirisc_common *esirisc = target_to_esirisc(target);
923  struct esirisc_trace *trace_info = &esirisc->trace_info;
924  int pc_bits;
925 
926  if (CMD_ARGC != 2)
928 
929  if (strcmp(CMD_ARGV[0], "full") == 0)
930  trace_info->format = ESIRISC_TRACE_FORMAT_FULL;
931  else if (strcmp(CMD_ARGV[0], "branch") == 0)
932  trace_info->format = ESIRISC_TRACE_FORMAT_BRANCH;
933  else if (strcmp(CMD_ARGV[0], "icache") == 0)
934  trace_info->format = ESIRISC_TRACE_FORMAT_ICACHE;
935  else
937 
939 
940  if (pc_bits < 1 || pc_bits > 31) {
941  command_print(CMD, "invalid pc_bits: %i; must be 1..31", pc_bits);
943  }
944 
945  trace_info->pc_bits = pc_bits;
946 
947  return ERROR_OK;
948 }
949 
950 COMMAND_HANDLER(handle_esirisc_trace_trigger_start_command)
951 {
953  struct esirisc_common *esirisc = target_to_esirisc(target);
954  struct esirisc_trace *trace_info = &esirisc->trace_info;
955 
956  if (CMD_ARGC != 1 && CMD_ARGC != 3)
958 
959  if (strcmp(CMD_ARGV[0], "none") == 0)
961  else if (strcmp(CMD_ARGV[0], "pc") == 0)
963  else if (strcmp(CMD_ARGV[0], "load") == 0)
965  else if (strcmp(CMD_ARGV[0], "store") == 0)
967  else if (strcmp(CMD_ARGV[0], "exception") == 0)
969  else if (strcmp(CMD_ARGV[0], "eret") == 0)
971  else if (strcmp(CMD_ARGV[0], "wait") == 0)
973  else if (strcmp(CMD_ARGV[0], "stop") == 0)
975  else if (strcmp(CMD_ARGV[0], "high") == 0)
977  else if (strcmp(CMD_ARGV[0], "low") == 0)
979  else
981 
982  if (CMD_ARGC == 3) {
983  COMMAND_PARSE_NUMBER(u32, CMD_ARGV[1], trace_info->start_data);
984  COMMAND_PARSE_NUMBER(u32, CMD_ARGV[2], trace_info->start_mask);
985  } else {
986  trace_info->start_data = 0;
987  trace_info->start_mask = 0;
988  }
989 
990  return ERROR_OK;
991 }
992 
993 COMMAND_HANDLER(handle_esirisc_trace_trigger_stop_command)
994 {
996  struct esirisc_common *esirisc = target_to_esirisc(target);
997  struct esirisc_trace *trace_info = &esirisc->trace_info;
998 
999  if (CMD_ARGC != 1 && CMD_ARGC != 3)
1001 
1002  if (strcmp(CMD_ARGV[0], "none") == 0)
1004  else if (strcmp(CMD_ARGV[0], "pc") == 0)
1005  trace_info->stop_trigger = ESIRISC_TRACE_TRIGGER_PC;
1006  else if (strcmp(CMD_ARGV[0], "load") == 0)
1008  else if (strcmp(CMD_ARGV[0], "store") == 0)
1010  else if (strcmp(CMD_ARGV[0], "exception") == 0)
1012  else if (strcmp(CMD_ARGV[0], "eret") == 0)
1014  else if (strcmp(CMD_ARGV[0], "wait") == 0)
1016  else if (strcmp(CMD_ARGV[0], "stop") == 0)
1018  else
1020 
1021  if (CMD_ARGC == 3) {
1022  COMMAND_PARSE_NUMBER(u32, CMD_ARGV[1], trace_info->stop_data);
1023  COMMAND_PARSE_NUMBER(u32, CMD_ARGV[2], trace_info->stop_mask);
1024  } else {
1025  trace_info->stop_data = 0;
1026  trace_info->stop_mask = 0;
1027  }
1028 
1029  return ERROR_OK;
1030 }
1031 
1032 COMMAND_HANDLER(handle_esirisc_trace_trigger_delay_command)
1033 {
1035  struct esirisc_common *esirisc = target_to_esirisc(target);
1036  struct esirisc_trace *trace_info = &esirisc->trace_info;
1037 
1038  if (CMD_ARGC < 1 || CMD_ARGC > 2)
1040 
1041  if (strcmp(CMD_ARGV[0], "none") == 0)
1042  trace_info->delay = ESIRISC_TRACE_DELAY_NONE;
1043  else if (strcmp(CMD_ARGV[0], "start") == 0)
1044  trace_info->delay = ESIRISC_TRACE_DELAY_START;
1045  else if (strcmp(CMD_ARGV[0], "stop") == 0)
1046  trace_info->delay = ESIRISC_TRACE_DELAY_STOP;
1047  else if (strcmp(CMD_ARGV[0], "both") == 0)
1048  trace_info->delay = ESIRISC_TRACE_DELAY_BOTH;
1049  else
1051 
1052  if (trace_info->delay == ESIRISC_TRACE_DELAY_NONE)
1053  trace_info->delay_cycles = 0;
1054  else {
1055  if (CMD_ARGC != 2)
1057 
1058  COMMAND_PARSE_NUMBER(u32, CMD_ARGV[1], trace_info->delay_cycles);
1059  }
1060 
1061  return ERROR_OK;
1062 }
1063 
1065  {
1066  .name = "init",
1067  .handler = handle_esirisc_trace_init_command,
1068  .mode = COMMAND_EXEC,
1069  .help = "initialize trace collection",
1070  .usage = "",
1071  },
1072  {
1073  .name = "info",
1074  .handler = handle_esirisc_trace_info_command,
1075  .mode = COMMAND_EXEC,
1076  .help = "display trace configuration",
1077  .usage = "",
1078  },
1079  {
1080  .name = "status",
1081  .handler = handle_esirisc_trace_status_command,
1082  .mode = COMMAND_EXEC,
1083  .help = "display trace collection status",
1084  .usage = "",
1085  },
1086  {
1087  .name = "start",
1088  .handler = handle_esirisc_trace_start_command,
1089  .mode = COMMAND_EXEC,
1090  .help = "start trace collection",
1091  .usage = "",
1092  },
1093  {
1094  .name = "stop",
1095  .handler = handle_esirisc_trace_stop_command,
1096  .mode = COMMAND_EXEC,
1097  .help = "stop trace collection",
1098  .usage = "",
1099  },
1100  {
1101  .name = "analyze",
1102  .handler = handle_esirisc_trace_analyze_command,
1103  .mode = COMMAND_EXEC,
1104  .usage = "[address size]",
1105  .help = "analyze collected trace data",
1106  },
1107  {
1108  .name = "dump",
1109  .handler = handle_esirisc_trace_dump_command,
1110  .mode = COMMAND_EXEC,
1111  .help = "dump collected trace data to file",
1112  .usage = "[address size] filename",
1113  },
1115 };
1116 
1118  {
1119  .name = "start",
1120  .handler = handle_esirisc_trace_trigger_start_command,
1121  .mode = COMMAND_ANY,
1122  .help = "configure trigger start condition",
1123  .usage = "('none'|'pc'|'load'|'store'|'exception'|'eret'|'wait'|'stop'|'high'|'low')"
1124  " [start_data start_mask]",
1125  },
1126  {
1127  .name = "stop",
1128  .handler = handle_esirisc_trace_trigger_stop_command,
1129  .mode = COMMAND_ANY,
1130  .help = "configure trigger stop condition",
1131  .usage = "('none'|'pc'|'load'|'store'|'exception'|'eret'|'wait'|'stop')"
1132  " [stop_data stop_mask]",
1133  },
1134  {
1135  .name = "delay",
1136  .handler = handle_esirisc_trace_trigger_delay_command,
1137  .mode = COMMAND_ANY,
1138  .help = "configure trigger start/stop delay in clock cycles",
1139  .usage = "('none'|'start'|'stop'|'both') [cycles]",
1140  },
1142 };
1143 
1145  {
1146  .name = "buffer",
1147  .handler = handle_esirisc_trace_buffer_command,
1148  .mode = COMMAND_ANY,
1149  .help = "configure trace buffer",
1150  .usage = "address size ['wrap']",
1151  },
1152  {
1153  .name = "fifo",
1154  .handler = handle_esirisc_trace_fifo_command,
1155  .mode = COMMAND_ANY,
1156  .help = "configure trace FIFO",
1157  .usage = "address",
1158  },
1159  {
1160  .name = "flow_control",
1161  .handler = handle_esirisc_trace_flow_control_command,
1162  .mode = COMMAND_ANY,
1163  .help = "enable or disable stalling CPU to collect trace data",
1164  .usage = "('enable'|'disable')",
1165  },
1166  {
1167  .name = "format",
1168  .handler = handle_esirisc_trace_format_command,
1169  .mode = COMMAND_ANY,
1170  .help = "configure trace format",
1171  .usage = "('full'|'branch'|'icache') pc_bits",
1172  },
1173  {
1174  .name = "trigger",
1175  .mode = COMMAND_ANY,
1176  .help = "eSi-Trace trigger command group",
1177  .usage = "",
1179  },
1180  {
1182  },
1184 };
1185 
1187  {
1188  .name = "trace",
1189  .mode = COMMAND_ANY,
1190  .help = "eSi-Trace command group",
1191  .usage = "",
1193  },
1195 };
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
void command_print(struct command_invocation *cmd, const char *format,...)
Definition: command.c:371
#define CMD
Use this macro to access the command being handled, rather than accessing the variable directly.
Definition: command.h:141
#define CMD_ARGV
Use this macro to access the arguments for the command being handled, rather than accessing the varia...
Definition: command.h:156
#define COMMAND_PARSE_ADDRESS(in, out)
Definition: command.h:450
#define ERROR_COMMAND_SYNTAX_ERROR
Definition: command.h:400
#define CMD_ARGC
Use this macro to access the number of arguments for the command being handled, rather than accessing...
Definition: command.h:151
#define COMMAND_PARSE_NUMBER(type, in, out)
parses the string in into out as a type, or prints a command error and passes the error code to the c...
Definition: command.h:440
#define CMD_CTX
Use this macro to access the context of the command being handled, rather than accessing the variable...
Definition: command.h:146
#define COMMAND_REGISTRATION_DONE
Use this as the last entry in an array of command_registration records.
Definition: command.h:251
@ COMMAND_ANY
Definition: command.h:42
@ COMMAND_EXEC
Definition: command.h:40
uint64_t buffer
Pointer to data buffer to send over SPI.
Definition: dw-spi-helper.h:0
uint32_t size
Size of dw_spi_transaction::buffer.
Definition: dw-spi-helper.h:4
uint32_t address
Starting address. Sector aligned.
Definition: dw-spi-helper.h:0
static struct esirisc_common * target_to_esirisc(const struct target *target)
Definition: esirisc.h:109
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_write_csr(struct esirisc_jtag *jtag_info, uint8_t bank, uint8_t csr, uint32_t data)
Definition: esirisc_jtag.c:459
#define CSR_TRACE_DELAY
Definition: esirisc_regs.h:171
#define CSR_TRACE_BUFFER_END
Definition: esirisc_regs.h:164
#define CSR_TRACE_START_DATA
Definition: esirisc_regs.h:167
#define CSR_TRACE_TRIGGER
Definition: esirisc_regs.h:166
#define CSR_TRACE_STOP_MASK
Definition: esirisc_regs.h:170
#define CSR_TRACE_START_MASK
Definition: esirisc_regs.h:168
#define CSR_TRACE_STATUS
Definition: esirisc_regs.h:162
#define CSR_TRACE_CONTROL
Definition: esirisc_regs.h:161
#define CSR_TRACE_STOP_DATA
Definition: esirisc_regs.h:169
#define CSR_TRACE
Definition: esirisc_regs.h:110
#define CSR_TRACE_BUFFER_START
Definition: esirisc_regs.h:163
#define CSR_TRACE_BUFFER_CUR
Definition: esirisc_regs.h:165
static int esirisc_trace_get_status(struct target *target, uint32_t *status)
Definition: esirisc_trace.c:95
static const struct command_registration esirisc_trace_trigger_any_command_handlers[]
static const char *const esirisc_trace_delay_strings[]
Definition: esirisc_trace.c:43
#define TRIGGER_TSP(x)
Definition: esirisc_trace.c:40
#define STATUS_O
Definition: esirisc_trace.c:35
static const char *const esirisc_trace_ext_id_strings[]
Definition: esirisc_trace.c:58
#define CONTROL_W
Definition: esirisc_trace.c:26
static int esirisc_trace_stop(struct target *target)
#define CONTROL_FC
Definition: esirisc_trace.c:27
static int esirisc_trace_start(struct target *target)
static int esirisc_trace_buf_get_pc(struct target *target, uint8_t *buffer, uint32_t size, unsigned int *pos, uint32_t *value)
static int esirisc_trace_analyze_simple(struct command_invocation *cmd, uint8_t *buffer, uint32_t size)
static int esirisc_trace_analyze(struct command_invocation *cmd, uint8_t *buffer, uint32_t size)
#define CONTROL_FMT(x)
Definition: esirisc_trace.c:28
static int esirisc_trace_dump_buffer(struct command_invocation *cmd, const char *filename)
#define STATUS_T
Definition: esirisc_trace.c:32
static int esirisc_trace_dump_memory(struct command_invocation *cmd, const char *filename, target_addr_t address, uint32_t size)
const struct command_registration esirisc_trace_command_handlers[]
static const char *const esirisc_trace_id_strings[]
Definition: esirisc_trace.c:51
static int esirisc_trace_analyze_buffer(struct command_invocation *cmd)
static const char *const esirisc_trace_trigger_strings[]
Definition: esirisc_trace.c:72
#define CONTROL_PCB(x)
Definition: esirisc_trace.c:29
#define STATUS_TD
Definition: esirisc_trace.c:33
#define TRIGGER_TST(x)
Definition: esirisc_trace.c:38
#define TRIGGER_DSP
Definition: esirisc_trace.c:41
#define CONTROL_SP
Definition: esirisc_trace.c:25
static int esirisc_trace_analyze_memory(struct command_invocation *cmd, target_addr_t address, uint32_t size)
#define STATUS_W
Definition: esirisc_trace.c:34
static int esirisc_trace_read_memory(struct target *target, target_addr_t address, uint32_t size, uint8_t *buffer)
#define TRIGGER_DST
Definition: esirisc_trace.c:39
static int esirisc_trace_clear_status(struct target *target)
Definition: esirisc_trace.c:77
static int esirisc_trace_analyze_full(struct command_invocation *cmd, uint8_t *buffer, uint32_t size)
static int esirisc_trace_dump(struct command_invocation *cmd, const char *filename, uint8_t *buffer, uint32_t size)
#define BIT_MASK(x)
Definition: esirisc_trace.c:21
static const struct command_registration esirisc_trace_exec_command_handlers[]
static const char *const esirisc_trace_format_strings[]
Definition: esirisc_trace.c:47
static int esirisc_trace_init(struct target *target)
static int esirisc_trace_buf_get_u32(uint8_t *buffer, uint32_t size, unsigned int *pos, unsigned int count, uint32_t *value)
static const struct command_registration esirisc_trace_any_command_handlers[]
static int esirisc_trace_read_buffer(struct target *target, uint8_t *buffer)
COMMAND_HANDLER(handle_esirisc_trace_init_command)
#define CONTROL_ST
Definition: esirisc_trace.c:24
static uint32_t esirisc_trace_buffer_size(struct esirisc_trace *trace_info)
Definition: esirisc_trace.h:84
@ ESIRISC_TRACE_TRIGGER_HIGH
Definition: esirisc_trace.h:57
@ ESIRISC_TRACE_TRIGGER_STORE
Definition: esirisc_trace.h:52
@ ESIRISC_TRACE_TRIGGER_STOP
Definition: esirisc_trace.h:56
@ ESIRISC_TRACE_TRIGGER_NONE
Definition: esirisc_trace.h:49
@ ESIRISC_TRACE_TRIGGER_WAIT
Definition: esirisc_trace.h:55
@ ESIRISC_TRACE_TRIGGER_LOW
Definition: esirisc_trace.h:58
@ ESIRISC_TRACE_TRIGGER_LOAD
Definition: esirisc_trace.h:51
@ ESIRISC_TRACE_TRIGGER_ERET
Definition: esirisc_trace.h:54
@ ESIRISC_TRACE_TRIGGER_PC
Definition: esirisc_trace.h:50
@ ESIRISC_TRACE_TRIGGER_EXCEPTION
Definition: esirisc_trace.h:53
static bool esirisc_trace_is_fifo(struct esirisc_trace *trace_info)
Definition: esirisc_trace.h:89
@ ESIRISC_TRACE_FORMAT_ICACHE
Definition: esirisc_trace.h:25
@ ESIRISC_TRACE_FORMAT_FULL
Definition: esirisc_trace.h:23
@ ESIRISC_TRACE_FORMAT_BRANCH
Definition: esirisc_trace.h:24
@ ESIRISC_TRACE_EXT_ID_WAIT
Definition: esirisc_trace.h:39
@ ESIRISC_TRACE_EXT_ID_MULTICYCLE
Definition: esirisc_trace.h:40
@ ESIRISC_TRACE_EXT_ID_STOP
Definition: esirisc_trace.h:38
@ ESIRISC_TRACE_EXT_ID_END
Definition: esirisc_trace.h:44
@ ESIRISC_TRACE_EXT_ID_END_PC
Definition: esirisc_trace.h:45
@ ESIRISC_TRACE_EXT_ID_INDIRECT
Definition: esirisc_trace.h:43
@ ESIRISC_TRACE_EXT_ID_COUNT
Definition: esirisc_trace.h:41
@ ESIRISC_TRACE_EXT_ID_PC
Definition: esirisc_trace.h:42
@ ESIRISC_TRACE_EXT_ID_ERET
Definition: esirisc_trace.h:37
@ ESIRISC_TRACE_EXT_ID_EXCEPTION
Definition: esirisc_trace.h:36
@ ESIRISC_TRACE_DELAY_NONE
Definition: esirisc_trace.h:16
@ ESIRISC_TRACE_DELAY_START
Definition: esirisc_trace.h:17
@ ESIRISC_TRACE_DELAY_BOTH
Definition: esirisc_trace.h:19
@ ESIRISC_TRACE_DELAY_STOP
Definition: esirisc_trace.h:18
@ ESIRISC_TRACE_ID_EXECUTE
Definition: esirisc_trace.h:29
@ ESIRISC_TRACE_ID_STALL
Definition: esirisc_trace.h:30
@ ESIRISC_TRACE_ID_BRANCH
Definition: esirisc_trace.h:31
@ ESIRISC_TRACE_ID_EXTENDED
Definition: esirisc_trace.h:32
int fileio_write(struct fileio *fileio, size_t size, const void *buffer, size_t *size_written)
int fileio_close(struct fileio *fileio)
int fileio_open(struct fileio **fileio, const char *url, enum fileio_access access_type, enum fileio_type type)
@ FILEIO_WRITE
Definition: helper/fileio.h:29
@ FILEIO_BINARY
Definition: helper/fileio.h:23
#define ERROR_FAIL
Definition: log.h:174
#define ERROR_BUF_TOO_SMALL
Definition: log.h:170
#define LOG_TARGET_ERROR(target, fmt_str,...)
Definition: log.h:162
#define ERROR_OK
Definition: log.h:168
char id[RTT_CB_MAX_ID_LENGTH]
Control block identifier.
Definition: rtt/rtt.c:32
When run_command is called, a new instance will be created on the stack, filled with the proper value...
Definition: command.h:76
const char * name
Definition: command.h:234
const struct command_registration * chain
If non-NULL, the commands in chain will be registered in the same context and scope of this registrat...
Definition: command.h:247
struct esirisc_jtag jtag_info
Definition: esirisc.h:66
bool has_trace
Definition: esirisc.h:82
int num_bits
Definition: esirisc.h:78
struct esirisc_trace trace_info
Definition: esirisc.h:90
uint32_t start_mask
Definition: esirisc_trace.h:72
target_addr_t buffer_end
Definition: esirisc_trace.h:63
enum esirisc_trace_format format
Definition: esirisc_trace.h:67
uint32_t stop_mask
Definition: esirisc_trace.h:76
uint32_t start_data
Definition: esirisc_trace.h:71
enum esirisc_trace_trigger stop_trigger
Definition: esirisc_trace.h:74
uint32_t stop_data
Definition: esirisc_trace.h:75
enum esirisc_trace_trigger start_trigger
Definition: esirisc_trace.h:70
uint32_t delay_cycles
Definition: esirisc_trace.h:79
enum esirisc_trace_delay delay
Definition: esirisc_trace.h:78
target_addr_t buffer_start
Definition: esirisc_trace.h:62
Definition: target.h:119
enum target_state state
Definition: target.h:160
int target_read_memory(struct target *target, target_addr_t address, uint32_t size, uint32_t count, uint8_t *buffer)
Read count items of size bytes from the memory of target at the address given.
Definition: target.c:1247
struct target * get_current_target(struct command_context *cmd_ctx)
Definition: target.c:467
#define ERROR_TARGET_NOT_HALTED
Definition: target.h:786
@ TARGET_HALTED
Definition: target.h:58
uint64_t target_addr_t
Definition: types.h:279
#define TARGET_PRIxADDR
Definition: types.h:284
uint8_t status[4]
Definition: vdebug.c:17
uint8_t cmd
Definition: vdebug.c:1
uint8_t count[4]
Definition: vdebug.c:22