diff --git a/src/target/riscv/riscv-011.c b/src/target/riscv/riscv-011.c index fc425be2c..fde2a521d 100644 --- a/src/target/riscv/riscv-011.c +++ b/src/target/riscv/riscv-011.c @@ -282,10 +282,9 @@ static uint32_t dtmcontrol_scan(struct target *target, uint32_t out) uint8_t out_value[4]; #if BUILD_RISCV_ARTY_BSCAN == 1 - if (target->bscan_tunnel_ir_width != 0) { + if (target->bscan_tunnel_ir_width != 0) return dtmcontrol_scan_via_bscan(target, out); - } -#endif +#endif buf_set_u32(out_value, 0, 32, out); diff --git a/src/target/riscv/riscv-013.c b/src/target/riscv/riscv-013.c index f62c2c6f2..4ce97fd7a 100644 --- a/src/target/riscv/riscv-013.c +++ b/src/target/riscv/riscv-013.c @@ -411,7 +411,7 @@ static void select_dmi(struct target *target) select_dmi_via_bscan(target); return; } -#endif +#endif jtag_add_ir_scan(target->tap, &select_dbus, TAP_IDLE); } @@ -422,10 +422,9 @@ static uint32_t dtmcontrol_scan(struct target *target, uint32_t out) uint8_t out_value[4]; #if BUILD_RISCV_ARTY_BSCAN == 1 - if (target->bscan_tunnel_ir_width != 0) { + if (target->bscan_tunnel_ir_width != 0) return dtmcontrol_scan_via_bscan(target, out); - } -#endif +#endif buf_set_u32(out_value, 0, 32, out); @@ -501,7 +500,7 @@ static dmi_status_t dmi_scan(struct target *target, uint32_t *address_in, #if BUILD_RISCV_ARTY_BSCAN == 1 /* I wanted to place this code in a different function, but the way JTAG command queueing works in the jtag handling functions, the scan fields either have to be - heap allocated, global/static, or else they need to stay on the stack until + heap allocated, global/static, or else they need to stay on the stack until the jtag_execute_queue() call. Heap or static fields in this case doesn't seem the best fit. Declaring stack based field values in a subsidiary function call wouldn't work. */ @@ -521,7 +520,7 @@ static dmi_status_t dmi_scan(struct target *target, uint32_t *address_in, .out_value = tunneled_dr_width, .in_value = NULL, }, - /* for BSCAN tunnel, there is a one-TCK skew between shift in and shift out, so + /* for BSCAN tunnel, there is a one-TCK skew between shift in and shift out, so scanning num_bits + 1, and then will right shift the input field after executing the queues */ { .num_bits = num_bits+1, @@ -534,10 +533,10 @@ static dmi_status_t dmi_scan(struct target *target, uint32_t *address_in, .in_value = NULL, } }; - - jtag_add_dr_scan(target->tap, DIM(tunneled_dr), tunneled_dr, TAP_IDLE); + + jtag_add_dr_scan(target->tap, DIM(tunneled_dr), tunneled_dr, TAP_IDLE); } else -#endif +#endif /* Assume dbus is already selected. */ jtag_add_dr_scan(target->tap, 1, &field, TAP_IDLE); @@ -557,9 +556,9 @@ static dmi_status_t dmi_scan(struct target *target, uint32_t *address_in, #if BUILD_RISCV_ARTY_BSCAN == 1 if (target->bscan_tunnel_ir_width != 0) { /* need to right-shift "in" by one bit, because of clock skew between BSCAN TAP and DM TAP */ - buffer_shr(in, num_bytes, 1); + buffer_shr(in, num_bytes, 1); } -#endif +#endif if (data_in) *data_in = buf_get_u32(in, DTM_DMI_DATA_OFFSET, DTM_DMI_DATA_LENGTH); diff --git a/src/target/riscv/riscv.c b/src/target/riscv/riscv.c index 785c3ffc5..2842a5a47 100644 --- a/src/target/riscv/riscv.c +++ b/src/target/riscv/riscv.c @@ -259,7 +259,7 @@ uint32_t dtmcontrol_scan_via_bscan(struct target *target, uint32_t out) uint8_t in_value[5]; buf_set_u32(out_value, 0, 32, out); - + struct scan_field tunneled_ir[] = { { .num_bits = 1, @@ -281,7 +281,6 @@ uint32_t dtmcontrol_scan_via_bscan(struct target *target, uint32_t out) .out_value = bscan_zero, .in_value = NULL, } - }; struct scan_field tunneled_dr[] = { { @@ -337,11 +336,10 @@ static uint32_t dtmcontrol_scan(struct target *target, uint32_t out) uint8_t out_value[4]; #if BUILD_RISCV_ARTY_BSCAN == 1 - if (target->bscan_tunnel_ir_width != 0) { + if (target->bscan_tunnel_ir_width != 0) return dtmcontrol_scan_via_bscan(target, out); - } -#endif - +#endif + buf_set_u32(out_value, 0, 32, out); @@ -408,8 +406,7 @@ static int riscv_init_target(struct command_context *cmd_ctx, bscan_tunneled_ir_width[0] = target->bscan_tunnel_ir_width; bscan_tunneled_select_dmi[2].num_bits = target->bscan_tunnel_ir_width; } - -#endif +#endif riscv_semihosting_init(target); diff --git a/src/target/target.c b/src/target/target.c index 30583ad47..fc27d04b3 100644 --- a/src/target/target.c +++ b/src/target/target.c @@ -4603,7 +4603,7 @@ enum target_cfg_param { TCFG_RTOS, TCFG_DEFER_EXAMINE, TCFG_GDB_PORT, - TCFG_BSCAN_TUNNEL_IR_WIDTH, + TCFG_BSCAN_TUNNEL_IR_WIDTH, }; static Jim_Nvp nvp_config_opts[] = { @@ -4621,8 +4621,8 @@ static Jim_Nvp nvp_config_opts[] = { { .name = "-defer-examine", .value = TCFG_DEFER_EXAMINE }, { .name = "-gdb-port", .value = TCFG_GDB_PORT }, #if BUILD_RISCV_ARTY_BSCAN == 1 - { .name = "-bscan-tunnel-ir-width", .value = TCFG_BSCAN_TUNNEL_IR_WIDTH }, -#endif + { .name = "-bscan-tunnel-ir-width", .value = TCFG_BSCAN_TUNNEL_IR_WIDTH }, +#endif { .name = NULL, .value = -1 } }; @@ -4924,7 +4924,7 @@ no_params: Jim_SetResultString(goi->interp, target->gdb_port_override ? : "undefined", -1); /* loop for more */ break; - + case TCFG_BSCAN_TUNNEL_IR_WIDTH: if (goi->isconfigure) { e = Jim_GetOpt_Wide(goi, &w); diff --git a/src/target/target.h b/src/target/target.h index 1ce1b1c57..8826e76c2 100644 --- a/src/target/target.h +++ b/src/target/target.h @@ -210,9 +210,9 @@ struct target { /* The semihosting information, extracted from the target. */ struct semihosting *semihosting; -#if BUILD_RISCV_ARTY_BSCAN == 1 +#if BUILD_RISCV_ARTY_BSCAN == 1 int bscan_tunnel_ir_width; /* if zero, then tunneling is not present/active */ -#endif +#endif }; struct target_list {