OpenOCD
batch.h
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 
3 #ifndef TARGET__RISCV__SCANS_H
4 #define TARGET__RISCV__SCANS_H
5 
6 #include "target/target.h"
7 #include "jtag/jtag.h"
8 #include "riscv.h"
9 
15 };
16 
17 /* A batch of multiple JTAG scans, which are grouped together to avoid the
18  * overhead of some JTAG adapters when sending single commands. This is
19  * designed to support block copies, as that's what we actually need to go
20  * fast. */
21 struct riscv_batch {
22  struct target *target;
23 
25  size_t used_scans;
26 
27  size_t idle_count;
28 
29  uint8_t *data_out;
30  uint8_t *data_in;
31  struct scan_field *fields;
32 
33  /* If in BSCAN mode, this field will be allocated (one per scan),
34  and utilized to tunnel all the scans in the batch. If not in
35  BSCAN mode, this field is unallocated and stays NULL */
37 
38  /* In JTAG we scan out the previous value's output when performing a
39  * scan. This is a pain for users, so we just provide them the
40  * illusion of not having to do this by eliding all but the last NOP.
41  * */
43 
44  /* The read keys. */
45  size_t *read_keys;
47 };
48 
49 /* Allocates (or frees) a new scan set. "scans" is the maximum number of JTAG
50  * scans that can be issued to this object, and idle is the number of JTAG idle
51  * cycles between every real scan. */
52 struct riscv_batch *riscv_batch_alloc(struct target *target, size_t scans, size_t idle);
53 void riscv_batch_free(struct riscv_batch *batch);
54 
55 /* Checks to see if this batch is full. */
56 bool riscv_batch_full(struct riscv_batch *batch);
57 
58 /* Executes this scan batch. */
59 int riscv_batch_run(struct riscv_batch *batch);
60 
61 /* Adds a DMI write to this batch. */
62 void riscv_batch_add_dmi_write(struct riscv_batch *batch, unsigned address, uint64_t data);
63 
64 /* DMI reads must be handled in two parts: the first one schedules a read and
65  * provides a key, the second one actually obtains the result of the read -
66  * status (op) and the actual data. */
67 size_t riscv_batch_add_dmi_read(struct riscv_batch *batch, unsigned address);
68 unsigned riscv_batch_get_dmi_read_op(struct riscv_batch *batch, size_t key);
69 uint32_t riscv_batch_get_dmi_read_data(struct riscv_batch *batch, size_t key);
70 
71 /* Scans in a NOP. */
72 void riscv_batch_add_nop(struct riscv_batch *batch);
73 
74 /* Returns the number of available scans. */
75 size_t riscv_batch_available_scans(struct riscv_batch *batch);
76 
77 #endif
uint32_t riscv_batch_get_dmi_read_data(struct riscv_batch *batch, size_t key)
Definition: batch.c:167
void riscv_batch_add_nop(struct riscv_batch *batch)
Definition: batch.c:177
size_t riscv_batch_add_dmi_read(struct riscv_batch *batch, unsigned address)
Definition: batch.c:141
size_t riscv_batch_available_scans(struct riscv_batch *batch)
Definition: batch.c:222
struct riscv_batch * riscv_batch_alloc(struct target *target, size_t scans, size_t idle)
Definition: batch.c:20
int riscv_batch_run(struct riscv_batch *batch)
Definition: batch.c:88
void riscv_batch_add_dmi_write(struct riscv_batch *batch, unsigned address, uint64_t data)
Definition: batch.c:128
unsigned riscv_batch_get_dmi_read_op(struct riscv_batch *batch, size_t key)
Definition: batch.c:157
riscv_scan_type
Definition: batch.h:10
@ RISCV_SCAN_TYPE_INVALID
Definition: batch.h:11
@ RISCV_SCAN_TYPE_WRITE
Definition: batch.h:14
@ RISCV_SCAN_TYPE_NOP
Definition: batch.h:12
@ RISCV_SCAN_TYPE_READ
Definition: batch.h:13
void riscv_batch_free(struct riscv_batch *batch)
Definition: batch.c:73
bool riscv_batch_full(struct riscv_batch *batch)
Definition: batch.c:83
The JTAG interface can be implemented with a software or hardware fifo.
uint8_t * data_in
Definition: batch.h:30
riscv_bscan_tunneled_scan_context_t * bscan_ctxt
Definition: batch.h:36
size_t allocated_scans
Definition: batch.h:24
struct target * target
Definition: batch.h:22
enum riscv_scan_type last_scan
Definition: batch.h:42
size_t idle_count
Definition: batch.h:27
size_t * read_keys
Definition: batch.h:45
uint8_t * data_out
Definition: batch.h:29
size_t read_keys_used
Definition: batch.h:46
size_t used_scans
Definition: batch.h:25
struct scan_field * fields
Definition: batch.h:31
This structure defines a single scan field in the scan.
Definition: jtag.h:86
Definition: target.h:120