adiv5: introduce optional dap_sync() function
authorMatthias Welwarsky <matthias@welwarsky.de>
Mon, 28 Dec 2015 21:33:51 +0000 (22:33 +0100)
committerPaul Fertser <fercerpav@gmail.com>
Fri, 22 Jan 2016 13:00:27 +0000 (13:00 +0000)
dap_sync() executes all commands in the JTAG queue and then checks
if a WAIT condition happened inside the last batch. If yes, a recovery
is invoked. If not, processing continues without checking for
errors. This function should be called in long AP read or writes, e.g.
while uploading a new application binary, at intermediate points within
the transfer where the cost of flushing the JTAG queue and checking the
journal doesn't affect performance too much.

Change-Id: I99eeaf47cdf951e15e589a04e74b90b5ce911386
Signed-off-by: Matthias Welwarsky <matthias@welwarsky.de>
Reviewed-on: http://openocd.zylin.com/3181
Tested-by: jenkins
Reviewed-by: Paul Fertser <fercerpav@gmail.com>
src/target/adi_v5_jtag.c
src/target/arm_adi_v5.h

index ff1680b0da883110444f1248b56ea25f4c1a9a03..201ed90aad336a13929d9039466c8e516bfc8fd0 100644 (file)
@@ -679,6 +679,11 @@ static int jtag_dp_run(struct adiv5_dap *dap)
        return (retval2 != ERROR_OK) ? retval2 : retval;
 }
 
+static int jtag_dp_sync(struct adiv5_dap *dap)
+{
+       return jtagdp_overrun_check(dap);
+}
+
 /* FIXME don't export ... just initialize as
  * part of DAP setup
 */
@@ -689,6 +694,7 @@ const struct dap_ops jtag_dp_ops = {
        .queue_ap_write      = jtag_ap_q_write,
        .queue_ap_abort      = jtag_ap_q_abort,
        .run                 = jtag_dp_run,
+       .sync                = jtag_dp_sync,
 };
 
 
index 44d3962cd3660cc7ccd4801139a2f42bbece5f84..f001d6a2634d1b328d3e289ded785dd6f7394186 100644 (file)
@@ -274,6 +274,10 @@ struct dap_ops {
 
        /** Executes all queued DAP operations. */
        int (*run)(struct adiv5_dap *dap);
+
+       /** Executes all queued DAP operations but doesn't check
+        * sticky error conditions */
+       int (*sync)(struct adiv5_dap *dap);
 };
 
 /*
@@ -397,6 +401,14 @@ static inline int dap_run(struct adiv5_dap *dap)
        return dap->ops->run(dap);
 }
 
+static inline int dap_sync(struct adiv5_dap *dap)
+{
+       assert(dap->ops != NULL);
+       if (dap->ops->sync)
+               return dap->ops->sync(dap);
+       return ERROR_OK;
+}
+
 static inline int dap_dp_read_atomic(struct adiv5_dap *dap, unsigned reg,
                                     uint32_t *value)
 {