Merge pull request #1146 from en-sc/en-sc/select-dmi-bypass

target/riscv: check other TAPs in `select_dmi()`
This commit is contained in:
Evgeniy Naydanov 2024-10-18 12:37:31 +03:00 committed by GitHub
commit bc68bd71a3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
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);
}