{
struct armv7a_common *armv7a = target_to_armv7a(target);
struct adiv5_dap *swjdp = &armv7a->dap;
- uint8_t saved_apsel = dap_ap_get_select(swjdp);
-
int retval;
uint32_t dummy;
- dap_ap_select(swjdp, swjdp_debugap);
-
LOG_DEBUG(" ");
/* Unlocking the debug registers for modification */
/* The debugport might be uninitialised so try twice */
- retval = mem_ap_write_atomic_u32(swjdp, armv7a->debug_base + CPUDBG_LOCKACCESS, 0xC5ACCE55);
+ retval = mem_ap_sel_write_atomic_u32(swjdp, swjdp_debugap,
+ armv7a->debug_base + CPUDBG_LOCKACCESS, 0xC5ACCE55);
if (retval != ERROR_OK)
{
/* try again */
- retval = mem_ap_write_atomic_u32(swjdp, armv7a->debug_base + CPUDBG_LOCKACCESS, 0xC5ACCE55);
+ retval = mem_ap_sel_write_atomic_u32(swjdp, swjdp_debugap,
+ armv7a->debug_base + CPUDBG_LOCKACCESS, 0xC5ACCE55);
if (retval == ERROR_OK)
{
LOG_USER("Locking debug access failed on first, but succeeded on second try.");
}
}
if (retval != ERROR_OK)
- goto out;
+ return retval;
/* Clear Sticky Power Down status Bit in PRSR to enable access to
the registers in the Core Power Domain */
- retval = mem_ap_read_atomic_u32(swjdp, armv7a->debug_base + CPUDBG_PRSR, &dummy);
+ retval = mem_ap_sel_read_atomic_u32(swjdp, swjdp_debugap,
+ armv7a->debug_base + CPUDBG_PRSR, &dummy);
if (retval != ERROR_OK)
- goto out;
+ return retval;
/* Enabling of instruction execution in debug mode is done in debug_entry code */
/* Resync breakpoint registers */
/* Since this is likely called from init or reset, update target state information*/
- retval = cortex_a9_poll(target);
-
- out:
- dap_ap_select(swjdp, saved_apsel);
- return retval;
+ return cortex_a9_poll(target);
}
/* To reduce needless round-trips, pass in a pointer to the current
long long then = timeval_ms();
while ((dscr & DSCR_INSTR_COMP) == 0)
{
- retval = mem_ap_read_atomic_u32(swjdp,
+ retval = mem_ap_sel_read_atomic_u32(swjdp, swjdp_debugap,
armv7a->debug_base + CPUDBG_DSCR, &dscr);
if (retval != ERROR_OK)
{
}
}
- retval = mem_ap_write_u32(swjdp, armv7a->debug_base + CPUDBG_ITR, opcode);
+ retval = mem_ap_sel_write_u32(swjdp, swjdp_debugap,
+ armv7a->debug_base + CPUDBG_ITR, opcode);
if (retval != ERROR_OK)
return retval;
then = timeval_ms();
do
{
- retval = mem_ap_read_atomic_u32(swjdp,
+ retval = mem_ap_sel_read_atomic_u32(swjdp, swjdp_debugap,
armv7a->debug_base + CPUDBG_DSCR, &dscr);
if (retval != ERROR_OK)
{
if (retval != ERROR_OK)
return retval;
- dap_ap_select(swjdp, swjdp_memoryap);
- retval = mem_ap_read_buf_u32(swjdp, (uint8_t *)(®file[1]), 4*15, address);
- if (retval != ERROR_OK)
- return retval;
- dap_ap_select(swjdp, swjdp_debugap);
+ retval = mem_ap_sel_read_buf_u32(swjdp, swjdp_memoryap,
+ (uint8_t *)(®file[1]), 4*15, address);
return retval;
}
long long then = timeval_ms();
while ((dscr & DSCR_DTR_TX_FULL) == 0)
{
- retval = mem_ap_read_atomic_u32(swjdp,
+ retval = mem_ap_sel_read_atomic_u32(swjdp, swjdp_debugap,
armv7a->debug_base + CPUDBG_DSCR, &dscr);
if (retval != ERROR_OK)
return retval;
}
}
- retval = mem_ap_read_atomic_u32(swjdp,
+ retval = mem_ap_sel_read_atomic_u32(swjdp, swjdp_debugap,
armv7a->debug_base + CPUDBG_DTRTX, value);
LOG_DEBUG("read DCC 0x%08" PRIx32, *value);
LOG_DEBUG("register %i, value 0x%08" PRIx32, regnum, value);
/* Check that DCCRX is not full */
- retval = mem_ap_read_atomic_u32(swjdp,
+ retval = mem_ap_sel_read_atomic_u32(swjdp, swjdp_debugap,
armv7a->debug_base + CPUDBG_DSCR, &dscr);
if (retval != ERROR_OK)
return retval;
/* Write DTRRX ... sets DSCR.DTRRXfull but exec_opcode() won't care */
LOG_DEBUG("write DCC 0x%08" PRIx32, value);
- retval = mem_ap_write_u32(swjdp,
+ retval = mem_ap_sel_write_u32(swjdp, swjdp_debugap,
armv7a->debug_base + CPUDBG_DTRRX, value);
if (retval != ERROR_OK)
return retval;
struct armv7a_common *armv7a = target_to_armv7a(target);
struct adiv5_dap *swjdp = &armv7a->dap;
- retval = mem_ap_write_atomic_u32(swjdp, address, value);
+ retval = mem_ap_sel_write_atomic_u32(swjdp, swjdp_debugap, address, value);
return retval;
}
static int cortex_a9_write_dcc(struct cortex_a9_common *a9, uint32_t data)
{
LOG_DEBUG("write DCC 0x%08" PRIx32, data);
- return mem_ap_write_u32(&a9->armv7a_common.dap,
+ return mem_ap_sel_write_u32(&a9->armv7a_common.dap, swjdp_debugap,
a9->armv7a_common.debug_base + CPUDBG_DTRRX, data);
}
/* Wait for DTRRXfull */
long long then = timeval_ms();
while ((dscr & DSCR_DTR_TX_FULL) == 0) {
- retval = mem_ap_read_atomic_u32(swjdp,
+ retval = mem_ap_sel_read_atomic_u32(swjdp, swjdp_debugap,
a9->armv7a_common.debug_base + CPUDBG_DSCR,
&dscr);
if (retval != ERROR_OK)
}
}
- retval = mem_ap_read_atomic_u32(swjdp,
+ retval = mem_ap_sel_read_atomic_u32(swjdp, swjdp_debugap,
a9->armv7a_common.debug_base + CPUDBG_DTRTX, data);
if (retval != ERROR_OK)
return retval;
long long then = timeval_ms();
for (;;)
{
- retval = mem_ap_read_atomic_u32(swjdp,
+ retval = mem_ap_sel_read_atomic_u32(swjdp, swjdp_debugap,
a9->armv7a_common.debug_base + CPUDBG_DSCR,
&dscr);
if (retval != ERROR_OK)
struct armv7a_common *armv7a = &cortex_a9->armv7a_common;
struct adiv5_dap *swjdp = &armv7a->dap;
enum target_state prev_target_state = target->state;
- uint8_t saved_apsel = dap_ap_get_select(swjdp);
- dap_ap_select(swjdp, swjdp_debugap);
- retval = mem_ap_read_atomic_u32(swjdp,
+ retval = mem_ap_sel_read_atomic_u32(swjdp, swjdp_debugap,
armv7a->debug_base + CPUDBG_DSCR, &dscr);
if (retval != ERROR_OK)
{
- dap_ap_select(swjdp, saved_apsel);
return retval;
}
cortex_a9->cpudbg_dscr = dscr;
target->state = TARGET_UNKNOWN;
}
- dap_ap_select(swjdp, saved_apsel);
-
return retval;
}
uint32_t dscr;
struct armv7a_common *armv7a = target_to_armv7a(target);
struct adiv5_dap *swjdp = &armv7a->dap;
- uint8_t saved_apsel = dap_ap_get_select(swjdp);
- dap_ap_select(swjdp, swjdp_debugap);
/*
* Tell the core to be halted by writing DRCR with 0x1
* and then wait for the core to be halted.
*/
- retval = mem_ap_write_atomic_u32(swjdp,
+ retval = mem_ap_sel_write_atomic_u32(swjdp, swjdp_debugap,
armv7a->debug_base + CPUDBG_DRCR, DRCR_HALT);
if (retval != ERROR_OK)
- goto out;
+ return retval;
/*
* enter halting debug mode
*/
- retval = mem_ap_read_atomic_u32(swjdp, armv7a->debug_base + CPUDBG_DSCR, &dscr);
+ retval = mem_ap_sel_read_atomic_u32(swjdp, swjdp_debugap,
+ armv7a->debug_base + CPUDBG_DSCR, &dscr);
if (retval != ERROR_OK)
- goto out;
+ return retval;
- retval = mem_ap_write_atomic_u32(swjdp,
+ retval = mem_ap_sel_write_atomic_u32(swjdp, swjdp_debugap,
armv7a->debug_base + CPUDBG_DSCR, dscr | DSCR_HALT_DBG_MODE);
if (retval != ERROR_OK)
- goto out;
+ return retval;
long long then = timeval_ms();
for (;;)
{
- retval = mem_ap_read_atomic_u32(swjdp,
+ retval = mem_ap_sel_read_atomic_u32(swjdp, swjdp_debugap,
armv7a->debug_base + CPUDBG_DSCR, &dscr);
if (retval != ERROR_OK)
- goto out;
+ return retval;
if ((dscr & DSCR_CORE_HALTED) != 0)
{
break;
target->debug_reason = DBG_REASON_DBGRQ;
-out:
- dap_ap_select(swjdp, saved_apsel);
- return retval;
+ return ERROR_OK;
}
static int cortex_a9_resume(struct target *target, int current,
// struct breakpoint *breakpoint = NULL;
uint32_t resume_pc, dscr;
- uint8_t saved_apsel = dap_ap_get_select(swjdp);
- dap_ap_select(swjdp, swjdp_debugap);
-
if (!debug_execution)
target_free_all_working_areas(target);
* disable IRQs by default, with optional override...
*/
- retval = mem_ap_read_atomic_u32(swjdp,
+ retval = mem_ap_sel_read_atomic_u32(swjdp, swjdp_debugap,
armv7a->debug_base + CPUDBG_DSCR, &dscr);
if (retval != ERROR_OK)
return retval;
if ((dscr & DSCR_INSTR_COMP) == 0)
LOG_ERROR("DSCR InstrCompl must be set before leaving debug!");
- retval = mem_ap_write_atomic_u32(swjdp,
+ retval = mem_ap_sel_write_atomic_u32(swjdp, swjdp_debugap,
armv7a->debug_base + CPUDBG_DSCR, dscr & ~DSCR_ITR_EN);
if (retval != ERROR_OK)
return retval;
- retval = mem_ap_write_atomic_u32(swjdp, armv7a->debug_base + CPUDBG_DRCR,
- DRCR_RESTART | DRCR_CLEAR_EXCEPTIONS);
+ retval = mem_ap_sel_write_atomic_u32(swjdp, swjdp_debugap,
+ armv7a->debug_base + CPUDBG_DRCR, DRCR_RESTART | DRCR_CLEAR_EXCEPTIONS);
if (retval != ERROR_OK)
return retval;
long long then = timeval_ms();
for (;;)
{
- retval = mem_ap_read_atomic_u32(swjdp,
+ retval = mem_ap_sel_read_atomic_u32(swjdp, swjdp_debugap,
armv7a->debug_base + CPUDBG_DSCR, &dscr);
if (retval != ERROR_OK)
return retval;
LOG_DEBUG("target debug resumed at 0x%" PRIx32, resume_pc);
}
- dap_ap_select(swjdp, saved_apsel);
-
return ERROR_OK;
}
LOG_DEBUG("dscr = 0x%08" PRIx32, cortex_a9->cpudbg_dscr);
/* REVISIT surely we should not re-read DSCR !! */
- retval = mem_ap_read_atomic_u32(swjdp,
+ retval = mem_ap_sel_read_atomic_u32(swjdp, swjdp_debugap,
armv7a->debug_base + CPUDBG_DSCR, &dscr);
if (retval != ERROR_OK)
return retval;
/* Enable the ITR execution once we are in debug mode */
dscr |= DSCR_ITR_EN;
- retval = mem_ap_write_atomic_u32(swjdp,
+ retval = mem_ap_sel_write_atomic_u32(swjdp, swjdp_debugap,
armv7a->debug_base + CPUDBG_DSCR, dscr);
if (retval != ERROR_OK)
return retval;
if (target->debug_reason == DBG_REASON_WATCHPOINT) {
uint32_t wfar;
- retval = mem_ap_read_atomic_u32(swjdp,
+ retval = mem_ap_sel_read_atomic_u32(swjdp, swjdp_debugap,
armv7a->debug_base + CPUDBG_WFAR,
&wfar);
if (retval != ERROR_OK)
}
else
{
- dap_ap_select(swjdp, swjdp_memoryap);
retval = cortex_a9_read_regs_through_mem(target,
regfile_working_area->address, regfile);
- dap_ap_select(swjdp, swjdp_memoryap);
+
target_free_working_area(target, regfile_working_area);
if (retval != ERROR_OK)
{
retval = cortex_a9_dap_read_coreregister_u32(target, &cpsr, 16);
if (retval != ERROR_OK)
return retval;
- dap_ap_select(swjdp, swjdp_debugap);
+
LOG_DEBUG("cpsr: %8.8" PRIx32, cpsr);
arm_set_cpsr(armv4_5, cpsr);
{
struct armv7a_common *armv7a = target_to_armv7a(target);
struct arm *armv4_5 = &armv7a->armv4_5_common;
- struct adiv5_dap *swjdp = &armv7a->dap;
struct breakpoint *breakpoint = NULL;
struct breakpoint stepbreakpoint;
struct reg *r;
int retval;
- uint8_t saved_apsel = dap_ap_get_select(swjdp);
if (target->state != TARGET_HALTED)
{
return ERROR_TARGET_NOT_HALTED;
}
- dap_ap_select(swjdp, swjdp_debugap);
-
/* current = 1: continue on current pc, otherwise continue at <address> */
r = armv4_5->pc;
if (!current)
retval = cortex_a9_resume(target, 1, address, 0, 0);
if (retval != ERROR_OK)
- goto out;
+ return retval;
long long then = timeval_ms();
while (target->state != TARGET_HALTED)
{
retval = cortex_a9_poll(target);
if (retval != ERROR_OK)
- goto out;
+ return retval;
if (timeval_ms() > then + 1000)
{
LOG_ERROR("timeout waiting for target halt");
- retval = ERROR_FAIL;
- goto out;
+ return ERROR_FAIL;
}
}
if (target->state != TARGET_HALTED)
LOG_DEBUG("target stepped");
- retval = ERROR_OK;
-
- out:
- dap_ap_select(swjdp, saved_apsel);
- return retval;
+ return ERROR_OK;
}
static int cortex_a9_restore_context(struct target *target, bool bpwp)
switch (size) {
case 4:
- retval = mem_ap_read_buf_u32(swjdp, buffer, 4 * count, address);
+ retval = mem_ap_sel_read_buf_u32(swjdp, swjdp_memoryap,
+ buffer, 4 * count, address);
break;
case 2:
- retval = mem_ap_read_buf_u16(swjdp, buffer, 2 * count, address);
+ retval = mem_ap_sel_read_buf_u16(swjdp, swjdp_memoryap,
+ buffer, 2 * count, address);
break;
case 1:
- retval = mem_ap_read_buf_u8(swjdp, buffer, count, address);
+ retval = mem_ap_sel_read_buf_u8(swjdp, swjdp_memoryap,
+ buffer, count, address);
break;
}
/* write memory through AHB-AP */
switch (size) {
case 4:
- retval = mem_ap_write_buf_u32(swjdp, buffer, 4 * count, address);
+ retval = mem_ap_sel_write_buf_u32(swjdp, swjdp_memoryap,
+ buffer, 4 * count, address);
break;
case 2:
- retval = mem_ap_write_buf_u16(swjdp, buffer, 2 * count, address);
+ retval = mem_ap_sel_write_buf_u16(swjdp, swjdp_memoryap,
+ buffer, 2 * count, address);
break;
case 1:
- retval = mem_ap_write_buf_u8(swjdp, buffer, count, address);
+ retval = mem_ap_sel_write_buf_u8(swjdp, swjdp_memoryap,
+ buffer, count, address);
break;
}
if (retval != ERROR_OK)
return retval;
- dap_ap_select(swjdp, swjdp_debugap);
-
/*
* FIXME: assuming omap4430
*
armv7a->debug_base = 0x80000000 |
((target->coreid & 0x3) << CORTEX_A9_PADDRDBG_CPU_SHIFT);
- retval = mem_ap_read_atomic_u32(swjdp,
+ retval = mem_ap_sel_read_atomic_u32(swjdp, swjdp_debugap,
armv7a->debug_base + CPUDBG_CPUID, &cpuid);
if (retval != ERROR_OK)
return retval;
- if ((retval = mem_ap_read_atomic_u32(swjdp,
+ if ((retval = mem_ap_sel_read_atomic_u32(swjdp, swjdp_debugap,
armv7a->debug_base + CPUDBG_CPUID, &cpuid)) != ERROR_OK)
{
LOG_DEBUG("Examine %s failed", "CPUID");
return retval;
}
- if ((retval = mem_ap_read_atomic_u32(swjdp,
+ if ((retval = mem_ap_sel_read_atomic_u32(swjdp, swjdp_debugap,
armv7a->debug_base + CPUDBG_CTYPR, &ctypr)) != ERROR_OK)
{
LOG_DEBUG("Examine %s failed", "CTYPR");
return retval;
}
- if ((retval = mem_ap_read_atomic_u32(swjdp,
+ if ((retval = mem_ap_sel_read_atomic_u32(swjdp, swjdp_debugap,
armv7a->debug_base + CPUDBG_TTYPR, &ttypr)) != ERROR_OK)
{
LOG_DEBUG("Examine %s failed", "TTYPR");
return retval;
}
- if ((retval = mem_ap_read_atomic_u32(swjdp,
+ if ((retval = mem_ap_sel_read_atomic_u32(swjdp, swjdp_debugap,
armv7a->debug_base + CPUDBG_DIDR, &didr)) != ERROR_OK)
{
LOG_DEBUG("Examine %s failed", "DIDR");