39 #define ARM_APB_PADDR31 BIT(31)
45 #define DMEM_DEV_PATH_DEFAULT "/dev/mem"
59 #define DMEM_MAX_EMULATE_APS 5
149 LOG_INFO(
"%s: Unknown reg: 0x%02x", __func__,
reg);
205 LOG_INFO(
"%s: Unknown reg: 0x%02x", __func__,
reg);
263 static bool error_flagged;
266 LOG_ERROR(
"ADIv6 dap not supported by dmem dap-direct mode");
268 error_flagged =
true;
286 static bool error_flagged;
289 LOG_ERROR(
"ADIv6 dap not supported by dmem dap-direct mode");
291 error_flagged =
true;
383 for (
unsigned int i = 0; i <
CMD_ARGC; i++) {
420 .handler = dmem_dap_config_info_command,
422 .help =
"print the config info",
427 .handler = dmem_dap_device_command,
429 .help =
"set the dmem memory access device (default: /dev/mem)",
430 .usage =
"device_path",
433 .name =
"base_address",
434 .handler = dmem_dap_base_address_command,
436 .help =
"set the dmem dap AP memory map base address",
437 .usage =
"base_address",
440 .name =
"ap_address_offset",
441 .handler = dmem_dap_ap_offset_command,
443 .help =
"set the offsets of each ap index",
444 .usage =
"offset_address",
448 .handler = dmem_dap_max_aps_command,
450 .help =
"set the maximum number of APs this will support",
454 .name =
"emu_ap_list",
455 .handler = dmem_emu_ap_list_command,
457 .help =
"set the list of AP indices to be emulated (upto max)",
461 .name =
"emu_base_address_range",
462 .handler = dmem_emu_base_address_command,
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",
474 .help =
"Perform dmem (Direct Memory) DAP management and configuration",
484 uint32_t dmem_total_memory_window_size;
486 size_t dmem_mapped_start, dmem_mapped_end;
491 LOG_ERROR(
"dmem DAP Base address NOT set? value is 0");
495 dmem_fd = open(path, O_RDWR | O_SYNC);
514 (PROT_READ | PROT_WRITE),
518 LOG_ERROR(
"Mapping address 0x%zx for 0x%zx bytes failed!",
538 (PROT_READ | PROT_WRITE),
542 LOG_ERROR(
"Mapping EMU address 0x%" PRIx64
" for 0x%" PRIx64
" bytes failed!",
561 LOG_ERROR(
"%s: Failed to unmap mapped memory!", __func__);
565 LOG_ERROR(
"%s: Failed to unmap emu mapped memory!", __func__);
This defines formats and data structures used to talk to ADIv5 entities.
#define ADIV5_MEM_AP_REG_DRW
#define ADIV5_MEM_AP_REG_BD3
#define ADIV5_MEM_AP_REG_BD2
#define ADIV5_MEM_AP_REG_CFG
#define ADIV5_MEM_AP_REG_BD1
#define ADIV5_MEM_AP_REG_BASE
#define ADIV5_MEM_AP_REG_CSW
static bool is_adiv6(const struct adiv5_dap *dap)
Check if DAP is ADIv6.
#define ADIV5_MEM_AP_REG_TAR
#define ADIV5_MEM_AP_REG_BD0
void command_print(struct command_invocation *cmd, const char *format,...)
#define CMD
Use this macro to access the command being handled, rather than accessing the variable directly.
#define CMD_ARGV
Use this macro to access the arguments for the command being handled, rather than accessing the varia...
#define ERROR_COMMAND_SYNTAX_ERROR
#define CMD_ARGC
Use this macro to access the number of arguments for the command being handled, rather than accessing...
#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...
#define COMMAND_REGISTRATION_DONE
Use this as the last entry in an array of command_registration records.
static int dmem_ap_q_write(struct adiv5_ap *ap, unsigned int reg, uint32_t data)
static char * dmem_dev_path
static int dmem_dp_q_read(struct adiv5_dap *dap, unsigned int reg, uint32_t *data)
static size_t dmem_mapped_size
static unsigned int dmem_emu_ap_count
static int dmem_dap_khz(int khz, int *jtag_speed)
static void * dmem_emu_map_base
COMMAND_HANDLER(dmem_dap_device_command)
static void dmem_set_ap_reg(struct adiv5_ap *ap, unsigned int reg, uint32_t val)
static uint32_t dmem_dap_ap_offset
static const struct command_registration dmem_dap_subcommand_handlers[]
#define DMEM_MAX_EMULATE_APS
static uint32_t dmem_get_ap_reg_offset(struct adiv5_ap *ap, unsigned int reg)
static uint64_t dmem_emu_size
static uint32_t dmem_emu_get_ap_reg(uint32_t addr)
static int dmem_dp_run(struct adiv5_dap *dap)
struct adapter_driver dmem_dap_adapter_driver
static const struct dap_ops dmem_dap_ops
static int dmem_emu_ap_q_write(unsigned int ap_idx, unsigned int reg, uint32_t data)
static const struct command_registration dmem_dap_command_handlers[]
static void * dmem_emu_virt_base_addr
static int dmem_dap_reset(int req_trst, int req_srst)
static int dmem_ap_q_read(struct adiv5_ap *ap, unsigned int reg, uint32_t *data)
static int dmem_ap_q_abort(struct adiv5_dap *dap, uint8_t *ack)
static void * dmem_virt_base_addr
static int dmem_dap_speed(int speed)
static int dmem_dap_retval
static bool dmem_is_emulated_ap(struct adiv5_ap *ap, unsigned int *idx)
static uint64_t dmem_dap_base_address
static int dmem_dap_speed_div(int speed, int *khz)
static void * dmem_map_base
static int dmem_emu_ap_q_read(unsigned int ap_idx, unsigned int reg, uint32_t *data)
static uint32_t dmem_memap_tar_inc(uint32_t csw)
static uint32_t dmem_get_ap_reg(struct adiv5_ap *ap, unsigned int reg)
static int dmem_connect(struct adiv5_dap *dap)
static struct dmem_emu_ap_info dmem_emu_ap_list[DMEM_MAX_EMULATE_APS]
static size_t dmem_emu_mapped_size
static uint64_t dmem_emu_base_address
#define DMEM_DEV_PATH_DEFAULT
static int dmem_dp_q_write(struct adiv5_dap *dap, unsigned int reg, uint32_t data)
static void dmem_emu_set_ap_reg(uint32_t addr, uint32_t val)
static int dmem_dap_init(void)
static int dmem_dap_quit(void)
static unsigned int dmem_dap_max_aps
uint32_t page_size
Page size.
#define LOG_ERROR(expr ...)
#define LOG_INFO(expr ...)
target_addr_t addr
Start address to search for the control block.
Represents a driver for a debugging interface.
const char *const name
The name of the interface driver.
This represents an ARM Debug Interface (v5) Access Port (AP).
uint64_t ap_num
ADIv5: Number of this AP (0~255) ADIv6: Base address of this AP (4k aligned) TODO: to be more coheren...
struct adiv5_dap * dap
DAP this AP belongs to.
This represents an ARM Debug Interface (v5) Debug Access Port (DAP).
const char * usage
a string listing the options and arguments, required or optional
Transport-neutral representation of queued DAP transactions, supporting both JTAG and SWD transports.
int(* connect)(struct adiv5_dap *dap)
connect operation for SWD
#define TRANSPORT_DAPDIRECT_SWD