]> git.sur5r.net Git - openocd/commitdiff
jtag: add jtag_flush_queue_sleep debug command
authorØyvind Harboe <oyvind.harboe@zylin.com>
Sat, 31 Jul 2010 19:45:56 +0000 (21:45 +0200)
committerØyvind Harboe <oyvind.harboe@zylin.com>
Mon, 2 Aug 2010 07:54:06 +0000 (09:54 +0200)
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>
src/jtag/core.c
src/jtag/jtag.h
src/jtag/tcl.c

index 352985ff3f790d115b3028100d424ddc720ba640..1068681964ee379a858078f434c31174cd4f1f82 100644 (file)
@@ -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)
index 3b0a145bb47af4413284824c01b35ad94f2d52bf..d6e49e0ac237a035307beff7b35033b347cb1849 100644 (file)
@@ -311,6 +311,10 @@ int  adapter_init(struct command_context* cmd_ctx);
 /// Shutdown the debug adapter upon program exit.
 int  adapter_quit(void);
 
+/// Set ms to sleep after jtag_execute_queue() flushes queue. Debug
+/// purposes.
+void jtag_set_flush_queue_sleep(int ms);
+
 /**
  * Initialize JTAG chain using only a RESET reset. If init fails,
  * try reset + init.
index ea6d07e341a34bf8a1eb6de45b8fc5416bed320b..69045c6001aaca6078575fd5be965ceaad7ec892 100644 (file)
@@ -1248,7 +1248,31 @@ COMMAND_HANDLER(handle_tms_sequence_command)
        return ERROR_OK;
 }
 
+COMMAND_HANDLER(handle_jtag_flush_queue_sleep)
+{
+       if (CMD_ARGC != 1)
+               return ERROR_COMMAND_SYNTAX_ERROR;
+
+       int sleep_ms;
+       COMMAND_PARSE_NUMBER(int, CMD_ARGV[0], sleep_ms);
+
+       jtag_set_flush_queue_sleep(sleep_ms);
+
+       return ERROR_OK;
+}
+
+
+
 static const struct command_registration jtag_command_handlers[] = {
+
+       {
+               .name = "jtag_flush_queue_sleep",
+               .handler = handle_jtag_flush_queue_sleep,
+               .mode = COMMAND_ANY,
+               .help = "For debug purposes(simulate long delays of interface) "
+                               "to test performance or change in behavior. Default 0ms.",
+               .usage = "[sleep in ms]",
+       },
        {
                .name = "jtag_rclk",
                .handler = handle_jtag_rclk_command,