Skip to content

Commit

Permalink
target/riscv: check other TAPs in select_dmi()
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
en-sc committed Oct 16, 2024
1 parent a4020f1 commit f3ed0ab
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 4 deletions.
1 change: 1 addition & 0 deletions src/jtag/jtag.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
29 changes: 25 additions & 4 deletions src/target/riscv/riscv-013.c
Original file line number Diff line number Diff line change
Expand Up @@ -357,10 +357,31 @@ 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;
jtag_add_ir_scan(target->tap, &select_dbus, TAP_IDLE);
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);
}

static int increase_dmi_busy_delay(struct target *target)
Expand Down

0 comments on commit f3ed0ab

Please sign in to comment.