aboutsummaryrefslogtreecommitdiff
path: root/src/target/adi_v5_jtag.c
diff options
context:
space:
mode:
authormike brown <theshed@mikebrown.org.uk>2013-03-18 17:19:14 +0000
committerSpencer Oliver <spen@spen-soft.co.uk>2013-04-02 15:09:40 +0000
commit2a8a89edcba49051315f59cea05834b5b704ee61 (patch)
tree872d1ce489227be454283bddf8da07ef49cef165 /src/target/adi_v5_jtag.c
parent0875e64ddb1cade43c7a56d8cc6e743364b65b58 (diff)
arm_adi_v5: fix mem_ap_read_buf_u32() JTAG nastiness..
Moved JTAG code out of transport-neutral file (arm_adi_v5.c) into transport specific file (adi_v5_jtag.c). Added ap_block_read to dap_ops interface (arm_adi_v5.h) to support the move. Change-Id: I796d3984f138aad052b97c77ac9c12ffd1158f74 Signed-off-by: mike brown <mike@theshedworks.org.uk> Reviewed-on: http://openocd.zylin.com/1277 Tested-by: jenkins Reviewed-by: Michel JAOUEN <michel.jaouen@stericsson.com> Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk>
Diffstat (limited to 'src/target/adi_v5_jtag.c')
-rw-r--r--src/target/adi_v5_jtag.c54
1 files changed, 43 insertions, 11 deletions
diff --git a/src/target/adi_v5_jtag.c b/src/target/adi_v5_jtag.c
index 9f37bd55..e500416b 100644
--- a/src/target/adi_v5_jtag.c
+++ b/src/target/adi_v5_jtag.c
@@ -75,10 +75,7 @@
* @param ack points to where the three bit JTAG_ACK_* code will be stored
*/
-/* FIXME don't export ... this is a temporary workaround for the
- * mem_ap_read_buf_u32() mess, until it's no longer JTAG-specific.
- */
-int adi_jtag_dp_scan(struct adiv5_dap *dap,
+static int adi_jtag_dp_scan(struct adiv5_dap *dap,
uint8_t instr, uint8_t reg_addr, uint8_t RnW,
uint8_t *outvalue, uint8_t *invalue, uint8_t *ack)
{
@@ -417,6 +414,40 @@ static int jtag_ap_q_write(struct adiv5_dap *dap, unsigned reg,
return adi_jtag_ap_write_check(dap, reg, out_value_buf);
}
+static int jtag_ap_q_read_block(struct adiv5_dap *dap, unsigned reg,
+ uint32_t blocksize, uint8_t *buffer)
+{
+ uint32_t readcount;
+ int retval = ERROR_OK;
+
+ /* Scan out first read */
+ retval = adi_jtag_dp_scan(dap, JTAG_DP_APACC, reg,
+ DPAP_READ, 0, NULL, NULL);
+ if (retval != ERROR_OK)
+ return retval;
+
+ for (readcount = 0; readcount < blocksize - 1; readcount++) {
+ /* Scan out next read; scan in posted value for the
+ * previous one. Assumes read is acked "OK/FAULT",
+ * and CTRL_STAT says that meant "OK".
+ */
+ retval = adi_jtag_dp_scan(dap, JTAG_DP_APACC, reg,
+ DPAP_READ, 0, buffer + 4 * readcount,
+ &dap->ack);
+ if (retval != ERROR_OK)
+ return retval;
+ }
+
+ /* Scan in last posted value; RDBUFF has no other effect,
+ * assuming ack is OK/FAULT and CTRL_STAT says "OK".
+ */
+ retval = adi_jtag_dp_scan(dap, JTAG_DP_DPACC, DP_RDBUFF,
+ DPAP_READ, 0, buffer + 4 * readcount,
+ &dap->ack);
+
+ return retval;
+}
+
static int jtag_ap_q_abort(struct adiv5_dap *dap, uint8_t *ack)
{
/* for JTAG, this is the only valid ABORT register operation */
@@ -433,13 +464,14 @@ static int jtag_dp_run(struct adiv5_dap *dap)
* part of DAP setup
*/
const struct dap_ops jtag_dp_ops = {
- .queue_idcode_read = jtag_idcode_q_read,
- .queue_dp_read = jtag_dp_q_read,
- .queue_dp_write = jtag_dp_q_write,
- .queue_ap_read = jtag_ap_q_read,
- .queue_ap_write = jtag_ap_q_write,
- .queue_ap_abort = jtag_ap_q_abort,
- .run = jtag_dp_run,
+ .queue_idcode_read = jtag_idcode_q_read,
+ .queue_dp_read = jtag_dp_q_read,
+ .queue_dp_write = jtag_dp_q_write,
+ .queue_ap_read = jtag_ap_q_read,
+ .queue_ap_write = jtag_ap_q_write,
+ .queue_ap_read_block = jtag_ap_q_read_block,
+ .queue_ap_abort = jtag_ap_q_abort,
+ .run = jtag_dp_run,
};