32 #define CMD_QUEUE_PAGE_SIZE (1024 * 1024)
51 LOG_ERROR(
"JTAG API jtag_queue_command() called on non JTAG interface");
92 union worse_case_align {
98 #define ALIGN_SIZE (sizeof(union worse_case_align))
107 p_page = &((*p_page)->next);
115 (*p_page)->address = malloc(alloc_size);
116 (*p_page)->next =
NULL;
121 (*p_page)->used +=
size;
123 t = (*p_page)->address;
171 for (
unsigned int i = 0; i <
cmd->num_fields; i++) {
172 if (
cmd->fields[i].in_value)
174 if (
cmd->fields[i].out_value)
183 unsigned int bit_count = 0;
186 for (
unsigned int i = 0; i <
cmd->num_fields; i++)
187 bit_count +=
cmd->fields[i].num_bits;
200 cmd->ir_scan ?
"IRSCAN" :
"DRSCAN",
203 for (
unsigned int i = 0; i <
cmd->num_fields; i++) {
204 if (
cmd->fields[i].out_value) {
209 :
cmd->fields[i].num_bits);
211 LOG_DEBUG(
"fields[%u].out_value[%u]: 0x%s", i,
212 cmd->fields[i].num_bits, char_buf);
216 bit_count,
cmd->fields[i].num_bits);
219 i,
cmd->fields[i].num_bits);
222 bit_count +=
cmd->fields[i].num_bits;
238 for (
unsigned int i = 0; i <
cmd->num_fields; i++) {
242 if (
cmd->fields[i].in_value) {
243 const unsigned int num_bits =
cmd->fields[i].num_bits;
253 LOG_DEBUG(
"fields[%u].in_value[%u]: 0x%s",
254 i, num_bits, char_buf);
258 if (
cmd->fields[i].in_value)
259 buf_cpy(captured,
cmd->fields[i].in_value, num_bits);
263 bit_count +=
cmd->fields[i].num_bits;
char * buf_to_hex_str(const void *_buf, unsigned int buf_len)
void * buf_set_buf(const void *_src, unsigned int src_start, void *_dst, unsigned int dst_start, unsigned int len)
void * buf_cpy(const void *from, void *_to, unsigned int size)
Copies size bits out of from and into to.
static struct jtag_command * jtag_command_queue
struct jtag_command * jtag_command_queue_get(void)
unsigned int jtag_scan_size(const struct scan_command *cmd)
int jtag_build_buffer(const struct scan_command *cmd, uint8_t **buffer)
void jtag_queue_command(struct jtag_command *cmd)
void jtag_scan_field_clone(struct scan_field *dst, const struct scan_field *src)
Copy a struct scan_field for insertion into the queue.
enum scan_type jtag_scan_type(const struct scan_command *cmd)
#define CMD_QUEUE_PAGE_SIZE
static struct cmd_queue_page * cmd_queue_pages
static struct jtag_command ** next_command_pointer
int jtag_read_buffer(uint8_t *buffer, const struct scan_command *cmd)
static struct cmd_queue_page * cmd_queue_pages_tail
void jtag_command_queue_reset(void)
void * cmd_queue_alloc(size_t size)
static void cmd_queue_free(void)
scan_type
The inferred type of a scan_command structure, indicating whether the command has the host scan in fr...
@ SCAN_IN
From device to host,.
@ SCAN_OUT
From host to device,.
bool transport_is_jtag(void)
Returns true if the current debug session is using JTAG as its transport.
The JTAG interface can be implemented with a software or hardware fifo.
#define LOG_DEBUG_IO(expr ...)
#define LOG_ERROR(expr ...)
#define LOG_LEVEL_IS(FOO)
#define LOG_DEBUG(expr ...)
size_t size
Size of the control block search area.
struct cmd_queue_page * next
The scan_command provide a means of encapsulating a set of scan_field structures that should be scann...
This structure defines a single scan field in the scan.
uint8_t * in_value
A pointer to a 32-bit memory location for data scanned out.
const uint8_t * out_value
A pointer to value to be scanned into the device.
unsigned int num_bits
The number of bits this field specifies.
#define DIV_ROUND_UP(m, n)
Rounds m up to the nearest multiple of n using division.