target/arm: Remove usage of struct arm_jtag in ARMv7 targets

The Cortex-A and Cortex-M keeps an arm_jtag struct around just to be
able to pass a pointer to it to one common JTAG function which anyway
only uses the TAP field.

Refactor the function to take a TAP directly, remove the legacy struct
from cortex instances and store the TAP pointer only in the DAP.

Cortex-M makes a call to arm_jtag_setup_connection() with the struct
but the function does nothing useful for a Cortex-M target so remove
the call.

Change-Id: I3b33709ef55372ef14522ed4337e9f2e817ae3ab
Signed-off-by: Andreas Fritiofson <andreas.fritiofson@gmail.com>
Reviewed-on: http://openocd.zylin.com/3142
Tested-by: jenkins
Reviewed-by: Matthias Welwarsky <matthias@welwarsky.de>
__archive__
Andreas Fritiofson 2015-11-14 00:30:28 +01:00
parent a6c4eb0345
commit dc574aa1da
19 changed files with 45 additions and 66 deletions

View File

@ -81,12 +81,12 @@ static int adi_jtag_dp_scan(struct adiv5_dap *dap,
uint8_t instr, uint8_t reg_addr, uint8_t RnW,
uint8_t *outvalue, uint8_t *invalue, uint8_t *ack)
{
struct arm_jtag *jtag_info = dap->jtag_info;
struct jtag_tap *tap = dap->tap;
struct scan_field fields[2];
uint8_t out_addr_buf;
int retval;
retval = arm_jtag_set_instr(jtag_info, instr, NULL, TAP_IDLE);
retval = arm_jtag_set_instr(tap, instr, NULL, TAP_IDLE);
if (retval != ERROR_OK)
return retval;
@ -107,7 +107,7 @@ static int adi_jtag_dp_scan(struct adiv5_dap *dap,
fields[1].out_value = outvalue;
fields[1].in_value = invalue;
jtag_add_dr_scan(jtag_info->tap, 2, fields, TAP_IDLE);
jtag_add_dr_scan(tap, 2, fields, TAP_IDLE);
/* Add specified number of tck clocks after starting memory bus
* access, giving the hardware time to complete the access.

View File

@ -58,7 +58,7 @@ static int arm720t_scan_cp15(struct target *target,
retval = arm_jtag_scann(jtag_info, 0xf, TAP_DRPAUSE);
if (retval != ERROR_OK)
return retval;
retval = arm_jtag_set_instr(jtag_info, jtag_info->intest_instr, NULL, TAP_DRPAUSE);
retval = arm_jtag_set_instr(jtag_info->tap, jtag_info->intest_instr, NULL, TAP_DRPAUSE);
if (retval != ERROR_OK)
return retval;

View File

@ -628,11 +628,11 @@ int arm7_9_execute_sys_speed(struct target *target)
/* set RESTART instruction */
if (arm7_9->need_bypass_before_restart) {
arm7_9->need_bypass_before_restart = 0;
retval = arm_jtag_set_instr(jtag_info, 0xf, NULL, TAP_IDLE);
retval = arm_jtag_set_instr(jtag_info->tap, 0xf, NULL, TAP_IDLE);
if (retval != ERROR_OK)
return retval;
}
retval = arm_jtag_set_instr(jtag_info, 0x4, NULL, TAP_IDLE);
retval = arm_jtag_set_instr(jtag_info->tap, 0x4, NULL, TAP_IDLE);
if (retval != ERROR_OK)
return retval;
@ -682,11 +682,11 @@ static int arm7_9_execute_fast_sys_speed(struct target *target)
/* set RESTART instruction */
if (arm7_9->need_bypass_before_restart) {
arm7_9->need_bypass_before_restart = 0;
retval = arm_jtag_set_instr(jtag_info, 0xf, NULL, TAP_IDLE);
retval = arm_jtag_set_instr(jtag_info->tap, 0xf, NULL, TAP_IDLE);
if (retval != ERROR_OK)
return retval;
}
retval = arm_jtag_set_instr(jtag_info, 0x4, NULL, TAP_IDLE);
retval = arm_jtag_set_instr(jtag_info->tap, 0x4, NULL, TAP_IDLE);
if (retval != ERROR_OK)
return retval;
@ -1639,11 +1639,11 @@ static int arm7_9_restart_core(struct target *target)
if (arm7_9->need_bypass_before_restart) {
arm7_9->need_bypass_before_restart = 0;
retval = arm_jtag_set_instr(jtag_info, 0xf, NULL, TAP_IDLE);
retval = arm_jtag_set_instr(jtag_info->tap, 0xf, NULL, TAP_IDLE);
if (retval != ERROR_OK)
return retval;
}
retval = arm_jtag_set_instr(jtag_info, 0x4, NULL, TAP_IDLE);
retval = arm_jtag_set_instr(jtag_info->tap, 0x4, NULL, TAP_IDLE);
if (retval != ERROR_OK)
return retval;

View File

@ -66,7 +66,7 @@ static int arm7tdmi_examine_debug_reason(struct target *target)
retval = arm_jtag_scann(&arm7_9->jtag_info, 0x1, TAP_DRPAUSE);
if (retval != ERROR_OK)
return retval;
retval = arm_jtag_set_instr(&arm7_9->jtag_info, arm7_9->jtag_info.intest_instr, NULL, TAP_DRPAUSE);
retval = arm_jtag_set_instr(arm7_9->jtag_info.tap, arm7_9->jtag_info.intest_instr, NULL, TAP_DRPAUSE);
if (retval != ERROR_OK)
return retval;
@ -126,7 +126,7 @@ static inline int arm7tdmi_clock_out(struct arm_jtag *jtag_info,
retval = arm_jtag_scann(jtag_info, 0x1, TAP_DRPAUSE);
if (retval != ERROR_OK)
return retval;
retval = arm_jtag_set_instr(jtag_info, jtag_info->intest_instr, NULL, TAP_DRPAUSE);
retval = arm_jtag_set_instr(jtag_info->tap, jtag_info->intest_instr, NULL, TAP_DRPAUSE);
if (retval != ERROR_OK)
return retval;
@ -142,7 +142,7 @@ static int arm7tdmi_clock_data_in(struct arm_jtag *jtag_info, uint32_t *in)
retval = arm_jtag_scann(jtag_info, 0x1, TAP_DRPAUSE);
if (retval != ERROR_OK)
return retval;
retval = arm_jtag_set_instr(jtag_info, jtag_info->intest_instr, NULL, TAP_DRPAUSE);
retval = arm_jtag_set_instr(jtag_info->tap, jtag_info->intest_instr, NULL, TAP_DRPAUSE);
if (retval != ERROR_OK)
return retval;
@ -187,7 +187,7 @@ static int arm7tdmi_clock_data_in_endianness(struct arm_jtag *jtag_info,
retval = arm_jtag_scann(jtag_info, 0x1, TAP_DRPAUSE);
if (retval != ERROR_OK)
return retval;
retval = arm_jtag_set_instr(jtag_info, jtag_info->intest_instr, NULL, TAP_DRPAUSE);
retval = arm_jtag_set_instr(jtag_info->tap, jtag_info->intest_instr, NULL, TAP_DRPAUSE);
if (retval != ERROR_OK)
return retval;

View File

@ -96,7 +96,7 @@ static int arm920t_read_cp15_physical(struct target *target,
retval = arm_jtag_scann(jtag_info, 0xf, TAP_IDLE);
if (retval != ERROR_OK)
return retval;
retval = arm_jtag_set_instr(jtag_info, jtag_info->intest_instr, NULL, TAP_IDLE);
retval = arm_jtag_set_instr(jtag_info->tap, jtag_info->intest_instr, NULL, TAP_IDLE);
if (retval != ERROR_OK)
return retval;
@ -151,7 +151,7 @@ static int arm920t_write_cp15_physical(struct target *target,
retval = arm_jtag_scann(jtag_info, 0xf, TAP_IDLE);
if (retval != ERROR_OK)
return retval;
retval = arm_jtag_set_instr(jtag_info, jtag_info->intest_instr, NULL, TAP_IDLE);
retval = arm_jtag_set_instr(jtag_info->tap, jtag_info->intest_instr, NULL, TAP_IDLE);
if (retval != ERROR_OK)
return retval;
@ -204,7 +204,7 @@ static int arm920t_execute_cp15(struct target *target, uint32_t cp15_opcode,
retval = arm_jtag_scann(jtag_info, 0xf, TAP_IDLE);
if (retval != ERROR_OK)
return retval;
retval = arm_jtag_set_instr(jtag_info, jtag_info->intest_instr, NULL, TAP_IDLE);
retval = arm_jtag_set_instr(jtag_info->tap, jtag_info->intest_instr, NULL, TAP_IDLE);
if (retval != ERROR_OK)
return retval;

View File

@ -67,7 +67,7 @@ static int arm926ejs_cp15_read(struct target *target, uint32_t op1, uint32_t op2
retval = arm_jtag_scann(jtag_info, 0xf, TAP_IDLE);
if (retval != ERROR_OK)
return retval;
retval = arm_jtag_set_instr(jtag_info, jtag_info->intest_instr, NULL, TAP_IDLE);
retval = arm_jtag_set_instr(jtag_info->tap, jtag_info->intest_instr, NULL, TAP_IDLE);
if (retval != ERROR_OK)
return retval;
@ -117,7 +117,7 @@ static int arm926ejs_cp15_read(struct target *target, uint32_t op1, uint32_t op2
LOG_DEBUG("addr: 0x%x value: %8.8x", address, *value);
#endif
retval = arm_jtag_set_instr(jtag_info, 0xc, NULL, TAP_IDLE);
retval = arm_jtag_set_instr(jtag_info->tap, 0xc, NULL, TAP_IDLE);
if (retval != ERROR_OK)
return retval;
@ -153,7 +153,7 @@ static int arm926ejs_cp15_write(struct target *target, uint32_t op1, uint32_t op
retval = arm_jtag_scann(jtag_info, 0xf, TAP_IDLE);
if (retval != ERROR_OK)
return retval;
retval = arm_jtag_set_instr(jtag_info, jtag_info->intest_instr, NULL, TAP_IDLE);
retval = arm_jtag_set_instr(jtag_info->tap, jtag_info->intest_instr, NULL, TAP_IDLE);
if (retval != ERROR_OK)
return retval;
@ -200,7 +200,7 @@ static int arm926ejs_cp15_write(struct target *target, uint32_t op1, uint32_t op
LOG_DEBUG("addr: 0x%x value: %8.8x", address, value);
#endif
retval = arm_jtag_set_instr(jtag_info, 0xf, NULL, TAP_IDLE);
retval = arm_jtag_set_instr(jtag_info->tap, 0xf, NULL, TAP_IDLE);
if (retval != ERROR_OK)
return retval;

View File

@ -139,7 +139,7 @@ static int arm946e_read_cp15(struct target *target, int reg_addr, uint32_t *valu
retval = arm_jtag_scann(jtag_info, 0xf, TAP_IDLE);
if (retval != ERROR_OK)
return retval;
retval = arm_jtag_set_instr(jtag_info, jtag_info->intest_instr, NULL, TAP_IDLE);
retval = arm_jtag_set_instr(jtag_info->tap, jtag_info->intest_instr, NULL, TAP_IDLE);
if (retval != ERROR_OK)
return retval;
@ -191,7 +191,7 @@ int arm946e_write_cp15(struct target *target, int reg_addr, uint32_t value)
retval = arm_jtag_scann(jtag_info, 0xf, TAP_IDLE);
if (retval != ERROR_OK)
return retval;
retval = arm_jtag_set_instr(jtag_info, jtag_info->intest_instr, NULL, TAP_IDLE);
retval = arm_jtag_set_instr(jtag_info->tap, jtag_info->intest_instr, NULL, TAP_IDLE);
if (retval != ERROR_OK)
return retval;

View File

@ -87,7 +87,7 @@ static int arm966e_read_cp15(struct target *target, int reg_addr, uint32_t *valu
retval = arm_jtag_scann(jtag_info, 0xf, TAP_IDLE);
if (retval != ERROR_OK)
return retval;
retval = arm_jtag_set_instr(jtag_info, jtag_info->intest_instr, NULL, TAP_IDLE);
retval = arm_jtag_set_instr(jtag_info->tap, jtag_info->intest_instr, NULL, TAP_IDLE);
if (retval != ERROR_OK)
return retval;
@ -141,7 +141,7 @@ int arm966e_write_cp15(struct target *target, int reg_addr, uint32_t value)
retval = arm_jtag_scann(jtag_info, 0xf, TAP_IDLE);
if (retval != ERROR_OK)
return retval;
retval = arm_jtag_set_instr(jtag_info, jtag_info->intest_instr, NULL, TAP_IDLE);
retval = arm_jtag_set_instr(jtag_info->tap, jtag_info->intest_instr, NULL, TAP_IDLE);
if (retval != ERROR_OK)
return retval;

View File

@ -100,7 +100,7 @@ int arm9tdmi_examine_debug_reason(struct target *target)
retval = arm_jtag_scann(&arm7_9->jtag_info, 0x1, TAP_DRPAUSE);
if (retval != ERROR_OK)
return retval;
retval = arm_jtag_set_instr(&arm7_9->jtag_info, arm7_9->jtag_info.intest_instr, NULL, TAP_DRPAUSE);
retval = arm_jtag_set_instr(arm7_9->jtag_info.tap, arm7_9->jtag_info.intest_instr, NULL, TAP_DRPAUSE);
if (retval != ERROR_OK)
return retval;
@ -154,7 +154,7 @@ int arm9tdmi_clock_out(struct arm_jtag *jtag_info, uint32_t instr,
if (retval != ERROR_OK)
return retval;
retval = arm_jtag_set_instr(jtag_info, jtag_info->intest_instr, NULL, TAP_DRPAUSE);
retval = arm_jtag_set_instr(jtag_info->tap, jtag_info->intest_instr, NULL, TAP_DRPAUSE);
if (retval != ERROR_OK)
return retval;
@ -206,7 +206,7 @@ int arm9tdmi_clock_data_in(struct arm_jtag *jtag_info, uint32_t *in)
if (retval != ERROR_OK)
return retval;
retval = arm_jtag_set_instr(jtag_info, jtag_info->intest_instr, NULL, TAP_DRPAUSE);
retval = arm_jtag_set_instr(jtag_info->tap, jtag_info->intest_instr, NULL, TAP_DRPAUSE);
if (retval != ERROR_OK)
return retval;
@ -258,7 +258,7 @@ int arm9tdmi_clock_data_in_endianness(struct arm_jtag *jtag_info,
if (retval != ERROR_OK)
return retval;
retval = arm_jtag_set_instr(jtag_info, jtag_info->intest_instr, NULL, TAP_DRPAUSE);
retval = arm_jtag_set_instr(jtag_info->tap, jtag_info->intest_instr, NULL, TAP_DRPAUSE);
if (retval != ERROR_OK)
return retval;

View File

@ -182,7 +182,7 @@ struct adiv5_ap {
struct adiv5_dap {
const struct dap_ops *ops;
struct arm_jtag *jtag_info;
struct jtag_tap *tap;
/* Control config */
uint32_t dp_ctrl_stat;

View File

@ -31,11 +31,9 @@
#define _ARM_JTAG_SCAN_N_CHECK_
#endif
int arm_jtag_set_instr_inner(struct arm_jtag *jtag_info,
int arm_jtag_set_instr_inner(struct jtag_tap *tap,
uint32_t new_instr, void *no_verify_capture, tap_state_t end_state)
{
struct jtag_tap *tap;
tap = jtag_info->tap;
struct scan_field field;
uint8_t t[4];
@ -64,7 +62,7 @@ int arm_jtag_scann_inner(struct arm_jtag *jtag_info, uint32_t new_scan_chain, ta
buf_set_u32(out_value, 0, jtag_info->scann_size, new_scan_chain);
struct scan_field field = { .num_bits = jtag_info->scann_size, .out_value = out_value, };
retval = arm_jtag_set_instr(jtag_info, jtag_info->scann_instr, NULL, end_state);
retval = arm_jtag_set_instr(jtag_info->tap, jtag_info->scann_instr, NULL, end_state);
if (retval != ERROR_OK)
return retval;

View File

@ -36,20 +36,16 @@ struct arm_jtag {
uint32_t intest_instr;
};
int arm_jtag_set_instr_inner(struct arm_jtag *jtag_info, uint32_t new_instr,
int arm_jtag_set_instr_inner(struct jtag_tap *tap, uint32_t new_instr,
void *no_verify_capture,
tap_state_t end_state);
static inline int arm_jtag_set_instr(struct arm_jtag *jtag_info,
static inline int arm_jtag_set_instr(struct jtag_tap *tap,
uint32_t new_instr, void *no_verify_capture, tap_state_t end_state)
{
/* inline most common code path */
struct jtag_tap *tap;
tap = jtag_info->tap;
assert(tap != NULL);
if (buf_get_u32(tap->cur_instr, 0, tap->ir_length) != new_instr)
return arm_jtag_set_instr_inner(jtag_info, new_instr, no_verify_capture, end_state);
return arm_jtag_set_instr_inner(tap, new_instr, no_verify_capture, end_state);
return ERROR_OK;

View File

@ -3127,12 +3127,8 @@ static int cortex_a_init_arch_info(struct target *target,
if (!tap->dap) {
tap->dap = dap_init();
/* prepare JTAG information for the new target */
cortex_a->jtag_info.tap = tap;
cortex_a->jtag_info.scann_size = 4;
/* Leave (only) generic DAP stuff for debugport_init() */
tap->dap->jtag_info = &cortex_a->jtag_info;
tap->dap->tap = tap;
}
tap->dap->ap[dap_ap_get_select(tap->dap)].memaccess_tck = 80;

View File

@ -70,7 +70,6 @@ struct cortex_a_brp {
struct cortex_a_common {
int common_magic;
struct arm_jtag jtag_info;
/* Context information */
uint32_t cpudbg_dscr;

View File

@ -2104,7 +2104,6 @@ static int cortex_m_handle_target_request(void *priv)
static int cortex_m_init_arch_info(struct target *target,
struct cortex_m_common *cortex_m, struct jtag_tap *tap)
{
int retval;
struct armv7m_common *armv7m = &cortex_m->armv7m;
armv7m_init_arch_info(target, armv7m);
@ -2113,12 +2112,8 @@ static int cortex_m_init_arch_info(struct target *target,
if (!tap->dap) {
tap->dap = dap_init();
/* prepare JTAG information for the new target */
cortex_m->jtag_info.tap = tap;
cortex_m->jtag_info.scann_size = 4;
/* Leave (only) generic DAP stuff for debugport_init() */
tap->dap->jtag_info = &cortex_m->jtag_info;
tap->dap->tap = tap;
}
/* default reset mode is to use srst if fitted
@ -2142,10 +2137,6 @@ static int cortex_m_init_arch_info(struct target *target,
target_register_timer_callback(cortex_m_handle_target_request, 1, 1, target);
retval = arm_jtag_setup_connection(&cortex_m->jtag_info);
if (retval != ERROR_OK)
return retval;
return ERROR_OK;
}

View File

@ -164,7 +164,6 @@ enum cortex_m_isrmasking_mode {
struct cortex_m_common {
int common_magic;
struct arm_jtag jtag_info;
/* Context information */
uint32_t dcb_dhcsr;

View File

@ -349,7 +349,7 @@ int embeddedice_read_reg_w_check(struct reg *reg,
if (retval != ERROR_OK)
return retval;
retval = arm_jtag_set_instr(ice_reg->jtag_info,
retval = arm_jtag_set_instr(ice_reg->jtag_info->tap,
ice_reg->jtag_info->intest_instr, NULL, TAP_IDLE);
if (retval != ERROR_OK)
return retval;
@ -415,7 +415,7 @@ int embeddedice_receive(struct arm_jtag *jtag_info, uint32_t *data, uint32_t siz
retval = arm_jtag_scann(jtag_info, 0x2, TAP_IDLE);
if (retval != ERROR_OK)
return retval;
retval = arm_jtag_set_instr(jtag_info, jtag_info->intest_instr, NULL, TAP_IDLE);
retval = arm_jtag_set_instr(jtag_info->tap, jtag_info->intest_instr, NULL, TAP_IDLE);
if (retval != ERROR_OK)
return retval;
@ -502,7 +502,7 @@ void embeddedice_write_reg(struct reg *reg, uint32_t value)
arm_jtag_scann(ice_reg->jtag_info, 0x2, TAP_IDLE);
arm_jtag_set_instr(ice_reg->jtag_info, ice_reg->jtag_info->intest_instr, NULL, TAP_IDLE);
arm_jtag_set_instr(ice_reg->jtag_info->tap, ice_reg->jtag_info->intest_instr, NULL, TAP_IDLE);
uint8_t reg_addr = ice_reg->addr & 0x1f;
embeddedice_write_reg_inner(ice_reg->jtag_info->tap, reg_addr, value);
@ -536,7 +536,7 @@ int embeddedice_send(struct arm_jtag *jtag_info, uint32_t *data, uint32_t size)
retval = arm_jtag_scann(jtag_info, 0x2, TAP_IDLE);
if (retval != ERROR_OK)
return retval;
retval = arm_jtag_set_instr(jtag_info, jtag_info->intest_instr, NULL, TAP_IDLE);
retval = arm_jtag_set_instr(jtag_info->tap, jtag_info->intest_instr, NULL, TAP_IDLE);
if (retval != ERROR_OK)
return retval;
@ -593,7 +593,7 @@ int embeddedice_handshake(struct arm_jtag *jtag_info, int hsbit, uint32_t timeou
retval = arm_jtag_scann(jtag_info, 0x2, TAP_IDLE);
if (retval != ERROR_OK)
return retval;
retval = arm_jtag_set_instr(jtag_info, jtag_info->intest_instr, NULL, TAP_IDLE);
retval = arm_jtag_set_instr(jtag_info->tap, jtag_info->intest_instr, NULL, TAP_IDLE);
if (retval != ERROR_OK)
return retval;

View File

@ -515,7 +515,7 @@ static int etm_read_reg_w_check(struct reg *reg,
retval = arm_jtag_scann(etm_reg->jtag_info, 0x6, TAP_IDLE);
if (retval != ERROR_OK)
return retval;
retval = arm_jtag_set_instr(etm_reg->jtag_info,
retval = arm_jtag_set_instr(etm_reg->jtag_info->tap,
etm_reg->jtag_info->intest_instr,
NULL,
TAP_IDLE);
@ -602,7 +602,7 @@ static int etm_write_reg(struct reg *reg, uint32_t value)
retval = arm_jtag_scann(etm_reg->jtag_info, 0x6, TAP_IDLE);
if (retval != ERROR_OK)
return retval;
retval = arm_jtag_set_instr(etm_reg->jtag_info,
retval = arm_jtag_set_instr(etm_reg->jtag_info->tap,
etm_reg->jtag_info->intest_instr,
NULL,
TAP_IDLE);

View File

@ -88,7 +88,7 @@ static int feroceon_dummy_clock_out(struct arm_jtag *jtag_info, uint32_t instr)
if (retval != ERROR_OK)
return retval;
retval = arm_jtag_set_instr(jtag_info, jtag_info->intest_instr, NULL, TAP_DRPAUSE);
retval = arm_jtag_set_instr(jtag_info->tap, jtag_info->intest_instr, NULL, TAP_DRPAUSE);
if (retval != ERROR_OK)
return retval;