mips32.h File Reference

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Defines

#define DBAN(x)   (DRSEG_BASE+DBAN_OFFSET(x))
#define DBAN_OFFSET(x)   (0x2100+0x100*x)
#define DBASIDN(x)   (DRSEG_BASE+DBASIDN_OFFSET(x))
#define DBASIDN_OFFSET(x)   (0x2110+0x100*x)
#define DBCN(x)   (DRSEG_BASE+DBCN_OFFSET(x))
#define DBCN_OFFSET(x)   (0x2118+0x100*x)
#define DBMN(x)   (DRSEG_BASE+DBMN_OFFSET(x))
#define DBMN_OFFSET(x)   (0x2108+0x100*x)
#define DBS   (DRSEG_BASE+DBS_OFFSET)
#define DBS_OFFSET   0x2000
#define DBVN(x)   (DRSEG_BASE+DBVN_OFFSET(x))
#define DBVN_OFFSET(x)   (0x2120+0x100*x)
#define dMIPS32_AU1500_HW_BKPT   0x17
#define dMIPS32_DATA_BKPT_ADDR(X)   0xFF302100 + (X * 0x100)
#define dMIPS32_DATA_BKPT_ADDR_MSK(X)   0xFF302108 + (X * 0x100)
#define dMIPS32_DATA_BKPT_ASID(X)   0xFF302110 + (X * 0x100)
#define dMIPS32_DATA_BKPT_CONTROL(X)   0xFF302118 + (X * 0x100)
#define dMIPS32_DATA_BKPT_STATUS   0xFF302000
#define dMIPS32_DATA_BKPT_VALUE(X)   0xFF302120 + (X * 0x100)
#define dMIPS32_DATAMEM   0xFF200000
#define dMIPS32_DEBUG_HW_DATA_LD_BKPT   0x00000004
#define dMIPS32_DEBUG_HW_DATA_LD_IMP_BKPT   0x00040000
#define dMIPS32_DEBUG_HW_DATA_ST_BKPT   0x00000008
#define dMIPS32_DEBUG_HW_DATA_ST_IMP_BKPT   0x00080000
#define dMIPS32_DEBUG_HW_INST_BKPT   0x00000010
#define dMIPS32_DEBUG_JTAG_BKPT   0x00000020
#define dMIPS32_DEBUG_SINGLE_STEP_BKPT   0x00000001
#define dMIPS32_DEBUG_SW_BKPT   0x00000002
#define dMIPS32_DERET_INSTRUCTION   0x4200001F
#define dMIPS32_ECR_ACCESS_BYTE   0x00000000
#define dMIPS32_ECR_ACCESS_HWORD   0x20000000
#define dMIPS32_ECR_ACCESS_PENDING   0x00040000
#define dMIPS32_ECR_ACCESS_RW   0x00080000
#define dMIPS32_ECR_ACCESS_SIZE   0x60000000
#define dMIPS32_ECR_ACCESS_TRIPLE   0x60000000
#define dMIPS32_ECR_ACCESS_WORD   0x40000000
#define dMIPS32_ECR_CPU_RESET   0x00010000
#define dMIPS32_ECR_CPU_RESET_OCCURED   0x00000000
#define dMIPS32_ECR_DOZE   0x00400000
#define dMIPS32_ECR_EJTAG_BREAK   0x00001000
#define dMIPS32_ECR_HALT   0x00200000
#define dMIPS32_ECR_IN_DEBUG_MODE   0x00000008
#define dMIPS32_ECR_PERIPHERAL_RESET   0x00100000
#define dMIPS32_ECR_PROBE_ENABLE   0x00008000
#define dMIPS32_ECR_PROBE_VECTOR   0x00004000
#define dMIPS32_EJTAG_EXIT_DEBUG_MODE   0x03
#define dMIPS32_EJTAG_FORCE_DEBUG_MODE   0x04
#define dMIPS32_EJTAG_WAIT_FOR_CONTINUE   0x02
#define dMIPS32_EJTAG_WAIT_FOR_DEBUG_MODE   0x01
#define dMIPS32_INST_BKPT_ADDR(X)   0xFF301100 + (X * 0x100)
#define dMIPS32_INST_BKPT_ADDR_MSK(X)   0xFF301108 + (X * 0x100)
#define dMIPS32_INST_BKPT_ASID(X)   0xFF301110 + (X * 0x100)
#define dMIPS32_INST_BKPT_CONTROL(X)   0xFF301118 + (X * 0x100)
#define dMIPS32_INST_BKPT_STATUS   0xFF301000
#define dMIPS32_MAX_HARDWARE_BKPTS   0x10
#define dMIPS32_NUM_DEBUG_REGISTERS   38
#define dMIPS32_PSEUDO_FIFO_ADDR   0xFF2001F8
#define dMIPS32_PSEUDO_SERIAL_ADDR   0xFF2001F4
#define dMIPS32_PSEUDO_STACK_ADDR   0xFF2001FC
#define dMIPS32_SW_BREAKPOINT_INSTRUCTION   0x7000003F
#define DRSEG_BASE   0xff300000
#define HI_HALF_MASK   0x0000000c
#define IBAN(x)   (DRSEG_BASE+IBAN_OFFSET(x))
#define IBAN_OFFSET(x)   (0x1100+0x100*x)
#define IBASIDN(x)   (DRSEG_BASE+IBASIDN_OFFSET(x))
#define IBASIDN_OFFSET(x)   (0x1110+0x100*x)
#define IBCN(x)   (DRSEG_BASE+IBCN_OFFSET(x))
#define IBCN_OFFSET(x)   (0x1118+0x100*x)
#define IBMN(x)   (DRSEG_BASE+IBMN_OFFSET(x))
#define IBMN_OFFESET(x)   (0x1108+0x100*x)
#define IBS   (DRSEG_BASE+IBS_OFFSET)
#define IBS_OFFSET   0x1000
#define LO_HALF_MASK   0x00000003
#define min(a, b)   ((a)<(b)?(a):(b))
#define tgt_compile(s)   tgt_compile(s)
#define tgt_exec(s, len)   ({unsigned int codebuf[]=tgt_compile(s);fMIPS32_ExecuteDebugModule(codebuf,min(len,sizeof(codebuf)),1);})
#define tgt_exec_safe(s, len)   ({unsigned int codebuf[]=tgt_compile(s);fMIPS32_ExecuteDebugModule_safe(codebuf,min(len,sizeof(codebuf)),1);})

Functions

int fMIPS32_EJTAG_Machine (void)
unsigned int fMIPS32_ExecuteDebugModule (unsigned int *pui_module, unsigned int len, unsigned int runonce)
unsigned char jtag_inb (unsigned long addr)
unsigned int jtag_inl (unsigned long addr)
unsigned short jtag_inw (unsigned long addr)
void jtag_outb (unsigned long addr, unsigned char val)
void jtag_outl (unsigned long addr, unsigned int val)
void jtag_outw (unsigned long addr, unsigned short val)

Variables

unsigned int aui_readregisters_code []
unsigned int aui_writeregisters_code []
unsigned int context_reg []
unsigned int ui_datamem []
unsigned int ui_ejtag_state
unsigned int * ui_fifomem
unsigned int ui_fifomem_size
unsigned int ui_last_signal
unsigned int uififo_raddr
unsigned int uififo_waddr


Define Documentation

#define DBAN ( x   )     (DRSEG_BASE+DBAN_OFFSET(x))

Definition at line 179 of file mips32.h.

#define DBAN_OFFSET ( x   )     (0x2100+0x100*x)

Definition at line 169 of file mips32.h.

#define DBASIDN ( x   )     (DRSEG_BASE+DBASIDN_OFFSET(x))

Definition at line 181 of file mips32.h.

#define DBASIDN_OFFSET ( x   )     (0x2110+0x100*x)

Definition at line 173 of file mips32.h.

#define DBCN ( x   )     (DRSEG_BASE+DBCN_OFFSET(x))

Definition at line 182 of file mips32.h.

#define DBCN_OFFSET ( x   )     (0x2118+0x100*x)

Definition at line 175 of file mips32.h.

#define DBMN ( x   )     (DRSEG_BASE+DBMN_OFFSET(x))

Definition at line 180 of file mips32.h.

#define DBMN_OFFSET ( x   )     (0x2108+0x100*x)

Definition at line 171 of file mips32.h.

#define DBS   (DRSEG_BASE+DBS_OFFSET)

Definition at line 178 of file mips32.h.

#define DBS_OFFSET   0x2000

Definition at line 167 of file mips32.h.

#define DBVN ( x   )     (DRSEG_BASE+DBVN_OFFSET(x))

Definition at line 183 of file mips32.h.

#define DBVN_OFFSET ( x   )     (0x2120+0x100*x)

Definition at line 177 of file mips32.h.

#define dMIPS32_AU1500_HW_BKPT   0x17

Definition at line 124 of file mips32.h.

Referenced by fMIPS32_EJTAG_Machine().

#define dMIPS32_DATA_BKPT_ADDR ( X   )     0xFF302100 + (X * 0x100)

Definition at line 113 of file mips32.h.

Referenced by set_data_breakpoint().

#define dMIPS32_DATA_BKPT_ADDR_MSK ( X   )     0xFF302108 + (X * 0x100)

Definition at line 114 of file mips32.h.

#define dMIPS32_DATA_BKPT_ASID ( X   )     0xFF302110 + (X * 0x100)

Definition at line 115 of file mips32.h.

#define dMIPS32_DATA_BKPT_CONTROL ( X   )     0xFF302118 + (X * 0x100)

Definition at line 116 of file mips32.h.

Referenced by unset_data_breakpoint().

#define dMIPS32_DATA_BKPT_STATUS   0xFF302000

Definition at line 112 of file mips32.h.

Referenced by unset_data_breakpoint().

#define dMIPS32_DATA_BKPT_VALUE ( X   )     0xFF302120 + (X * 0x100)

Definition at line 117 of file mips32.h.

#define dMIPS32_DATAMEM   0xFF200000

Definition at line 93 of file mips32.h.

Referenced by fMIPS32_HandleRead(), and fMIPS32_HandleWrite().

#define dMIPS32_DEBUG_HW_DATA_LD_BKPT   0x00000004

Definition at line 138 of file mips32.h.

Referenced by check_ejtag(), and fMIPS32_EJTAG_Machine().

#define dMIPS32_DEBUG_HW_DATA_LD_IMP_BKPT   0x00040000

Definition at line 140 of file mips32.h.

Referenced by check_ejtag(), and fMIPS32_EJTAG_Machine().

#define dMIPS32_DEBUG_HW_DATA_ST_BKPT   0x00000008

Definition at line 139 of file mips32.h.

Referenced by check_ejtag(), and fMIPS32_EJTAG_Machine().

#define dMIPS32_DEBUG_HW_DATA_ST_IMP_BKPT   0x00080000

Definition at line 141 of file mips32.h.

Referenced by check_ejtag(), and fMIPS32_EJTAG_Machine().

#define dMIPS32_DEBUG_HW_INST_BKPT   0x00000010

Definition at line 137 of file mips32.h.

Referenced by check_ejtag(), and fMIPS32_EJTAG_Machine().

#define dMIPS32_DEBUG_JTAG_BKPT   0x00000020

Definition at line 143 of file mips32.h.

Referenced by check_ejtag(), and fMIPS32_EJTAG_Machine().

#define dMIPS32_DEBUG_SINGLE_STEP_BKPT   0x00000001

Definition at line 142 of file mips32.h.

Referenced by check_ejtag(), cmd_si(), and fMIPS32_EJTAG_Machine().

#define dMIPS32_DEBUG_SW_BKPT   0x00000002

Definition at line 136 of file mips32.h.

Referenced by check_ejtag(), and fMIPS32_EJTAG_Machine().

#define dMIPS32_DERET_INSTRUCTION   0x4200001F

Definition at line 75 of file mips32.h.

Referenced by fMIPS32_ExitDebugMode().

#define dMIPS32_ECR_ACCESS_BYTE   0x00000000

Definition at line 69 of file mips32.h.

#define dMIPS32_ECR_ACCESS_HWORD   0x20000000

Definition at line 70 of file mips32.h.

#define dMIPS32_ECR_ACCESS_PENDING   0x00040000

#define dMIPS32_ECR_ACCESS_RW   0x00080000

#define dMIPS32_ECR_ACCESS_SIZE   0x60000000

Definition at line 54 of file mips32.h.

#define dMIPS32_ECR_ACCESS_TRIPLE   0x60000000

Definition at line 72 of file mips32.h.

#define dMIPS32_ECR_ACCESS_WORD   0x40000000

Definition at line 71 of file mips32.h.

#define dMIPS32_ECR_CPU_RESET   0x00010000

Definition at line 60 of file mips32.h.

#define dMIPS32_ECR_CPU_RESET_OCCURED   0x00000000

#define dMIPS32_ECR_DOZE   0x00400000

Definition at line 55 of file mips32.h.

#define dMIPS32_ECR_EJTAG_BREAK   0x00001000

#define dMIPS32_ECR_HALT   0x00200000

Definition at line 56 of file mips32.h.

#define dMIPS32_ECR_IN_DEBUG_MODE   0x00000008

#define dMIPS32_ECR_PERIPHERAL_RESET   0x00100000

Definition at line 57 of file mips32.h.

#define dMIPS32_ECR_PROBE_ENABLE   0x00008000

#define dMIPS32_ECR_PROBE_VECTOR   0x00004000

#define dMIPS32_EJTAG_EXIT_DEBUG_MODE   0x03

#define dMIPS32_EJTAG_FORCE_DEBUG_MODE   0x04

Definition at line 130 of file mips32.h.

Referenced by fGDBRDP_InputHandler(), and fMIPS32_EJTAG_Machine().

#define dMIPS32_EJTAG_WAIT_FOR_CONTINUE   0x02

Definition at line 128 of file mips32.h.

Referenced by cmd_gdbserver(), fGDBRDP_CommandInterpreter(), and fMIPS32_EJTAG_Machine().

#define dMIPS32_EJTAG_WAIT_FOR_DEBUG_MODE   0x01

Definition at line 127 of file mips32.h.

Referenced by fGDBRDP_InputHandler(), and fMIPS32_EJTAG_Machine().

#define dMIPS32_INST_BKPT_ADDR ( X   )     0xFF301100 + (X * 0x100)

Definition at line 107 of file mips32.h.

Referenced by set_inst_breakpoint(), and unset_inst_breakpoint().

#define dMIPS32_INST_BKPT_ADDR_MSK ( X   )     0xFF301108 + (X * 0x100)

Definition at line 108 of file mips32.h.

#define dMIPS32_INST_BKPT_ASID ( X   )     0xFF301110 + (X * 0x100)

Definition at line 109 of file mips32.h.

#define dMIPS32_INST_BKPT_CONTROL ( X   )     0xFF301118 + (X * 0x100)

Definition at line 110 of file mips32.h.

Referenced by unset_inst_breakpoint().

#define dMIPS32_INST_BKPT_STATUS   0xFF301000

Definition at line 106 of file mips32.h.

#define dMIPS32_MAX_HARDWARE_BKPTS   0x10

#define dMIPS32_NUM_DEBUG_REGISTERS   38

#define dMIPS32_PSEUDO_FIFO_ADDR   0xFF2001F8

Definition at line 91 of file mips32.h.

Referenced by fMIPS32_HandleRead(), and fMIPS32_HandleWrite().

#define dMIPS32_PSEUDO_SERIAL_ADDR   0xFF2001F4

Definition at line 92 of file mips32.h.

Referenced by fMIPS32_HandleWrite().

#define dMIPS32_PSEUDO_STACK_ADDR   0xFF2001FC

Definition at line 86 of file mips32.h.

Referenced by fMIPS32_HandleRead(), and fMIPS32_HandleWrite().

#define dMIPS32_SW_BREAKPOINT_INSTRUCTION   0x7000003F

Definition at line 133 of file mips32.h.

Referenced by set_soft_breakpoint().

#define DRSEG_BASE   0xff300000

Definition at line 149 of file mips32.h.

#define HI_HALF_MASK   0x0000000c

Definition at line 184 of file mips32.h.

#define IBAN ( x   )     (DRSEG_BASE+IBAN_OFFSET(x))

Definition at line 161 of file mips32.h.

#define IBAN_OFFSET ( x   )     (0x1100+0x100*x)

Definition at line 153 of file mips32.h.

#define IBASIDN ( x   )     (DRSEG_BASE+IBASIDN_OFFSET(x))

Definition at line 163 of file mips32.h.

#define IBASIDN_OFFSET ( x   )     (0x1110+0x100*x)

Definition at line 157 of file mips32.h.

#define IBCN ( x   )     (DRSEG_BASE+IBCN_OFFSET(x))

Definition at line 164 of file mips32.h.

#define IBCN_OFFSET ( x   )     (0x1118+0x100*x)

Definition at line 159 of file mips32.h.

#define IBMN ( x   )     (DRSEG_BASE+IBMN_OFFSET(x))

Definition at line 162 of file mips32.h.

#define IBMN_OFFESET ( x   )     (0x1108+0x100*x)

Definition at line 155 of file mips32.h.

#define IBS   (DRSEG_BASE+IBS_OFFSET)

Definition at line 160 of file mips32.h.

#define IBS_OFFSET   0x1000

Definition at line 151 of file mips32.h.

#define LO_HALF_MASK   0x00000003

Definition at line 185 of file mips32.h.

#define min ( a,
b   )     ((a)<(b)?(a):(b))

Definition at line 186 of file mips32.h.

Referenced by jtag_getmem(), and jtag_putmem().

#define tgt_compile ( s   )     tgt_compile(s)

#define tgt_exec ( s,
len   )     ({unsigned int codebuf[]=tgt_compile(s);fMIPS32_ExecuteDebugModule(codebuf,min(len,sizeof(codebuf)),1);})

#define tgt_exec_safe ( s,
len   )     ({unsigned int codebuf[]=tgt_compile(s);fMIPS32_ExecuteDebugModule_safe(codebuf,min(len,sizeof(codebuf)),1);})

Definition at line 189 of file mips32.h.


Function Documentation

int fMIPS32_EJTAG_Machine ( void   ) 

Definition at line 1015 of file mips32.c.

References aui_singlestepclear_code, dJTAG_REGISTER_CONTROL, dMIPS32_AU1500_HW_BKPT, dMIPS32_DEBUG_HW_DATA_LD_BKPT, dMIPS32_DEBUG_HW_DATA_LD_IMP_BKPT, dMIPS32_DEBUG_HW_DATA_ST_BKPT, dMIPS32_DEBUG_HW_DATA_ST_IMP_BKPT, dMIPS32_DEBUG_HW_INST_BKPT, dMIPS32_DEBUG_JTAG_BKPT, dMIPS32_DEBUG_SINGLE_STEP_BKPT, dMIPS32_DEBUG_SW_BKPT, dMIPS32_ECR_ACCESS_PENDING, dMIPS32_ECR_CPU_RESET_OCCURED, dMIPS32_ECR_EJTAG_BREAK, dMIPS32_ECR_IN_DEBUG_MODE, dMIPS32_ECR_PROBE_ENABLE, dMIPS32_ECR_PROBE_VECTOR, dMIPS32_EJTAG_EXIT_DEBUG_MODE, dMIPS32_EJTAG_FORCE_DEBUG_MODE, dMIPS32_EJTAG_WAIT_FOR_CONTINUE, dMIPS32_EJTAG_WAIT_FOR_DEBUG_MODE, fJTAG_Data(), fJTAG_Instruction(), fMIPS32_ExecuteDebugModule(), fMIPS32_ExitDebugMode(), tgt_exec, ui_datamem, ui_ejtag_state, and ui_last_signal.

Referenced by fGDBRDP_Handler().

01016 {
01017   unsigned int ui_result;
01018 
01019   // Need to handle resets here on each execution.
01020   ui_result = dMIPS32_ECR_CPU_RESET_OCCURED | dMIPS32_ECR_ACCESS_PENDING |
01021               dMIPS32_ECR_PROBE_ENABLE | dMIPS32_ECR_PROBE_VECTOR;
01022 
01023   fJTAG_Instruction(dJTAG_REGISTER_CONTROL);
01024   ui_result = fJTAG_Data(ui_result);
01025 
01026   // Check for reset
01027   if (ui_result & dMIPS32_ECR_CPU_RESET_OCCURED)
01028   {
01029     // Reset occured - Must acknowlege this before EJTAG will work
01030     printf("JTAGEMUL: Processor was reset.\n");
01031     
01032     // Clear the reset and set our bits
01033     ui_result = dMIPS32_ECR_ACCESS_PENDING | dMIPS32_ECR_PROBE_ENABLE | 
01034                 dMIPS32_ECR_PROBE_VECTOR;
01035 
01036     ui_result = fJTAG_Data(ui_result);
01037   }
01038   
01039   switch(ui_ejtag_state)
01040   {
01041     case dMIPS32_EJTAG_WAIT_FOR_DEBUG_MODE:
01042       // Check to see if we have entered debug mode
01043 
01044       ui_result = dMIPS32_ECR_CPU_RESET_OCCURED | dMIPS32_ECR_ACCESS_PENDING |
01045                   dMIPS32_ECR_PROBE_ENABLE | dMIPS32_ECR_PROBE_VECTOR;
01046 
01047       fJTAG_Instruction(dJTAG_REGISTER_CONTROL);
01048       ui_result = fJTAG_Data(ui_result);
01049       
01050       // Check for debug mode
01051       if (ui_result & dMIPS32_ECR_IN_DEBUG_MODE)
01052       {
01053         // We have entered debug mode.
01054         ui_ejtag_state = dMIPS32_EJTAG_WAIT_FOR_CONTINUE;
01055         
01056         printf("JTAGEMUL: Debug exception!\n");
01057 
01058         // Turn on the debug mode LED
01059 //        fMIPS32_ExecuteDebugModule(aui_led_code,0x80000);
01060 
01061         // Read out the debug register to determine the cause
01062  tgt_exec(\
01063 "1:\n" \
01064 "       mtc0    $15, $31;\n" \
01065 "       lui     $15, 0xFF20;\n" \
01066 "       sw      $2,  0x1fc($15);\n" \
01067 "       mfc0    $2,  $23;\n" \
01068 "       sw      $2,  0($15);\n" \
01069 "       lw      $2,  0x1fc($15);\n" \
01070 "       mfc0    $15, $31 ;\n" \
01071 "       b 1b;\n" \
01072 "       nop;\n" \
01073 ,0x8000);
01074 
01075         // We're done with ui_result at this point - Use it as a count
01076         // of how many exceptions matched.  We only ever want to match
01077         // one exception at any given time.
01078         ui_result = 0x00;
01079                 printf("ui_datamem[0]=%x\n",ui_datamem[0]);
01080 
01081         if (ui_datamem[0] & dMIPS32_DEBUG_SW_BKPT)
01082         {
01083           ui_result++;
01084           ui_last_signal=SIGTRAP; // Breakpoint
01085         }
01086         if (ui_datamem[0] & dMIPS32_DEBUG_HW_INST_BKPT)
01087         {
01088           ui_result++;
01089           ui_last_signal=SIGTRAP; // Breakpoint
01090         }
01091         if (ui_datamem[0] & dMIPS32_DEBUG_HW_DATA_LD_BKPT)
01092         {
01093           ui_result++;
01094           ui_last_signal=SIGTRAP; // Breakpoint
01095         }
01096         if (ui_datamem[0] & dMIPS32_DEBUG_HW_DATA_ST_BKPT)
01097         {
01098           ui_result++;
01099           ui_last_signal=SIGTRAP; // Breakpoint
01100         }
01101         if (ui_datamem[0] & dMIPS32_DEBUG_HW_DATA_LD_IMP_BKPT)
01102         {
01103           ui_result++;
01104           ui_last_signal=SIGTRAP; // Breakpoint
01105         }
01106         if (ui_datamem[0] & dMIPS32_DEBUG_HW_DATA_ST_IMP_BKPT)
01107         {
01108           ui_result++;
01109           ui_last_signal=SIGTRAP; // Breakpoint
01110         }
01111         if (ui_datamem[0] & dMIPS32_DEBUG_SINGLE_STEP_BKPT)
01112         {
01113           ui_result++;
01114           ui_last_signal=SIGTRAP; // Breakpoint
01115           
01116           // We need to clear the single step bit
01117           fMIPS32_ExecuteDebugModule(aui_singlestepclear_code,0x80000,1);
01118         }
01119         if (ui_datamem[0] & dMIPS32_DEBUG_JTAG_BKPT)
01120         {
01121           ui_result++;
01122           ui_last_signal=SIGTSTP; // User stop
01123         }
01124 
01125         // Check for AU1500 specific hardware breakpoint
01126         ui_datamem[0] = ui_datamem[0] >> 10;
01127         ui_datamem[0] &= 0x1F;
01128         if (dMIPS32_AU1500_HW_BKPT == ui_datamem[0])
01129         {
01130           ui_result++;
01131           ui_last_signal=SIGTRAP; // Breakpoint
01132         }
01133 
01134         if (ui_result == 0x00)
01135         {
01136           printf("JTAGEMUL ERROR: Unknown debug exception = 0x%08X\n", ui_datamem[0]);
01137         }
01138         if (ui_result > 0x01)
01139         {
01140           printf("JTAGEMUL ERROR: Multiple debug exceptions = 0x%08X\n", ui_datamem[0]);
01141         }
01142 
01143         return(-1); // Tell GDBRDP we entered debug mode
01144       }
01145       
01146       break;
01147 
01148     case dMIPS32_EJTAG_WAIT_FOR_CONTINUE:
01149       // Check to see if we have stayed in debug mode
01150 
01151       ui_result = dMIPS32_ECR_CPU_RESET_OCCURED | dMIPS32_ECR_ACCESS_PENDING |
01152                   dMIPS32_ECR_PROBE_ENABLE | dMIPS32_ECR_PROBE_VECTOR;
01153 
01154       fJTAG_Instruction(dJTAG_REGISTER_CONTROL);
01155       ui_result = fJTAG_Data(ui_result);
01156       
01157       // Check for debug mode
01158       if (!(ui_result & dMIPS32_ECR_IN_DEBUG_MODE))
01159       {
01160         // Program got away from us and is RUNNING!?!?!?! ARGH!
01161         printf("JTAGEMUL: Program got away, currently running!\n");
01162 
01163         ui_ejtag_state = dMIPS32_EJTAG_WAIT_FOR_DEBUG_MODE;
01164       }
01165       
01166       break;
01167       
01168     case dMIPS32_EJTAG_EXIT_DEBUG_MODE:
01169       if (!fMIPS32_ExitDebugMode()) 
01170       {
01171         printf("JTAGEMUL ERROR: Could not resume!\n");
01172       }
01173 
01174       ui_ejtag_state = dMIPS32_EJTAG_WAIT_FOR_DEBUG_MODE;
01175       break;
01176 
01177     case dMIPS32_EJTAG_FORCE_DEBUG_MODE:
01178       // Force debug break  
01179       ui_result = dMIPS32_ECR_CPU_RESET_OCCURED | dMIPS32_ECR_ACCESS_PENDING |
01180                   dMIPS32_ECR_PROBE_ENABLE | dMIPS32_ECR_PROBE_VECTOR |
01181                   dMIPS32_ECR_EJTAG_BREAK;
01182   
01183       fJTAG_Instruction(dJTAG_REGISTER_CONTROL);
01184       ui_result = fJTAG_Data(ui_result);
01185 
01186       ui_ejtag_state = dMIPS32_EJTAG_WAIT_FOR_DEBUG_MODE;
01187       break;
01188     
01189     default:
01190       // Should never get here
01191       ui_ejtag_state = dMIPS32_EJTAG_WAIT_FOR_DEBUG_MODE;
01192       printf("JTAGEMUL ERROR: Corrupted debug mode catcher state!\n");
01193       break;  
01194   }
01195   
01196   return(1);
01197 }

Here is the call graph for this function:

unsigned int fMIPS32_ExecuteDebugModule ( unsigned int *  pui_module,
unsigned int  len,
unsigned int  runonce 
)

Definition at line 473 of file mips32.c.

References dJTAG_REGISTER_ADDRESS, dJTAG_REGISTER_CONTROL, dJTAG_REGISTER_DATA, dJTAG_REGISTER_EJTAG_BOOT, dJTAG_REGISTER_FASTDATA, dMIPS32_ECR_ACCESS_PENDING, dMIPS32_ECR_ACCESS_RW, dMIPS32_ECR_CPU_RESET_OCCURED, dMIPS32_ECR_EJTAG_BREAK, dMIPS32_ECR_IN_DEBUG_MODE, dMIPS32_ECR_PROBE_ENABLE, dMIPS32_ECR_PROBE_VECTOR, Ejtag_boot_flag, fJTAG_Data(), fJTAG_FastData(), fJTAG_Instruction(), fMIPS32_HandleRead(), fMIPS32_HandleWrite(), fMIPS32_Init(), log_disasm, md_disasm(), STATE_CONNECTING, STATE_RUN, and STATE_WAITING.

Referenced by __cp0syscall1(), __cp0syscall2(), check_ejtag(), cmd_cache(), cmd_cacheflush(), cmd_checksum(), cmd_erase(), cmd_erase_area(), cmd_fget(), cmd_fput(), cmd_fputflash(), cmd_get(), cmd_program(), cmd_put(), cmd_run(), cmd_set(), cmd_si(), cmd_test_erase_spi_area(), cmd_test_program_spi(), context_restore(), context_save(), fGDBRDP_CommandInterpreter(), fMIPS32_EJTAG_Machine(), fMIPS32_ExecuteDebugModule_safe(), and help_access().

00474 {
00475   unsigned int ui_result;
00476   unsigned int ui_address;
00477   unsigned int ui_data;
00478   unsigned int ui_finished;
00479   unsigned int start_address;
00480   unsigned int end_address;
00481   unsigned int state=STATE_CONNECTING;
00482   unsigned int download_size=0;
00483   unsigned int init_do=0;
00484     //time_t *time_start=malloc(sizeof(time_t));
00485     //time_t *time_end=malloc(sizeof(time_t));
00486     time_t time_start;
00487     time_t time_end;
00488     time_t  time_deta=0;
00489         int runonce=flags&1;
00490         int waitacc=!(flags&2);
00491         int allowbefore=flags&4;
00492     
00493 
00494   fprintf(stderr,"JTAGEMUL: Executing a module.\n");
00495   fMIPS32_Init();
00496 
00497   fprintf(stderr,"connecting...\n");
00498 #if 0
00499   if(!Ejtag_boot_flag)
00500   {
00501         fprintf(stderr,"===============dJTAG_REGISTER_EJTAG_BOOT ==========\n");
00502         Ejtag_boot_flag=1;      
00503         fJTAG_Instruction(dJTAG_REGISTER_EJTAG_BOOT);
00504   }
00505          fprintf(stderr,"dJTAG_REGISTER_EJTAG_BOOT done\n");
00506 #endif
00507   
00508 while(1)
00509 {
00510   ui_result = dMIPS32_ECR_CPU_RESET_OCCURED|dMIPS32_ECR_ACCESS_PENDING|dMIPS32_ECR_PROBE_ENABLE | dMIPS32_ECR_PROBE_VECTOR ;
00511   fJTAG_Instruction(dJTAG_REGISTER_CONTROL);
00512   ui_result = fJTAG_Data(ui_result);
00513 
00514 if(!(ui_result&dMIPS32_ECR_IN_DEBUG_MODE))  {
00515     ui_result = dMIPS32_ECR_PROBE_ENABLE | dMIPS32_ECR_PROBE_VECTOR |dMIPS32_ECR_EJTAG_BREAK;
00516   fJTAG_Instruction(dJTAG_REGISTER_CONTROL);
00517   ui_result = fJTAG_Data(ui_result);
00518   continue;
00519   }
00520   fprintf(stderr,"connected\n");
00521   state=STATE_RUN;
00522   break;
00523 }
00524 
00525     fJTAG_Instruction(dJTAG_REGISTER_ADDRESS);
00526     start_address = fJTAG_Data(0x00)|0xff000000;
00527         end_address=start_address+len;
00528     ui_finished    = 0x00;
00529           fprintf(stderr,"start_address=%x,end_address=%x\n",start_address,end_address);
00530 
00531 
00532   // Feed that chip
00533   while (1)
00534   {
00535     // Read the control register.  Make sure an access is requested, then 
00536     // do it.
00537     ui_result = dMIPS32_ECR_CPU_RESET_OCCURED | dMIPS32_ECR_ACCESS_PENDING |
00538                 dMIPS32_ECR_PROBE_ENABLE | dMIPS32_ECR_PROBE_VECTOR;
00539   
00540     fJTAG_Instruction(dJTAG_REGISTER_CONTROL);
00541     ui_result = fJTAG_Data(ui_result);
00542         if(!(ui_result & dMIPS32_ECR_IN_DEBUG_MODE))
00543         {
00544       fprintf(stderr,"not in debug mode!\n");
00545     //            printf("not in debug mode!\n");
00546           return 0;
00547         }
00548     
00549     if (!(ui_result & dMIPS32_ECR_ACCESS_PENDING))
00550     {
00551           if(!waitacc)return -1;
00552           if(state!=STATE_WAITING)printf("waiting\n");
00553           state=STATE_WAITING;
00554           continue;
00555     }
00556         state=STATE_RUN;
00557 
00558         
00559     fJTAG_Instruction(dJTAG_REGISTER_ADDRESS);
00560     ui_address = fJTAG_Data(0x00)|0xff000000;
00561    
00562      if(ui_address<0xff200000|| ui_address>=0xff300000)
00563      {
00564      fprintf(stderr,"JTAGEMUL: %s to unknown location 0x%08X.\n", (ui_result & dMIPS32_ECR_ACCESS_RW)?"write":"read",ui_address);
00565      return 0;
00566      }
00567 
00568    //fprintf(stderr,"%s ui_address=%x,accesstype=%x\n",(ui_result & dMIPS32_ECR_ACCESS_RW)?"write":"read",ui_address,(ui_result>>29)&3);
00569     // Check for read or write
00570     if (ui_result & dMIPS32_ECR_ACCESS_RW) // Bit set for a WRITE
00571     {
00572       unsigned data0,data1,mask;
00573       int accesstype=(ui_result>>29)&3;
00574       // Read the data out
00575 #ifdef USE_FASTDATA
00576       fJTAG_Instruction(dJTAG_REGISTER_FASTDATA);
00577       ui_data = fJTAG_FastData(0x00);
00578 #else
00579           fJTAG_Instruction(dJTAG_REGISTER_DATA);
00580       ui_data = fJTAG_Data(0x00);
00581       // Clear the access pending bit (let the processor eat!)
00582       ui_result = dMIPS32_ECR_CPU_RESET_OCCURED | dMIPS32_ECR_PROBE_ENABLE | 
00583                   dMIPS32_ECR_PROBE_VECTOR;
00584   
00585       fJTAG_Instruction(dJTAG_REGISTER_CONTROL);
00586       ui_result = fJTAG_Data(ui_result);
00587 #endif
00588 
00589         if(ui_address >= 0xFF200200)
00590         {
00591        data0=pui_module[(ui_address - start_address) / 4];
00592        data1=ui_data;
00593 
00594         switch(accesstype)
00595         {
00596         case 0:
00597         mask=0xff<<((ui_address&3)*8); break;
00598         case 1:
00599         mask=0xffff<<(((ui_address>>1)&1)*16); break;
00600         case 2: mask=0xffffffff;break;
00601         default: mask=0xffffff<<((ui_address&1)*8);break;
00602         }
00603 
00604         ui_data=(data1&mask)|(data0&~mask);
00605         }
00606 
00607       // Processor is writing to us
00608       if (ui_address >= 0xFF200200)
00609         pui_module[(ui_address - start_address) / 4]=ui_data;
00610       else
00611       {
00612         // Data out to the real world
00613         //fprintf(stderr,"JTAGEMUL: Write 0x%08X to address 0x%08X.\n", ui_data, ui_address);
00614         fMIPS32_HandleWrite(ui_address, ui_data, accesstype);
00615       }
00616     }
00617     else
00618     {
00619       // Check to see if its reading at the debug vector.  The first pass through
00620       // the module is always read at the vector, so the first one we allow.  When
00621       // the second read from the vector occurs we are done and just exit.
00622       if ((start_address == ui_address)&&runonce)
00623       {
00624         if (ui_finished++) // Allows ONE pass
00625         {
00626                 ui_finished=0;
00627          // fprintf(stderr,"JTAGEMUL: Finished module.\n");
00628           return ui_address;
00629         }
00630       }
00631 
00632       // Processor is reading from us
00633       if (ui_address >= 0xFF200200)
00634       {
00635             if(ui_address>=end_address|| ( ui_address<start_address && !allowbefore))return ui_address;
00636         // Reading an instruction from our module
00637 
00638         // Fetch the instruction from the module
00639         //fprintf(stderr,"JTAGEMUL: Instruction read at 0x%08X ", ui_address); fflush(stdout);
00640         ui_data = (ui_address - start_address) / 4;
00641         //fprintf(stderr,"offset -> %04d ", ui_data); fflush(stdout);
00642         ui_data = *(unsigned int *)(pui_module + ui_data);
00643         //fprintf(stderr,"data -> 0x%08X\n", ui_data); fflush(stdout);
00644         
00645         if(log_disasm)
00646         {
00647         char buf[256];
00648         md_disasm (buf, ui_address, ui_data);
00649         fprintf(stderr,"%s\n",buf);
00650         }
00651 
00652         // Send the data out
00653 #ifdef USE_FASTDATA
00654         fJTAG_Instruction(dJTAG_REGISTER_FASTDATA);
00655         ui_data = fJTAG_Data(ui_data);
00656 #else
00657           fJTAG_Instruction(dJTAG_REGISTER_DATA);
00658       ui_data = fJTAG_Data(ui_data);
00659         // Clear the access pending bit (let the processor eat!)
00660         ui_result = dMIPS32_ECR_CPU_RESET_OCCURED | dMIPS32_ECR_PROBE_ENABLE | 
00661                     dMIPS32_ECR_PROBE_VECTOR;
00662   
00663         fJTAG_Instruction(dJTAG_REGISTER_CONTROL);
00664         ui_result = fJTAG_Data(ui_result);
00665 #endif
00666       }
00667       else
00668       {
00669         // A read from dmseg virtual registers
00670         ui_data = fMIPS32_HandleRead(ui_address);
00671       
00672 
00673         //fprintf(stderr,"JTAGEMUL: Read address 0x%08X result = 0x%08X.\n", ui_address, ui_data);
00674 
00675         // Send the data out
00676 #ifdef USE_FASTDATA
00677         fJTAG_Instruction(dJTAG_REGISTER_FASTDATA);
00678         ui_data = fJTAG_Data(ui_data);
00679 #else
00680           fJTAG_Instruction(dJTAG_REGISTER_DATA);
00681       ui_data = fJTAG_Data(ui_data);
00682         // Clear the access pending bit (let the processor eat!)
00683         ui_result = dMIPS32_ECR_CPU_RESET_OCCURED | dMIPS32_ECR_PROBE_ENABLE | 
00684                     dMIPS32_ECR_PROBE_VECTOR;
00685   
00686         fJTAG_Instruction(dJTAG_REGISTER_CONTROL);
00687         ui_result = fJTAG_Data(ui_result);
00688 #endif
00689       }
00690     }    
00691   }  
00692 }

Here is the call graph for this function:

unsigned char jtag_inb ( unsigned long  addr  ) 

Definition at line 1199 of file mips32.c.

References tgt_exec, and ui_datamem.

Referenced by __syscall1().

01200 {
01201       ui_datamem[0]=addr;
01202           tgt_exec(\
01203           ".set noat;\n" \
01204           "1:\n" \
01205           "mtc0    $15, $31;\n" \
01206           "li    $15,0xFF200000;\n" \
01207           "sw    $2, 0x1fc($15);\n" \
01208           "sw    $3, 0x1fc($15);\n" \
01209           "lw    $2, ($15);\n" \
01210           "lb    $3, ($2);\n" \
01211           "sb    $3, 4($15);\n" \
01212           "lw    $3, 0x1fc($15);\n" \
01213           "lw    $2, 0x1fc($15);\n" \
01214           "mfc0    $15, $31;\n" \
01215           "b 1b;\n" \
01216           "nop;\n" \
01217           ,0x80000);
01218           return (unsigned char)(ui_datamem[1]&0xff);
01219 }

unsigned int jtag_inl ( unsigned long  addr  ) 

Definition at line 1243 of file mips32.c.

References tgt_exec, and ui_datamem.

Referenced by __syscall1(), and cmd_disas().

01244 {
01245       ui_datamem[0]=addr;
01246           tgt_exec(\
01247           ".set noat;\n" \
01248           "1:\n" \
01249           "mtc0    $15, $31;\n" \
01250           "li    $15,0xFF200000;\n" \
01251           "sw    $2, 0x1fc($15);\n" \
01252           "sw    $3, 0x1fc($15);\n" \
01253           "lw    $2, ($15);\n" \
01254           "lw    $3, ($2);\n" \
01255           "sw    $3, 4($15);\n" \
01256           "lw    $3, 0x1fc($15);\n" \
01257           "lw    $2, 0x1fc($15);\n" \
01258           "mfc0    $15, $31;\n" \
01259           "b 1b;\n" \
01260           "nop;\n" \
01261           ,0x80000);
01262           return (unsigned int)ui_datamem[1];
01263 }

unsigned short jtag_inw ( unsigned long  addr  ) 

Definition at line 1221 of file mips32.c.

References tgt_exec, and ui_datamem.

Referenced by __syscall1().

01222 {
01223       ui_datamem[0]=addr;
01224           tgt_exec(\
01225           ".set noat;\n" \
01226           "1:\n" \
01227           "mtc0    $15, $31;\n" \
01228           "li    $15,0xFF200000;\n" \
01229           "sw    $2, 0x1fc($15);\n" \
01230           "sw    $3, 0x1fc($15);\n" \
01231           "lw    $2, ($15);\n" \
01232           "lh    $3, ($2);\n" \
01233           "sh    $3, 4($15);\n" \
01234           "lw    $3, 0x1fc($15);\n" \
01235           "lw    $2, 0x1fc($15);\n" \
01236           "mfc0    $15, $31;\n" \
01237           "b 1b;\n" \
01238           "nop;\n" \
01239           ,0x80000);
01240           return (unsigned short)(ui_datamem[1]&0xffff);
01241 }

void jtag_outb ( unsigned long  addr,
unsigned char  val 
)

Definition at line 1265 of file mips32.c.

References tgt_exec, and ui_datamem.

Referenced by __syscall2().

01266 {
01267       ui_datamem[0]=addr;
01268       ui_datamem[1]=val;
01269 
01270           tgt_exec(\
01271           ".set noat;\n" \
01272           "1:\n" \
01273           "mtc0    $15, $31;\n" \
01274           "li    $15,0xFF200000;\n" \
01275           "sw    $2, 0x1fc($15);\n" \
01276           "sw    $3, 0x1fc($15);\n" \
01277           "lw    $2, ($15);\n" \
01278           "lw    $3, 0x4($15);\n" \
01279           "sb    $3, ($2);\n" \
01280           "lw    $3, 0x1fc($15);\n" \
01281           "lw    $2, 0x1fc($15);\n" \
01282           "mfc0    $15, $31;\n" \
01283           "b 1b;\n" \
01284           "nop;\n" \
01285           ,0x80000);
01286 }

void jtag_outl ( unsigned long  addr,
unsigned int  val 
)

Definition at line 1310 of file mips32.c.

References tgt_exec, and ui_datamem.

Referenced by __syscall2(), jtag_download_crc_checksum(), and jtag_download_length().

01311 {
01312       ui_datamem[0]=addr;
01313       ui_datamem[1]=val;
01314 
01315           tgt_exec(\
01316           ".set noat;\n" \
01317           "1:\n" \
01318           "mtc0    $15, $31;\n" \
01319           "li    $15,0xFF200000;\n" \
01320           "sw    $2, 0x1fc($15);\n" \
01321           "sw    $3, 0x1fc($15);\n" \
01322           "lw    $2, ($15);\n" \
01323           "lw    $3, 0x4($15);\n" \
01324           "sw    $3, ($2);\n" \
01325           "lw    $3, 0x1fc($15);\n" \
01326           "lw    $2, 0x1fc($15);\n" \
01327           "mfc0    $15, $31;\n" \
01328           "b 1b;\n" \
01329           "nop;\n" \
01330           ,0x80000);
01331 
01332 }

void jtag_outw ( unsigned long  addr,
unsigned short  val 
)

Definition at line 1288 of file mips32.c.

References tgt_exec, and ui_datamem.

Referenced by __syscall2().

01289 {
01290       ui_datamem[0]=addr;
01291       ui_datamem[1]=val;
01292           tgt_exec(\
01293           ".set noat;\n" \
01294           "1:\n" \
01295           "mtc0    $15, $31;\n" \
01296           "li    $15,0xFF200000;\n" \
01297           "sw    $2, 0x1fc($15);\n" \
01298           "sw    $3, 0x1fc($15);\n" \
01299           "lw    $2, ($15);\n" \
01300           "lw    $3, 0x4($15);\n" \
01301           "sh    $3, ($2);\n" \
01302           "lw    $3, 0x1fc($15);\n" \
01303           "lw    $2, 0x1fc($15);\n" \
01304           "mfc0    $15, $31;\n" \
01305           "b 1b;\n" \
01306           "nop;\n" \
01307           ,0x80000);
01308 }


Variable Documentation

unsigned int aui_readregisters_code[]

Definition at line 11 of file readregisters.h.

Referenced by cmd_set(), context_save(), fGDBRDP_CommandInterpreter(), and help_access().

unsigned int aui_writeregisters_code[]

Definition at line 11 of file writeregisters.h.

Referenced by context_restore(), and fGDBRDP_CommandInterpreter().

unsigned int context_reg[]

unsigned int ui_datamem[]

unsigned int ui_ejtag_state

Definition at line 84 of file mips32.c.

unsigned int * ui_fifomem

unsigned int ui_fifomem_size

Definition at line 88 of file mips32.c.

Referenced by jtag_getmem(), jtag_putmem(), and main().

unsigned int ui_last_signal

Definition at line 85 of file mips32.c.

unsigned int uififo_raddr

unsigned int uififo_waddr


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