1 #ifndef TARGET__RISCV__SCANS_H
2 #define TARGET__RISCV__SCANS_H
4 #include "target/target.h"
8 RISCV_SCAN_TYPE_INVALID,
11 RISCV_SCAN_TYPE_WRITE,
14 /* A batch of multiple JTAG scans, which are grouped together to avoid the
15 * overhead of some JTAG adapters when sending single commands. This is
16 * designed to support block copies, as that's what we actually need to go
19 struct target *target;
21 size_t allocated_scans;
28 struct scan_field *fields;
30 /* In JTAG we scan out the previous value's output when performing a
31 * scan. This is a pain for users, so we just provide them the
32 * illusion of not having to do this by eliding all but the last NOP.
34 enum riscv_scan_type last_scan;
38 size_t read_keys_used;
41 /* Allocates (or frees) a new scan set. "scans" is the maximum number of JTAG
42 * scans that can be issued to this object, and idle is the number of JTAG idle
43 * cycles between every real scan. */
44 struct riscv_batch *riscv_batch_alloc(struct target *target, size_t scans, size_t idle);
45 void riscv_batch_free(struct riscv_batch *batch);
47 /* Checks to see if this batch is full. */
48 bool riscv_batch_full(struct riscv_batch *batch);
50 /* Executes this scan batch. */
51 int riscv_batch_run(struct riscv_batch *batch);
53 /* Adds a DMI write to this batch. */
54 void riscv_batch_add_dmi_write(struct riscv_batch *batch, unsigned address, uint64_t data);
56 /* DMI reads must be handled in two parts: the first one schedules a read and
57 * provides a key, the second one actually obtains the value of that read .*/
58 size_t riscv_batch_add_dmi_read(struct riscv_batch *batch, unsigned address);
59 uint64_t riscv_batch_get_dmi_read(struct riscv_batch *batch, size_t key);
62 void riscv_batch_add_nop(struct riscv_batch *batch);