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(uint32_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(uint32_t addr)
104 {
105  addr &= ~ARM_APB_PADDR31;
106 
107  return *(volatile uint32_t *)((uintptr_t)dmem_emu_virt_base_addr + addr);
108 }
109 
110 static int dmem_emu_ap_q_read(unsigned int ap_idx, unsigned int reg, uint32_t *data)
111 {
112  uint32_t addr;
113  int ret = ERROR_OK;
114  struct dmem_emu_ap_info *ap_info = &dmem_emu_ap_list[ap_idx];
115 
116  switch (reg) {
118  *data = ap_info->apbap_csw;
119  break;
121  *data = ap_info->apbap_tar;
122  break;
124  *data = 0;
125  break;
127  *data = 0;
128  break;
129  case ADIV5_AP_REG_IDR:
130  *data = 0;
131  break;
136  addr = (ap_info->apbap_tar & ~0xf) + (reg & 0x0C);
137 
138  *data = dmem_emu_get_ap_reg(addr);
139 
140  break;
142  addr = ap_info->apbap_tar;
143 
144  *data = dmem_emu_get_ap_reg(addr);
145 
146  ap_info->apbap_tar += dmem_memap_tar_inc(ap_info->apbap_csw);
147  break;
148  default:
149  LOG_INFO("%s: Unknown reg: 0x%02x", __func__, reg);
150  ret = ERROR_FAIL;
151  break;
152  }
153 
154  /* Track the last error code. */
155  if (ret != ERROR_OK)
156  dmem_dap_retval = ret;
157 
158  return ret;
159 }
160 
161 static int dmem_emu_ap_q_write(unsigned int ap_idx, unsigned int reg, uint32_t data)
162 {
163  uint32_t addr;
164  int ret = ERROR_OK;
165  struct dmem_emu_ap_info *ap_info = &dmem_emu_ap_list[ap_idx];
166 
167  switch (reg) {
169  /*
170  * This implementation only supports 32-bit accesses.
171  * Force this by ensuring CSW_SIZE field indicates 32-BIT.
172  */
173  ap_info->apbap_csw = ((data & ~CSW_SIZE_MASK) | CSW_32BIT);
174  break;
176  /*
177  * This implementation only supports 32-bit accesses.
178  * Force LS 2-bits of TAR to 00b
179  */
180  ap_info->apbap_tar = (data & ~0x3);
181  break;
182 
185  case ADIV5_AP_REG_IDR:
186  /* We don't use this, so we don't need to store */
187  break;
188 
193  addr = (ap_info->apbap_tar & ~0xf) + (reg & 0x0C);
194 
195  dmem_emu_set_ap_reg(addr, data);
196 
197  break;
199  addr = ap_info->apbap_tar;
200  dmem_emu_set_ap_reg(addr, data);
201 
202  ap_info->apbap_tar += dmem_memap_tar_inc(ap_info->apbap_csw);
203  break;
204  default:
205  LOG_INFO("%s: Unknown reg: 0x%02x", __func__, reg);
206  ret = EINVAL;
207  break;
208  }
209 
210  /* Track the last error code. */
211  if (ret != ERROR_OK)
212  dmem_dap_retval = ret;
213 
214  return ret;
215 }
216 
217 /* AP MODE */
218 static uint32_t dmem_get_ap_reg_offset(struct adiv5_ap *ap, unsigned int reg)
219 {
220  return (dmem_dap_ap_offset * ap->ap_num) + reg;
221 }
222 
223 static void dmem_set_ap_reg(struct adiv5_ap *ap, unsigned int reg, uint32_t val)
224 {
225  *(volatile uint32_t *)((uintptr_t)dmem_virt_base_addr +
226  dmem_get_ap_reg_offset(ap, reg)) = val;
227 }
228 
229 static uint32_t dmem_get_ap_reg(struct adiv5_ap *ap, unsigned int reg)
230 {
231  return *(volatile uint32_t *)((uintptr_t)dmem_virt_base_addr +
233 }
234 
235 static int dmem_dp_q_read(struct adiv5_dap *dap, unsigned int reg, uint32_t *data)
236 {
237  if (!data)
238  return ERROR_OK;
239 
240  switch (reg) {
241  case DP_CTRL_STAT:
242  *data = CDBGPWRUPACK | CSYSPWRUPACK;
243  break;
244 
245  default:
246  *data = 0;
247  break;
248  }
249 
250  return ERROR_OK;
251 }
252 
253 static int dmem_dp_q_write(struct adiv5_dap *dap, unsigned int reg, uint32_t data)
254 {
255  return ERROR_OK;
256 }
257 
258 static int dmem_ap_q_read(struct adiv5_ap *ap, unsigned int reg, uint32_t *data)
259 {
260  unsigned int idx;
261 
262  if (is_adiv6(ap->dap)) {
263  static bool error_flagged;
264 
265  if (!error_flagged)
266  LOG_ERROR("ADIv6 dap not supported by dmem dap-direct mode");
267 
268  error_flagged = true;
269 
270  return ERROR_FAIL;
271  }
272 
273  if (dmem_is_emulated_ap(ap, &idx))
274  return dmem_emu_ap_q_read(idx, reg, data);
275 
276  *data = dmem_get_ap_reg(ap, reg);
277 
278  return ERROR_OK;
279 }
280 
281 static int dmem_ap_q_write(struct adiv5_ap *ap, unsigned int reg, uint32_t data)
282 {
283  unsigned int idx;
284 
285  if (is_adiv6(ap->dap)) {
286  static bool error_flagged;
287 
288  if (!error_flagged)
289  LOG_ERROR("ADIv6 dap not supported by dmem dap-direct mode");
290 
291  error_flagged = true;
292 
293  return ERROR_FAIL;
294  }
295 
296  if (dmem_is_emulated_ap(ap, &idx))
297  return dmem_emu_ap_q_write(idx, reg, data);
298 
299  dmem_set_ap_reg(ap, reg, data);
300 
301  return ERROR_OK;
302 }
303 
304 static int dmem_ap_q_abort(struct adiv5_dap *dap, uint8_t *ack)
305 {
306  return ERROR_OK;
307 }
308 
309 static int dmem_dp_run(struct adiv5_dap *dap)
310 {
311  int retval = dmem_dap_retval;
312 
313  /* Clear the error code. */
315 
316  return retval;
317 }
318 
319 static int dmem_connect(struct adiv5_dap *dap)
320 {
321  return ERROR_OK;
322 }
323 
324 COMMAND_HANDLER(dmem_dap_device_command)
325 {
326  if (CMD_ARGC != 1)
328 
329  free(dmem_dev_path);
330  dmem_dev_path = strdup(CMD_ARGV[0]);
331 
332  return ERROR_OK;
333 }
334 
335 COMMAND_HANDLER(dmem_dap_base_address_command)
336 {
337  if (CMD_ARGC != 1)
339 
341 
342  return ERROR_OK;
343 }
344 
345 COMMAND_HANDLER(dmem_dap_max_aps_command)
346 {
347  if (CMD_ARGC != 1)
349 
351 
352  return ERROR_OK;
353 }
354 
355 COMMAND_HANDLER(dmem_dap_ap_offset_command)
356 {
357  if (CMD_ARGC != 1)
359 
361 
362  return ERROR_OK;
363 }
364 
365 COMMAND_HANDLER(dmem_emu_base_address_command)
366 {
367  if (CMD_ARGC != 2)
369 
372 
373  return ERROR_OK;
374 }
375 
376 COMMAND_HANDLER(dmem_emu_ap_list_command)
377 {
378  uint64_t em_ap;
379 
380  if (CMD_ARGC < 1 || CMD_ARGC > DMEM_MAX_EMULATE_APS)
382 
383  for (unsigned int i = 0; i < CMD_ARGC; i++) {
384  COMMAND_PARSE_NUMBER(u64, CMD_ARGV[i], em_ap);
385  dmem_emu_ap_list[i].ap_num = em_ap;
386  }
387 
389 
390  return ERROR_OK;
391 }
392 
393 COMMAND_HANDLER(dmem_dap_config_info_command)
394 {
395  if (CMD_ARGC != 0)
397 
398  command_print(CMD, "dmem (Direct Memory) AP Adapter Configuration:");
399  command_print(CMD, " Device : %s",
401  command_print(CMD, " Base Address : 0x%" PRIx64, dmem_dap_base_address);
402  command_print(CMD, " Max APs : %u", dmem_dap_max_aps);
403  command_print(CMD, " AP offset : 0x%08" PRIx32, dmem_dap_ap_offset);
404  command_print(CMD, " Emulated AP Count : %u", dmem_emu_ap_count);
405 
406  if (dmem_emu_ap_count) {
407  command_print(CMD, " Emulated AP details:");
408  command_print(CMD, " Emulated address : 0x%" PRIx64, dmem_emu_base_address);
409  command_print(CMD, " Emulated size : 0x%" PRIx64, dmem_emu_size);
410  for (unsigned int i = 0; i < dmem_emu_ap_count; i++)
411  command_print(CMD, " Emulated AP [%u] : %" PRIx64, i,
413  }
414  return ERROR_OK;
415 }
416 
417 static const struct command_registration dmem_dap_subcommand_handlers[] = {
418  {
419  .name = "info",
420  .handler = dmem_dap_config_info_command,
421  .mode = COMMAND_ANY,
422  .help = "print the config info",
423  .usage = "",
424  },
425  {
426  .name = "device",
427  .handler = dmem_dap_device_command,
428  .mode = COMMAND_CONFIG,
429  .help = "set the dmem memory access device (default: /dev/mem)",
430  .usage = "device_path",
431  },
432  {
433  .name = "base_address",
434  .handler = dmem_dap_base_address_command,
435  .mode = COMMAND_CONFIG,
436  .help = "set the dmem dap AP memory map base address",
437  .usage = "base_address",
438  },
439  {
440  .name = "ap_address_offset",
441  .handler = dmem_dap_ap_offset_command,
442  .mode = COMMAND_CONFIG,
443  .help = "set the offsets of each ap index",
444  .usage = "offset_address",
445  },
446  {
447  .name = "max_aps",
448  .handler = dmem_dap_max_aps_command,
449  .mode = COMMAND_CONFIG,
450  .help = "set the maximum number of APs this will support",
451  .usage = "n",
452  },
453  {
454  .name = "emu_ap_list",
455  .handler = dmem_emu_ap_list_command,
456  .mode = COMMAND_CONFIG,
457  .help = "set the list of AP indices to be emulated (upto max)",
458  .usage = "n",
459  },
460  {
461  .name = "emu_base_address_range",
462  .handler = dmem_emu_base_address_command,
463  .mode = COMMAND_CONFIG,
464  .help = "set the base address and size of emulated AP range (all emulated APs access this range)",
465  .usage = "base_address address_window_size",
466  },
468 };
469 
470 static const struct command_registration dmem_dap_command_handlers[] = {
471  {
472  .name = "dmem",
473  .mode = COMMAND_ANY,
474  .help = "Perform dmem (Direct Memory) DAP management and configuration",
476  .usage = "",
477  },
479 };
480 
481 static int dmem_dap_init(void)
482 {
484  uint32_t dmem_total_memory_window_size;
485  long page_size = sysconf(_SC_PAGESIZE);
486  size_t dmem_mapped_start, dmem_mapped_end;
487  long start_delta;
488  int dmem_fd;
489 
490  if (!dmem_dap_base_address) {
491  LOG_ERROR("dmem DAP Base address NOT set? value is 0");
492  return ERROR_FAIL;
493  }
494 
495  dmem_fd = open(path, O_RDWR | O_SYNC);
496  if (dmem_fd == -1) {
497  LOG_ERROR("Unable to open %s", path);
498  return ERROR_FAIL;
499  }
500 
501  dmem_total_memory_window_size = (dmem_dap_max_aps + 1) * dmem_dap_ap_offset;
502 
503  dmem_mapped_start = dmem_dap_base_address;
504  dmem_mapped_end = dmem_dap_base_address + dmem_total_memory_window_size;
505  /* mmap() requires page aligned offsets */
506  dmem_mapped_start = ALIGN_DOWN(dmem_mapped_start, page_size);
507  dmem_mapped_end = ALIGN_UP(dmem_mapped_end, page_size);
508 
509  dmem_mapped_size = dmem_mapped_end - dmem_mapped_start;
510  start_delta = dmem_mapped_start - dmem_dap_base_address;
511 
512  dmem_map_base = mmap(NULL,
514  (PROT_READ | PROT_WRITE),
515  MAP_SHARED, dmem_fd,
516  dmem_mapped_start);
517  if (dmem_map_base == MAP_FAILED) {
518  LOG_ERROR("Mapping address 0x%zx for 0x%zx bytes failed!",
519  dmem_mapped_start, dmem_mapped_size);
520  goto error_fail;
521  }
522 
523  dmem_virt_base_addr = (void *)((uintptr_t)dmem_map_base + start_delta);
524 
525  /* Lets Map the emulated address if necessary */
526  if (dmem_emu_ap_count) {
527  dmem_mapped_start = dmem_emu_base_address;
528  dmem_mapped_end = dmem_emu_base_address + dmem_emu_size;
529  /* mmap() requires page aligned offsets */
530  dmem_mapped_start = ALIGN_DOWN(dmem_mapped_start, page_size);
531  dmem_mapped_end = ALIGN_UP(dmem_mapped_end, page_size);
532 
533  dmem_emu_mapped_size = dmem_mapped_end - dmem_mapped_start;
534  start_delta = dmem_mapped_start - dmem_emu_base_address;
535 
536  dmem_emu_map_base = mmap(NULL,
538  (PROT_READ | PROT_WRITE),
539  MAP_SHARED, dmem_fd,
540  dmem_mapped_start);
541  if (dmem_emu_map_base == MAP_FAILED) {
542  LOG_ERROR("Mapping EMU address 0x%" PRIx64 " for 0x%" PRIx64 " bytes failed!",
544  goto error_fail;
545  }
546  dmem_emu_virt_base_addr = (void *)((uintptr_t)dmem_emu_map_base +
547  start_delta);
548  }
549 
550  close(dmem_fd);
551  return ERROR_OK;
552 
553 error_fail:
554  close(dmem_fd);
555  return ERROR_FAIL;
556 }
557 
558 static int dmem_dap_quit(void)
559 {
560  if (munmap(dmem_map_base, dmem_mapped_size) == -1)
561  LOG_ERROR("%s: Failed to unmap mapped memory!", __func__);
562 
564  && munmap(dmem_emu_map_base, dmem_emu_mapped_size) == -1)
565  LOG_ERROR("%s: Failed to unmap emu mapped memory!", __func__);
566 
567  return ERROR_OK;
568 }
569 
570 static int dmem_dap_reset(int req_trst, int req_srst)
571 {
572  return ERROR_OK;
573 }
574 
575 static int dmem_dap_speed(int speed)
576 {
577  return ERROR_OK;
578 }
579 
580 static int dmem_dap_khz(int khz, int *jtag_speed)
581 {
582  *jtag_speed = khz;
583  return ERROR_OK;
584 }
585 
586 static int dmem_dap_speed_div(int speed, int *khz)
587 {
588  *khz = speed;
589  return ERROR_OK;
590 }
591 
592 /* DAP operations. */
593 static const struct dap_ops dmem_dap_ops = {
595  .queue_dp_read = dmem_dp_q_read,
596  .queue_dp_write = dmem_dp_q_write,
597  .queue_ap_read = dmem_ap_q_read,
598  .queue_ap_write = dmem_ap_q_write,
599  .queue_ap_abort = dmem_ap_q_abort,
600  .run = dmem_dp_run,
601 };
602 
604  .name = "dmem",
605  .transport_ids = TRANSPORT_DAPDIRECT_SWD,
606  .transport_preferred_id = TRANSPORT_DAPDIRECT_SWD,
607  .commands = dmem_dap_command_handlers,
608 
609  .init = dmem_dap_init,
610  .quit = dmem_dap_quit,
611  .reset = dmem_dap_reset,
612  .speed = dmem_dap_speed,
613  .khz = dmem_dap_khz,
614  .speed_div = dmem_dap_speed_div,
615 
616  .dap_swd_ops = &dmem_dap_ops,
617 };
#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:389
#define CMD
Use this macro to access the command being handled, rather than accessing the variable directly.
Definition: command.h:146
#define CMD_ARGV
Use this macro to access the arguments for the command being handled, rather than accessing the varia...
Definition: command.h:161
#define ERROR_COMMAND_SYNTAX_ERROR
Definition: command.h:405
#define CMD_ARGC
Use this macro to access the number of arguments for the command being handled, rather than accessing...
Definition: command.h:156
#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:445
#define COMMAND_REGISTRATION_DONE
Use this as the last entry in an array of command_registration records.
Definition: command.h:256
@ 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:281
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:235
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:580
static void * dmem_emu_map_base
Definition: dmem.c:57
COMMAND_HANDLER(dmem_dap_device_command)
Definition: dmem.c:324
static void dmem_set_ap_reg(struct adiv5_ap *ap, unsigned int reg, uint32_t val)
Definition: dmem.c:223
static uint32_t dmem_dap_ap_offset
Definition: dmem.c:49
static const struct command_registration dmem_dap_subcommand_handlers[]
Definition: dmem.c:417
#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:218
static uint64_t dmem_emu_size
Definition: dmem.c:56
static uint32_t dmem_emu_get_ap_reg(uint32_t addr)
Definition: dmem.c:103
static int dmem_dp_run(struct adiv5_dap *dap)
Definition: dmem.c:309
struct adapter_driver dmem_dap_adapter_driver
Definition: dmem.c:603
static const struct dap_ops dmem_dap_ops
Definition: dmem.c:593
static int dmem_emu_ap_q_write(unsigned int ap_idx, unsigned int reg, uint32_t data)
Definition: dmem.c:161
static const struct command_registration dmem_dap_command_handlers[]
Definition: dmem.c:470
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:570
static int dmem_ap_q_read(struct adiv5_ap *ap, unsigned int reg, uint32_t *data)
Definition: dmem.c:258
static int dmem_ap_q_abort(struct adiv5_dap *dap, uint8_t *ack)
Definition: dmem.c:304
static void * dmem_virt_base_addr
Definition: dmem.c:41
static int dmem_dap_speed(int speed)
Definition: dmem.c:575
static int dmem_dap_retval
Definition: dmem.c:52
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:586
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:110
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:229
static int dmem_connect(struct adiv5_dap *dap)
Definition: dmem.c:319
#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:253
static void dmem_emu_set_ap_reg(uint32_t addr, uint32_t val)
Definition: dmem.c:96
static int dmem_dap_init(void)
Definition: dmem.c:481
static int dmem_dap_quit(void)
Definition: dmem.c:558
static unsigned int dmem_dap_max_aps
Definition: dmem.c:48
uint32_t page_size
Page size.
Definition: dw-spi-helper.h:3
#define ERROR_FAIL
Definition: log.h:188
#define LOG_ERROR(expr ...)
Definition: log.h:147
#define LOG_INFO(expr ...)
Definition: log.h:141
#define ERROR_OK
Definition: log.h:182
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:208
const char *const name
The name of the interface driver.
Definition: interface.h:210
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:239
const char * usage
a string listing the options and arguments, required or optional
Definition: command.h:244
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 TRANSPORT_DAPDIRECT_SWD
Definition: transport.h:24
#define NULL
Definition: usb.h:16