summaryrefslogtreecommitdiff
path: root/src/jtag/core.c
diff options
context:
space:
mode:
authorØyvind Harboe <oyvind.harboe@zylin.com>2010-07-31 21:45:56 +0200
committerØyvind Harboe <oyvind.harboe@zylin.com>2010-08-02 09:54:06 +0200
commit803351ec59cb57c63129c77d95b5edf2fc65c302 (patch)
tree35ea721d89a115af2e6e17ec3ad5a621ba3b1669 /src/jtag/core.c
parent630fc86ee339aa400f58fe80cbc5a1926eb3ef39 (diff)
downloadopenocd_libswd-803351ec59cb57c63129c77d95b5edf2fc65c302.tar.gz
openocd_libswd-803351ec59cb57c63129c77d95b5edf2fc65c302.tar.bz2
openocd_libswd-803351ec59cb57c63129c77d95b5edf2fc65c302.tar.xz
openocd_libswd-803351ec59cb57c63129c77d95b5edf2fc65c302.zip
jtag: add jtag_flush_queue_sleep debug command
it can be useful to throttle performance: test differences in behavior, test performance effect of long roundtrips. Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
Diffstat (limited to 'src/jtag/core.c')
-rw-r--r--src/jtag/core.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/jtag/core.c b/src/jtag/core.c
index 352985ff..10686819 100644
--- a/src/jtag/core.c
+++ b/src/jtag/core.c
@@ -46,6 +46,9 @@
/// The number of JTAG queue flushes (for profiling and debugging purposes).
static int jtag_flush_queue_count;
+// Sleep this # of ms after flushing the queue
+static int jtag_flush_queue_sleep = 0;
+
static void jtag_add_scan_check(struct jtag_tap *active,
void (*jtag_add_scan)(struct jtag_tap *active, int in_num_fields, const struct scan_field *in_fields, tap_state_t state),
int in_num_fields, struct scan_field *in_fields, tap_state_t state);
@@ -129,6 +132,11 @@ static struct jtag_interface *jtag = NULL;
/* configuration */
struct jtag_interface *jtag_interface = NULL;
+void jtag_set_flush_queue_sleep(int ms)
+{
+ jtag_flush_queue_sleep = ms;
+}
+
void jtag_set_error(int error)
{
if ((error == ERROR_OK) || (jtag_error != ERROR_OK))
@@ -826,6 +834,15 @@ void jtag_execute_queue_noclear(void)
{
jtag_flush_queue_count++;
jtag_set_error(interface_jtag_execute_queue());
+
+ if (jtag_flush_queue_sleep > 0)
+ {
+ /* For debug purposes it can be useful to test performance
+ * or behavior when delaying after flushing the queue,
+ * e.g. to simulate long roundtrip times.
+ */
+ usleep(jtag_flush_queue_sleep * 1000);
+ }
}
int jtag_get_flush_queue_count(void)