jtag interfaces: Reduce usage of global for jtag queue
Makes driver interface slightly more flexible. Change-Id: I2c7f5cb6d014e94a0e6122cbe2f4002c77fbabb9 Signed-off-by: Evan Hunter <ehunter@broadcom.com> Signed-off-by: David Ryskalczyk <david.rysk@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/945 Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com> Tested-by: jenkins
This commit is contained in:
parent
c6e7e48b05
commit
847f1209d6
|
@ -33,7 +33,7 @@ struct cmd_queue_page {
|
|||
static struct cmd_queue_page *cmd_queue_pages;
|
||||
static struct cmd_queue_page *cmd_queue_pages_tail;
|
||||
|
||||
struct jtag_command *jtag_command_queue;
|
||||
static struct jtag_command *jtag_command_queue;
|
||||
static struct jtag_command **next_command_pointer = &jtag_command_queue;
|
||||
|
||||
void jtag_queue_command(struct jtag_command *cmd)
|
||||
|
@ -147,6 +147,11 @@ void jtag_command_queue_reset(void)
|
|||
next_command_pointer = &jtag_command_queue;
|
||||
}
|
||||
|
||||
struct jtag_command *jtag_command_queue_get(void)
|
||||
{
|
||||
return jtag_command_queue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Copy a struct scan_field for insertion into the queue.
|
||||
*
|
||||
|
|
|
@ -149,13 +149,11 @@ struct jtag_command {
|
|||
struct jtag_command *next;
|
||||
};
|
||||
|
||||
/** The current queue of jtag_command_s structures. */
|
||||
extern struct jtag_command *jtag_command_queue;
|
||||
|
||||
void *cmd_queue_alloc(size_t size);
|
||||
|
||||
void jtag_queue_command(struct jtag_command *cmd);
|
||||
void jtag_command_queue_reset(void);
|
||||
struct jtag_command *jtag_command_queue_get(void);
|
||||
|
||||
void jtag_scan_field_clone(struct scan_field *dst, const struct scan_field *src);
|
||||
enum scan_type jtag_scan_type(const struct scan_command *cmd);
|
||||
|
|
|
@ -951,9 +951,9 @@ int default_interface_jtag_execute_queue(void)
|
|||
return ERROR_OK;
|
||||
}
|
||||
|
||||
int result = adapter_driver->jtag_ops->execute_queue();
|
||||
struct jtag_command *cmd = jtag_command_queue_get();
|
||||
int result = adapter_driver->jtag_ops->execute_queue(cmd);
|
||||
|
||||
struct jtag_command *cmd = jtag_command_queue;
|
||||
while (debug_level >= LOG_LVL_DEBUG_IO && cmd) {
|
||||
switch (cmd->type) {
|
||||
case JTAG_SCAN:
|
||||
|
|
|
@ -317,9 +317,9 @@ static void amt_jtagaccel_scan(bool ir_scan, enum scan_type type, uint8_t *buffe
|
|||
tap_set_state(tap_get_end_state());
|
||||
}
|
||||
|
||||
static int amt_jtagaccel_execute_queue(void)
|
||||
static int amt_jtagaccel_execute_queue(struct jtag_command *cmd_queue)
|
||||
{
|
||||
struct jtag_command *cmd = jtag_command_queue; /* currently processed command */
|
||||
struct jtag_command *cmd = cmd_queue; /* currently processed command */
|
||||
int scan_size;
|
||||
enum scan_type type;
|
||||
uint8_t *buffer;
|
||||
|
|
|
@ -233,7 +233,7 @@ static int angie_post_process_scan(struct angie_cmd *angie_cmd);
|
|||
static int angie_post_process_queue(struct angie *device);
|
||||
|
||||
/* adapter driver functions */
|
||||
static int angie_execute_queue(void);
|
||||
static int angie_execute_queue(struct jtag_command *cmd_queue);
|
||||
static int angie_khz(int khz, int *jtag_speed);
|
||||
static int angie_speed(int speed);
|
||||
static int angie_speed_div(int speed, int *khz);
|
||||
|
@ -2037,9 +2037,9 @@ static int angie_post_process_queue(struct angie *device)
|
|||
* @return on success: ERROR_OK
|
||||
* @return on failure: ERROR_FAIL
|
||||
*/
|
||||
static int angie_execute_queue(void)
|
||||
static int angie_execute_queue(struct jtag_command *cmd_queue)
|
||||
{
|
||||
struct jtag_command *cmd = jtag_command_queue;
|
||||
struct jtag_command *cmd = cmd_queue;
|
||||
int ret;
|
||||
|
||||
while (cmd) {
|
||||
|
|
|
@ -85,9 +85,9 @@ static struct armjtagew *armjtagew_handle;
|
|||
/**************************************************************************
|
||||
* External interface implementation */
|
||||
|
||||
static int armjtagew_execute_queue(void)
|
||||
static int armjtagew_execute_queue(struct jtag_command *cmd_queue)
|
||||
{
|
||||
struct jtag_command *cmd = jtag_command_queue;
|
||||
struct jtag_command *cmd = cmd_queue;
|
||||
int scan_size;
|
||||
enum scan_type type;
|
||||
uint8_t *buffer;
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <jtag/jtag.h> /* Added to avoid include loop in commands.h */
|
||||
#include "bitbang.h"
|
||||
#include <jtag/interface.h>
|
||||
#include <jtag/commands.h>
|
||||
|
@ -287,9 +288,9 @@ static void bitbang_sleep(unsigned int microseconds)
|
|||
}
|
||||
}
|
||||
|
||||
int bitbang_execute_queue(void)
|
||||
int bitbang_execute_queue(struct jtag_command *cmd_queue)
|
||||
{
|
||||
struct jtag_command *cmd = jtag_command_queue; /* currently processed command */
|
||||
struct jtag_command *cmd = cmd_queue; /* currently processed command */
|
||||
int scan_size;
|
||||
enum scan_type type;
|
||||
uint8_t *buffer;
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
#define OPENOCD_JTAG_DRIVERS_BITBANG_H
|
||||
|
||||
#include <jtag/swd.h>
|
||||
#include <jtag/commands.h>
|
||||
|
||||
typedef enum {
|
||||
BB_LOW,
|
||||
|
@ -64,7 +65,7 @@ struct bitbang_interface {
|
|||
|
||||
extern const struct swd_driver bitbang_swd;
|
||||
|
||||
int bitbang_execute_queue(void);
|
||||
int bitbang_execute_queue(struct jtag_command *cmd_queue);
|
||||
|
||||
extern struct bitbang_interface *bitbang_interface;
|
||||
|
||||
|
|
|
@ -203,11 +203,11 @@ static void bitq_scan(struct scan_command *cmd)
|
|||
bitq_scan_field(&cmd->fields[i], 1);
|
||||
}
|
||||
|
||||
int bitq_execute_queue(void)
|
||||
int bitq_execute_queue(struct jtag_command *cmd_queue)
|
||||
{
|
||||
struct jtag_command *cmd = jtag_command_queue; /* currently processed command */
|
||||
struct jtag_command *cmd = cmd_queue; /* currently processed command */
|
||||
|
||||
bitq_in_state.cmd = jtag_command_queue;
|
||||
bitq_in_state.cmd = cmd_queue;
|
||||
bitq_in_state.field_idx = 0;
|
||||
bitq_in_state.bit_pos = 0;
|
||||
bitq_in_state.status = ERROR_OK;
|
||||
|
|
|
@ -27,7 +27,7 @@ struct bitq_interface {
|
|||
|
||||
extern struct bitq_interface *bitq_interface;
|
||||
|
||||
int bitq_execute_queue(void);
|
||||
int bitq_execute_queue(struct jtag_command *cmd_queue);
|
||||
|
||||
void bitq_cleanup(void);
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
|
||||
#undef DEBUG_SERIAL
|
||||
/*#define DEBUG_SERIAL */
|
||||
static int buspirate_execute_queue(void);
|
||||
static int buspirate_execute_queue(struct jtag_command *cmd_queue);
|
||||
static int buspirate_init(void);
|
||||
static int buspirate_quit(void);
|
||||
static int buspirate_reset(int trst, int srst);
|
||||
|
@ -151,10 +151,10 @@ static int buspirate_serial_read(int fd, uint8_t *buf, int size);
|
|||
static void buspirate_serial_close(int fd);
|
||||
static void buspirate_print_buffer(uint8_t *buf, int size);
|
||||
|
||||
static int buspirate_execute_queue(void)
|
||||
static int buspirate_execute_queue(struct jtag_command *cmd_queue)
|
||||
{
|
||||
/* currently processed command */
|
||||
struct jtag_command *cmd = jtag_command_queue;
|
||||
struct jtag_command *cmd = cmd_queue;
|
||||
int scan_size;
|
||||
enum scan_type type;
|
||||
uint8_t *buffer;
|
||||
|
|
|
@ -1954,9 +1954,9 @@ static void cmsis_dap_execute_command(struct jtag_command *cmd)
|
|||
}
|
||||
}
|
||||
|
||||
static int cmsis_dap_execute_queue(void)
|
||||
static int cmsis_dap_execute_queue(struct jtag_command *cmd_queue)
|
||||
{
|
||||
struct jtag_command *cmd = jtag_command_queue;
|
||||
struct jtag_command *cmd = cmd_queue;
|
||||
|
||||
while (cmd) {
|
||||
cmsis_dap_execute_command(cmd);
|
||||
|
|
|
@ -803,9 +803,9 @@ static void syncbb_scan(bool ir_scan, enum scan_type type, uint8_t *buffer, int
|
|||
}
|
||||
}
|
||||
|
||||
static int syncbb_execute_queue(void)
|
||||
static int syncbb_execute_queue(struct jtag_command *cmd_queue)
|
||||
{
|
||||
struct jtag_command *cmd = jtag_command_queue; /* currently processed command */
|
||||
struct jtag_command *cmd = cmd_queue; /* currently processed command */
|
||||
int scan_size;
|
||||
enum scan_type type;
|
||||
uint8_t *buffer;
|
||||
|
|
|
@ -625,14 +625,14 @@ static void ftdi_execute_command(struct jtag_command *cmd)
|
|||
}
|
||||
}
|
||||
|
||||
static int ftdi_execute_queue(void)
|
||||
static int ftdi_execute_queue(struct jtag_command *cmd_queue)
|
||||
{
|
||||
/* blink, if the current layout has that feature */
|
||||
struct signal *led = find_signal_by_name("LED");
|
||||
if (led)
|
||||
ftdi_set_signal(led, '1');
|
||||
|
||||
for (struct jtag_command *cmd = jtag_command_queue; cmd; cmd = cmd->next) {
|
||||
for (struct jtag_command *cmd = cmd_queue; cmd; cmd = cmd->next) {
|
||||
/* fill the write buffer with the desired command */
|
||||
ftdi_execute_command(cmd);
|
||||
}
|
||||
|
|
|
@ -270,9 +270,9 @@ static void gw16012_scan(bool ir_scan, enum scan_type type, uint8_t *buffer, int
|
|||
}
|
||||
}
|
||||
|
||||
static int gw16012_execute_queue(void)
|
||||
static int gw16012_execute_queue(struct jtag_command *cmd_queue)
|
||||
{
|
||||
struct jtag_command *cmd = jtag_command_queue; /* currently processed command */
|
||||
struct jtag_command *cmd = cmd_queue; /* currently processed command */
|
||||
int scan_size;
|
||||
enum scan_type type;
|
||||
uint8_t *buffer;
|
||||
|
|
|
@ -276,10 +276,10 @@ static int jlink_execute_command(struct jtag_command *cmd)
|
|||
return ERROR_OK;
|
||||
}
|
||||
|
||||
static int jlink_execute_queue(void)
|
||||
static int jlink_execute_queue(struct jtag_command *cmd_queue)
|
||||
{
|
||||
int ret;
|
||||
struct jtag_command *cmd = jtag_command_queue;
|
||||
struct jtag_command *cmd = cmd_queue;
|
||||
|
||||
while (cmd) {
|
||||
ret = jlink_execute_command(cmd);
|
||||
|
|
|
@ -222,12 +222,12 @@ static int jtag_dpi_stableclocks(int cycles)
|
|||
return jtag_dpi_runtest(cycles);
|
||||
}
|
||||
|
||||
static int jtag_dpi_execute_queue(void)
|
||||
static int jtag_dpi_execute_queue(struct jtag_command *cmd_queue)
|
||||
{
|
||||
struct jtag_command *cmd;
|
||||
int ret = ERROR_OK;
|
||||
|
||||
for (cmd = jtag_command_queue; ret == ERROR_OK && cmd;
|
||||
for (cmd = cmd_queue; ret == ERROR_OK && cmd;
|
||||
cmd = cmd->next) {
|
||||
switch (cmd->type) {
|
||||
case JTAG_RUNTEST:
|
||||
|
|
|
@ -480,12 +480,12 @@ static int jtag_vpi_stableclocks(int cycles)
|
|||
return ERROR_OK;
|
||||
}
|
||||
|
||||
static int jtag_vpi_execute_queue(void)
|
||||
static int jtag_vpi_execute_queue(struct jtag_command *cmd_queue)
|
||||
{
|
||||
struct jtag_command *cmd;
|
||||
int retval = ERROR_OK;
|
||||
|
||||
for (cmd = jtag_command_queue; retval == ERROR_OK && cmd;
|
||||
for (cmd = cmd_queue; retval == ERROR_OK && cmd;
|
||||
cmd = cmd->next) {
|
||||
switch (cmd->type) {
|
||||
case JTAG_RESET:
|
||||
|
|
|
@ -99,7 +99,7 @@ static char *opendous_type;
|
|||
static const struct opendous_probe *opendous_probe;
|
||||
|
||||
/* External interface functions */
|
||||
static int opendous_execute_queue(void);
|
||||
static int opendous_execute_queue(struct jtag_command *cmd_queue);
|
||||
static int opendous_init(void);
|
||||
static int opendous_quit(void);
|
||||
|
||||
|
@ -238,9 +238,9 @@ struct adapter_driver opendous_adapter_driver = {
|
|||
.jtag_ops = &opendous_interface,
|
||||
};
|
||||
|
||||
static int opendous_execute_queue(void)
|
||||
static int opendous_execute_queue(struct jtag_command *cmd_queue)
|
||||
{
|
||||
struct jtag_command *cmd = jtag_command_queue;
|
||||
struct jtag_command *cmd = cmd_queue;
|
||||
int scan_size;
|
||||
enum scan_type type;
|
||||
uint8_t *buffer;
|
||||
|
|
|
@ -805,9 +805,9 @@ static void openjtag_execute_command(struct jtag_command *cmd)
|
|||
}
|
||||
}
|
||||
|
||||
static int openjtag_execute_queue(void)
|
||||
static int openjtag_execute_queue(struct jtag_command *cmd_queue)
|
||||
{
|
||||
struct jtag_command *cmd = jtag_command_queue;
|
||||
struct jtag_command *cmd = cmd_queue;
|
||||
|
||||
while (cmd) {
|
||||
openjtag_execute_command(cmd);
|
||||
|
|
|
@ -628,7 +628,7 @@ static int osbdm_execute_command(
|
|||
return retval;
|
||||
}
|
||||
|
||||
static int osbdm_execute_queue(void)
|
||||
static int osbdm_execute_queue(struct jtag_command *cmd_queue)
|
||||
{
|
||||
int retval = ERROR_OK;
|
||||
|
||||
|
@ -637,7 +637,7 @@ static int osbdm_execute_queue(void)
|
|||
LOG_ERROR("BUG: can't allocate bit queue");
|
||||
retval = ERROR_FAIL;
|
||||
} else {
|
||||
struct jtag_command *cmd = jtag_command_queue;
|
||||
struct jtag_command *cmd = cmd_queue;
|
||||
|
||||
while (retval == ERROR_OK && cmd) {
|
||||
retval = osbdm_execute_command(&osbdm_context, queue, cmd);
|
||||
|
|
|
@ -456,14 +456,14 @@ static const struct command_registration remote_bitbang_command_handlers[] = {
|
|||
COMMAND_REGISTRATION_DONE
|
||||
};
|
||||
|
||||
static int remote_bitbang_execute_queue(void)
|
||||
static int remote_bitbang_execute_queue(struct jtag_command *cmd_queue)
|
||||
{
|
||||
/* safety: the send buffer must be empty, no leftover characters from
|
||||
* previous transactions */
|
||||
assert(remote_bitbang_send_buf_used == 0);
|
||||
|
||||
/* process the JTAG command queue */
|
||||
int ret = bitbang_execute_queue();
|
||||
int ret = bitbang_execute_queue(cmd_queue);
|
||||
if (ret != ERROR_OK)
|
||||
return ret;
|
||||
|
||||
|
|
|
@ -1262,9 +1262,9 @@ static int rlink_scan(struct jtag_command *cmd, enum scan_type type,
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int rlink_execute_queue(void)
|
||||
static int rlink_execute_queue(struct jtag_command *cmd_queue)
|
||||
{
|
||||
struct jtag_command *cmd = jtag_command_queue; /* currently processed command */
|
||||
struct jtag_command *cmd = cmd_queue; /* currently processed command */
|
||||
int scan_size;
|
||||
enum scan_type type;
|
||||
uint8_t *buffer;
|
||||
|
|
|
@ -227,7 +227,7 @@ static int ulink_post_process_scan(struct ulink_cmd *ulink_cmd);
|
|||
static int ulink_post_process_queue(struct ulink *device);
|
||||
|
||||
/* adapter driver functions */
|
||||
static int ulink_execute_queue(void);
|
||||
static int ulink_execute_queue(struct jtag_command *cmd_queue);
|
||||
static int ulink_khz(int khz, int *jtag_speed);
|
||||
static int ulink_speed(int speed);
|
||||
static int ulink_speed_div(int speed, int *khz);
|
||||
|
@ -1905,9 +1905,9 @@ static int ulink_post_process_queue(struct ulink *device)
|
|||
* @return on success: ERROR_OK
|
||||
* @return on failure: ERROR_FAIL
|
||||
*/
|
||||
static int ulink_execute_queue(void)
|
||||
static int ulink_execute_queue(struct jtag_command *cmd_queue)
|
||||
{
|
||||
struct jtag_command *cmd = jtag_command_queue;
|
||||
struct jtag_command *cmd = cmd_queue;
|
||||
int ret;
|
||||
|
||||
while (cmd) {
|
||||
|
|
|
@ -765,7 +765,7 @@ static void ublast_initial_wipeout(void)
|
|||
tap_set_state(TAP_RESET);
|
||||
}
|
||||
|
||||
static int ublast_execute_queue(void)
|
||||
static int ublast_execute_queue(struct jtag_command *cmd_queue)
|
||||
{
|
||||
struct jtag_command *cmd;
|
||||
static int first_call = 1;
|
||||
|
@ -776,7 +776,7 @@ static int ublast_execute_queue(void)
|
|||
ublast_initial_wipeout();
|
||||
}
|
||||
|
||||
for (cmd = jtag_command_queue; ret == ERROR_OK && cmd;
|
||||
for (cmd = cmd_queue; ret == ERROR_OK && cmd;
|
||||
cmd = cmd->next) {
|
||||
switch (cmd->type) {
|
||||
case JTAG_RESET:
|
||||
|
|
|
@ -83,9 +83,9 @@ static void usbprog_jtag_write_slice(struct usbprog_jtag *usbprog_jtag, unsigned
|
|||
static void usbprog_jtag_set_bit(struct usbprog_jtag *usbprog_jtag, int bit, int value);
|
||||
/* static int usbprog_jtag_get_bit(struct usbprog_jtag *usbprog_jtag, int bit); */
|
||||
|
||||
static int usbprog_execute_queue(void)
|
||||
static int usbprog_execute_queue(struct jtag_command *cmd_queue)
|
||||
{
|
||||
struct jtag_command *cmd = jtag_command_queue; /* currently processed command */
|
||||
struct jtag_command *cmd = cmd_queue; /* currently processed command */
|
||||
int scan_size;
|
||||
enum scan_type type;
|
||||
uint8_t *buffer;
|
||||
|
|
|
@ -1046,11 +1046,11 @@ static int vdebug_jtag_div(int speed, int *khz)
|
|||
return ERROR_OK;
|
||||
}
|
||||
|
||||
static int vdebug_jtag_execute_queue(void)
|
||||
static int vdebug_jtag_execute_queue(struct jtag_command *cmd_queue)
|
||||
{
|
||||
int rc = ERROR_OK;
|
||||
|
||||
for (struct jtag_command *cmd = jtag_command_queue; rc == ERROR_OK && cmd; cmd = cmd->next) {
|
||||
for (struct jtag_command *cmd = cmd_queue; rc == ERROR_OK && cmd; cmd = cmd->next) {
|
||||
switch (cmd->type) {
|
||||
case JTAG_RUNTEST:
|
||||
rc = vdebug_jtag_runtest(cmd->cmd.runtest->num_cycles, cmd->cmd.runtest->end_state, !cmd->next);
|
||||
|
|
|
@ -84,9 +84,9 @@ static bool swd_mode;
|
|||
|
||||
static struct vsllink *vsllink_handle;
|
||||
|
||||
static int vsllink_execute_queue(void)
|
||||
static int vsllink_execute_queue(struct jtag_command *cmd_queue)
|
||||
{
|
||||
struct jtag_command *cmd = jtag_command_queue;
|
||||
struct jtag_command *cmd = cmd_queue;
|
||||
int scan_size;
|
||||
enum scan_type type;
|
||||
uint8_t *buffer;
|
||||
|
|
|
@ -1840,9 +1840,9 @@ static void xds110_execute_command(struct jtag_command *cmd)
|
|||
}
|
||||
}
|
||||
|
||||
static int xds110_execute_queue(void)
|
||||
static int xds110_execute_queue(struct jtag_command *cmd_queue)
|
||||
{
|
||||
struct jtag_command *cmd = jtag_command_queue;
|
||||
struct jtag_command *cmd = cmd_queue;
|
||||
|
||||
while (cmd) {
|
||||
xds110_execute_command(cmd);
|
||||
|
|
|
@ -362,9 +362,9 @@ static int xlnx_pcie_xvc_execute_command(struct jtag_command *cmd)
|
|||
return ERROR_OK;
|
||||
}
|
||||
|
||||
static int xlnx_pcie_xvc_execute_queue(void)
|
||||
static int xlnx_pcie_xvc_execute_queue(struct jtag_command *cmd_queue)
|
||||
{
|
||||
struct jtag_command *cmd = jtag_command_queue;
|
||||
struct jtag_command *cmd = cmd_queue;
|
||||
int ret;
|
||||
|
||||
while (cmd) {
|
||||
|
|
|
@ -187,10 +187,12 @@ struct jtag_interface {
|
|||
#define DEBUG_CAP_TMS_SEQ (1 << 0)
|
||||
|
||||
/**
|
||||
* Execute queued commands.
|
||||
* Execute commands in the supplied queue
|
||||
* @param cmd_queue - a linked list of commands to execute
|
||||
* @returns ERROR_OK on success, or an error code on failure.
|
||||
*/
|
||||
int (*execute_queue)(void);
|
||||
|
||||
int (*execute_queue)(struct jtag_command *cmd_queue);
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue