Skip to content

Commit

Permalink
Fixes of review findings
Browse files Browse the repository at this point in the history
Change-Id: Ie9889d995d7b2a6e458ad5f66cc3d990888f54ec
Signed-off-by: Jan Matyas <jan.matyas@codasip.com>
  • Loading branch information
Jan Matyas committed Feb 9, 2024
1 parent 67a3d4f commit cd286f2
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/target/riscv/batch.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,11 @@
#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 for additional scans:
* - one scan for the extra NOP at the end of the batch
* - three scans for the (optionally enabled) BSCAN tunneling
*/
#define BATCH_RESERVED_SCANS (1 + 3)

static void dump_field(int idle, const struct scan_field *field);

Expand All @@ -37,6 +41,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.");
Expand Down Expand Up @@ -84,7 +91,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)
Expand Down

0 comments on commit cd286f2

Please sign in to comment.