/* JTAG low level functions and base class for cables Copyright (C) 2004 Andrew Rogers This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "iobase.h" #include using namespace std; IOBase::IOBase() { current_state=UNKNOWN; } int IOBase::shiftTDITDO(const unsigned char *tdi, unsigned char *tdo, int length, bool last) { if(length==0)return 0; int i=0; int j=0; unsigned char tdo_byte=0; unsigned char tdi_byte=tdi[j]; while(i>1; i++; if((i%8)==0){ // Next byte tdo[j]=tdo_byte; // Save the TDO byte tdo_byte=0; j++; tdi_byte=tdi[j]; // Get the next TDI byte } }; tdo_byte=tdo_byte+(txrx(last, (tdi_byte&1)==1)<<(i%8)); // TMS set if last=true tdo[j]=tdo_byte; nextTapState(last); // If TMS is set the the state of the tap changes } int IOBase::shiftTDI(const unsigned char *tdi, int length, bool last) { if(length==0)return 0; int i=0; int j=0; unsigned char tdi_byte=tdi[j]; while(i>1; i++; if((i%8)==0){ // Next byte j++; tdi_byte=tdi[j]; //Get the next TDI byte } }; tx(last, (tdi_byte&1)==1); // TMS set if last=true nextTapState(last); // If TMS is set the the state of the tap changes } // TDI gets a load of zeros, we just record TDO. int IOBase::shiftTDO(unsigned char *tdo, int length, bool last) { if(length==0)return 0; int i=0; int j=0; unsigned char tdo_byte=0; while(i