Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 16 additions & 6 deletions src/target/riscv/batch.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#include "field_helpers.h"

// TODO: DTM_DMI_MAX_ADDRESS_LENGTH should be reduced to 32 (per the debug spec)
#define DTM_DMI_MAX_ADDRESS_LENGTH ((1<<DTM_DTMCS_ABITS_LENGTH)-1)
#define DTM_DMI_MAX_ADDRESS_LENGTH ((1 << DTM_DTMCS_ABITS_LENGTH) - 1)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's separate formatting fixes from functional once for the sake of a sane git blame.

#define DMI_SCAN_MAX_BIT_LENGTH (DTM_DMI_MAX_ADDRESS_LENGTH + DTM_DMI_DATA_LENGTH + DTM_DMI_OP_LENGTH)

#define DMI_SCAN_BUF_SIZE (DIV_ROUND_UP(DMI_SCAN_MAX_BIT_LENGTH, 8))
Expand Down Expand Up @@ -295,14 +295,24 @@ int riscv_batch_run_from(struct riscv_batch *batch, size_t start_idx,
for (size_t i = start_idx; i < batch->used_scans; ++i) {
if (bscan_tunnel_ir_width != 0)
riscv_add_bscan_tunneled_scan(batch->target->tap, batch->fields + i,
batch->bscan_ctxt + i);
batch->bscan_ctxt + i);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This does not seem like a correct formatting fix -- AFAIK, throughout the codebase the prevailing pattern is +2 TABs when inside the braces of a function call, e.g.:
https://github.com/Biancaa-R/riscv-openocd/blob/f9ef41bf7622d65a14066056eda3876a0b9d29cc/src/target/target.c#L738-L739

else
jtag_add_dr_scan(batch->target->tap, 1, batch->fields + i, TAP_IDLE);

delay = get_delay(batch, i, delays, resets_delays,
reset_delays_after);
if (delay > 0)
jtag_add_runtest(delay, TAP_IDLE);
//conditional execution
const unsigned int out_op = buf_get_u32(batch->fields->out_value,
DTM_DMI_OP_OFFSET, DTM_DMI_OP_LENGTH);

if (out_op == DTM_DMI_OP_NOP) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd suggest to keep the logic around delay times inside get_delay(). The main reason -- here the operations are scheduled, but the results are reported separately, in the log_batch() function. With the current implementation the delay will be logged incorrectly.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@en-sc so you want me to add this same logic but inside get_delay() right? so the timing logs and scheduling stay consistent.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes

LOG_TARGET_DEBUG(batch->target, "Skipping RTI for DMI NOP at scan %zu", i);
/* leave delay == 0 so batch->last_scan_delay becomes 0 for this run */
delay = 0;
} else {
delay = get_delay(batch, i, delays, resets_delays,
reset_delays_after);
if (delay > 0)
jtag_add_runtest(delay, TAP_IDLE);
}
}

keep_alive();
Expand Down
Loading