39 #define ARM_APB_PADDR31 BIT(31)
45 #define DMEM_DEV_PATH_DEFAULT "/dev/mem"
59 #define DMEM_MAX_EMULATE_APS 5
153 LOG_INFO(
"%s: Unknown reg: 0x%02x", __func__,
reg);
209 LOG_INFO(
"%s: Unknown reg: 0x%02x", __func__,
reg);
267 static bool error_flagged;
270 LOG_ERROR(
"ADIv6 dap not supported by dmem dap-direct mode");
272 error_flagged =
true;
290 static bool error_flagged;
293 LOG_ERROR(
"ADIv6 dap not supported by dmem dap-direct mode");
295 error_flagged =
true;
387 for (
unsigned int i = 0; i <
CMD_ARGC; i++) {
424 .handler = dmem_dap_config_info_command,
426 .help =
"print the config info",
431 .handler = dmem_dap_device_command,
433 .help =
"set the dmem memory access device (default: /dev/mem)",
434 .usage =
"device_path",
437 .name =
"base_address",
438 .handler = dmem_dap_base_address_command,
440 .help =
"set the dmem dap AP memory map base address",
441 .usage =
"base_address",
444 .name =
"ap_address_offset",
445 .handler = dmem_dap_ap_offset_command,
447 .help =
"set the offsets of each ap index",
448 .usage =
"offset_address",
452 .handler = dmem_dap_max_aps_command,
454 .help =
"set the maximum number of APs this will support",
458 .name =
"emu_ap_list",
459 .handler = dmem_emu_ap_list_command,
461 .help =
"set the list of AP indices to be emulated (upto max)",
465 .name =
"emu_base_address_range",
466 .handler = dmem_emu_base_address_command,
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",
478 .help =
"Perform dmem (Direct Memory) DAP management and configuration",
488 uint32_t dmem_total_memory_window_size;
489 long page_size = sysconf(_SC_PAGESIZE);
490 size_t dmem_mapped_start, dmem_mapped_end;
495 LOG_ERROR(
"dmem DAP Base address NOT set? value is 0");
499 dmem_fd = open(path, O_RDWR | O_SYNC);
510 dmem_mapped_start =
ALIGN_DOWN(dmem_mapped_start, page_size);
511 dmem_mapped_end =
ALIGN_UP(dmem_mapped_end, page_size);
518 (PROT_READ | PROT_WRITE),
522 LOG_ERROR(
"Mapping address 0x%lx for 0x%lx bytes failed!",
534 dmem_mapped_start =
ALIGN_DOWN(dmem_mapped_start, page_size);
535 dmem_mapped_end =
ALIGN_UP(dmem_mapped_end, page_size);
542 (PROT_READ | PROT_WRITE),
546 LOG_ERROR(
"Mapping EMU address 0x%lx for 0x%lx bytes failed!",
565 LOG_ERROR(
"%s: Failed to unmap mapped memory!", __func__);
569 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 void dmem_emu_set_ap_reg(uint64_t addr, 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 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 const char *const dmem_dap_transport[]
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 int dmem_dap_init(void)
static int dmem_dap_quit(void)
static uint32_t dmem_emu_get_ap_reg(uint64_t addr)
static unsigned int dmem_dap_max_aps
#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