OpenOCD
dmem.c
Go to the documentation of this file.
1 // SPDX-License-Identifier: GPL-2.0-or-later
2 
3 /* Copyright (C) 2022 Texas Instruments Incorporated - https://www.ti.com/ */
4 
12 #ifdef HAVE_CONFIG_H
13 #include "config.h"
14 #endif
15 
16 #include <sys/mman.h>
17 
18 #include <helper/align.h>
19 #include <helper/types.h>
20 #include <helper/system.h>
21 #include <helper/time_support.h>
22 #include <helper/list.h>
23 #include <jtag/interface.h>
24 
25 #include <target/arm_adi_v5.h>
26 #include <transport/transport.h>
27 
29  uint64_t ap_num;
30  /* Emulation mode AP state variables */
31  uint32_t apbap_tar;
32  uint32_t apbap_csw;
33 };
34 
35 /*
36  * This bit tells if the transaction is coming in from jtag or not
37  * we just mask this out to emulate direct address access
38  */
39 #define ARM_APB_PADDR31 BIT(31)
40 
42 static size_t dmem_mapped_size;
43 
44 /* Default dmem device. */
45 #define DMEM_DEV_PATH_DEFAULT "/dev/mem"
46 static char *dmem_dev_path;
47 static uint64_t dmem_dap_base_address;
48 static unsigned int dmem_dap_max_aps = 1;
49 static uint32_t dmem_dap_ap_offset = 0x100;
50 
51 /* DAP error code. */
53 
54 /* AP Emulation Mode */
55 static uint64_t dmem_emu_base_address;
56 static uint64_t dmem_emu_size;
58 static size_t dmem_emu_mapped_size;
59 #define DMEM_MAX_EMULATE_APS 5
60 static unsigned int dmem_emu_ap_count;
62 
63 /*
64  * This helper is used to determine the TAR increment size in bytes. The AP's
65  * CSW encoding for SIZE supports byte count decode using "1 << SIZE".
66  */
67 static uint32_t dmem_memap_tar_inc(uint32_t csw)
68 {
69  if ((csw & CSW_ADDRINC_MASK) != 0)
70  return 1 << (csw & CSW_SIZE_MASK);
71  return 0;
72 }
73 
74 /*
75  * EMULATION MODE: In Emulation MODE, we assume the following:
76  * TCL still describes as system is operational from the view of AP (ex. jtag)
77  * However, the hardware doesn't permit direct memory access to these APs
78  * (only permitted via JTAG).
79  *
80  * So, the access to these APs have to be decoded to a memory map
81  * access which we can directly access.
82  *
83  * A few TI processors have this issue.
84  */
85 static bool dmem_is_emulated_ap(struct adiv5_ap *ap, unsigned int *idx)
86 {
87  for (unsigned int i = 0; i < dmem_emu_ap_count; i++) {
88  if (ap->ap_num == dmem_emu_ap_list[i].ap_num) {
89  *idx = i;
90  return true;
91  }
92  }
93  return false;
94 }
95 
96 static void dmem_emu_set_ap_reg(uint64_t addr, uint32_t val)
97 {
99 
100  *(volatile uint32_t *)((uintptr_t)dmem_emu_virt_base_addr + addr) = val;
101 }
102 
103 static uint32_t dmem_emu_get_ap_reg(uint64_t addr)
104 {
105  uint32_t val;
106 
107  addr &= ~ARM_APB_PADDR31;
108 
109  val = *(volatile uint32_t *)((uintptr_t)dmem_emu_virt_base_addr + addr);
110 
111  return val;
112 }
113 
114 static int dmem_emu_ap_q_read(unsigned int ap_idx, unsigned int reg, uint32_t *data)
115 {
116  uint64_t addr;
117  int ret = ERROR_OK;
118  struct dmem_emu_ap_info *ap_info = &dmem_emu_ap_list[ap_idx];
119 
120  switch (reg) {
122  *data = ap_info->apbap_csw;
123  break;
125  *data = ap_info->apbap_tar;
126  break;
128  *data = 0;
129  break;
131  *data = 0;
132  break;
133  case ADIV5_AP_REG_IDR:
134  *data = 0;
135  break;
140  addr = (ap_info->apbap_tar & ~0xf) + (reg & 0x0C);
141 
142  *data = dmem_emu_get_ap_reg(addr);
143 
144  break;
146  addr = ap_info->apbap_tar;
147 
148  *data = dmem_emu_get_ap_reg(addr);
149 
150  ap_info->apbap_tar += dmem_memap_tar_inc(ap_info->apbap_csw);
151  break;
152  default:
153  LOG_INFO("%s: Unknown reg: 0x%02x", __func__, reg);
154  ret = ERROR_FAIL;
155  break;
156  }
157 
158  /* Track the last error code. */
159  if (ret != ERROR_OK)
160  dmem_dap_retval = ret;
161 
162  return ret;
163 }
164 
165 static int dmem_emu_ap_q_write(unsigned int ap_idx, unsigned int reg, uint32_t data)
166 {
167  uint64_t addr;
168  int ret = ERROR_OK;
169  struct dmem_emu_ap_info *ap_info = &dmem_emu_ap_list[ap_idx];
170 
171  switch (reg) {
173  /*
174  * This implementation only supports 32-bit accesses.
175  * Force this by ensuring CSW_SIZE field indicates 32-BIT.
176  */
177  ap_info->apbap_csw = ((data & ~CSW_SIZE_MASK) | CSW_32BIT);
178  break;
180  /*
181  * This implementation only supports 32-bit accesses.
182  * Force LS 2-bits of TAR to 00b
183  */
184  ap_info->apbap_tar = (data & ~0x3);
185  break;
186 
189  case ADIV5_AP_REG_IDR:
190  /* We don't use this, so we don't need to store */
191  break;
192 
197  addr = (ap_info->apbap_tar & ~0xf) + (reg & 0x0C);
198 
199  dmem_emu_set_ap_reg(addr, data);
200 
201  break;
203  addr = ap_info->apbap_tar;
204  dmem_emu_set_ap_reg(addr, data);
205 
206  ap_info->apbap_tar += dmem_memap_tar_inc(ap_info->apbap_csw);
207  break;
208  default:
209  LOG_INFO("%s: Unknown reg: 0x%02x", __func__, reg);
210  ret = EINVAL;
211  break;
212  }
213 
214  /* Track the last error code. */
215  if (ret != ERROR_OK)
216  dmem_dap_retval = ret;
217 
218  return ret;
219 }
220 
221 /* AP MODE */
222 static uint32_t dmem_get_ap_reg_offset(struct adiv5_ap *ap, unsigned int reg)
223 {
224  return (dmem_dap_ap_offset * ap->ap_num) + reg;
225 }
226 
227 static void dmem_set_ap_reg(struct adiv5_ap *ap, unsigned int reg, uint32_t val)
228 {
229  *(volatile uint32_t *)((uintptr_t)dmem_virt_base_addr +
230  dmem_get_ap_reg_offset(ap, reg)) = val;
231 }
232 
233 static uint32_t dmem_get_ap_reg(struct adiv5_ap *ap, unsigned int reg)
234 {
235  return *(volatile uint32_t *)((uintptr_t)dmem_virt_base_addr +
237 }
238 
239 static int dmem_dp_q_read(struct adiv5_dap *dap, unsigned int reg, uint32_t *data)
240 {
241  if (!data)
242  return ERROR_OK;
243 
244  switch (reg) {
245  case DP_CTRL_STAT:
246  *data = CDBGPWRUPACK | CSYSPWRUPACK;
247  break;
248 
249  default:
250  *data = 0;
251  break;
252  }
253 
254  return ERROR_OK;
255 }
256 
257 static int dmem_dp_q_write(struct adiv5_dap *dap, unsigned int reg, uint32_t data)
258 {
259  return ERROR_OK;
260 }
261 
262 static int dmem_ap_q_read(struct adiv5_ap *ap, unsigned int reg, uint32_t *data)
263 {
264  unsigned int idx;
265 
266  if (is_adiv6(ap->dap)) {
267  static bool error_flagged;
268 
269  if (!error_flagged)
270  LOG_ERROR("ADIv6 dap not supported by dmem dap-direct mode");
271 
272  error_flagged = true;
273 
274  return ERROR_FAIL;
275  }
276 
277  if (dmem_is_emulated_ap(ap, &idx))
278  return dmem_emu_ap_q_read(idx, reg, data);
279 
280  *data = dmem_get_ap_reg(ap, reg);
281 
282  return ERROR_OK;
283 }
284 
285 static int dmem_ap_q_write(struct adiv5_ap *ap, unsigned int reg, uint32_t data)
286 {
287  unsigned int idx;
288 
289  if (is_adiv6(ap->dap)) {
290  static bool error_flagged;
291 
292  if (!error_flagged)
293  LOG_ERROR("ADIv6 dap not supported by dmem dap-direct mode");
294 
295  error_flagged = true;
296 
297  return ERROR_FAIL;
298  }
299 
300  if (dmem_is_emulated_ap(ap, &idx))
301  return dmem_emu_ap_q_write(idx, reg, data);
302 
303  dmem_set_ap_reg(ap, reg, data);
304 
305  return ERROR_OK;
306 }
307 
308 static int dmem_ap_q_abort(struct adiv5_dap *dap, uint8_t *ack)
309 {
310  return ERROR_OK;
311 }
312 
313 static int dmem_dp_run(struct adiv5_dap *dap)
314 {
315  int retval = dmem_dap_retval;
316 
317  /* Clear the error code. */
319 
320  return retval;
321 }
322 
323 static int dmem_connect(struct adiv5_dap *dap)
324 {
325  return ERROR_OK;
326 }
327 
328 COMMAND_HANDLER(dmem_dap_device_command)
329 {
330  if (CMD_ARGC != 1)
332 
333  free(dmem_dev_path);
334  dmem_dev_path = strdup(CMD_ARGV[0]);
335 
336  return ERROR_OK;
337 }
338 
339 COMMAND_HANDLER(dmem_dap_base_address_command)
340 {
341  if (CMD_ARGC != 1)
343 
345 
346  return ERROR_OK;
347 }
348 
349 COMMAND_HANDLER(dmem_dap_max_aps_command)
350 {
351  if (CMD_ARGC != 1)
353 
355 
356  return ERROR_OK;
357 }
358 
359 COMMAND_HANDLER(dmem_dap_ap_offset_command)
360 {
361  if (CMD_ARGC != 1)
363 
365 
366  return ERROR_OK;
367 }
368 
369 COMMAND_HANDLER(dmem_emu_base_address_command)
370 {
371  if (CMD_ARGC != 2)
373 
376 
377  return ERROR_OK;
378 }
379 
380 COMMAND_HANDLER(dmem_emu_ap_list_command)
381 {
382  uint64_t em_ap;
383 
384  if (CMD_ARGC < 1 || CMD_ARGC > DMEM_MAX_EMULATE_APS)
386 
387  for (unsigned int i = 0; i < CMD_ARGC; i++) {
388  COMMAND_PARSE_NUMBER(u64, CMD_ARGV[i], em_ap);
389  dmem_emu_ap_list[i].ap_num = em_ap;
390  }
391 
393 
394  return ERROR_OK;
395 }
396 
397 COMMAND_HANDLER(dmem_dap_config_info_command)
398 {
399  if (CMD_ARGC != 0)
401 
402  command_print(CMD, "dmem (Direct Memory) AP Adapter Configuration:");
403  command_print(CMD, " Device : %s",
405  command_print(CMD, " Base Address : 0x%" PRIx64, dmem_dap_base_address);
406  command_print(CMD, " Max APs : %u", dmem_dap_max_aps);
407  command_print(CMD, " AP offset : 0x%08" PRIx32, dmem_dap_ap_offset);
408  command_print(CMD, " Emulated AP Count : %u", dmem_emu_ap_count);
409 
410  if (dmem_emu_ap_count) {
411  command_print(CMD, " Emulated AP details:");
412  command_print(CMD, " Emulated address : 0x%" PRIx64, dmem_emu_base_address);
413  command_print(CMD, " Emulated size : 0x%" PRIx64, dmem_emu_size);
414  for (unsigned int i = 0; i < dmem_emu_ap_count; i++)
415  command_print(CMD, " Emulated AP [%u] : %" PRIx64, i,
417  }
418  return ERROR_OK;
419 }
420 
421 static const struct command_registration dmem_dap_subcommand_handlers[] = {
422  {
423  .name = "info",
424  .handler = dmem_dap_config_info_command,
425  .mode = COMMAND_ANY,
426  .help = "print the config info",
427  .usage = "",
428  },
429  {
430  .name = "device",
431  .handler = dmem_dap_device_command,
432  .mode = COMMAND_CONFIG,
433  .help = "set the dmem memory access device (default: /dev/mem)",
434  .usage = "device_path",
435  },
436  {
437  .name = "base_address",
438  .handler = dmem_dap_base_address_command,
439  .mode = COMMAND_CONFIG,
440  .help = "set the dmem dap AP memory map base address",
441  .usage = "base_address",
442  },
443  {
444  .name = "ap_address_offset",
445  .handler = dmem_dap_ap_offset_command,
446  .mode = COMMAND_CONFIG,
447  .help = "set the offsets of each ap index",
448  .usage = "offset_address",
449  },
450  {
451  .name = "max_aps",
452  .handler = dmem_dap_max_aps_command,
453  .mode = COMMAND_CONFIG,
454  .help = "set the maximum number of APs this will support",
455  .usage = "n",
456  },
457  {
458  .name = "emu_ap_list",
459  .handler = dmem_emu_ap_list_command,
460  .mode = COMMAND_CONFIG,
461  .help = "set the list of AP indices to be emulated (upto max)",
462  .usage = "n",
463  },
464  {
465  .name = "emu_base_address_range",
466  .handler = dmem_emu_base_address_command,
467  .mode = COMMAND_CONFIG,
468  .help = "set the base address and size of emulated AP range (all emulated APs access this range)",
469  .usage = "base_address address_window_size",
470  },
472 };
473 
474 static const struct command_registration dmem_dap_command_handlers[] = {
475  {
476  .name = "dmem",
477  .mode = COMMAND_ANY,
478  .help = "Perform dmem (Direct Memory) DAP management and configuration",
480  .usage = "",
481  },
483 };
484 
485 static int dmem_dap_init(void)
486 {
488  uint32_t dmem_total_memory_window_size;
489  long page_size = sysconf(_SC_PAGESIZE);
490  size_t dmem_mapped_start, dmem_mapped_end;
491  long start_delta;
492  int dmem_fd;
493 
494  if (!dmem_dap_base_address) {
495  LOG_ERROR("dmem DAP Base address NOT set? value is 0");
496  return ERROR_FAIL;
497  }
498 
499  dmem_fd = open(path, O_RDWR | O_SYNC);
500  if (dmem_fd == -1) {
501  LOG_ERROR("Unable to open %s", path);
502  return ERROR_FAIL;
503  }
504 
505  dmem_total_memory_window_size = (dmem_dap_max_aps + 1) * dmem_dap_ap_offset;
506 
507  dmem_mapped_start = dmem_dap_base_address;
508  dmem_mapped_end = dmem_dap_base_address + dmem_total_memory_window_size;
509  /* mmap() requires page aligned offsets */
510  dmem_mapped_start = ALIGN_DOWN(dmem_mapped_start, page_size);
511  dmem_mapped_end = ALIGN_UP(dmem_mapped_end, page_size);
512 
513  dmem_mapped_size = dmem_mapped_end - dmem_mapped_start;
514  start_delta = dmem_mapped_start - dmem_dap_base_address;
515 
516  dmem_map_base = mmap(NULL,
518  (PROT_READ | PROT_WRITE),
519  MAP_SHARED, dmem_fd,
520  dmem_mapped_start);
521  if (dmem_map_base == MAP_FAILED) {
522  LOG_ERROR("Mapping address 0x%lx for 0x%lx bytes failed!",
523  dmem_mapped_start, dmem_mapped_size);
524  goto error_fail;
525  }
526 
527  dmem_virt_base_addr = (void *)((uintptr_t)dmem_map_base + start_delta);
528 
529  /* Lets Map the emulated address if necessary */
530  if (dmem_emu_ap_count) {
531  dmem_mapped_start = dmem_emu_base_address;
532  dmem_mapped_end = dmem_emu_base_address + dmem_emu_size;
533  /* mmap() requires page aligned offsets */
534  dmem_mapped_start = ALIGN_DOWN(dmem_mapped_start, page_size);
535  dmem_mapped_end = ALIGN_UP(dmem_mapped_end, page_size);
536 
537  dmem_emu_mapped_size = dmem_mapped_end - dmem_mapped_start;
538  start_delta = dmem_mapped_start - dmem_emu_base_address;
539 
540  dmem_emu_map_base = mmap(NULL,
542  (PROT_READ | PROT_WRITE),
543  MAP_SHARED, dmem_fd,
544  dmem_mapped_start);
545  if (dmem_emu_map_base == MAP_FAILED) {
546  LOG_ERROR("Mapping EMU address 0x%lx for 0x%lx bytes failed!",
548  goto error_fail;
549  }
550  dmem_emu_virt_base_addr = (void *)((uintptr_t)dmem_emu_map_base +
551  start_delta);
552  }
553 
554  close(dmem_fd);
555  return ERROR_OK;
556 
557 error_fail:
558  close(dmem_fd);
559  return ERROR_FAIL;
560 }
561 
562 static int dmem_dap_quit(void)
563 {
564  if (munmap(dmem_map_base, dmem_mapped_size) == -1)
565  LOG_ERROR("%s: Failed to unmap mapped memory!", __func__);
566 
568  && munmap(dmem_emu_map_base, dmem_emu_mapped_size) == -1)
569  LOG_ERROR("%s: Failed to unmap emu mapped memory!", __func__);
570 
571  return ERROR_OK;
572 }
573 
574 static int dmem_dap_reset(int req_trst, int req_srst)
575 {
576  return ERROR_OK;
577 }
578 
579 static int dmem_dap_speed(int speed)
580 {
581  return ERROR_OK;
582 }
583 
584 static int dmem_dap_khz(int khz, int *jtag_speed)
585 {
586  *jtag_speed = khz;
587  return ERROR_OK;
588 }
589 
590 static int dmem_dap_speed_div(int speed, int *khz)
591 {
592  *khz = speed;
593  return ERROR_OK;
594 }
595 
596 /* DAP operations. */
597 static const struct dap_ops dmem_dap_ops = {
599  .queue_dp_read = dmem_dp_q_read,
600  .queue_dp_write = dmem_dp_q_write,
601  .queue_ap_read = dmem_ap_q_read,
602  .queue_ap_write = dmem_ap_q_write,
603  .queue_ap_abort = dmem_ap_q_abort,
604  .run = dmem_dp_run,
605 };
606 
607 static const char *const dmem_dap_transport[] = { "dapdirect_swd", NULL };
608 
610  .name = "dmem",
611  .transports = dmem_dap_transport,
612  .commands = dmem_dap_command_handlers,
613 
614  .init = dmem_dap_init,
615  .quit = dmem_dap_quit,
616  .reset = dmem_dap_reset,
617  .speed = dmem_dap_speed,
618  .khz = dmem_dap_khz,
619  .speed_div = dmem_dap_speed_div,
620 
621  .dap_swd_ops = &dmem_dap_ops,
622 };
#define ALIGN_DOWN(x, a)
Definition: align.h:21
#define ALIGN_UP(x, a)
Definition: align.h:20
This defines formats and data structures used to talk to ADIv5 entities.
#define ADIV5_MEM_AP_REG_DRW
Definition: arm_adi_v5.h:122
#define ADIV5_MEM_AP_REG_BD3
Definition: arm_adi_v5.h:126
#define CSW_ADDRINC_MASK
Definition: arm_adi_v5.h:171
#define ADIV5_MEM_AP_REG_BD2
Definition: arm_adi_v5.h:125
#define CSW_32BIT
Definition: arm_adi_v5.h:167
#define ADIV5_MEM_AP_REG_CFG
Definition: arm_adi_v5.h:129
#define ADIV5_MEM_AP_REG_BD1
Definition: arm_adi_v5.h:124
#define ADIV5_MEM_AP_REG_BASE
Definition: arm_adi_v5.h:130
#define ADIV5_MEM_AP_REG_CSW
Definition: arm_adi_v5.h:119
#define DP_CTRL_STAT
Definition: arm_adi_v5.h:50
#define CDBGPWRUPACK
Definition: arm_adi_v5.h:94
#define CSYSPWRUPACK
Definition: arm_adi_v5.h:96
#define ADIV5_AP_REG_IDR
Definition: arm_adi_v5.h:159
#define CSW_SIZE_MASK
Definition: arm_adi_v5.h:164
static bool is_adiv6(const struct adiv5_dap *dap)
Check if DAP is ADIv6.
Definition: arm_adi_v5.h:523
#define ADIV5_MEM_AP_REG_TAR
Definition: arm_adi_v5.h:120
#define ADIV5_MEM_AP_REG_BD0
Definition: arm_adi_v5.h:123
void command_print(struct command_invocation *cmd, const char *format,...)
Definition: command.c:443
#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 ERROR_COMMAND_SYNTAX_ERROR
Definition: command.h:402
#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:442
#define COMMAND_REGISTRATION_DONE
Use this as the last entry in an array of command_registration records.
Definition: command.h:253
@ COMMAND_CONFIG
Definition: command.h:41
@ COMMAND_ANY
Definition: command.h:42
static int dmem_ap_q_write(struct adiv5_ap *ap, unsigned int reg, uint32_t data)
Definition: dmem.c:285
static char * dmem_dev_path
Definition: dmem.c:46
static int dmem_dp_q_read(struct adiv5_dap *dap, unsigned int reg, uint32_t *data)
Definition: dmem.c:239
static size_t dmem_mapped_size
Definition: dmem.c:42
static unsigned int dmem_emu_ap_count
Definition: dmem.c:60
static int dmem_dap_khz(int khz, int *jtag_speed)
Definition: dmem.c:584
static void * dmem_emu_map_base
Definition: dmem.c:57
COMMAND_HANDLER(dmem_dap_device_command)
Definition: dmem.c:328
static void dmem_set_ap_reg(struct adiv5_ap *ap, unsigned int reg, uint32_t val)
Definition: dmem.c:227
static void dmem_emu_set_ap_reg(uint64_t addr, uint32_t val)
Definition: dmem.c:96
static uint32_t dmem_dap_ap_offset
Definition: dmem.c:49
static const struct command_registration dmem_dap_subcommand_handlers[]
Definition: dmem.c:421
#define DMEM_MAX_EMULATE_APS
Definition: dmem.c:59
static uint32_t dmem_get_ap_reg_offset(struct adiv5_ap *ap, unsigned int reg)
Definition: dmem.c:222
static uint64_t dmem_emu_size
Definition: dmem.c:56
static int dmem_dp_run(struct adiv5_dap *dap)
Definition: dmem.c:313
struct adapter_driver dmem_dap_adapter_driver
Definition: dmem.c:609
static const struct dap_ops dmem_dap_ops
Definition: dmem.c:597
static int dmem_emu_ap_q_write(unsigned int ap_idx, unsigned int reg, uint32_t data)
Definition: dmem.c:165
static const struct command_registration dmem_dap_command_handlers[]
Definition: dmem.c:474
static void * dmem_emu_virt_base_addr
Definition: dmem.c:57
static int dmem_dap_reset(int req_trst, int req_srst)
Definition: dmem.c:574
static int dmem_ap_q_read(struct adiv5_ap *ap, unsigned int reg, uint32_t *data)
Definition: dmem.c:262
static int dmem_ap_q_abort(struct adiv5_dap *dap, uint8_t *ack)
Definition: dmem.c:308
static void * dmem_virt_base_addr
Definition: dmem.c:41
static int dmem_dap_speed(int speed)
Definition: dmem.c:579
static int dmem_dap_retval
Definition: dmem.c:52
static const char *const dmem_dap_transport[]
Definition: dmem.c:607
static bool dmem_is_emulated_ap(struct adiv5_ap *ap, unsigned int *idx)
Definition: dmem.c:85
static uint64_t dmem_dap_base_address
Definition: dmem.c:47
static int dmem_dap_speed_div(int speed, int *khz)
Definition: dmem.c:590
static void * dmem_map_base
Definition: dmem.c:41
static int dmem_emu_ap_q_read(unsigned int ap_idx, unsigned int reg, uint32_t *data)
Definition: dmem.c:114
static uint32_t dmem_memap_tar_inc(uint32_t csw)
Definition: dmem.c:67
static uint32_t dmem_get_ap_reg(struct adiv5_ap *ap, unsigned int reg)
Definition: dmem.c:233
static int dmem_connect(struct adiv5_dap *dap)
Definition: dmem.c:323
#define ARM_APB_PADDR31
Definition: dmem.c:39
static struct dmem_emu_ap_info dmem_emu_ap_list[DMEM_MAX_EMULATE_APS]
Definition: dmem.c:61
static size_t dmem_emu_mapped_size
Definition: dmem.c:58
static uint64_t dmem_emu_base_address
Definition: dmem.c:55
#define DMEM_DEV_PATH_DEFAULT
Definition: dmem.c:45
static int dmem_dp_q_write(struct adiv5_dap *dap, unsigned int reg, uint32_t data)
Definition: dmem.c:257
static int dmem_dap_init(void)
Definition: dmem.c:485
static int dmem_dap_quit(void)
Definition: dmem.c:562
static uint32_t dmem_emu_get_ap_reg(uint64_t addr)
Definition: dmem.c:103
static unsigned int dmem_dap_max_aps
Definition: dmem.c:48
#define ERROR_FAIL
Definition: log.h:170
#define LOG_ERROR(expr ...)
Definition: log.h:132
#define LOG_INFO(expr ...)
Definition: log.h:126
#define ERROR_OK
Definition: log.h:164
target_addr_t addr
Start address to search for the control block.
Definition: rtt/rtt.c:28
Represents a driver for a debugging interface.
Definition: interface.h:207
const char *const name
The name of the interface driver.
Definition: interface.h:209
This represents an ARM Debug Interface (v5) Access Port (AP).
Definition: arm_adi_v5.h:250
uint64_t ap_num
ADIv5: Number of this AP (0~255) ADIv6: Base address of this AP (4k aligned) TODO: to be more coheren...
Definition: arm_adi_v5.h:261
struct adiv5_dap * dap
DAP this AP belongs to.
Definition: arm_adi_v5.h:254
This represents an ARM Debug Interface (v5) Debug Access Port (DAP).
Definition: arm_adi_v5.h:348
const char * name
Definition: command.h:235
const char * usage
a string listing the options and arguments, required or optional
Definition: command.h:241
Transport-neutral representation of queued DAP transactions, supporting both JTAG and SWD transports.
Definition: arm_adi_v5.h:446
int(* connect)(struct adiv5_dap *dap)
connect operation for SWD
Definition: arm_adi_v5.h:451
uint32_t apbap_tar
Definition: dmem.c:31
uint32_t apbap_csw
Definition: dmem.c:32
uint64_t ap_num
Definition: dmem.c:29
Definition: register.h:111
#define NULL
Definition: usb.h:16