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
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)
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.
*
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);
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:
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;
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);
* @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) {
/**************************************************************************
* 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;
#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>
}
}
-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;
#define OPENOCD_JTAG_DRIVERS_BITBANG_H
#include <jtag/swd.h>
+#include <jtag/commands.h>
typedef enum {
BB_LOW,
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;
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;
extern struct bitq_interface *bitq_interface;
-int bitq_execute_queue(void);
+int bitq_execute_queue(struct jtag_command *cmd_queue);
void bitq_cleanup(void);
#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);
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;
}
}
-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);
}
}
-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;
}
}
-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);
}
}
}
-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;
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);
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:
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:
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);
.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;
}
}
-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);
return retval;
}
-static int osbdm_execute_queue(void)
+static int osbdm_execute_queue(struct jtag_command *cmd_queue)
{
int retval = ERROR_OK;
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);
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;
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;
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);
* @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) {
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;
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:
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;
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);
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;
}
}
-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);
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) {
#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);
};
/**