Skip to content

Commit

Permalink
Merge pull request #1146 from en-sc/en-sc/select-dmi-bypass
Browse files Browse the repository at this point in the history
target/riscv: check other TAPs in `select_dmi()`
  • Loading branch information
en-sc authored Oct 18, 2024
2 parents 417ff40 + f3ed0ab commit bc68bd7
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 bc68bd7

Please sign in to comment.