ejtag.h

Go to the documentation of this file.
00001 #ifndef _LINUX_EJTAG_H
00002 #define _LINUX_EJTAG_H
00003 
00004 /*
00005  *   ejtag.h
00006  *
00007  *   ejtag primitives
00008  *
00009  *   Copyright 2000 padraigo <padraigo@yahoo.com>
00010  */
00011 
00012 #define DEV_VERSION (0x24<<16 | 0x00)
00013 
00014 #define EJTAGBUFSIZE (1024*4) /* 4kbytes */
00015 
00016 typedef enum {
00017   Start, 
00018   Type,
00019   Count,
00020   Addr,
00021   Data,
00022   ChkSum
00023 } ejtag_srec_state ;
00024 
00025 typedef struct ejtag_bufm_s {
00026   ejtag_srec_state state ;
00027   int wptr, rptr ;
00028   int left ;
00029   int eob ;
00030   long int bytes ;
00031   int srecCount, srecAddr, srecData ;
00032   char srecType ;
00033   struct wait_queue *wait_q;
00034   char buf[EJTAGBUFSIZE];
00035 } ejtag_bufm_t ;
00036 
00037 struct ejtag_struct {
00038   unsigned long flags;
00039   unsigned int time;
00040   unsigned int wait;
00041   unsigned int debug ;
00042   ejtag_bufm_t *bufout;
00043   ejtag_bufm_t *bufin;
00044   unsigned int *ejtag_probe_mem ; /* must be 4Kbytes */
00045   unsigned int instr ;
00046   unsigned int ctrl ;
00047   unsigned int last_error;
00048   volatile unsigned int irq_detected:1;
00049   volatile unsigned int irq_missed:1;
00050 };
00051 
00052 /*------------------------------------------------------------------------*/
00053 /*  EJTAG IOCTL COMMANDS                                                  */
00054 /*------------------------------------------------------------------------*/
00055 #define EJTAG_TAPRESET       0x0000
00056 #define EJTAG_INIT           0x0001
00057 #define EJTAG_TAPMOVE        0x0002
00058 #define EJTAG_DATA           0x1000
00059 #define EJTAG_INSTR          0x1001
00060 #define EJTAG_IMPLEMENTATION 0x1002
00061 #define EJTAG_VERSION        0x1003
00062 #define EJTAG_CTRL_REG       0x1100
00063 #define EJTAG_ADDR_REG       0x1101
00064 #define EJTAG_DATA_REG       0x1102
00065 #define EJTAG_WRITE_WORD     0x2000
00066 #define EJTAG_READ_WORD      0x2001
00067 #define EJTAG_WRITE_HWORD    0x2010
00068 #define EJTAG_READ_HWORD     0x2011
00069 #define EJTAG_WRITE_BYTE     0x2020
00070 #define EJTAG_READ_BYTE      0x2021
00071 #define EJTAG_CHECKSTATUS    0x3000
00072 #define EJTAG_PORTWRITE      0x3001
00073 #define EJTAG_PORTREAD       0x3002
00074 #define EJTAG_BIGENDIAN      0x3003
00075 #define EJTAG_WRITE_DATAP    0x4000
00076 #define EJTAG_WRITE_CTRLP    0x4001
00077 #define EJTAG_READ_STATP     0x4002
00078 
00079 #define EJTAG_F(minor)  ejtag_table[(minor)].flags              /* flags for busy, etc. */
00080 #define EJTAG_TIME(minor)       ejtag_table[(minor)].time               /* wait time */
00081 #define EJTAG_WAIT(minor)       ejtag_table[(minor)].wait               /* strobe wait */
00082 #define EJTAG_IRQ(minor)        ejtag_table[(minor)].dev->port->irq /* interrupt # */
00083 
00084 #define EJTAG_BUFFER_SIZE 256
00085 #define EJTAG_INIT_CHAR 1000
00086 #define EJTAG_INIT_WAIT 1
00087 #define EJTAG_INIT_TIME 2
00088 #define EJTAG_INIT_DEBUG 0
00089 #define EJTAG_WAIT(minor)       ejtag_table[(minor)].wait               /* strobe wait */
00090 
00091 /* flag definitions */
00092 #define EJTAG_EXIST 0x0001 /* ejtag exists for this minor */
00093 #define EJTAG_BIGEND 0x0002 /* ejtag is bigendian for this minor */
00094 //#define EJTAG_LITTLEEND 0x0008 /* ejtag is littleendian for this minor */
00095 
00096 /* Magic numbers for defining port-device mappings */
00097 #define EJTAG_PARPORT_UNSPEC -4
00098 #define EJTAG_PARPORT_AUTO -3
00099 #define EJTAG_PARPORT_OFF -2
00100 #define EJTAG_PARPORT_NONE -1
00101 #define EJTAG_BUSY       0x0004
00102 #define EJTAG_BUSY_BIT_POS 2
00103 #define PROBE_MEM_SIZE 0x1000
00104 
00105 /*------------------------------------------------------------------------*/
00106 /*  TARGET JTAG INSTRUCTIONS                                              */
00107 /*------------------------------------------------------------------------*/
00108 #define EXTEST          0x00    //TAP select boundaryscan register
00109 #define IDCODE          0x01    //TAP select chip ID register
00110 #define SAMPLE_PRELOAD  0x02    //TAP select boundaryscan register
00111 #define IMPCODE         0x03    //TAP select chip implementation code
00112 #define HI_Z            0x05    //TAP Tristate outputs disabled
00113 #define BYPASS          0x07    //TAP Bypass mode (no registers in chain)
00114 #define JTAG_ADDRESS_IR 0x08    //JTAG address register (DMA)
00115 #define JTAG_DATA_IR    0x09    //JTAG data register (DMA)
00116 #define JTAG_CONTROL_IR 0x0A    //JTAG control register (DMA/DSU)
00117 #define JTAG_ALL_IR     0x0B    //JTAG all IR regs. linked together
00118 #define JTAG_BOOT       0x0C    //JTAG BOOT
00119 #define PCTRACE         0x10    //JTAG PC-trace enabled
00120 #define MACRO           0x1E    //JTAG macro (???)
00121 
00122 /*------------------------------------------------------------------------*/
00123 /*  TARGET CONTROLREGISTER BITS                                           */
00124 /*------------------------------------------------------------------------*/
00125 #define CLKEN           0x00000001  //DCLK enabled
00126 #define TOF             0x00000002  //TOF semaphore
00127 #define TIF             0x00000004  //TIF semaphore
00128 #define BRKST           0x00000008  //Break status
00129 #define DINC            0x00000010  //Auto DMA address increment
00130 #define DLOCK           0x00000020  //DMA lock
00131 #define JTS_BYTE        0x00000000  //DMA tranfser size BYTE
00132 #define JTS_HALFWORD    0x00000080  //DMA transfer size HALFWORD
00133 #define JTS_WORD        0x00000100  //DMA transfer size WORD
00134 #define JTS_TRIPLEBYTE  0x00000180  //DMA transfer size TRIPLEBYTE
00135 #define DRWN            0x00000200  //DMA Read, Write NOT
00136 #define DERR            0x00000400  //PI-Bus error
00137 #define DSTRT           0x00000800  //DMA start/busy
00138 #define JTAGBRK         0x00001000  //Initiated a JTAG break -> Debugex.
00139 #define DEV             0x00004000  //0 Normal 0xbfc00480, 1 EJTAG MEM 0xff200200
00140 #define PROBEN          0x0000c000  //Probe enabled/present and set probetrap 1
00141 #define PRRST           0x00010000  //Processor reset
00142 #define DMAACC          0x00020000  //DMA access, set with every transfer!
00143 #define PRACC           0x00040000  //Processor access, reset by software!
00144 #define PRNW            0x00080000  //Processor access read not, write
00145 #define PERRST          0x00100000  //Peripheral reset, JTAG excluded
00146 #define RUN             0x00200000  //Processor is running
00147 #define DOZE            0x00400000  //Processor is in doze state
00148 #define SYNC_FLAG       0x00800000  //Trace will sync. with pctrace instr.
00149 #define PCLEN           0x01000000  //Trace addrs. long, !short
00150 
00151 /*------------------------------------------------------------------------*/
00152 /*  DMA TRANSFER TYPES (INTERNAL)                                         */
00153 /*------------------------------------------------------------------------*/
00154 #define LITTLE_E        0 //Little Endian
00155 #define BIG_E           1 //Big Endian
00156 
00157 /*------------------------------------------------------------------------*/
00158 /*  TARGET JTAG IMPLEMENTATION BITS                                       */
00159 /*------------------------------------------------------------------------*/
00160 #define MIPS64          0x00000001                 //ID MiPS64, !MiPS32
00161 #define CH(dword)       (dword>>1)&0x000000F       //# of brk. channels (old)
00162 #define INSTBRK         0x00000020                 //Imp. Instr. Addrs. break
00163 #define DATABRK         0x00000040                 //Imp. Data Addrs. break
00164 #define PROCBRK         0x00000080                 //Imp. Proc. Addrs. break
00165 #define PCSTW(dword)    1+((dword)>>8&0x0000007)   //# of PCST channels
00166 #define TPCW(dword)     1+((dword)>>11&0x0000007)  //# of TPC channels
00167 #define NODMA           0x00004000                 
00168 #define NOPCTRACE       0x00008000                 
00169 #define MIPS16          0x00010000                 //Imp. MiPS16 support
00170 #define ICACHEC         0x00020000                 //Imp. Instr. cache coh.
00171 #define DCACHEC         0x00040000                 //Imp. Data cache coh.
00172 #define PHYSAW          0x00080000                 //JTAG addrs. reg. size
00173 #define SDBBPC          0x00800000                 //SDBBPCode zero=1.3 spec, one=Special2 Opcode
00174 
00175 /*------------------------------------------------------------------------*/
00176 /* TARGET DSU REGISTERS                                                   */
00177 /*------------------------------------------------------------------------*/
00178 #define BASE    0xFF300000  //DSU BASE address
00179 #define DCR     BASE+0x0000 //DSU Control register
00180 //#define IBS   BASE+0x0004 //Instruction Address Break Register //zgj
00181 //#define DBS   BASE+0x0008 //Data Break Status Register         //zgj 
00182 #define PBS     BASE+0x000C //Processor Break Status Register
00183 #define IBA0    BASE+0x0100 //Instruction Address Break Register 0
00184 #define IBC0    BASE+0x0104 //Instruction Break Control Register 0
00185 #define IBM0    BASE+0x0108 //Instruction Address Break Mask Register 0
00186 #define DBA0    BASE+0x0200 //Data Address Break Register 0
00187 #define DBC0    BASE+0x0204 //Data Break Control register 0
00188 #define DBM0    BASE+0x0208 //Data Address Break Mask register 0
00189 #define DB0     BASE+0x020C //Data Value Break Register 0
00190 #define PBA0    BASE+0x0300 //Processor Address Bus Break Register 0
00191 #define PBD0    BASE+0x0304 //Processor Data Bus Break Register 0
00192 #define PBM0    BASE+0x0308 //Processor Data Bus Break Mask Register 0
00193 #define PBC0    BASE+0x030C //Processor Bus Break Control and Address Mask Register 0
00194 
00195 /*------------------------------------------------------------------------*/
00196 /*  BIT MAPS DEBUG CONTROL REGISTER                                       */
00197 /*------------------------------------------------------------------------*/
00198 #define DCR_TM          0x00000001   //Trace Mode
00199 #define DCR_MRST        0x00000002   //Mask soft reset
00200 #define DCR_MP          0x00000004   //Memory protection
00201 #define DCR_MNMI        0x00000008   //Mask Non-Maskable interrupt
00202                                      //(in non debug mode)
00203 #define DCR_MINT        0x00000010   //Mask Interrupt
00204 #define DCR_TOFDSU      0x00000020   //Test Output Full
00205 #define DCR_TIFDSU      0x00000040   //Test Input Full
00206 #define DCR_ENM         0x20000000   //Endianess '0'=littel endian '1'=big endian
00207 #define DCR_HIS         0x40000000   //Halt status
00208 #define DCR_DZS         0x80000000   //Doze status
00209 
00210 /*------------------------------------------------------------------------*/
00211 /*  BITS INSTRUCTION ADDRESS BREAK STATUS                                 */
00212 /*------------------------------------------------------------------------*/
00213 #define IBS_BS0         0x00000001   //Break Status
00214 #define IBS_BS(dword)   ((dword&0x00004FF2)>>1)//channel status bits
00215 #define IBS_BCN(dword)  (dword>>24)  //Break Channel Number
00216 
00217 /*------------------------------------------------------------------------*/
00218 /*  BITS INSTRUCTION ADDRESS BREAK CONTROL                                */
00219 /*------------------------------------------------------------------------*/
00220 #define IBC_BE          0x00000001   //Break Enable
00221 #define IBC_TE          0x00000004   //Trigger Enable
00222 
00223 /*------------------------------------------------------------------------*/
00224 /*  BITS DATA ADDRESS BREAK STATUS                                        */
00225 /*------------------------------------------------------------------------*/
00226 #define DBS_BS0         0x00000001   //Break Status
00227 #define DBS_BS(dword)   ((dword&0x00004FF2)>>1)//channel status bits
00228 #define DBS_BCN(dword)  (dword>>24)  //Break Channel Number
00229 
00230 /*------------------------------------------------------------------------*/
00231 /*  BITS DATA ADDRESS BREAK CONTROL                                       */
00232 /*------------------------------------------------------------------------*/
00233 #define DBC_BE          0x00000001   //Break Enable
00234 #define DBC_TE          0x00000004   //Trigger Enable
00235 #define DBC_BLM         0x00000FF0   //BLM D[63..0]
00236 
00237 /*------------------------------------------------------------------------*/
00238 /*  BITS PROCESSOR BREAK STATUS                                           */
00239 /*------------------------------------------------------------------------*/
00240 #define PBS_BS0         0x00000001   //Break Status
00241 #define PBS_BS(dword)   ((dword&0x00004FF2)>>1)//channel status bits
00242 #define PBS_BCN(dword)  (dword>>24)  //Break Channel Number
00243 
00244 /*------------------------------------------------------------------------*/
00245 /*  BITS PROCESSOR BREAK CONTROL                                          */
00246 /*------------------------------------------------------------------------*/
00247 #define PBC_BE          0x00000001   //Break Enable
00248 #define PBC_TE          0x00000004   //Trigger Enable
00249 #define PBC_IFUC        0x00000010   //Instruction fetch from uncached area
00250 #define PBC_DLUC        0x00000020   //Data load uncached area
00251 #define PBC_DSUC        0x00000040   //Data store to uncached area
00252 #define PBC_LAM         0xFFFFFF00   //Lower Address Mask
00253 
00254 /*------------------------------------------------------------------------*/
00255 /*  DEBUG EXCEPTION HOST-MEMORY SETUP                                     */
00256 /*------------------------------------------------------------------------*/
00257 #define DEX_LOW         0xFF200000   //Low memory boundary
00258 #define DEX_HIGH        0xFF200FFF   //High memory boundary
00259 #define DEX_SIZE_W      0xFFF        //4kb
00260 
00261 /*------------------------------------------------------------------------*/
00262 /*  UPLOAD DESTINATIONS SETUP                                             */
00263 /*------------------------------------------------------------------------*/
00264 #define DEST_NORMAL     0xA          //Destination is normal DMA write
00265 #define DEST_FLASH      0xB          //Destination is FLASH memory on target
00266 #define DEST_HOST       0xC          //Destination is shared host memory
00267 
00268 /*------------------------------------------------------------------------*/
00269 /*  PARPORT BIT DEFINITIONS                                               */
00270 /*------------------------------------------------------------------------*/
00271 #define TRSTN_BIT_MASK  (0x1<<3)
00272 #define TMS_BIT_MASK    (0x1<<1)
00273 #define TDO_BIT_MASK    (0x1<<6)
00274 #define TCK_BIT_MASK    (0x1<<0)
00275 
00276 #define TMS_BIT(x)      ((x)?TMS_BIT_MASK:0x0)
00277 #define TCK_BIT(x)      ((x)?TCK_BIT_MASK:0x0)
00278 #define TRSTN_BIT(x)    ((x)?TRSTN_BIT_MASK:0x0)
00279 #define TDO_BIT(x)      ((x)?TDO_BIT_MASK:0x0)
00280 
00281 #endif /* _LINUX_EJTAG_H */

Generated on Fri Nov 5 07:24:46 2010 for ejtag debug tools for loongson 232 cpu by  doxygen 1.5.6