94 bool pre_connect =
true;
145 LOG_ERROR(
"DAP read of DPIDR1 failed...");
150 LOG_ERROR(
"DAP read of DPIDR1 failed...");
193 { .name =
"-dp-id", .value =
CFG_DP_ID },
195 { .name =
"-adiv6", .value =
CFG_ADIV6 },
196 { .name =
"-adiv5", .value =
CFG_ADIV5 },
197 { .name =
NULL, .value = -1 }
206 while (goi->
argc > 0) {
207 Jim_SetEmptyResult(goi->
interp);
224 Jim_SetResultString(goi->
interp,
"-chain-position is invalid", -1);
238 Jim_SetResultFormatted(goi->
interp,
239 "create %s: bad parameter %s",
244 Jim_SetResultFormatted(goi->
interp,
245 "create %s: %s out of range",
259 Jim_SetResultFormatted(goi->
interp,
260 "create %s: bad parameter %s",
264 if (w < 0 || w > 15) {
265 Jim_SetResultFormatted(goi->
interp,
266 "create %s: %s out of range",
297 bool had_multidrop = new_multidrop;
299 unsigned int non_multidrop_count = had_multidrop ? 0 : 1;
306 had_multidrop =
true;
310 LOG_ERROR(
"%s and %s have the same multidrop selectors -dp-id 0x%08"
311 PRIx32
" and -instance-id 0x%" PRIx32,
317 non_multidrop_count++;
320 non_multidrop_count++;
324 if (non_multidrop_count > 1) {
325 LOG_ERROR(
"Two or more SWD non multidrop DAPs are not supported");
328 if (had_multidrop && non_multidrop_count) {
329 LOG_ERROR(
"Mixing of SWD multidrop DAPs and non multidrop DAPs is not supported");
349 Jim_WrongNumArgs(goi->
interp, 1, goi->
argv,
"?name? ..options...");
355 cmd = Jim_GetCommand(goi->
interp, new_cmd, JIM_NONE);
357 cp = Jim_GetString(new_cmd,
NULL);
358 Jim_SetResultFormatted(goi->
interp,
"Command: %s Exists", cp);
369 cp = Jim_GetString(new_cmd,
NULL);
370 dap->name = strdup(cp);
377 Jim_SetResultString(goi->
interp,
"-chain-position required when creating DAP", -1);
392 .help =
"dap instance command group",
425 "<name> [<dap_options> ...]");
456 LOG_ERROR(
"DAP instance not available. Probably a HLA target...");
500 .usage =
"name '-chain-position' name",
501 .help =
"Creates a new DAP instance",
506 .handler = handle_dap_names,
508 .help =
"Lists all registered DAP instances by name",
513 .handler = handle_dap_init,
515 .help =
"Initialize all registered DAP instances"
519 .handler = handle_dap_info_command,
521 .help =
"display ROM table for specified MEM-AP (default MEM-AP of current target) "
522 "or the ADIv6 root ROM table of current target's DAP",
523 .usage =
"[ap_num | 'root']",
532 .help =
"DAP commands",
bool transport_is_dapdirect_swd(void)
Returns true if the current debug session is using SWD as its transport.
bool transport_is_dapdirect_jtag(void)
Returns true if the current debug session is using JTAG as its transport.
const struct dap_ops jtag_dp_ops
const struct dap_ops swd_dap_ops
bool transport_is_swd(void)
Returns true if the current debug session is using SWD as its transport.
Holds the interface to ARM cores.
static struct arm * target_to_arm(const struct target *target)
Convert target handle to generic ARM target state handle.
int dap_info_command(struct command_invocation *cmd, struct adiv5_ap *ap)
bool is_ap_num_valid(struct adiv5_dap *dap, uint64_t ap_num)
int adiv6_dap_read_baseptr(struct command_invocation *cmd, struct adiv5_dap *dap, uint64_t *baseptr)
struct adiv5_ap * dap_get_ap(struct adiv5_dap *dap, uint64_t ap_num)
int dap_put_ap(struct adiv5_ap *ap)
const struct command_registration dap_instance_commands[]
This defines formats and data structures used to talk to ADIv5 entities.
#define DP_DPIDR1_ASIZE_MASK
#define DP_TARGETSEL_INSTANCEID_MASK
#define DP_TARGETSEL_INSTANCEID_SHIFT
static bool is_adiv6(const struct adiv5_dap *dap)
Check if DAP is ADIv6.
static int dap_run(struct adiv5_dap *dap)
Perform all queued DAP operations, and clear any errors posted in the CTRL_STAT register when they ar...
static bool dap_is_multidrop(struct adiv5_dap *dap)
Check if SWD multidrop configuration is valid.
#define DP_TARGETSEL_DPID_MASK
#define MEM_AP_REG_CFG_INVALID
static int dap_create(struct jim_getopt_info *goi)
static int dap_init_all(void)
int dap_cleanup_all(void)
static const struct jim_nvp nvp_config_opts[]
static const struct command_registration dap_subcommand_handlers[]
struct adiv5_dap * dap_instance_by_jim_obj(Jim_Interp *interp, Jim_Obj *o)
static int dap_configure(struct jim_getopt_info *goi, struct arm_dap_object *dap)
static const struct command_registration dap_commands[]
const struct swd_driver * adiv5_dap_swd_driver(struct adiv5_dap *self)
static LIST_HEAD(all_dap)
static void dap_instance_init(struct adiv5_dap *dap)
int dap_register_commands(struct command_context *cmd_ctx)
struct adiv5_dap * adiv5_get_dap(struct arm_dap_object *obj)
static int jim_dap_create(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
static int dap_check_config(struct adiv5_dap *dap)
const char * adiv5_dap_name(struct adiv5_dap *self)
struct adapter_driver * adapter_driver
COMMAND_HANDLER(handle_dap_names)
struct command_context * current_command_context(Jim_Interp *interp)
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...
static int register_commands_with_data(struct command_context *cmd_ctx, const char *cmd_prefix, const struct command_registration *cmds, void *data)
Register one or more commands, as register_commands(), plus specify a pointer to command private data...
#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 CMD_CTX
Use this macro to access the context of the command being handled, rather than accessing the variable...
#define COMMAND_REGISTRATION_DONE
Use this as the last entry in an array of command_registration records.
#define ERROR_COMMAND_ARGUMENT_INVALID
static int register_commands(struct command_context *cmd_ctx, const char *cmd_prefix, const struct command_registration *cmds)
Register one or more commands in the specified context, as children of parent (or top-level commends,...
bool transport_is_hla(void)
int jim_getopt_wide(struct jim_getopt_info *goi, jim_wide *puthere)
Remove argv[0] as wide.
int jim_getopt_setup(struct jim_getopt_info *p, Jim_Interp *interp, int argc, Jim_Obj *const *argv)
GetOpt - how to.
int jim_getopt_nvp(struct jim_getopt_info *goi, const struct jim_nvp *nvp, struct jim_nvp **puthere)
Remove argv[0] as NVP.
void jim_getopt_nvp_unknown(struct jim_getopt_info *goi, const struct jim_nvp *nvptable, int hadprefix)
Create an appropriate error message for an NVP.
int jim_getopt_obj(struct jim_getopt_info *goi, Jim_Obj **puthere)
Remove argv[0] from the list.
bool transport_is_jtag(void)
Returns true if the current debug session is using JTAG as its transport.
const char * jtag_tap_name(const struct jtag_tap *tap)
struct jtag_tap * jtag_tap_by_jim_obj(Jim_Interp *interp, Jim_Obj *obj)
static void list_add_tail(struct list_head *new, struct list_head *head)
#define list_for_each_entry_safe(p, n, h, field)
#define list_for_each_entry(p, h, field)
static void INIT_LIST_HEAD(struct list_head *list)
#define LOG_ERROR(expr ...)
#define LOG_DEBUG(expr ...)
static uint32_t lh(unsigned int rd, unsigned int base, uint16_t offset) __attribute__((unused))
Represents a driver for a debugging interface.
const struct swd_driver * swd_ops
Low-level SWD APIs.
const struct dap_ops * dap_swd_ops
const struct dap_ops * dap_jtag_ops
This represents an ARM Debug Interface (v5) Access Port (AP).
bool config_ap_never_release
uint32_t tar_autoincr_block
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.
uint32_t memaccess_tck
Configures how many extra tck clocks are added after starting a MEM-AP access before we try to read i...
uint32_t csw_default
Default value for (MEM-AP) AP_REG_CSW register.
This represents an ARM Debug Interface (v5) Debug Access Port (DAP).
unsigned int adi_version
Indicates ADI version (5, 6 or 0 for unknown) being used.
struct list_head cmd_journal
struct adiv5_ap ap[DP_APSEL_MAX+1]
bool multidrop_instance_id_valid
TINSTANCE field of multidrop_targetsel has been configured.
const struct dap_ops * ops
uint32_t multidrop_targetsel
Value to select DP in SWD multidrop mode or DP_TARGETSEL_INVALID.
bool multidrop_dp_id_valid
TPARTNO and TDESIGNER fields of multidrop_targetsel have been configured.
struct list_head cmd_pool
bool ignore_syspwrupack
Flag saying whether to ignore the syspwrupack flag in DAP.
const struct swd_driver * swd
Represents a generic ARM core, with standard application registers.
struct adiv5_dap * dap
For targets conforming to ARM Debug Interface v5, this handle references the Debug Access Port (DAP) ...
const struct command_registration * chain
If non-NULL, the commands in chain will be registered in the same context and scope of this registrat...
const char * usage
a string listing the options and arguments, required or optional
int(* connect)(struct adiv5_dap *dap)
connect operation for SWD
int(* queue_dp_read)(struct adiv5_dap *dap, unsigned int reg, uint32_t *data)
DP register read.
void(* quit)(struct adiv5_dap *dap)
Optional; called at OpenOCD exit.
int(* pre_connect_init)(struct adiv5_dap *dap)
Optional; called once on the first enabled dap before connecting.
A TCL -ish GetOpt like code.
Name Value Pairs, aka: NVP.
bool enabled
Is this TAP currently enabled?
struct target * get_current_target(struct command_context *cmd_ctx)
#define ERROR_TARGET_RESOURCE_NOT_AVAILABLE
#define container_of(ptr, type, member)
Cast a member of a structure out to the containing structure.