138 LOG_ERROR(
"DAP read of DPIDR1 failed...");
143 LOG_ERROR(
"DAP read of DPIDR1 failed...");
186 { .name =
"-dp-id", .value =
CFG_DP_ID },
188 { .name =
"-adiv6", .value =
CFG_ADIV6 },
189 { .name =
"-adiv5", .value =
CFG_ADIV5 },
190 { .name =
NULL, .value = -1 }
199 while (goi->
argc > 0) {
200 Jim_SetEmptyResult(goi->
interp);
217 Jim_SetResultString(goi->
interp,
"-chain-position is invalid", -1);
231 Jim_SetResultFormatted(goi->
interp,
232 "create %s: bad parameter %s",
237 Jim_SetResultFormatted(goi->
interp,
238 "create %s: %s out of range",
252 Jim_SetResultFormatted(goi->
interp,
253 "create %s: bad parameter %s",
257 if (w < 0 || w > 15) {
258 Jim_SetResultFormatted(goi->
interp,
259 "create %s: %s out of range",
290 bool had_multidrop = new_multidrop;
292 unsigned int non_multidrop_count = had_multidrop ? 0 : 1;
299 had_multidrop =
true;
303 LOG_ERROR(
"%s and %s have the same multidrop selectors -dp-id 0x%08"
304 PRIx32
" and -instance-id 0x%" PRIx32,
310 non_multidrop_count++;
313 non_multidrop_count++;
317 if (non_multidrop_count > 1) {
318 LOG_ERROR(
"Two or more SWD non multidrop DAPs are not supported");
321 if (had_multidrop && non_multidrop_count) {
322 LOG_ERROR(
"Mixing of SWD multidrop DAPs and non multidrop DAPs is not supported");
342 Jim_WrongNumArgs(goi->
interp, 1, goi->
argv,
"?name? ..options...");
348 cmd = Jim_GetCommand(goi->
interp, new_cmd, JIM_NONE);
350 cp = Jim_GetString(new_cmd,
NULL);
351 Jim_SetResultFormatted(goi->
interp,
"Command: %s Exists", cp);
362 cp = Jim_GetString(new_cmd,
NULL);
363 dap->name = strdup(cp);
370 Jim_SetResultString(goi->
interp,
"-chain-position required when creating DAP", -1);
385 .help =
"dap instance command group",
418 "<name> [<dap_options> ...]");
429 Jim_WrongNumArgs(interp, 1, argv,
"Too many parameters");
432 Jim_SetResult(interp, Jim_NewListObj(interp,
NULL, 0));
434 Jim_ListAppendElement(interp, Jim_GetResult(interp),
435 Jim_NewStringObj(interp, obj->
name, -1));
453 LOG_ERROR(
"DAP instance not available. Probably a HLA target...");
497 .usage =
"name '-chain-position' name",
498 .help =
"Creates a new DAP instance",
505 .help =
"Lists all registered DAP instances by name",
510 .handler = handle_dap_init,
512 .help =
"Initialize all registered DAP instances"
516 .handler = handle_dap_info_command,
518 .help =
"display ROM table for specified MEM-AP (default MEM-AP of current target) "
519 "or the ADIv6 root ROM table of current target's DAP",
520 .usage =
"[ap_num | 'root']",
529 .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.
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(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)
const struct dap_ops jtag_dp_ops
const struct dap_ops swd_dap_ops
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[]
COMMAND_HANDLER(handle_dap_init)
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
static int jim_dap_names(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
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)
list_add_tail - add a new entry
#define list_for_each_entry(pos, head, member)
list_for_each_entry - iterate over list of given type
#define list_for_each_entry_safe(pos, n, head, member)
list_for_each_entry_safe - iterate over list of given type safe against removal of list entry
static void INIT_LIST_HEAD(struct list_head *list)
INIT_LIST_HEAD - Initialize a list_head structure.
#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
Transport-neutral representation of queued DAP transactions, supporting both JTAG and SWD transports.
int(* connect)(struct adiv5_dap *dap)
connect operation for SWD
void(* quit)(struct adiv5_dap *dap)
Optional; called at OpenOCD exit.
int(* queue_dp_read)(struct adiv5_dap *dap, unsigned reg, uint32_t *data)
DP register read.
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.