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/bits.h>
14 #include <helper/command.h>
15 #include <helper/fileio.h>
16 #include <helper/log.h>
17 #include <helper/types.h>
18 #include <target/target.h>
19 
20 #include "esirisc.h"
21 
22 /* Control Fields */
23 #define CONTROL_ST (1<<0) /* Start */
24 #define CONTROL_SP (1<<1) /* Stop */
25 #define CONTROL_W (1<<2) /* Wrap */
26 #define CONTROL_FC (1<<3) /* Flow Control */
27 #define CONTROL_FMT(x) (((x) << 4) & 0x30) /* Format */
28 #define CONTROL_PCB(x) (((x) << 10) & 0x7c00) /* PC Bits */
29 
30 /* Status Fields */
31 #define STATUS_T (1<<0) /* Trace Started */
32 #define STATUS_TD (1<<1) /* Trace Disabled */
33 #define STATUS_W (1<<2) /* Wrapped */
34 #define STATUS_O (1<<3) /* Overflow */
35 
36 /* Trigger Fields */
37 #define TRIGGER_TST(x) (((x) << 0) & 0xf) /* Trigger Start */
38 #define TRIGGER_DST (1<<7) /* Delay Start */
39 #define TRIGGER_TSP(x) (((x) << 8) & 0xf00) /* Trigger Stop */
40 #define TRIGGER_DSP (1<<15) /* Delay Start */
41 
42 static const char * const esirisc_trace_delay_strings[] = {
43  "none", "start", "stop", "both",
44 };
45 
46 static const char * const esirisc_trace_format_strings[] = {
47  "full", "branch", "icache",
48 };
49 
50 static const char * const esirisc_trace_id_strings[] = {
51  "sequential instruction",
52  "pipeline stall",
53  "direct branch",
54  "extended ID",
55 };
56 
57 static const char * const esirisc_trace_ext_id_strings[] = {
58  "", /* unused */
59  "exception",
60  "eret",
61  "stop instruction",
62  "wait instruction",
63  "multicycle instruction",
64  "count",
65  "initial",
66  "indirect branch",
67  "end of trace",
68  "final",
69 };
70 
71 static const char * const esirisc_trace_trigger_strings[] = {
72  "none", "pc", "load", "store", "exception", "eret", "wait", "stop",
73  "high", "low", /* start only */
74 };
75 
77 {
78  struct esirisc_common *esirisc = target_to_esirisc(target);
79  struct esirisc_jtag *jtag_info = &esirisc->jtag_info;
80  int retval;
81 
82  if (target->state != TARGET_HALTED)
84 
85  retval = esirisc_jtag_write_csr(jtag_info, CSR_TRACE, CSR_TRACE_STATUS, ~0);
86  if (retval != ERROR_OK) {
87  LOG_TARGET_ERROR(target, "failed to write Trace CSR: Status");
88  return retval;
89  }
90 
91  return ERROR_OK;
92 }
93 
94 static int esirisc_trace_get_status(struct target *target, uint32_t *status)
95 {
96  struct esirisc_common *esirisc = target_to_esirisc(target);
97  struct esirisc_jtag *jtag_info = &esirisc->jtag_info;
98 
99  if (target->state != TARGET_HALTED)
101 
102  int retval = esirisc_jtag_read_csr(jtag_info, CSR_TRACE, CSR_TRACE_STATUS, status);
103  if (retval != ERROR_OK) {
104  LOG_TARGET_ERROR(target, "failed to read Trace CSR: Status");
105  return retval;
106  }
107 
108  return ERROR_OK;
109 }
110 
111 static int esirisc_trace_start(struct target *target)
112 {
113  struct esirisc_common *esirisc = target_to_esirisc(target);
114  struct esirisc_jtag *jtag_info = &esirisc->jtag_info;
115  uint32_t control;
116  int retval;
117 
118  if (target->state != TARGET_HALTED)
120 
121  retval = esirisc_jtag_read_csr(jtag_info, CSR_TRACE, CSR_TRACE_CONTROL, &control);
122  if (retval != ERROR_OK) {
123  LOG_TARGET_ERROR(target, "failed to read Trace CSR: Control");
124  return retval;
125  }
126 
127  control |= CONTROL_ST;
128 
129  retval = esirisc_jtag_write_csr(jtag_info, CSR_TRACE, CSR_TRACE_CONTROL, control);
130  if (retval != ERROR_OK) {
131  LOG_TARGET_ERROR(target, "failed to write Trace CSR: Control");
132  return retval;
133  }
134 
135  return ERROR_OK;
136 }
137 
138 static int esirisc_trace_stop(struct target *target)
139 {
140  struct esirisc_common *esirisc = target_to_esirisc(target);
141  struct esirisc_jtag *jtag_info = &esirisc->jtag_info;
142  uint32_t control;
143  int retval;
144 
145  if (target->state != TARGET_HALTED)
147 
148  retval = esirisc_jtag_read_csr(jtag_info, CSR_TRACE, CSR_TRACE_CONTROL, &control);
149  if (retval != ERROR_OK) {
150  LOG_TARGET_ERROR(target, "failed to read Trace CSR: Control");
151  return retval;
152  }
153 
154  control |= CONTROL_SP;
155 
156  retval = esirisc_jtag_write_csr(jtag_info, CSR_TRACE, CSR_TRACE_CONTROL, control);
157  if (retval != ERROR_OK) {
158  LOG_TARGET_ERROR(target, "failed to write Trace CSR: Control");
159  return retval;
160  }
161 
162  return ERROR_OK;
163 }
164 
165 static int esirisc_trace_init(struct target *target)
166 {
167  struct esirisc_common *esirisc = target_to_esirisc(target);
168  struct esirisc_jtag *jtag_info = &esirisc->jtag_info;
169  struct esirisc_trace *trace_info = &esirisc->trace_info;
170  uint32_t control, trigger;
171  int retval;
172 
173  if (target->state != TARGET_HALTED)
175 
176  /* stop if running and clear status */
177  retval = esirisc_trace_stop(target);
178  if (retval != ERROR_OK)
179  return retval;
180 
182  if (retval != ERROR_OK)
183  return retval;
184 
185  /* initialize Control CSR */
186  control = CONTROL_FMT(trace_info->format)
187  | CONTROL_PCB(trace_info->pc_bits);
188 
189  if (trace_info->buffer_wrap)
190  control |= CONTROL_W;
191 
192  if (trace_info->flow_control)
193  control |= CONTROL_FC;
194 
195  retval = esirisc_jtag_write_csr(jtag_info, CSR_TRACE, CSR_TRACE_CONTROL, control);
196  if (retval != ERROR_OK) {
197  LOG_TARGET_ERROR(target, "failed to write Trace CSR: Control");
198  return retval;
199  }
200 
201  /* initialize buffer CSRs */
203  trace_info->buffer_start);
204  if (retval != ERROR_OK) {
205  LOG_TARGET_ERROR(target, "failed to write Trace CSR: BufferStart");
206  return retval;
207  }
208 
210  trace_info->buffer_end);
211  if (retval != ERROR_OK) {
212  LOG_TARGET_ERROR(target, "failed to write Trace CSR: BufferEnd");
213  return retval;
214  }
215 
216  /*
217  * The BufferCurrent CSR must be initialized to the same value as
218  * BufferStart before tracing can be enabled:
219  */
221  trace_info->buffer_start);
222  if (retval != ERROR_OK) {
223  LOG_TARGET_ERROR(target, "failed to write Trace CSR: BufferCurrent");
224  return retval;
225  }
226 
227  /* initialize Trigger CSR */
228  trigger = TRIGGER_TST(trace_info->start_trigger)
229  | TRIGGER_TSP(trace_info->stop_trigger);
230 
231  if (trace_info->delay == ESIRISC_TRACE_DELAY_START
232  || trace_info->delay == ESIRISC_TRACE_DELAY_BOTH) {
233  trigger |= TRIGGER_DST;
234  }
235 
236  if (trace_info->delay == ESIRISC_TRACE_DELAY_STOP
237  || trace_info->delay == ESIRISC_TRACE_DELAY_BOTH) {
238  trigger |= TRIGGER_DSP;
239  }
240 
242  if (retval != ERROR_OK) {
243  LOG_TARGET_ERROR(target, "failed to write Trace CSR: Trigger");
244  return retval;
245  }
246 
247  /* initialize StartData/StartMask CSRs */
249  trace_info->start_data);
250  if (retval != ERROR_OK) {
251  LOG_TARGET_ERROR(target, "failed to write Trace CSR: StartData");
252  return retval;
253  }
254 
256  trace_info->start_mask);
257  if (retval != ERROR_OK) {
258  LOG_TARGET_ERROR(target, "failed to write Trace CSR: StartMask");
259  return retval;
260  }
261 
262  /* initialize StopData/StopMask CSRs */
264  trace_info->stop_data);
265  if (retval != ERROR_OK) {
266  LOG_TARGET_ERROR(target, "failed to write Trace CSR: StopData");
267  return retval;
268  }
269 
271  trace_info->stop_mask);
272  if (retval != ERROR_OK) {
273  LOG_TARGET_ERROR(target, "failed to write Trace CSR: StopMask");
274  return retval;
275  }
276 
277  /* initialize Delay CSR */
278  retval = esirisc_jtag_write_csr(jtag_info, CSR_TRACE, CSR_TRACE_DELAY,
279  trace_info->delay_cycles);
280  if (retval != ERROR_OK) {
281  LOG_TARGET_ERROR(target, "failed to write Trace CSR: Delay");
282  return retval;
283  }
284 
285  return ERROR_OK;
286 }
287 
288 static int esirisc_trace_buf_get_u32(uint8_t *buffer, uint32_t size,
289  unsigned int *pos, unsigned int count, uint32_t *value)
290 {
291  const unsigned int num_bits = size * 8;
292 
293  if (*pos+count > num_bits)
294  return ERROR_FAIL;
295 
296  *value = buf_get_u32(buffer, *pos, count);
297  *pos += count;
298 
299  return ERROR_OK;
300 }
301 
302 static int esirisc_trace_buf_get_pc(struct target *target, uint8_t *buffer, uint32_t size,
303  unsigned int *pos, uint32_t *value)
304 {
305  struct esirisc_common *esirisc = target_to_esirisc(target);
306  struct esirisc_trace *trace_info = &esirisc->trace_info;
307  int retval;
308 
309  retval = esirisc_trace_buf_get_u32(buffer, size, pos, trace_info->pc_bits, value);
310  if (retval != ERROR_OK)
311  return retval;
312 
313  *value <<= esirisc->num_bits - trace_info->pc_bits;
314 
315  return ERROR_OK;
316 }
317 
319  uint8_t *buffer)
320 {
321  int retval;
322 
323  if (target->state != TARGET_HALTED)
325 
326  retval = target_read_memory(target, address, 1, size, buffer);
327  if (retval != ERROR_OK) {
328  LOG_TARGET_ERROR(target, "failed to read trace data");
329  return retval;
330  }
331 
332  return ERROR_OK;
333 }
334 
335 static int esirisc_trace_read_buffer(struct target *target, uint8_t *buffer)
336 {
337  struct esirisc_common *esirisc = target_to_esirisc(target);
338  struct esirisc_jtag *jtag_info = &esirisc->jtag_info;
339  struct esirisc_trace *trace_info = &esirisc->trace_info;
340  uint32_t buffer_cur, status;
341  int retval;
342 
343  if (target->state != TARGET_HALTED)
345 
346  retval = esirisc_jtag_read_csr(jtag_info, CSR_TRACE, CSR_TRACE_BUFFER_CUR, &buffer_cur);
347  if (retval != ERROR_OK) {
348  LOG_TARGET_ERROR(target, "failed to read Trace CSR: BufferCurrent");
349  return retval;
350  }
351 
352  /*
353  * If the buffer has wrapped, the BufferCurrent CSR indicates the
354  * next address to be written (ie. the start address). These bytes
355  * must be dumped first to maintain coherency when analyzing
356  * captured data.
357  */
359  if (retval != ERROR_OK)
360  return retval;
361 
362  if (status & STATUS_W) {
363  uint32_t size = trace_info->buffer_end - buffer_cur;
364 
365  retval = esirisc_trace_read_memory(target, buffer_cur, size, buffer);
366  if (retval != ERROR_OK)
367  return retval;
368 
369  buffer += size;
370  }
371 
372  return esirisc_trace_read_memory(target, trace_info->buffer_start,
373  buffer_cur - trace_info->buffer_start, buffer);
374 }
375 
376 static int esirisc_trace_analyze_full(struct command_invocation *cmd, uint8_t *buffer, uint32_t size)
377 {
378  struct target *target = get_current_target(cmd->ctx);
379  const uint32_t num_bits = size * 8;
380  int retval;
381 
382  unsigned int pos = 0;
383  while (pos < num_bits) {
384  uint32_t id;
385 
386  retval = esirisc_trace_buf_get_u32(buffer, size, &pos, 2, &id);
387  if (retval != ERROR_OK)
388  goto fail;
389 
390  switch (id) {
395  break;
396 
398  uint32_t ext_id;
399 
400  retval = esirisc_trace_buf_get_u32(buffer, size, &pos, 4, &ext_id);
401  if (retval != ERROR_OK)
402  goto fail;
403 
404  switch (ext_id) {
409  break;
410 
415  uint32_t pc;
416 
417  retval = esirisc_trace_buf_get_pc(target, buffer, size, &pos, &pc);
418  if (retval != ERROR_OK)
419  goto fail;
420 
421  command_print(cmd, "%s PC: 0x%" PRIx32,
422  esirisc_trace_ext_id_strings[ext_id], pc);
423 
424  if (ext_id == ESIRISC_TRACE_EXT_ID_END_PC) {
425  command_print(cmd, "--- end of trace ---");
426  return ERROR_OK;
427  }
428  break;
429  }
430 
432  uint32_t eid, epc;
433 
434  retval = esirisc_trace_buf_get_u32(buffer, size, &pos, 6, &eid);
435  if (retval != ERROR_OK)
436  goto fail;
437 
438  retval = esirisc_trace_buf_get_pc(target, buffer, size, &pos, &epc);
439  if (retval != ERROR_OK)
440  goto fail;
441 
442  command_print(cmd, "%s EID: 0x%" PRIx32 ", EPC: 0x%" PRIx32,
443  esirisc_trace_ext_id_strings[ext_id], eid, epc);
444  break;
445  }
446 
448  uint32_t count;
449 
450  retval = esirisc_trace_buf_get_u32(buffer, size, &pos, 6, &count);
451  if (retval != ERROR_OK)
452  goto fail;
453 
454  command_print(cmd, "repeats %" PRIu32 " %s", count,
455  (count == 1) ? "time" : "times");
456  break;
457  }
458 
460  command_print(cmd, "--- end of trace ---");
461  return ERROR_OK;
462 
463  default:
464  command_print(cmd, "invalid extended trace ID: %" PRIu32, ext_id);
465  return ERROR_FAIL;
466  }
467  break;
468  }
469  default:
470  command_print(cmd, "invalid trace ID: %" PRIu32, id);
471  return ERROR_FAIL;
472  }
473  }
474 
475 fail:
476  command_print(cmd, "trace buffer too small");
477  return ERROR_BUF_TOO_SMALL;
478 }
479 
480 static int esirisc_trace_analyze_simple(struct command_invocation *cmd, uint8_t *buffer, uint32_t size)
481 {
482  struct target *target = get_current_target(cmd->ctx);
483  struct esirisc_common *esirisc = target_to_esirisc(target);
484  struct esirisc_trace *trace_info = &esirisc->trace_info;
485  const uint32_t end_of_trace = GENMASK(trace_info->pc_bits, 1);
486  const uint32_t num_bits = size * 8;
487  int retval;
488 
489  unsigned int pos = 0;
490  while (pos < num_bits) {
491  uint32_t pc;
492 
493  retval = esirisc_trace_buf_get_pc(target, buffer, size, &pos, &pc);
494  if (retval != ERROR_OK)
495  break;
496 
497  if (pc == end_of_trace) {
498  command_print(cmd, "--- end of trace ---");
499  return ERROR_OK;
500  }
501 
502  command_print(cmd, "PC: 0x%" PRIx32, pc);
503  }
504 
505  command_print(cmd, "trace buffer too small");
506  return ERROR_BUF_TOO_SMALL;
507 }
508 
509 static int esirisc_trace_analyze(struct command_invocation *cmd, uint8_t *buffer, uint32_t size)
510 {
511  struct target *target = get_current_target(cmd->ctx);
512  struct esirisc_common *esirisc = target_to_esirisc(target);
513  struct esirisc_trace *trace_info = &esirisc->trace_info;
514 
515  switch (trace_info->format) {
517  command_print(cmd, "--- full pipeline ---");
519 
521  command_print(cmd, "--- branches taken ---");
523 
525  command_print(cmd, "--- icache misses ---");
527 
528  default:
529  command_print(cmd, "invalid trace format: %i", trace_info->format);
530  return ERROR_FAIL;
531  }
532 }
533 
535 {
536  struct target *target = get_current_target(cmd->ctx);
537  struct esirisc_common *esirisc = target_to_esirisc(target);
538  struct esirisc_trace *trace_info = &esirisc->trace_info;
539  uint8_t *buffer;
540  uint32_t size;
541  int retval;
542 
543  size = esirisc_trace_buffer_size(trace_info);
544  buffer = calloc(1, size);
545  if (!buffer) {
546  command_print(cmd, "out of memory");
547  return ERROR_FAIL;
548  }
549 
551  if (retval != ERROR_OK)
552  goto done;
553 
554  retval = esirisc_trace_analyze(cmd, buffer, size);
555 
556 done:
557  free(buffer);
558 
559  return retval;
560 }
561 
563  target_addr_t address, uint32_t size)
564 {
565  struct target *target = get_current_target(cmd->ctx);
566  uint8_t *buffer;
567  int retval;
568 
569  buffer = calloc(1, size);
570  if (!buffer) {
571  command_print(cmd, "out of memory");
572  return ERROR_FAIL;
573  }
574 
576  if (retval != ERROR_OK)
577  goto done;
578 
579  retval = esirisc_trace_analyze(cmd, buffer, size);
580 
581 done:
582  free(buffer);
583 
584  return retval;
585 }
586 
587 static int esirisc_trace_dump(struct command_invocation *cmd, const char *filename,
588  uint8_t *buffer, uint32_t size)
589 {
590  struct fileio *fileio;
591  size_t size_written;
592  int retval;
593 
594  retval = fileio_open(&fileio, filename, FILEIO_WRITE, FILEIO_BINARY);
595  if (retval != ERROR_OK) {
596  command_print(cmd, "could not open dump file: %s", filename);
597  return retval;
598  }
599 
600  retval = fileio_write(fileio, size, buffer, &size_written);
601  if (retval == ERROR_OK)
602  command_print(cmd, "trace data dumped to: %s", filename);
603  else
604  command_print(cmd, "could not write dump file: %s", filename);
605 
607 
608  return retval;
609 }
610 
611 static int esirisc_trace_dump_buffer(struct command_invocation *cmd, const char *filename)
612 {
613  struct target *target = get_current_target(cmd->ctx);
614  struct esirisc_common *esirisc = target_to_esirisc(target);
615  struct esirisc_trace *trace_info = &esirisc->trace_info;
616  uint8_t *buffer;
617  uint32_t size;
618  int retval;
619 
620  size = esirisc_trace_buffer_size(trace_info);
621  buffer = calloc(1, size);
622  if (!buffer) {
623  command_print(cmd, "out of memory");
624  return ERROR_FAIL;
625  }
626 
628  if (retval != ERROR_OK)
629  goto done;
630 
631  retval = esirisc_trace_dump(cmd, filename, buffer, size);
632 
633 done:
634  free(buffer);
635 
636  return retval;
637 }
638 
639 static int esirisc_trace_dump_memory(struct command_invocation *cmd, const char *filename,
640  target_addr_t address, uint32_t size)
641 {
642  struct target *target = get_current_target(cmd->ctx);
643  uint8_t *buffer;
644  int retval;
645 
646  buffer = calloc(1, size);
647  if (!buffer) {
648  command_print(cmd, "out of memory");
649  return ERROR_FAIL;
650  }
651 
653  if (retval != ERROR_OK)
654  goto done;
655 
656  retval = esirisc_trace_dump(cmd, filename, buffer, size);
657 
658 done:
659  free(buffer);
660 
661  return retval;
662 }
663 
664 COMMAND_HANDLER(handle_esirisc_trace_init_command)
665 {
667  struct esirisc_common *esirisc = target_to_esirisc(target);
668 
669  if (!esirisc->has_trace) {
670  command_print(CMD, "target does not support trace");
671  return ERROR_FAIL;
672  }
673 
674  int retval = esirisc_trace_init(target);
675  if (retval == ERROR_OK)
676  command_print(CMD, "trace initialized");
677 
678  return retval;
679 }
680 
681 COMMAND_HANDLER(handle_esirisc_trace_info_command)
682 {
684  struct esirisc_common *esirisc = target_to_esirisc(target);
685  struct esirisc_trace *trace_info = &esirisc->trace_info;
686 
687  if (!esirisc->has_trace) {
688  command_print(CMD, "target does not support trace");
689  return ERROR_FAIL;
690  }
691 
692  if (esirisc_trace_is_fifo(trace_info))
693  command_print(CMD, "trace FIFO address: 0x%" TARGET_PRIxADDR,
694  trace_info->buffer_start);
695  else {
696  command_print(CMD, "trace buffer start: 0x%" TARGET_PRIxADDR,
697  trace_info->buffer_start);
698  command_print(CMD, "trace buffer end: 0x%" TARGET_PRIxADDR,
699  trace_info->buffer_end);
700  command_print(CMD, "trace buffer will %swrap",
701  trace_info->buffer_wrap ? "" : "not ");
702  }
703 
704  command_print(CMD, "flow control: %s",
705  trace_info->flow_control ? "enabled" : "disabled");
706 
707  command_print(CMD, "trace format: %s",
708  esirisc_trace_format_strings[trace_info->format]);
709  command_print(CMD, "number of PC bits: %i", trace_info->pc_bits);
710 
711  command_print(CMD, "start trigger: %s",
713  command_print(CMD, "start data: 0x%" PRIx32, trace_info->start_data);
714  command_print(CMD, "start mask: 0x%" PRIx32, trace_info->start_mask);
715 
716  command_print(CMD, "stop trigger: %s",
718  command_print(CMD, "stop data: 0x%" PRIx32, trace_info->stop_data);
719  command_print(CMD, "stop mask: 0x%" PRIx32, trace_info->stop_mask);
720 
721  command_print(CMD, "trigger delay: %s",
722  esirisc_trace_delay_strings[trace_info->delay]);
723  command_print(CMD, "trigger delay cycles: %" PRIu32, trace_info->delay_cycles);
724 
725  return ERROR_OK;
726 }
727 
728 COMMAND_HANDLER(handle_esirisc_trace_status_command)
729 {
731  struct esirisc_common *esirisc = target_to_esirisc(target);
732  uint32_t status;
733 
734  if (!esirisc->has_trace) {
735  command_print(CMD, "target does not support trace");
736  return ERROR_FAIL;
737  }
738 
739  int retval = esirisc_trace_get_status(target, &status);
740  if (retval != ERROR_OK)
741  return retval;
742 
743  command_print(CMD, "trace is %s%s%s%s",
744  (status & STATUS_T) ? "started" : "stopped",
745  (status & STATUS_TD) ? ", disabled" : "",
746  (status & STATUS_W) ? ", wrapped" : "",
747  (status & STATUS_O) ? ", overflowed" : "");
748 
749  return ERROR_OK;
750 }
751 
752 COMMAND_HANDLER(handle_esirisc_trace_start_command)
753 {
755  struct esirisc_common *esirisc = target_to_esirisc(target);
756 
757  if (!esirisc->has_trace) {
758  command_print(CMD, "target does not support trace");
759  return ERROR_FAIL;
760  }
761 
762  int retval = esirisc_trace_start(target);
763  if (retval == ERROR_OK)
764  command_print(CMD, "trace started");
765 
766  return retval;
767 }
768 
769 COMMAND_HANDLER(handle_esirisc_trace_stop_command)
770 {
772  struct esirisc_common *esirisc = target_to_esirisc(target);
773 
774  if (!esirisc->has_trace) {
775  command_print(CMD, "target does not support trace");
776  return ERROR_FAIL;
777  }
778 
779  int retval = esirisc_trace_stop(target);
780  if (retval == ERROR_OK)
781  command_print(CMD, "trace stopped");
782 
783  return retval;
784 }
785 
786 COMMAND_HANDLER(handle_esirisc_trace_analyze_command)
787 {
789  struct esirisc_common *esirisc = target_to_esirisc(target);
790  struct esirisc_trace *trace_info = &esirisc->trace_info;
792  uint32_t size;
793 
794  if (!esirisc->has_trace) {
795  command_print(CMD, "target does not support trace");
796  return ERROR_FAIL;
797  }
798 
799  if (CMD_ARGC != 0 && CMD_ARGC != 2)
801 
802  if (CMD_ARGC == 0) {
803  /*
804  * Use of the Trace FIFO typically involves DMA to a peripheral
805  * (eg. SPI) or a separately managed buffer in memory, neither
806  * of which may be under our control. If the destination address
807  * and size are known in the latter case, they may be specified
808  * as arguments as a workaround.
809  */
810  if (esirisc_trace_is_fifo(trace_info)) {
811  command_print(CMD, "analyze from FIFO not supported");
812  return ERROR_FAIL;
813  }
814 
816  } else {
819 
821  }
822 }
823 
824 COMMAND_HANDLER(handle_esirisc_trace_dump_command)
825 {
827  struct esirisc_common *esirisc = target_to_esirisc(target);
828  struct esirisc_trace *trace_info = &esirisc->trace_info;
830  uint32_t size;
831 
832  if (!esirisc->has_trace) {
833  command_print(CMD, "target does not support trace");
834  return ERROR_FAIL;
835  }
836 
837  if (CMD_ARGC != 1 && CMD_ARGC != 3)
839 
840  if (CMD_ARGC == 1) {
841  /* also see: handle_esirisc_trace_analyze_command() */
842  if (esirisc_trace_is_fifo(trace_info)) {
843  command_print(CMD, "dump from FIFO not supported");
844  return ERROR_FAIL;
845  }
846 
848  } else {
851 
853  }
854 }
855 
856 COMMAND_HANDLER(handle_esirisc_trace_buffer_command)
857 {
859  struct esirisc_common *esirisc = target_to_esirisc(target);
860  struct esirisc_trace *trace_info = &esirisc->trace_info;
861  uint32_t size;
862 
863  if (CMD_ARGC < 2 || CMD_ARGC > 3)
865 
868 
869  trace_info->buffer_end = trace_info->buffer_start + size;
870 
871  if (CMD_ARGC == 3) {
872  if (strcmp("wrap", CMD_ARGV[2]) == 0)
873  trace_info->buffer_wrap = true;
874  else
876  }
877 
878  return ERROR_OK;
879 }
880 
881 COMMAND_HANDLER(handle_esirisc_trace_fifo_command)
882 {
884  struct esirisc_common *esirisc = target_to_esirisc(target);
885  struct esirisc_trace *trace_info = &esirisc->trace_info;
886 
887  if (CMD_ARGC != 1)
889 
891 
892  /* FIFOs have the same start and end address */
893  trace_info->buffer_end = trace_info->buffer_start;
894  trace_info->buffer_wrap = true;
895 
896  return ERROR_OK;
897 }
898 
899 COMMAND_HANDLER(handle_esirisc_trace_flow_control_command)
900 {
902  struct esirisc_common *esirisc = target_to_esirisc(target);
903  struct esirisc_trace *trace_info = &esirisc->trace_info;
904 
905  if (CMD_ARGC != 1)
907 
908  if (strcmp(CMD_ARGV[0], "enable") == 0)
909  trace_info->flow_control = true;
910  else if (strcmp(CMD_ARGV[0], "disable") == 0)
911  trace_info->flow_control = false;
912  else
914 
915  return ERROR_OK;
916 }
917 
918 COMMAND_HANDLER(handle_esirisc_trace_format_command)
919 {
921  struct esirisc_common *esirisc = target_to_esirisc(target);
922  struct esirisc_trace *trace_info = &esirisc->trace_info;
923  int pc_bits;
924 
925  if (CMD_ARGC != 2)
927 
928  if (strcmp(CMD_ARGV[0], "full") == 0)
929  trace_info->format = ESIRISC_TRACE_FORMAT_FULL;
930  else if (strcmp(CMD_ARGV[0], "branch") == 0)
931  trace_info->format = ESIRISC_TRACE_FORMAT_BRANCH;
932  else if (strcmp(CMD_ARGV[0], "icache") == 0)
933  trace_info->format = ESIRISC_TRACE_FORMAT_ICACHE;
934  else
936 
938 
939  if (pc_bits < 1 || pc_bits > 31) {
940  command_print(CMD, "invalid pc_bits: %i; must be 1..31", pc_bits);
942  }
943 
944  trace_info->pc_bits = pc_bits;
945 
946  return ERROR_OK;
947 }
948 
949 COMMAND_HANDLER(handle_esirisc_trace_trigger_start_command)
950 {
952  struct esirisc_common *esirisc = target_to_esirisc(target);
953  struct esirisc_trace *trace_info = &esirisc->trace_info;
954 
955  if (CMD_ARGC != 1 && CMD_ARGC != 3)
957 
958  if (strcmp(CMD_ARGV[0], "none") == 0)
960  else if (strcmp(CMD_ARGV[0], "pc") == 0)
962  else if (strcmp(CMD_ARGV[0], "load") == 0)
964  else if (strcmp(CMD_ARGV[0], "store") == 0)
966  else if (strcmp(CMD_ARGV[0], "exception") == 0)
968  else if (strcmp(CMD_ARGV[0], "eret") == 0)
970  else if (strcmp(CMD_ARGV[0], "wait") == 0)
972  else if (strcmp(CMD_ARGV[0], "stop") == 0)
974  else if (strcmp(CMD_ARGV[0], "high") == 0)
976  else if (strcmp(CMD_ARGV[0], "low") == 0)
978  else
980 
981  if (CMD_ARGC == 3) {
982  COMMAND_PARSE_NUMBER(u32, CMD_ARGV[1], trace_info->start_data);
983  COMMAND_PARSE_NUMBER(u32, CMD_ARGV[2], trace_info->start_mask);
984  } else {
985  trace_info->start_data = 0;
986  trace_info->start_mask = 0;
987  }
988 
989  return ERROR_OK;
990 }
991 
992 COMMAND_HANDLER(handle_esirisc_trace_trigger_stop_command)
993 {
995  struct esirisc_common *esirisc = target_to_esirisc(target);
996  struct esirisc_trace *trace_info = &esirisc->trace_info;
997 
998  if (CMD_ARGC != 1 && CMD_ARGC != 3)
1000 
1001  if (strcmp(CMD_ARGV[0], "none") == 0)
1003  else if (strcmp(CMD_ARGV[0], "pc") == 0)
1004  trace_info->stop_trigger = ESIRISC_TRACE_TRIGGER_PC;
1005  else if (strcmp(CMD_ARGV[0], "load") == 0)
1007  else if (strcmp(CMD_ARGV[0], "store") == 0)
1009  else if (strcmp(CMD_ARGV[0], "exception") == 0)
1011  else if (strcmp(CMD_ARGV[0], "eret") == 0)
1013  else if (strcmp(CMD_ARGV[0], "wait") == 0)
1015  else if (strcmp(CMD_ARGV[0], "stop") == 0)
1017  else
1019 
1020  if (CMD_ARGC == 3) {
1021  COMMAND_PARSE_NUMBER(u32, CMD_ARGV[1], trace_info->stop_data);
1022  COMMAND_PARSE_NUMBER(u32, CMD_ARGV[2], trace_info->stop_mask);
1023  } else {
1024  trace_info->stop_data = 0;
1025  trace_info->stop_mask = 0;
1026  }
1027 
1028  return ERROR_OK;
1029 }
1030 
1031 COMMAND_HANDLER(handle_esirisc_trace_trigger_delay_command)
1032 {
1034  struct esirisc_common *esirisc = target_to_esirisc(target);
1035  struct esirisc_trace *trace_info = &esirisc->trace_info;
1036 
1037  if (CMD_ARGC < 1 || CMD_ARGC > 2)
1039 
1040  if (strcmp(CMD_ARGV[0], "none") == 0)
1041  trace_info->delay = ESIRISC_TRACE_DELAY_NONE;
1042  else if (strcmp(CMD_ARGV[0], "start") == 0)
1043  trace_info->delay = ESIRISC_TRACE_DELAY_START;
1044  else if (strcmp(CMD_ARGV[0], "stop") == 0)
1045  trace_info->delay = ESIRISC_TRACE_DELAY_STOP;
1046  else if (strcmp(CMD_ARGV[0], "both") == 0)
1047  trace_info->delay = ESIRISC_TRACE_DELAY_BOTH;
1048  else
1050 
1051  if (trace_info->delay == ESIRISC_TRACE_DELAY_NONE)
1052  trace_info->delay_cycles = 0;
1053  else {
1054  if (CMD_ARGC != 2)
1056 
1057  COMMAND_PARSE_NUMBER(u32, CMD_ARGV[1], trace_info->delay_cycles);
1058  }
1059 
1060  return ERROR_OK;
1061 }
1062 
1064  {
1065  .name = "init",
1066  .handler = handle_esirisc_trace_init_command,
1067  .mode = COMMAND_EXEC,
1068  .help = "initialize trace collection",
1069  .usage = "",
1070  },
1071  {
1072  .name = "info",
1073  .handler = handle_esirisc_trace_info_command,
1074  .mode = COMMAND_EXEC,
1075  .help = "display trace configuration",
1076  .usage = "",
1077  },
1078  {
1079  .name = "status",
1080  .handler = handle_esirisc_trace_status_command,
1081  .mode = COMMAND_EXEC,
1082  .help = "display trace collection status",
1083  .usage = "",
1084  },
1085  {
1086  .name = "start",
1087  .handler = handle_esirisc_trace_start_command,
1088  .mode = COMMAND_EXEC,
1089  .help = "start trace collection",
1090  .usage = "",
1091  },
1092  {
1093  .name = "stop",
1094  .handler = handle_esirisc_trace_stop_command,
1095  .mode = COMMAND_EXEC,
1096  .help = "stop trace collection",
1097  .usage = "",
1098  },
1099  {
1100  .name = "analyze",
1101  .handler = handle_esirisc_trace_analyze_command,
1102  .mode = COMMAND_EXEC,
1103  .usage = "[address size]",
1104  .help = "analyze collected trace data",
1105  },
1106  {
1107  .name = "dump",
1108  .handler = handle_esirisc_trace_dump_command,
1109  .mode = COMMAND_EXEC,
1110  .help = "dump collected trace data to file",
1111  .usage = "[address size] filename",
1112  },
1114 };
1115 
1117  {
1118  .name = "start",
1119  .handler = handle_esirisc_trace_trigger_start_command,
1120  .mode = COMMAND_ANY,
1121  .help = "configure trigger start condition",
1122  .usage = "('none'|'pc'|'load'|'store'|'exception'|'eret'|'wait'|'stop'|'high'|'low')"
1123  " [start_data start_mask]",
1124  },
1125  {
1126  .name = "stop",
1127  .handler = handle_esirisc_trace_trigger_stop_command,
1128  .mode = COMMAND_ANY,
1129  .help = "configure trigger stop condition",
1130  .usage = "('none'|'pc'|'load'|'store'|'exception'|'eret'|'wait'|'stop')"
1131  " [stop_data stop_mask]",
1132  },
1133  {
1134  .name = "delay",
1135  .handler = handle_esirisc_trace_trigger_delay_command,
1136  .mode = COMMAND_ANY,
1137  .help = "configure trigger start/stop delay in clock cycles",
1138  .usage = "('none'|'start'|'stop'|'both') [cycles]",
1139  },
1141 };
1142 
1144  {
1145  .name = "buffer",
1146  .handler = handle_esirisc_trace_buffer_command,
1147  .mode = COMMAND_ANY,
1148  .help = "configure trace buffer",
1149  .usage = "address size ['wrap']",
1150  },
1151  {
1152  .name = "fifo",
1153  .handler = handle_esirisc_trace_fifo_command,
1154  .mode = COMMAND_ANY,
1155  .help = "configure trace FIFO",
1156  .usage = "address",
1157  },
1158  {
1159  .name = "flow_control",
1160  .handler = handle_esirisc_trace_flow_control_command,
1161  .mode = COMMAND_ANY,
1162  .help = "enable or disable stalling CPU to collect trace data",
1163  .usage = "('enable'|'disable')",
1164  },
1165  {
1166  .name = "format",
1167  .handler = handle_esirisc_trace_format_command,
1168  .mode = COMMAND_ANY,
1169  .help = "configure trace format",
1170  .usage = "('full'|'branch'|'icache') pc_bits",
1171  },
1172  {
1173  .name = "trigger",
1174  .mode = COMMAND_ANY,
1175  .help = "eSi-Trace trigger command group",
1176  .usage = "",
1178  },
1179  {
1181  },
1183 };
1184 
1186  {
1187  .name = "trace",
1188  .mode = COMMAND_ANY,
1189  .help = "eSi-Trace command group",
1190  .usage = "",
1192  },
1194 };
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
#define GENMASK(h, l)
Definition: bits.h:24
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:94
static const struct command_registration esirisc_trace_trigger_any_command_handlers[]
static const char *const esirisc_trace_delay_strings[]
Definition: esirisc_trace.c:42
#define TRIGGER_TSP(x)
Definition: esirisc_trace.c:39
#define STATUS_O
Definition: esirisc_trace.c:34
static const char *const esirisc_trace_ext_id_strings[]
Definition: esirisc_trace.c:57
#define CONTROL_W
Definition: esirisc_trace.c:25
static int esirisc_trace_stop(struct target *target)
#define CONTROL_FC
Definition: esirisc_trace.c:26
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:27
static int esirisc_trace_dump_buffer(struct command_invocation *cmd, const char *filename)
#define STATUS_T
Definition: esirisc_trace.c:31
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:50
static int esirisc_trace_analyze_buffer(struct command_invocation *cmd)
static const char *const esirisc_trace_trigger_strings[]
Definition: esirisc_trace.c:71
#define CONTROL_PCB(x)
Definition: esirisc_trace.c:28
#define STATUS_TD
Definition: esirisc_trace.c:32
#define TRIGGER_TST(x)
Definition: esirisc_trace.c:37
#define TRIGGER_DSP
Definition: esirisc_trace.c:40
#define CONTROL_SP
Definition: esirisc_trace.c:24
static int esirisc_trace_analyze_memory(struct command_invocation *cmd, target_addr_t address, uint32_t size)
#define STATUS_W
Definition: esirisc_trace.c:33
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:38
static int esirisc_trace_clear_status(struct target *target)
Definition: esirisc_trace.c:76
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)
static const struct command_registration esirisc_trace_exec_command_handlers[]
static const char *const esirisc_trace_format_strings[]
Definition: esirisc_trace.c:46
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:23
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:175
#define ERROR_BUF_TOO_SMALL
Definition: log.h:171
#define LOG_TARGET_ERROR(target, fmt_str,...)
Definition: log.h:163
#define ERROR_OK
Definition: log.h:169
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
Definition: riscv.c:124
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