From: <ge...@op...> - 2012-10-30 22:15:48
|
This is an automated email from Gerrit. Evan Hunter (eva...@gm...) just uploaded a new patch set to Gerrit, which you can find at http://openocd.zylin.com/945 -- gerrit commit d40aa77e0a29d792250ba8943fac18c35c8d1f34 Author: Evan Hunter <eh...@br...> Date: Tue Oct 30 20:18:31 2012 +1100 jtag interfaces: Reduce usage of global for jtag queue Makes driver interface slightly more flexible. Change-Id: I2c7f5cb6d014e94a0e6122cbe2f4002c77fbabb9 Signed-off-by: Evan Hunter <eh...@br...> diff --git a/src/jtag/commands.c b/src/jtag/commands.c index 546b12f..addf322 100644 --- a/src/jtag/commands.c +++ b/src/jtag/commands.c @@ -142,6 +142,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; +} + enum scan_type jtag_scan_type(const struct scan_command *cmd) { int i; diff --git a/src/jtag/commands.h b/src/jtag/commands.h index da563e9..2c9b9e9 100644 --- a/src/jtag/commands.h +++ b/src/jtag/commands.h @@ -162,13 +162,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); enum scan_type jtag_scan_type(const struct scan_command *cmd); int jtag_scan_size(const struct scan_command *cmd); diff --git a/src/jtag/core.c b/src/jtag/core.c index d259730..0bb18dd 100644 --- a/src/jtag/core.c +++ b/src/jtag/core.c @@ -832,7 +832,7 @@ int default_interface_jtag_execute_queue(void) return ERROR_FAIL; } - return current_adapter_driver->execute_queue(); + return current_adapter_driver->execute_queue(jtag_command_queue_get()); } void jtag_execute_queue_noclear(void) diff --git a/src/jtag/drivers/amt_jtagaccel.c b/src/jtag/drivers/amt_jtagaccel.c index cccf4f2..574fbe2 100644 --- a/src/jtag/drivers/amt_jtagaccel.c +++ b/src/jtag/drivers/amt_jtagaccel.c @@ -326,9 +326,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; diff --git a/src/jtag/drivers/arm-jtag-ew.c b/src/jtag/drivers/arm-jtag-ew.c index 906b219..a438591 100644 --- a/src/jtag/drivers/arm-jtag-ew.c +++ b/src/jtag/drivers/arm-jtag-ew.c @@ -98,9 +98,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; diff --git a/src/jtag/drivers/bitbang.c b/src/jtag/drivers/bitbang.c index 8a097ca..4011838 100644 --- a/src/jtag/drivers/bitbang.c +++ b/src/jtag/drivers/bitbang.c @@ -235,9 +235,9 @@ static void bitbang_scan(bool ir_scan, enum scan_type type, uint8_t *buffer, int } } -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; diff --git a/src/jtag/drivers/bitq.c b/src/jtag/drivers/bitq.c index ac58190..782e002 100644 --- a/src/jtag/drivers/bitq.c +++ b/src/jtag/drivers/bitq.c @@ -218,11 +218,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; diff --git a/src/jtag/drivers/buspirate.c b/src/jtag/drivers/buspirate.c index a969ffd..2c4e653 100644 --- a/src/jtag/drivers/buspirate.c +++ b/src/jtag/drivers/buspirate.c @@ -130,10 +130,10 @@ static int buspirate_khz(int khz, int *jtag_speed) return ERROR_OK; } -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; diff --git a/src/jtag/drivers/ft2232.c b/src/jtag/drivers/ft2232.c index 39d40a3..e0ec9e2 100644 --- a/src/jtag/drivers/ft2232.c +++ b/src/jtag/drivers/ft2232.c @@ -1978,9 +1978,9 @@ static int ft2232_execute_command(struct jtag_command *cmd) return retval; } -static int ft2232_execute_queue(void) +static int ft2232_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 retval; first_unsent = cmd; /* next command that has to be sent */ diff --git a/src/jtag/drivers/ftdi.c b/src/jtag/drivers/ftdi.c index 2a22dbb..347a410 100644 --- a/src/jtag/drivers/ftdi.c +++ b/src/jtag/drivers/ftdi.c @@ -595,7 +595,7 @@ static int ftdi_execute_command(struct jtag_command *cmd) return retval; } -static int ftdi_execute_queue(void) +static int ftdi_execute_queue(struct jtag_command *cmd_queue) { int retval = ERROR_OK; @@ -604,7 +604,7 @@ static int ftdi_execute_queue(void) 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 */ if (ftdi_execute_command(cmd) != ERROR_OK) retval = ERROR_JTAG_QUEUE_FAILED; diff --git a/src/jtag/drivers/gw16012.c b/src/jtag/drivers/gw16012.c index d754bef..8418b97 100644 --- a/src/jtag/drivers/gw16012.c +++ b/src/jtag/drivers/gw16012.c @@ -289,9 +289,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; diff --git a/src/jtag/drivers/jlink.c b/src/jtag/drivers/jlink.c index c4e1bae..39c3f60 100644 --- a/src/jtag/drivers/jlink.c +++ b/src/jtag/drivers/jlink.c @@ -369,9 +369,9 @@ static void jlink_execute_command(struct jtag_command *cmd) } } -static int jlink_execute_queue(void) +static int jlink_execute_queue(struct jtag_command *cmd_queue) { - struct jtag_command *cmd = jtag_command_queue; + struct jtag_command *cmd = cmd_queue; while (cmd != NULL) { jlink_execute_command(cmd); diff --git a/src/jtag/drivers/opendous.c b/src/jtag/drivers/opendous.c index 4ba2215..6f07d8b 100644 --- a/src/jtag/drivers/opendous.c +++ b/src/jtag/drivers/opendous.c @@ -201,9 +201,9 @@ const struct adapter_driver opendous_driver = { .quit = opendous_quit, }; -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; diff --git a/src/jtag/drivers/osbdm.c b/src/jtag/drivers/osbdm.c index 3fa1b51..0a9ed85 100644 --- a/src/jtag/drivers/osbdm.c +++ b/src/jtag/drivers/osbdm.c @@ -640,7 +640,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; @@ -649,7 +649,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); diff --git a/src/jtag/drivers/rlink.c b/src/jtag/drivers/rlink.c index acdce0c..247d8ab 100644 --- a/src/jtag/drivers/rlink.c +++ b/src/jtag/drivers/rlink.c @@ -1264,9 +1264,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; diff --git a/src/jtag/drivers/ulink.c b/src/jtag/drivers/ulink.c index bdedb38..fc85d59 100644 --- a/src/jtag/drivers/ulink.c +++ b/src/jtag/drivers/ulink.c @@ -1938,9 +1938,9 @@ 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) { diff --git a/src/jtag/drivers/usbprog.c b/src/jtag/drivers/usbprog.c index a0e1786..954b806 100644 --- a/src/jtag/drivers/usbprog.c +++ b/src/jtag/drivers/usbprog.c @@ -101,9 +101,9 @@ static int usbprog_speed(int speed) return ERROR_OK; } -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; diff --git a/src/jtag/drivers/vsllink.c b/src/jtag/drivers/vsllink.c index 528fe80..3bfb4c3 100644 --- a/src/jtag/drivers/vsllink.c +++ b/src/jtag/drivers/vsllink.c @@ -90,9 +90,9 @@ static uint8_t *tdo_buffer; 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; diff --git a/src/jtag/interface.h b/src/jtag/interface.h index 541549f..99b9e3c 100644 --- a/src/jtag/interface.h +++ b/src/jtag/interface.h @@ -209,10 +209,11 @@ struct adapter_driver { const struct swd_driver *swd; /** - * 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); /** * Set the interface speed. diff --git a/src/jtag/stlink/stlink_interface.c b/src/jtag/stlink/stlink_interface.c index 1920020..c84b0ca 100644 --- a/src/jtag/stlink/stlink_interface.c +++ b/src/jtag/stlink/stlink_interface.c @@ -120,9 +120,10 @@ static int stlink_khz(int khz, int *jtag_speed) return ERROR_OK; } -static int stlink_interface_execute_queue(void) +static int stlink_interface_execute_queue(struct jtag_command *cmd_queue) { LOG_DEBUG("stlink_interface_execute_queue: ignored"); + (void) cmd_queue; return ERROR_OK; } -- |