Permalink
Browse files

Removed commented-out CSVF-player stuff

  • Loading branch information...
makestuff
makestuff committed Mar 19, 2013
1 parent b54c60f commit ab71623d06960cbb24c4fe77e3abdfce0b21525d
Showing with 0 additions and 285 deletions.
  1. +0 −285 firmware/fx2/jtag.c
View
@@ -523,288 +523,3 @@ void jtagClocks(uint32 numClocks) {
cjne r5, #255, jcLoop
_endasm;
}
-
-////////////////////////////////////////////////////////////////////////////////////////////////////
-// CSVF Player Stuff
-////////////////////////////////////////////////////////////////////////////////////////////////////
-/*
-// XSVF commands (from xapp503 appendix B)
-typedef enum {
- XCOMPLETE = 0x00,
- XTDOMASK = 0x01,
- XSIR = 0x02,
- XSDR = 0x03,
- XRUNTEST = 0x04,
- XREPEAT = 0x07,
- XSDRSIZE = 0x08,
- XSDRTDO = 0x09,
- XSETSDRMASKS = 0x0A,
- XSDRINC = 0x0B,
- XSDRB = 0x0C,
- XSDRC = 0x0D,
- XSDRE = 0x0E,
- XSDRTDOB = 0x0F,
- XSDRTDOC = 0x10,
- XSDRTDOE = 0x11,
- XSTATE = 0x12,
- XENDIR = 0x13,
- XENDDR = 0x14,
- XSIR2 = 0x15,
- XCOMMENT = 0x16,
- XWAIT = 0x17,
-} Command;
-
-// TAP states (from xapp503 appendix B)
-typedef enum {
- TAPSTATE_TEST_LOGIC_RESET = 0x00,
- TAPSTATE_RUN_TEST_IDLE = 0x01,
- TAPSTATE_SELECT_DR = 0x02,
- TAPSTATE_CAPTURE_DR = 0x03,
- TAPSTATE_SHIFT_DR = 0x04,
- TAPSTATE_EXIT1_DR = 0x05,
- TAPSTATE_PAUSE_DR = 0x06,
- TAPSTATE_EXIT2_DR = 0x07,
- TAPSTATE_UPDATE_DR = 0x08,
- TAPSTATE_SELECT_IR = 0x09,
- TAPSTATE_CAPTURE_IR = 0x0A,
- TAPSTATE_SHIFT_IR = 0x0B,
- TAPSTATE_EXIT1_IR = 0x0C,
- TAPSTATE_PAUSE_IR = 0x0D,
- TAPSTATE_EXIT2_IR = 0x0E,
- TAPSTATE_UPDATE_IR = 0x0F
-} TAPState;
-
-// "Member" variables to store the state of the compression algorithm.
-static bool m_isReadingChunk;
-static xdata uint32 m_count;
-
-// Read the length (of the chunk or the zero run). A short block (<256 bytes) length is encoded in a
-// single byte. If that single byte is zero, we know it's a medium block (256-65535 bytes), so read
-// in the next two bytes as a big-endian uint16. If that is zero, we know it's a long block (65536-
-// 4294967295 bytes), so read in the next four bytes as a big-endian uint32.
-//
-static uint32 readLength(void) {
- xdata uint32 len = promPeekByte();
- promNextByte();
- if ( !len ) {
- len = promPeekByte();
- promNextByte();
- len <<= 8;
- len |= promPeekByte();
- promNextByte();
- }
- if ( !len ) {
- len = promPeekByte();
- promNextByte();
- len <<= 8;
- len |= promPeekByte();
- promNextByte();
- len <<= 8;
- len |= promPeekByte();
- promNextByte();
- len <<= 8;
- len |= promPeekByte();
- promNextByte();
- }
- return len;
-}
-
-// Get the next byte from the uncompressed stream. Uses m_count & m_isReadingChunk to keep state.
-//
-static uint8 getNextByte(void) {
- if ( m_isReadingChunk ) {
- // We're in the middle of reading a chunk.
- if ( m_count ) {
- // There are still some bytes to copy verbatim into the uncompressed stream.
- xdata uint8 thisByte;
- m_count--;
- thisByte = promPeekByte();
- promNextByte();
- return thisByte;
- } else {
- // We're at the end of this chunk; there will now be some zeros to insert into the
- // uncompressed stream.
- m_count = readLength();
- m_isReadingChunk = false;
- return getNextByte();
- }
- } else {
- // We're in the middle of a run of zeros.
- if ( m_count ) {
- // There are still some zero bytes to write to the uncompressed stream.
- m_count--;
- return 0x00;
- } else {
- // We're at the end of this run of zeros; there will now be a chunk of data to be copied
- // verbatim over to the uncompressed stream.
- m_count = readLength();
- m_isReadingChunk = true;
- return getNextByte();
- }
- }
-}
-
-// Initialise the CSVF reader
-//
-void jtagCsvfInit(void) {
- promNextByte(); // Skip header byte
- m_count = readLength();
- m_isReadingChunk = true;
-}
-
-// Get big-endian uint16 from the stream
-//
-static uint16 getWord(void) {
- xdata uint16 value;
- value = getNextByte();
- value <<= 8;
- value |= getNextByte();
- return value;
-}
-
-// Get big-endian uint32 from the stream
-//
-static uint32 getLong(void) {
- xdata uint32 value;
- value = getNextByte();
- value <<= 8;
- value |= getNextByte();
- value <<= 8;
- value |= getNextByte();
- value <<= 8;
- value |= getNextByte();
- return value;
-}
-
-// Shift out "numBits" bits from the CSVF stream. If "isLast", exit Shift-DR on the final bit.
-//
-static void shiftOutCsvf(uint32 numBits, bool isLast) {
- xdata uint32 bitsRemaining = (numBits-1) & 0xFFFFFFF8; // Now an integer number of bytes
- xdata uint8 leftOver = (uint8)(numBits - bitsRemaining); // How many bits in last byte (1-8)
- xdata uint32 bytesRemaining = (bitsRemaining>>3);
- xdata uint8 tdiByte, i;
- while ( bytesRemaining-- ) {
- shiftOut(getNextByte());
- }
- tdiByte = getNextByte(); // Now do the bits in the final byte
- i = 1;
- while ( i && leftOver ) {
- leftOver--;
- if ( isLast && !leftOver ) {
- TMS = 1; // Exit Shift-DR state on next clock
- }
- TDI = tdiByte & 1;
- tdiByte >>= 1;
- TCK = 1;
- TCK = 0;
- i <<= 1;
- }
-}
-
-// Play the uncompressed CSVF stream into the JTAG port.
-//
-uint8 jtagCsvfPlay(void) {
- xdata uint8 returnCode = 0;
- xdata uint8 thisByte;
- xdata uint32 numBytes;
- xdata uint8 *ptr;
- xdata uint8 i;
- xdata uint32 xsdrSize = 0;
- xdata uint16 xruntest = 0;
- xdata uint8 tdoMask[CSVF_BUF_SIZE];
- jtagClockFSM(0x0000001F, 6); // Go to Run-Test/Idle
- thisByte = getNextByte();
- while ( thisByte != XCOMPLETE ) {
- switch ( thisByte ) {
- case XTDOMASK:
- numBytes = bitsToBytes(xsdrSize);
- ptr = tdoMask;
- while ( numBytes-- ) {
- *ptr++ = getNextByte();
- }
- break;
-
- case XRUNTEST:
- getNextByte(); // Ignore the MSW (realistically will it ever be nonzero?)
- getNextByte();
- xruntest = getWord();
- break;
-
- case XSIR:
- jtagClockFSM(0x00000003, 4);
- shiftOutCsvf(getNextByte(), true);
- jtagClockFSM(0x00000001, 2);
- if ( xruntest ) {
- jtagClocks(xruntest);
- }
- break;
-
- case XSDRSIZE:
- xsdrSize = getLong();
- break;
-
- case XSDRTDO: {
- xdata uint32 bitsRemaining = (xsdrSize-1) & 0xFFFFFFF8; // Now an int number of bytes
- xdata uint8 leftOver = (uint8)(xsdrSize - bitsRemaining); // No bits in last byte (1-8)
- xdata uint8 tdoByte, tdiByte, expectedByte, i, lastIndex;
- jtagClockFSM(0x00000001, 3);
- numBytes = (bitsRemaining>>3);
- i = 0;
- while ( numBytes-- ) {
- tdoByte = shiftInOut(getNextByte());
- expectedByte = getNextByte();
- if ( (tdoByte & tdoMask[i]) != (expectedByte & tdoMask[i]) ) {
- returnCode = ERROR_CSVF_FAILED_COMPARE;
- goto cleanup;
- }
- i++;
- }
- lastIndex = i;
- tdiByte = getNextByte(); // Now do the bits in the final byte
- expectedByte = getNextByte();
- tdoByte = 0x00;
- i = 1;
- while ( i && leftOver ) {
- leftOver--;
- if ( !leftOver ) {
- TMS = 1; // Exit Shift-DR state on next clock
- }
- TDI = tdiByte & 1;
- tdiByte >>= 1;
- if ( TDO ) {
- tdoByte |= i;
- }
- TCK = 1;
- TCK = 0;
- i <<= 1;
- }
- if ( (tdoByte & tdoMask[lastIndex]) != (expectedByte & tdoMask[lastIndex]) ) {
- returnCode = ERROR_CSVF_FAILED_COMPARE;
- goto cleanup;
- }
- jtagClockFSM(0x00000001, 2);
- if ( xruntest ) {
- jtagClocks(xruntest);
- }
- break;
- }
-
- case XSDR:
- jtagClockFSM(0x00000001, 3);
- shiftOutCsvf(xsdrSize, true);
- jtagClockFSM(0x00000001, 2);
- if ( xruntest ) {
- jtagClocks(xruntest);
- }
- break;
-
- default:
- returnCode = ERROR_CSVF_BAD_COMMAND;
- goto cleanup;
- }
- thisByte = getNextByte();
- }
-cleanup:
- return returnCode;
-}
-*/

0 comments on commit ab71623

Please sign in to comment.