mips32.h

Go to the documentation of this file.
00001 //
00002 // MIPS32.H
00003 //
00004 // Target specific EJTAG code for MIPS32
00005 //
00006 // Copyright (c) 2002, Jason Riffel - TotalEmbedded LLC.
00007 // All rights reserved.
00008 //
00009 // Redistribution and use in source and binary forms, with or without 
00010 // modification, are permitted provided that the following conditions 
00011 // are met:
00012 //
00013 // Redistributions of source code must retain the above copyright 
00014 // notice, this list of conditions and the following disclaimer. 
00015 //
00016 // Redistributions in binary form must reproduce the above copyright
00017 // notice, this list of conditions and the following disclaimer in 
00018 // the documentation and/or other materials provided with the
00019 // distribution. 
00020 //
00021 // Neither the name of TotalEmbedded nor the names of its 
00022 // contributors may be used to endorse or promote products derived 
00023 // from this software without specific prior written permission.
00024 // 
00025 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
00026 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
00027 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 
00028 // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 
00029 // COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 
00030 // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 
00031 // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 
00032 // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 
00033 // CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
00034 // LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 
00035 // ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
00036 // POSSIBILITY OF SUCH DAMAGE.
00037 //
00038 
00039 #ifndef dMIPS32_H
00040 #define dMIPS32_H
00041 
00042 // 
00043 // PROTOTYPES
00044 //
00045 int  fMIPS32_EJTAG_Machine     (void);
00046 unsigned int fMIPS32_ExecuteDebugModule(unsigned int *pui_module,unsigned int len,unsigned int runonce);
00047 
00048 //
00049 // DEFINES
00050 //
00051 // ECR register definition
00052 //
00053 #define dMIPS32_ECR_CPU_RESET_OCCURED  0x00000000 // Set to 1 if a reset occured
00054 #define dMIPS32_ECR_ACCESS_SIZE        0x60000000 // See below note 1
00055 #define dMIPS32_ECR_DOZE               0x00400000 // Set to 1 if processor is in low power mode
00056 #define dMIPS32_ECR_HALT               0x00200000 // Set to 1 if system bus clock is stopped
00057 #define dMIPS32_ECR_PERIPHERAL_RESET   0x00100000 // Set to 1 to reset peripherals (optional)
00058 #define dMIPS32_ECR_ACCESS_RW          0x00080000 // Set to 1 if pending access is write, 0 for read
00059 #define dMIPS32_ECR_ACCESS_PENDING     0x00040000 // Set to 1 to indicate access pending
00060 #define dMIPS32_ECR_CPU_RESET          0x00010000 // Set to 1 to reset CPU (optional)
00061 #define dMIPS32_ECR_PROBE_ENABLE       0x00008000 // Set to 1 to enable remote hosted memory
00062 #define dMIPS32_ECR_PROBE_VECTOR       0x00004000 // Set to 1 to use dmseg location for remote memory
00063 #define dMIPS32_ECR_EJTAG_BREAK        0x00001000 // Set to 1 to request a debug interrupt exception
00064 #define dMIPS32_ECR_IN_DEBUG_MODE      0x00000008 // Set to 1 to indicate in debug mode
00065 
00066 // Note 1
00067 //
00068 // Possible values of dMIPS32_ECR_ACCESS_SIZE
00069 #define dMIPS32_ECR_ACCESS_BYTE        0x00000000 // 0 = 1 byte
00070 #define dMIPS32_ECR_ACCESS_HWORD       0x20000000 // 1 = 2 bytes
00071 #define dMIPS32_ECR_ACCESS_WORD        0x40000000 // 2 = 4 bytes
00072 #define dMIPS32_ECR_ACCESS_TRIPLE      0x60000000 // 3 = ? bytes
00073 
00074 // Instruction for return from debug handler
00075 #define dMIPS32_DERET_INSTRUCTION      0x4200001F // Big endian format
00076 
00077 // A slight note about EJTAG hosted memory.  Nothing is designated as ROM
00078 // or RAM its all virtual definitions we create for being able to identify
00079 // accesses for instructions or accesses for data.  The begining of EJTAG
00080 // hosted memory is designated for ROM up to where RAM begins.  All 
00081 // virtual registers (RAM) will live above the ROM section.  This is useful
00082 // when exiting debug mode to send the correct DERET instruction only when
00083 // retrieving instructions not data.
00084 //
00085 // Our pseudo stack location
00086 #define dMIPS32_PSEUDO_STACK_ADDR      0xFF2001FC
00087  
00088 #define dMIPS32_NUM_DEBUG_REGISTERS    38
00089  
00090 // Define the memory access registers
00091 #define dMIPS32_PSEUDO_FIFO_ADDR         0xFF2001F8
00092 #define dMIPS32_PSEUDO_SERIAL_ADDR       0xFF2001F4
00093 #define dMIPS32_DATAMEM         0xFF200000
00094 
00095 //
00096 // EXTERNS - For sharing the register array
00097 extern unsigned int  ui_datamem[];
00098 extern unsigned int  context_reg[];
00099 extern unsigned int  uififo_raddr,uififo_waddr,*ui_fifomem,aui_readregisters_code[],ui_fifomem_size;
00100 extern unsigned int  ui_ejtag_state;
00101 extern unsigned int  ui_last_signal;
00102 extern unsigned int aui_writeregisters_code[];
00103 
00104 // Define the register locations of the DRSEG hardware breakpoint registers
00105 // These are not implemented on the au1500 (suck!)
00106 #define dMIPS32_INST_BKPT_STATUS       0xFF301000
00107 #define dMIPS32_INST_BKPT_ADDR(X)      0xFF301100 + (X * 0x100)
00108 #define dMIPS32_INST_BKPT_ADDR_MSK(X)  0xFF301108 + (X * 0x100)
00109 #define dMIPS32_INST_BKPT_ASID(X)      0xFF301110 + (X * 0x100)
00110 #define dMIPS32_INST_BKPT_CONTROL(X)   0xFF301118 + (X * 0x100)
00111 
00112 #define dMIPS32_DATA_BKPT_STATUS       0xFF302000
00113 #define dMIPS32_DATA_BKPT_ADDR(X)      0xFF302100 + (X * 0x100)
00114 #define dMIPS32_DATA_BKPT_ADDR_MSK(X)  0xFF302108 + (X * 0x100)
00115 #define dMIPS32_DATA_BKPT_ASID(X)      0xFF302110 + (X * 0x100)
00116 #define dMIPS32_DATA_BKPT_CONTROL(X)   0xFF302118 + (X * 0x100)
00117 #define dMIPS32_DATA_BKPT_VALUE(X)     0xFF302120 + (X * 0x100)
00118 
00119 // AU1500 supports 1 instruction and 1 data breakpoint
00120 #define dMIPS32_MAX_HARDWARE_BKPTS     0x10
00121 
00122 // AU1500 hardware breakpoints put the following value into the
00123 // debug register CP0 #23 sel 0 in the DExcCode bits
00124 #define dMIPS32_AU1500_HW_BKPT         0x17
00125 
00126 // States of the debug exception catcher
00127 #define dMIPS32_EJTAG_WAIT_FOR_DEBUG_MODE    0x01
00128 #define dMIPS32_EJTAG_WAIT_FOR_CONTINUE      0x02
00129 #define dMIPS32_EJTAG_EXIT_DEBUG_MODE        0x03
00130 #define dMIPS32_EJTAG_FORCE_DEBUG_MODE       0x04
00131 
00132 // Software breakpoint instruction
00133 #define dMIPS32_SW_BREAKPOINT_INSTRUCTION    0x7000003F
00134 
00135 // Bits in the debug register (CP0 register 23 select 0)
00136 #define dMIPS32_DEBUG_SW_BKPT                0x00000002
00137 #define dMIPS32_DEBUG_HW_INST_BKPT           0x00000010
00138 #define dMIPS32_DEBUG_HW_DATA_LD_BKPT        0x00000004
00139 #define dMIPS32_DEBUG_HW_DATA_ST_BKPT        0x00000008
00140 #define dMIPS32_DEBUG_HW_DATA_LD_IMP_BKPT    0x00040000
00141 #define dMIPS32_DEBUG_HW_DATA_ST_IMP_BKPT    0x00080000
00142 #define dMIPS32_DEBUG_SINGLE_STEP_BKPT       0x00000001
00143 #define dMIPS32_DEBUG_JTAG_BKPT              0x00000020
00144 
00145 
00146 //
00147 // EXTERNS - For sharing the register array
00148 
00149 #define DRSEG_BASE      0xff300000
00150 /* instruction breakpoint status */
00151 #define IBS_OFFSET      0x1000                  
00152 /* instruction breakpoint address n */
00153 #define IBAN_OFFSET(x)  (0x1100+0x100*x)
00154 /* instruction breakpoint address mask n */
00155 #define IBMN_OFFESET(x) (0x1108+0x100*x)
00156 /* instruction breakpoint asid n */
00157 #define IBASIDN_OFFSET(x)       (0x1110+0x100*x)
00158 /* instruction breakpoint control n */
00159 #define IBCN_OFFSET(x)  (0x1118+0x100*x)
00160 #define IBS     (DRSEG_BASE+IBS_OFFSET)
00161 #define IBAN(x)         (DRSEG_BASE+IBAN_OFFSET(x))
00162 #define IBMN(x)         (DRSEG_BASE+IBMN_OFFSET(x))
00163 #define IBASIDN(x)      (DRSEG_BASE+IBASIDN_OFFSET(x))
00164 #define IBCN(x)         (DRSEG_BASE+IBCN_OFFSET(x))
00165 
00166 /* data breakpoint status */
00167 #define DBS_OFFSET      0x2000
00168 /* data breakpoint address n */
00169 #define DBAN_OFFSET(x)  (0x2100+0x100*x)
00170 /* data breakpoint address mask n */
00171 #define DBMN_OFFSET(x)  (0x2108+0x100*x)
00172 /* data breakpoint asid n */
00173 #define DBASIDN_OFFSET(x)       (0x2110+0x100*x)
00174 /* data breakpoint control n */
00175 #define DBCN_OFFSET(x)  (0x2118+0x100*x)
00176 /* data breakpoint value n */
00177 #define DBVN_OFFSET(x)  (0x2120+0x100*x)
00178 #define DBS     (DRSEG_BASE+DBS_OFFSET)
00179 #define DBAN(x) (DRSEG_BASE+DBAN_OFFSET(x))
00180 #define DBMN(x) (DRSEG_BASE+DBMN_OFFSET(x))
00181 #define DBASIDN(x)      (DRSEG_BASE+DBASIDN_OFFSET(x))
00182 #define DBCN(x) (DRSEG_BASE+DBCN_OFFSET(x))
00183 #define DBVN(x) (DRSEG_BASE+DBVN_OFFSET(x))
00184 #define HI_HALF_MASK 0x0000000c
00185 #define LO_HALF_MASK 0x00000003
00186 #define min(a,b) ((a)<(b)?(a):(b))
00187 #define tgt_compile(s) tgt_compile(s)
00188 #define tgt_exec(s,len) ({unsigned int codebuf[]=tgt_compile(s);fMIPS32_ExecuteDebugModule(codebuf,min(len,sizeof(codebuf)),1);})
00189 #define tgt_exec_safe(s,len) ({unsigned int codebuf[]=tgt_compile(s);fMIPS32_ExecuteDebugModule_safe(codebuf,min(len,sizeof(codebuf)),1);})
00190 unsigned char jtag_inb(unsigned long addr);
00191 unsigned short jtag_inw(unsigned long addr);
00192 unsigned int jtag_inl(unsigned long addr);
00193 void jtag_outb(unsigned long addr,unsigned char val);
00194 void jtag_outw(unsigned long addr,unsigned short val);
00195 void jtag_outl(unsigned long addr,unsigned int val);
00196 
00197 #endif // #ifndef dMIPS32_H

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