From 617583d07236b4b34e5b5105d99e0f40bf2bbb4f Mon Sep 17 00:00:00 2001 From: michael Date: Tue, 1 May 2007 10:21:51 +0000 Subject: [PATCH] some microoptimazation --- jtagkey.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/jtagkey.c b/jtagkey.c index 129cfe1..fc762d3 100644 --- a/jtagkey.c +++ b/jtagkey.c @@ -161,6 +161,7 @@ static void *jtagkey_reader(void *thread_arg) { pthread_exit(NULL); } +/* TODO: Interpret JTAG commands and transfer in MPSSE mode */ int jtagkey_transfer(WD_TRANSFER *tr, int fd, unsigned int request, int ppbase, int ecpbase, int num) { int ret = 0; int i; @@ -171,7 +172,7 @@ int jtagkey_transfer(WD_TRANSFER *tr, int fd, unsigned int request, int ppbase, static unsigned char last_write = 0x00; static unsigned char writebuf[USBBUFSIZE], *writepos = writebuf; static unsigned char readbuf[USBBUFSIZE], *readpos; - unsigned char data, prev_data; + unsigned char data, prev_data, last_cyc_write; struct jtagkey_reader_arg targ; pthread_t reader_thread; @@ -212,6 +213,8 @@ int jtagkey_transfer(WD_TRANSFER *tr, int fd, unsigned int request, int ppbase, writepos = writebuf; } + last_cyc_write = last_write; + for (i = 0; i < num; i++) { DPRINTF("dwPort: 0x%lx, cmdTrans: %lu, dwbytes: %ld, fautoinc: %ld, dwoptions: %ld\n", (unsigned long)tr[i].dwPort, tr[i].cmdTrans, tr[i].dwBytes, @@ -283,7 +286,7 @@ int jtagkey_transfer(WD_TRANSFER *tr, int fd, unsigned int request, int ppbase, } } - if (nread || (*writepos != prev_data) || (i == num-1)) + if ((tr[i].cmdTrans == PP_READ) || (*writepos != prev_data) || (i == num-1)) writepos++; } @@ -316,6 +319,7 @@ int jtagkey_transfer(WD_TRANSFER *tr, int fd, unsigned int request, int ppbase, } readpos = readbuf; + last_write = last_cyc_write; for (i = 0; i < num; i++) { DPRINTF("dwPort: 0x%lx, cmdTrans: %lu, dwbytes: %ld, fautoinc: %ld, dwoptions: %ld\n", @@ -324,6 +328,10 @@ int jtagkey_transfer(WD_TRANSFER *tr, int fd, unsigned int request, int ppbase, port = (unsigned long)tr[i].dwPort; val = tr[i].Data.Byte; + + if ((tr[i].cmdTrans != PP_READ) && (val == last_write) && (i != num-1)) + continue; + readpos++; if (port == ppbase + PP_DATA) { @@ -345,7 +353,7 @@ int jtagkey_transfer(WD_TRANSFER *tr, int fd, unsigned int request, int ppbase, if ((data & JTAGKEY_TDO) && (last_write & PP_PROG)) val |= PP_TDO; - if (!(last_write & PP_PROG)) + if (~last_write & PP_PROG) val |= 0x08; if (last_write & 0x40) -- 2.39.5