aboutsummaryrefslogtreecommitdiff
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
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>
-rw-r--r--src/target/adi_v5_jtag.c54
-rw-r--r--src/target/arm_adi_v5.c40
-rw-r--r--src/target/arm_adi_v5.h21
3 files changed, 65 insertions, 50 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,
};
diff --git a/src/target/arm_adi_v5.c b/src/target/arm_adi_v5.c
index 1572861d..28f4318c 100644
--- a/src/target/arm_adi_v5.c
+++ b/src/target/arm_adi_v5.c
@@ -539,13 +539,6 @@ int mem_ap_write_buf_u8(struct adiv5_dap *dap, const uint8_t *buffer, int count,
return retval;
}
-/* FIXME don't import ... this is a temporary workaround for the
- * mem_ap_read_buf_u32() mess, until it's no longer JTAG-specific.
- */
-extern 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);
-
/**
* Synchronously read a block of 32-bit words into a buffer
* @param dap The DAP connected to the MEM-AP.
@@ -588,38 +581,7 @@ int mem_ap_read_buf_u32(struct adiv5_dap *dap, uint8_t *buffer,
if (retval != ERROR_OK)
return retval;
- /* FIXME remove these three calls to adi_jtag_dp_scan(),
- * so this routine becomes transport-neutral. Be careful
- * not to cause performance problems with JTAG; would it
- * suffice to loop over dap_queue_ap_read(), or would that
- * be slower when JTAG is the chosen transport?
- */
-
- /* Scan out first read */
- retval = adi_jtag_dp_scan(dap, JTAG_DP_APACC, AP_REG_DRW,
- 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, AP_REG_DRW,
- 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);
- if (retval != ERROR_OK)
- return retval;
+ retval = dap_queue_ap_read_block(dap, AP_REG_DRW, blocksize, buffer);
retval = dap_run(dap);
if (retval != ERROR_OK) {
diff --git a/src/target/arm_adi_v5.h b/src/target/arm_adi_v5.h
index 7f1ebf5e..301402ec 100644
--- a/src/target/arm_adi_v5.h
+++ b/src/target/arm_adi_v5.h
@@ -216,6 +216,9 @@ struct dap_ops {
/** AP register write. */
int (*queue_ap_write)(struct adiv5_dap *dap, unsigned reg,
uint32_t data);
+ /** AP read block. */
+ int (*queue_ap_read_block)(struct adiv5_dap *dap, unsigned reg,
+ uint32_t blocksize, uint8_t *buffer);
/** AP operation abort. */
int (*queue_ap_abort)(struct adiv5_dap *dap, uint8_t *ack);
@@ -322,6 +325,24 @@ static inline int dap_queue_ap_write(struct adiv5_dap *dap,
}
/**
+ * Queue an AP block read.
+ *
+ * @param dap The DAP used for reading.
+ * @param reg The number of the AP register being read.
+ * @param blocksize The number of the AP register being read.
+ * @param buffer Pointer saying where to store the data
+ * (in host endianness).
+ *
+ * @return ERROR_OK for success, else a fault code.
+ */
+static inline int dap_queue_ap_read_block(struct adiv5_dap *dap,
+ unsigned reg, unsigned blocksize, uint8_t *buffer)
+{
+ assert(dap->ops != NULL);
+ return dap->ops->queue_ap_read_block(dap, reg, blocksize, buffer);
+}
+
+/**
* Queue an AP abort operation. The current AP transaction is aborted,
* including any update of the transaction counter. The AP is left in
* an unknown state (so it must be re-initialized). For use only after