diff options
author | Jan Matyas <jan.matyas@codasip.com> | 2024-02-09 08:30:18 +0100 |
---|---|---|
committer | Jan Matyas <jan.matyas@codasip.com> | 2024-02-15 12:22:42 +0100 |
commit | 9bcbae13e086e6894265439e25098395f3e7e6df (patch) | |
tree | 296e66d3386c73868846b9ac827befa4762e1533 /src | |
parent | 67a3d4fe7fbaf65b612a49c7d0a4f739eaa67be7 (diff) | |
download | riscv-openocd-riscv-batch-cleanup.zip riscv-openocd-riscv-batch-cleanup.tar.gz riscv-openocd-riscv-batch-cleanup.tar.bz2 |
Fixes of review findingsriscv-batch-cleanup
Change-Id: Ie9889d995d7b2a6e458ad5f66cc3d990888f54ec
Signed-off-by: Jan Matyas <jan.matyas@codasip.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/target/riscv/batch.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/src/target/riscv/batch.c b/src/target/riscv/batch.c index 2779535..faa9256 100644 --- a/src/target/riscv/batch.c +++ b/src/target/riscv/batch.c @@ -13,7 +13,8 @@ #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)) -#define BATCH_RESERVED_SCANS 4 +/* Reserve extra room in the batch (needed for the last NOP operation) */ +#define BATCH_RESERVED_SCANS 1 static void dump_field(int idle, const struct scan_field *field); @@ -37,6 +38,9 @@ struct riscv_batch *riscv_batch_alloc(struct target *target, size_t scans, size_ out->bscan_ctxt = NULL; out->read_keys = NULL; + /* FIXME: There is potential for memory usage reduction. We could allocate + * smaller buffers than DMI_SCAN_BUF_SIZE (that is, buffers that correspond to + * the real DR scan length on the given target) */ out->data_out = malloc(sizeof(*out->data_out) * scans * DMI_SCAN_BUF_SIZE); if (!out->data_out) { LOG_ERROR("Failed to allocate data_out in RISC-V batch."); @@ -84,7 +88,7 @@ void riscv_batch_free(struct riscv_batch *batch) bool riscv_batch_full(struct riscv_batch *batch) { - return batch->used_scans >= (batch->allocated_scans - BATCH_RESERVED_SCANS); + return riscv_batch_available_scans(batch) == 0; } int riscv_batch_run(struct riscv_batch *batch) @@ -98,7 +102,7 @@ int riscv_batch_run(struct riscv_batch *batch) for (size_t i = 0; i < batch->used_scans; ++i) { if (bscan_tunnel_ir_width != 0) - riscv_add_bscan_tunneled_scan(batch->target, batch->fields+i, batch->bscan_ctxt+i); + riscv_add_bscan_tunneled_scan(batch->target, batch->fields + i, batch->bscan_ctxt + i); else jtag_add_dr_scan(batch->target->tap, 1, batch->fields + i, TAP_IDLE); |