+
+ return ERROR_OK;
+}
+
+/*--------------------------------------------------------------------------*/
+
+/*
+ * Only stuff below this line should need to verify that its target
+ * is an ARMv7-M node.
+ *
+ * FIXME yet none of it _does_ verify target types yet!
+ */
+
+
+/*
+ * Return the debug ap baseaddress in hexadecimal;
+ * no extra output to simplify script processing
+ */
+COMMAND_HANDLER(handle_dap_baseaddr_command)
+{
+ struct target *target = get_current_target(cmd_ctx);
+ struct armv7m_common *armv7m = target_to_armv7m(target);
+ struct swjdp_common *swjdp = &armv7m->swjdp_info;
+ uint32_t apsel, apselsave, baseaddr;
+ int retval;
+
+ apselsave = swjdp->apsel;
+ switch (argc) {
+ case 0:
+ apsel = swjdp->apsel;
+ break;
+ case 1:
+ COMMAND_PARSE_NUMBER(u32, args[0], apsel);
+ break;
+ default:
+ return ERROR_COMMAND_SYNTAX_ERROR;
+ }
+
+ if (apselsave != apsel)
+ dap_ap_select(swjdp, apsel);
+
+ dap_ap_read_reg_u32(swjdp, 0xF8, &baseaddr);
+ retval = swjdp_transaction_endcheck(swjdp);
+ command_print(cmd_ctx, "0x%8.8" PRIx32 "", baseaddr);
+
+ if (apselsave != apsel)
+ dap_ap_select(swjdp, apselsave);
+
+ return retval;
+}
+
+/*
+ * Return the debug ap id in hexadecimal;
+ * no extra output to simplify script processing
+ */
+COMMAND_HANDLER(handle_dap_apid_command)
+{
+ struct target *target = get_current_target(cmd_ctx);
+ struct armv7m_common *armv7m = target_to_armv7m(target);
+ struct swjdp_common *swjdp = &armv7m->swjdp_info;
+
+ return CALL_COMMAND_HANDLER(dap_apid_command, swjdp);
+}
+
+COMMAND_HANDLER(handle_dap_apsel_command)
+{
+ struct target *target = get_current_target(cmd_ctx);
+ struct armv7m_common *armv7m = target_to_armv7m(target);
+ struct swjdp_common *swjdp = &armv7m->swjdp_info;
+
+ return CALL_COMMAND_HANDLER(dap_apsel_command, swjdp);
+}
+
+COMMAND_HANDLER(handle_dap_memaccess_command)
+{
+ struct target *target = get_current_target(cmd_ctx);
+ struct armv7m_common *armv7m = target_to_armv7m(target);
+ struct swjdp_common *swjdp = &armv7m->swjdp_info;
+
+ return CALL_COMMAND_HANDLER(dap_memaccess_command, swjdp);
+}
+
+
+COMMAND_HANDLER(handle_dap_info_command)
+{
+ struct target *target = get_current_target(cmd_ctx);
+ struct armv7m_common *armv7m = target_to_armv7m(target);
+ struct swjdp_common *swjdp = &armv7m->swjdp_info;
+ uint32_t apsel;
+
+ switch (argc) {
+ case 0:
+ apsel = swjdp->apsel;
+ break;
+ case 1:
+ COMMAND_PARSE_NUMBER(u32, args[0], apsel);
+ break;
+ default:
+ return ERROR_COMMAND_SYNTAX_ERROR;
+ }
+
+ return dap_info_command(cmd_ctx, swjdp, apsel);
+}
+
+/** Registers commands used to access DAP resources. */
+int armv7m_register_commands(struct command_context *cmd_ctx)
+{
+ struct command *arm_adi_v5_dap_cmd;
+
+ arm_adi_v5_dap_cmd = register_command(cmd_ctx, NULL, "dap",
+ NULL, COMMAND_ANY,
+ "cortex dap specific commands");
+
+ register_command(cmd_ctx, arm_adi_v5_dap_cmd, "info",
+ handle_dap_info_command, COMMAND_EXEC,
+ "Displays dap info for ap [num],"
+ "default currently selected AP");
+ register_command(cmd_ctx, arm_adi_v5_dap_cmd, "apsel",
+ handle_dap_apsel_command, COMMAND_EXEC,
+ "Select a different AP [num] (default 0)");
+ register_command(cmd_ctx, arm_adi_v5_dap_cmd, "apid",
+ handle_dap_apid_command, COMMAND_EXEC,
+ "Displays id reg from AP [num], "
+ "default currently selected AP");
+ register_command(cmd_ctx, arm_adi_v5_dap_cmd, "baseaddr",
+ handle_dap_baseaddr_command, COMMAND_EXEC,
+ "Displays debug base address from AP [num],"
+ "default currently selected AP");
+ register_command(cmd_ctx, arm_adi_v5_dap_cmd, "memaccess",
+ handle_dap_memaccess_command, COMMAND_EXEC,
+ "set/get number of extra tck for mem-ap "
+ "memory bus access [0-255]");
+