struct jtag_callback_entry *next;
jtag_callback_t callback;
- uint8_t *in;
+ jtag_callback_data_t data0;
jtag_callback_data_t data1;
jtag_callback_data_t data2;
jtag_callback_data_t data3;
}
/**
- * Copy a scan_field_t for insertion into the queue.
+ * Copy a struct scan_field for insertion into the queue.
*
* This allocates a new copy of out_value using cmd_queue_alloc.
*/
-static void cmd_queue_scan_field_clone(scan_field_t * dst, const scan_field_t * src)
+static void cmd_queue_scan_field_clone(struct scan_field * dst, const struct scan_field * src)
{
dst->tap = src->tap;
dst->num_bits = src->num_bits;
- dst->out_value = buf_cpy(src->out_value, cmd_queue_alloc(CEIL(src->num_bits, 8)), src->num_bits);
+ dst->out_value = buf_cpy(src->out_value, cmd_queue_alloc(DIV_ROUND_UP(src->num_bits, 8)), src->num_bits);
dst->in_value = src->in_value;
}
* see jtag_add_ir_scan()
*
*/
-int interface_jtag_add_ir_scan(int in_num_fields, const scan_field_t *in_fields, tap_state_t state)
+int interface_jtag_add_ir_scan(int in_num_fields, const struct scan_field *in_fields, tap_state_t state)
{
size_t num_taps = jtag_tap_count_enabled();
- jtag_command_t * cmd = cmd_queue_alloc(sizeof(jtag_command_t));
- scan_command_t * scan = cmd_queue_alloc(sizeof(scan_command_t));
- scan_field_t * out_fields = cmd_queue_alloc(num_taps * sizeof(scan_field_t));
+ struct jtag_command * cmd = cmd_queue_alloc(sizeof(struct jtag_command));
+ struct scan_command * scan = cmd_queue_alloc(sizeof(struct scan_command));
+ struct scan_field * out_fields = cmd_queue_alloc(num_taps * sizeof(struct scan_field));
jtag_queue_command(cmd);
scan->end_state = state;
- scan_field_t * field = out_fields; /* keep track where we insert data */
+ struct scan_field * field = out_fields; /* keep track where we insert data */
/* loop over all enabled TAPs */
- for (jtag_tap_t * tap = jtag_tap_next_enabled(NULL); tap != NULL; tap = jtag_tap_next_enabled(tap))
+ for (struct jtag_tap * tap = jtag_tap_next_enabled(NULL); tap != NULL; tap = jtag_tap_next_enabled(tap))
{
/* search the input field list for fields for the current TAP */
field->tap = tap;
field->num_bits = tap->ir_length;
- field->out_value = buf_set_ones(cmd_queue_alloc(CEIL(tap->ir_length, 8)), tap->ir_length);
+ field->out_value = buf_set_ones(cmd_queue_alloc(DIV_ROUND_UP(tap->ir_length, 8)), tap->ir_length);
field->in_value = NULL; /* do not collect input for tap's in bypass */
}
* see jtag_add_plain_ir_scan()
*
*/
-int interface_jtag_add_plain_ir_scan(int in_num_fields, const scan_field_t *in_fields, tap_state_t state)
+int interface_jtag_add_plain_ir_scan(int in_num_fields, const struct scan_field *in_fields, tap_state_t state)
{
- jtag_command_t * cmd = cmd_queue_alloc(sizeof(jtag_command_t));
- scan_command_t * scan = cmd_queue_alloc(sizeof(scan_command_t));
- scan_field_t * out_fields = cmd_queue_alloc(in_num_fields * sizeof(scan_field_t));
+ struct jtag_command * cmd = cmd_queue_alloc(sizeof(struct jtag_command));
+ struct scan_command * scan = cmd_queue_alloc(sizeof(struct scan_command));
+ struct scan_field * out_fields = cmd_queue_alloc(in_num_fields * sizeof(struct scan_field));
jtag_queue_command(cmd);
* see jtag_add_dr_scan()
*
*/
-int interface_jtag_add_dr_scan(int in_num_fields, const scan_field_t *in_fields, tap_state_t state)
+int interface_jtag_add_dr_scan(int in_num_fields, const struct scan_field *in_fields, tap_state_t state)
{
/* count devices in bypass */
size_t bypass_devices = 0;
- for (jtag_tap_t * tap = jtag_tap_next_enabled(NULL); tap != NULL; tap = jtag_tap_next_enabled(tap))
+ for (struct jtag_tap * tap = jtag_tap_next_enabled(NULL); tap != NULL; tap = jtag_tap_next_enabled(tap))
{
if (tap->bypass)
bypass_devices++;
}
- jtag_command_t * cmd = cmd_queue_alloc(sizeof(jtag_command_t));
- scan_command_t * scan = cmd_queue_alloc(sizeof(scan_command_t));
- scan_field_t * out_fields = cmd_queue_alloc((in_num_fields + bypass_devices) * sizeof(scan_field_t));
+ struct jtag_command * cmd = cmd_queue_alloc(sizeof(struct jtag_command));
+ struct scan_command * scan = cmd_queue_alloc(sizeof(struct scan_command));
+ struct scan_field * out_fields = cmd_queue_alloc((in_num_fields + bypass_devices) * sizeof(struct scan_field));
jtag_queue_command(cmd);
scan->end_state = state;
- scan_field_t * field = out_fields; /* keep track where we insert data */
+ struct scan_field * field = out_fields; /* keep track where we insert data */
/* loop over all enabled TAPs */
- for (jtag_tap_t * tap = jtag_tap_next_enabled(NULL); tap != NULL; tap = jtag_tap_next_enabled(tap))
+ for (struct jtag_tap * tap = jtag_tap_next_enabled(NULL); tap != NULL; tap = jtag_tap_next_enabled(tap))
{
/* if TAP is not bypassed insert matching input fields */
if (!tap->bypass)
{
- scan_field_t * start_field = field; /* keep initial position for assert() */
+ struct scan_field * start_field = field; /* keep initial position for assert() */
for (int j = 0; j < in_num_fields; j++)
{
* The bypass status of TAPs is set by jtag_add_ir_scan().
*
*/
-void interface_jtag_add_dr_out(jtag_tap_t *target_tap,
+void interface_jtag_add_dr_out(struct jtag_tap *target_tap,
int in_num_fields,
const int *num_bits,
const uint32_t *value,
size_t bypass_devices = 0;
- for (jtag_tap_t * tap = jtag_tap_next_enabled(NULL); tap != NULL; tap = jtag_tap_next_enabled(tap))
+ for (struct jtag_tap * tap = jtag_tap_next_enabled(NULL); tap != NULL; tap = jtag_tap_next_enabled(tap))
{
if (tap->bypass)
bypass_devices++;
}
- jtag_command_t * cmd = cmd_queue_alloc(sizeof(jtag_command_t));
- scan_command_t * scan = cmd_queue_alloc(sizeof(scan_command_t));
- scan_field_t * out_fields = cmd_queue_alloc((in_num_fields + bypass_devices) * sizeof(scan_field_t));
+ struct jtag_command * cmd = cmd_queue_alloc(sizeof(struct jtag_command));
+ struct scan_command * scan = cmd_queue_alloc(sizeof(struct scan_command));
+ struct scan_field * out_fields = cmd_queue_alloc((in_num_fields + bypass_devices) * sizeof(struct scan_field));
jtag_queue_command(cmd);
bool target_tap_match = false;
- scan_field_t * field = out_fields; /* keep track where we insert data */
+ struct scan_field * field = out_fields; /* keep track where we insert data */
/* loop over all enabled TAPs */
- for (jtag_tap_t * tap = jtag_tap_next_enabled(NULL); tap != NULL; tap = jtag_tap_next_enabled(tap))
+ for (struct jtag_tap * tap = jtag_tap_next_enabled(NULL); tap != NULL; tap = jtag_tap_next_enabled(tap))
{
/* if TAP is not bypassed insert matching input fields */
field->tap = tap;
field->num_bits = scan_size;
- field->out_value = buf_cpy(out_value, cmd_queue_alloc(CEIL(scan_size, 8)), scan_size);
+ field->out_value = buf_cpy(out_value, cmd_queue_alloc(DIV_ROUND_UP(scan_size, 8)), scan_size);
field->in_value = NULL;
field++;
* see jtag_add_plain_dr_scan()
*
*/
-int interface_jtag_add_plain_dr_scan(int in_num_fields, const scan_field_t *in_fields, tap_state_t state)
+int interface_jtag_add_plain_dr_scan(int in_num_fields, const struct scan_field *in_fields, tap_state_t state)
{
- jtag_command_t * cmd = cmd_queue_alloc(sizeof(jtag_command_t));
- scan_command_t * scan = cmd_queue_alloc(sizeof(scan_command_t));
- scan_field_t * out_fields = cmd_queue_alloc(in_num_fields * sizeof(scan_field_t));
+ struct jtag_command * cmd = cmd_queue_alloc(sizeof(struct jtag_command));
+ struct scan_command * scan = cmd_queue_alloc(sizeof(struct scan_command));
+ struct scan_field * out_fields = cmd_queue_alloc(in_num_fields * sizeof(struct scan_field));
jtag_queue_command(cmd);
tap_state_t state = TAP_RESET;
/* allocate memory for a new list member */
- jtag_command_t * cmd = cmd_queue_alloc(sizeof(jtag_command_t));
+ struct jtag_command * cmd = cmd_queue_alloc(sizeof(struct jtag_command));
jtag_queue_command(cmd);
cmd->type = JTAG_STATEMOVE;
- cmd->cmd.statemove = cmd_queue_alloc(sizeof(statemove_command_t));
+ cmd->cmd.statemove = cmd_queue_alloc(sizeof(struct statemove_command));
cmd->cmd.statemove->end_state = state;
return ERROR_OK;
int interface_jtag_add_pathmove(int num_states, const tap_state_t *path)
{
/* allocate memory for a new list member */
- jtag_command_t * cmd = cmd_queue_alloc(sizeof(jtag_command_t));
+ struct jtag_command * cmd = cmd_queue_alloc(sizeof(struct jtag_command));
jtag_queue_command(cmd);
cmd->type = JTAG_PATHMOVE;
- cmd->cmd.pathmove = cmd_queue_alloc(sizeof(pathmove_command_t));
+ cmd->cmd.pathmove = cmd_queue_alloc(sizeof(struct pathmove_command));
cmd->cmd.pathmove->num_states = num_states;
cmd->cmd.pathmove->path = cmd_queue_alloc(sizeof(tap_state_t) * num_states);
int interface_jtag_add_runtest(int num_cycles, tap_state_t state)
{
/* allocate memory for a new list member */
- jtag_command_t * cmd = cmd_queue_alloc(sizeof(jtag_command_t));
+ struct jtag_command * cmd = cmd_queue_alloc(sizeof(struct jtag_command));
jtag_queue_command(cmd);
cmd->type = JTAG_RUNTEST;
- cmd->cmd.runtest = cmd_queue_alloc(sizeof(runtest_command_t));
+ cmd->cmd.runtest = cmd_queue_alloc(sizeof(struct runtest_command));
cmd->cmd.runtest->num_cycles = num_cycles;
cmd->cmd.runtest->end_state = state;
return ERROR_OK;
}
-int interface_jtag_add_clocks( int num_cycles )
+int interface_jtag_add_clocks(int num_cycles)
{
/* allocate memory for a new list member */
- jtag_command_t * cmd = cmd_queue_alloc(sizeof(jtag_command_t));
+ struct jtag_command * cmd = cmd_queue_alloc(sizeof(struct jtag_command));
jtag_queue_command(cmd);
cmd->type = JTAG_STABLECLOCKS;
- cmd->cmd.stableclocks = cmd_queue_alloc(sizeof(stableclocks_command_t));
+ cmd->cmd.stableclocks = cmd_queue_alloc(sizeof(struct stableclocks_command));
cmd->cmd.stableclocks->num_cycles = num_cycles;
return ERROR_OK;
int interface_jtag_add_reset(int req_trst, int req_srst)
{
/* allocate memory for a new list member */
- jtag_command_t * cmd = cmd_queue_alloc(sizeof(jtag_command_t));
+ struct jtag_command * cmd = cmd_queue_alloc(sizeof(struct jtag_command));
jtag_queue_command(cmd);
cmd->type = JTAG_RESET;
- cmd->cmd.reset = cmd_queue_alloc(sizeof(reset_command_t));
+ cmd->cmd.reset = cmd_queue_alloc(sizeof(struct reset_command));
cmd->cmd.reset->trst = req_trst;
cmd->cmd.reset->srst = req_srst;
int interface_jtag_add_sleep(uint32_t us)
{
/* allocate memory for a new list member */
- jtag_command_t * cmd = cmd_queue_alloc(sizeof(jtag_command_t));
+ struct jtag_command * cmd = cmd_queue_alloc(sizeof(struct jtag_command));
jtag_queue_command(cmd);
cmd->type = JTAG_SLEEP;
- cmd->cmd.sleep = cmd_queue_alloc(sizeof(sleep_command_t));
+ cmd->cmd.sleep = cmd_queue_alloc(sizeof(struct sleep_command));
cmd->cmd.sleep->us = us;
return ERROR_OK;
}
/* add callback to end of queue */
-void interface_jtag_add_callback4(jtag_callback_t callback, uint8_t *in, jtag_callback_data_t data1, jtag_callback_data_t data2, jtag_callback_data_t data3)
+void interface_jtag_add_callback4(jtag_callback_t callback, jtag_callback_data_t data0, jtag_callback_data_t data1, jtag_callback_data_t data2, jtag_callback_data_t data3)
{
- struct jtag_callback_entry *entry=cmd_queue_alloc(sizeof(struct jtag_callback_entry));
+ struct jtag_callback_entry *entry = cmd_queue_alloc(sizeof(struct jtag_callback_entry));
- entry->next=NULL;
- entry->callback=callback;
- entry->in=in;
- entry->data1=data1;
- entry->data2=data2;
- entry->data3=data3;
+ entry->next = NULL;
+ entry->callback = callback;
+ entry->data0 = data0;
+ entry->data1 = data1;
+ entry->data2 = data2;
+ entry->data3 = data3;
- if (jtag_callback_queue_head==NULL)
+ if (jtag_callback_queue_head == NULL)
{
- jtag_callback_queue_head=entry;
- jtag_callback_queue_tail=entry;
+ jtag_callback_queue_head = entry;
+ jtag_callback_queue_tail = entry;
} else
{
- jtag_callback_queue_tail->next=entry;
- jtag_callback_queue_tail=entry;
+ jtag_callback_queue_tail->next = entry;
+ jtag_callback_queue_tail = entry;
}
}
int interface_jtag_execute_queue(void)
{
+ static int reentry = 0;
+
+ assert(reentry==0);
+ reentry++;
+
int retval = default_interface_jtag_execute_queue();
if (retval == ERROR_OK)
{
struct jtag_callback_entry *entry;
- for (entry=jtag_callback_queue_head; entry!=NULL; entry=entry->next)
+ for (entry = jtag_callback_queue_head; entry != NULL; entry = entry->next)
{
- retval=entry->callback(entry->in, entry->data1, entry->data2, entry->data3);
- if (retval!=ERROR_OK)
+ retval = entry->callback(entry->data0, entry->data1, entry->data2, entry->data3);
+ if (retval != ERROR_OK)
break;
}
}
jtag_command_queue_reset();
jtag_callback_queue_reset();
+ reentry--;
+
return retval;
}
-static int jtag_convert_to_callback4(uint8_t *in, jtag_callback_data_t data1, jtag_callback_data_t data2, jtag_callback_data_t data3)
+static int jtag_convert_to_callback4(jtag_callback_data_t data0, jtag_callback_data_t data1, jtag_callback_data_t data2, jtag_callback_data_t data3)
{
- ((jtag_callback1_t)data1)(in);
+ ((jtag_callback1_t)data1)(data0);
return ERROR_OK;
}
-void interface_jtag_add_callback(jtag_callback1_t callback, uint8_t *in)
+void interface_jtag_add_callback(jtag_callback1_t callback, jtag_callback_data_t data0)
{
- jtag_add_callback4(jtag_convert_to_callback4, in, (jtag_callback_data_t)callback, 0, 0);
+ jtag_add_callback4(jtag_convert_to_callback4, data0, (jtag_callback_data_t)callback, 0, 0);
}