target/riscv: check other TAPs in `select_dmi()`

If some other TAP is not in BYPASS, an IR scan is needed to select
BYPASS on that TAP.

Change-Id: Iae425a415109b1a853db3718762661877eea56e8
Signed-off-by: Evgeniy Naydanov <evgeniy.naydanov@syntacore.com>
This commit is contained in:
Evgeniy Naydanov 2024-10-10 14:18:59 +03:00
parent a4020f1a02
commit f3ed0ab608
2 changed files with 26 additions and 4 deletions

View File

@ -151,6 +151,7 @@ const char *jtag_tap_name(const struct jtag_tap *tap);
struct jtag_tap *jtag_tap_by_string(const char *dotted_name);
struct jtag_tap *jtag_tap_by_jim_obj(Jim_Interp *interp, Jim_Obj *obj);
struct jtag_tap *jtag_tap_by_position(unsigned int abs_position);
/* FIXME: "jtag_tap_next_enabled()" should accept a const pointer. */
struct jtag_tap *jtag_tap_next_enabled(struct jtag_tap *p);
unsigned int jtag_tap_count_enabled(void);
unsigned int jtag_tap_count(void);

View File

@ -357,9 +357,30 @@ static void select_dmi(struct target *target)
select_dmi_via_bscan(target);
return;
}
if (buf_eq(target->tap->cur_instr, select_dbus.out_value,
target->tap->ir_length))
return;
if (!target->tap->enabled)
LOG_TARGET_ERROR(target, "BUG: Target's TAP '%s' is disabled!",
jtag_tap_name(target->tap));
bool need_ir_scan = false;
/* FIXME: make "tap" a const pointer. */
for (struct jtag_tap *tap = jtag_tap_next_enabled(NULL);
tap; tap = jtag_tap_next_enabled(tap)) {
if (tap != target->tap) {
/* Different TAP than ours - check if it is in bypass */
if (!tap->bypass) {
need_ir_scan = true;
break;
}
} else {
/* Our TAP - check if the correct instruction is already loaded */
if (!buf_eq(target->tap->cur_instr, select_dbus.out_value, target->tap->ir_length)) {
need_ir_scan = true;
break;
}
}
}
if (need_ir_scan)
jtag_add_ir_scan(target->tap, &select_dbus, TAP_IDLE);
}