1 /* JTAG low level functions and base class for cables 2 3 Copyright (C) 2004 Andrew Rogers 4 5 This program is free software; you can redistribute it and/or modify 6 it under the terms of the GNU General Public License as published by 7 the Free Software Foundation; either version 2 of the License, or 8 (at your option) any later version. 9 10 This program is distributed in the hope that it will be useful, 11 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 GNU General Public License for more details. 14 15 You should have received a copy of the GNU General Public License 16 along with this program; if not, write to the Free Software 17 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 19 Changes: 20 Dmitry Teytelman [dimtey@gmail.com] 14 Jun 2006 [applied 13 Aug 2006]: 21 Code cleanup for clean -Wall compile. 22 Extensive changes to support FT2232 driver. 23 */ 24 25 #ifndef IOBASE_H 26 #define IOBASE_H 27 28 #define BLOCK_SIZE 65536 29 #define CHUNK_SIZE 128 30 #define TICK_COUNT 2048 31 32 class IOBase 33 { 34 public: 35 enum tapState_t{ 36 TEST_LOGIC_RESET=0, 37 RUN_TEST_IDLE=1, 38 SELECT_DR_SCAN=2, 39 CAPTURE_DR=3, 40 SHIFT_DR=4, 41 EXIT1_DR=5, 42 PAUSE_DR=6, 43 EXIT2_DR=7, 44 UPDATE_DR=8, 45 SELECT_IR_SCAN=9, 46 CAPTURE_IR=10, 47 SHIFT_IR=11, 48 EXIT1_IR=12, 49 PAUSE_IR=13, 50 EXIT2_IR=14, 51 UPDATE_IR=15, 52 UNKNOWN=999 53 }; 54 55 protected: 56 bool verbose; 57 tapState_t current_state; 58 unsigned char ones[CHUNK_SIZE], zeros[CHUNK_SIZE]; 59 unsigned char tms_buf[CHUNK_SIZE]; 60 unsigned int tms_len; /* in Bits*/ 61 62 protected: 63 IOBase(); 64 public: ~IOBase()65 virtual ~IOBase() {} 66 67 public: flush()68 virtual void flush() {} 69 70 public: setVerbose(bool v)71 void setVerbose(bool v) { verbose = v; } getVerbose(void)72 bool getVerbose(void) { return verbose; } 73 74 public: 75 void shiftTDITDO(const unsigned char *tdi, unsigned char *tdo, int length, bool last=true); 76 void shiftTDI(const unsigned char *tdi, int length, bool last=true); 77 void shiftTDO(unsigned char *tdo, int length, bool last=true); 78 void shift(bool tdi, int length, bool last=true); 79 80 public: 81 void setTapState(tapState_t state, int pre=0); 82 void tapTestLogicReset(); 83 void cycleTCK(int n, bool tdi=1); 84 void flush_tms(void); 85 86 protected: 87 virtual void txrx_block(const unsigned char *tdi, unsigned char *tdo, int length, bool last)=0; 88 virtual void tx_tms(unsigned char *pat, int length)=0; settype(int subtype)89 virtual void settype(int subtype) {} 90 91 private: 92 void nextTapState(bool tms); 93 }; 94 #endif // IOBASE_H 95