#include <errno.h>#include <signal.h>#include <stdio.h>#include <unistd.h>#include <sys/time.h>#include <sys/types.h>#include <sys/socket.h>#include <sys/wait.h>#include <netinet/in.h>#include <netdb.h>#include <asm/ioctls.h>#include "jtagsock.h"#include "gdbrdp.h"#include "mips32.h"#include "readbyte.h"#include "readhalf.h"#include "readword.h"#include "writebyte.h"#include "writehalf.h"#include "writeword.h"#include "singlestepset.h"#include <myconfig.h>#include <cmdparser.h>
Go to the source code of this file.
Data Structures | |
| struct | _hw_breakpoint_ |
| struct | _sw_breakpoint_ |
Defines | |
| #define | ACTION_ALL 3 |
| #define | ACTION_READ 2 |
| #define | ACTION_WRITE 1 |
| #define | gdb_little_endian(x) (((x>>24)&0xff)|((x>>8)&0xff00)|((x&0xff00)<<8)|((x&0xff)<<24)) |
| #define | Z_DEBUG |
Typedefs | |
| typedef struct _hw_breakpoint_ | hw_breakpoint |
| typedef struct _sw_breakpoint_ | sw_breakpoint |
Functions | |
| int | check_ejtag (char *buf, int *debug_reg) |
| static int | cmd_awatch (int argc, char **argv) |
| static int | cmd_b (int argc, char **argv) |
| static int | cmd_hb (int argc, char **argv) |
| static int | cmd_rwatch (int argc, char **argv) |
| static int | cmd_si (int argc, char **argv) |
| static int | cmd_watch (int argc, char **argv) |
| char | fGDBRDP_CalculateNibble (int i_nibble) |
| int | fGDBRDP_CommandInterpreter (int i_socket, char *pc_command, unsigned int ui_size) |
| int | fGDBRDP_ConvertNibble (char c_nibble) |
| int | fGDBRDP_HandleHardwareDataBreakpoint (char *pc_command, unsigned int ui_size) |
| int | fGDBRDP_HandleHardwareInstBreakpoint (char *pc_command, unsigned int ui_size) |
| int | fGDBRDP_Handler (int i_socket) |
| int | fGDBRDP_HandleSoftwareBreakpoint (char *pc_command, unsigned int ui_size) |
| int | fGDBRDP_InputHandler (int i_socket, char c_byte) |
| void | fGDBRDP_SendToGDB (int i_socket, char *pc_message, unsigned int ui_length) |
| int | help_access (unsigned int ui_address, int andlo0, int orlo0, int *entrylo0) |
| mycmd_init (unsi, cmd_si,"unsi","unset single step") | |
| mycmd_init (si, cmd_si,"si","single step") | |
| mycmd_init (unawatch, cmd_awatch,"uawatch addr [size]","unset databeakpoint on addr for all access") | |
| mycmd_init (awatch, cmd_awatch,"awatch addr [size]","set databeakpoint on addr for all access") | |
| mycmd_init (unrwatch, cmd_rwatch,"unrwatch addr [size]","unset databeakpoint on addr for read access") | |
| mycmd_init (rwatch, cmd_rwatch,"rwatch addr [size]","set databeakpoint on addr for read access") | |
| mycmd_init (unwatch, cmd_watch,"unwatch addr [size]","unset databeakpoint on addr for write access") | |
| mycmd_init (watch, cmd_watch,"watch addr [size]","set databeakpoint on addr for write access") | |
| mycmd_init (unhb, cmd_hb,"unbh addr","unset hardbeakpoint on addr") | |
| mycmd_init (hb, cmd_hb,"bh addr","set hardbeakpoint on addr") | |
| mycmd_init (unb, cmd_b,"unb addr","unset softbeakpoint on addr") | |
| mycmd_init (b, cmd_b,"b addr","set softbeakpoint on addr") | |
| myconfig_init ("gdbserver.quitgdb", config_gdbserver_quitgdb, CONFIG_I,"quit gdb") | |
| myconfig_init ("gdbserver.compareadata.val", config_gdbserver_comparedata_val, CONFIG_I,"gdbserver compare data val") | |
| myconfig_init ("gdbserver.compareadata", config_gdbserver_comparedata, CONFIG_I,"gdbserver compare data") | |
| myconfig_init ("gdbserver.compareasid", config_gdbserver_compareasid, CONFIG_I,"gdbserver compare asid") | |
| int | set_data_breakpoint (unsigned int ui_address, unsigned int ui_addrsize, int action) |
| int | set_inst_breakpoint (unsigned int ui_address) |
| int | set_soft_breakpoint (unsigned ui_address) |
| int | unset_data_breakpoint (unsigned int ui_address) |
| int | unset_inst_breakpoint (unsigned int ui_address) |
| int | unset_soft_breakpoint (unsigned ui_address) |
Variables | |
| static unsigned int | aui_registers [dMIPS32_NUM_DEBUG_REGISTERS] |
| static int | config_gdbserver_compareasid = 0 |
| static int | config_gdbserver_comparedata = 0 |
| static int | config_gdbserver_comparedata_val = 0 |
| int | config_gdbserver_quitgdb = 0 |
| static hw_breakpoint | hwb_data_array [dMIPS32_MAX_HARDWARE_BKPTS] |
| static hw_breakpoint | hwb_inst_array [dMIPS32_MAX_HARDWARE_BKPTS] |
| static char | sac_commandbuffer [dGDBRDP_MAX_CMD_BUFFER] |
| static int | si_inputhandlerstate |
| static unsigned char | suc_calculatedchecksum |
| static unsigned char | suc_receivedchecksum |
| static unsigned int | sui_numbytesreceived |
| static sw_breakpoint | swb_array [dGDBRDP_MAX_SW_BREAKPOINTS] |
| #define ACTION_ALL 3 |
Referenced by cmd_awatch().
| #define ACTION_READ 2 |
Referenced by cmd_rwatch(), and set_data_breakpoint().
| #define ACTION_WRITE 1 |
Referenced by cmd_watch(), and set_data_breakpoint().
| #define gdb_little_endian | ( | x | ) | (((x>>24)&0xff)|((x>>8)&0xff00)|((x&0xff00)<<8)|((x&0xff)<<24)) |
| #define Z_DEBUG |
| typedef struct _hw_breakpoint_ hw_breakpoint |
| typedef struct _sw_breakpoint_ sw_breakpoint |
| int check_ejtag | ( | char * | buf, | |
| int * | debug_reg | |||
| ) |
Definition at line 104 of file mips32.c.
References dJTAG_REGISTER_CONTROL, 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_IN_DEBUG_MODE, dMIPS32_ECR_PROBE_ENABLE, dMIPS32_ECR_PROBE_VECTOR, fJTAG_Data(), fJTAG_Instruction(), fMIPS32_ExecuteDebugModule(), md_disasm(), tgt_compile, and tgt_exec.
Referenced by cmd_si(), and timer_handler().
00105 { 00106 unsigned int ui_result,debug_reg1; 00107 char *p = buf; 00108 *p=0; 00109 00110 ui_result = dMIPS32_ECR_CPU_RESET_OCCURED | dMIPS32_ECR_ACCESS_PENDING | 00111 dMIPS32_ECR_PROBE_ENABLE | dMIPS32_ECR_PROBE_VECTOR; 00112 00113 fJTAG_Instruction(dJTAG_REGISTER_CONTROL); 00114 ui_result = fJTAG_Data(ui_result); 00115 00116 // Check for debug mode 00117 if (ui_result & dMIPS32_ECR_IN_DEBUG_MODE) 00118 { 00119 00120 // Read out the debug register to determine the cause 00121 static int codebuf[100] =tgt_compile( 00122 "1:\n" 00123 "mtc0 ra, $31;\n" 00124 "bal 2f;\n" 00125 "nop;\n" 00126 ".word 0;\n" /*v0*/ 00127 ".word 0;\n" /*debug reg*/ 00128 ".word 0;\n" /*depc*/ 00129 ".word 0;\n" /*inst*/ 00130 "2:sw v0, 0(ra);\n" 00131 "mfc0 v0, $23;\n" 00132 "sw v0, 4(ra);\n" 00133 "mfc0 v0, $24;\n" 00134 "sw v0, 8(ra);\n" 00135 "mfc0 v0, $24;\n" 00136 "lw v0,(v0)\n" 00137 "sw v0, 12(ra);\n" 00138 "lw v0, 0(ra);\n" 00139 "mfc0 ra, $31 ;\n" 00140 "b 1b;\n" 00141 "nop;\n" 00142 ); 00143 00144 fMIPS32_ExecuteDebugModule(codebuf,0x8000,1); 00145 debug_reg1 = codebuf[4]; 00146 00147 p += sprintf(p,"debug:%08x #",debug_reg1); 00148 00149 if (debug_reg1 & dMIPS32_DEBUG_SW_BKPT) 00150 p += sprintf(p,"i"); 00151 00152 if (debug_reg1 & dMIPS32_DEBUG_HW_INST_BKPT) 00153 p += sprintf(p,"I "); 00154 00155 if (debug_reg1 & dMIPS32_DEBUG_HW_DATA_LD_BKPT) 00156 p += sprintf(p,"l"); 00157 00158 if (debug_reg1 & dMIPS32_DEBUG_HW_DATA_ST_BKPT) 00159 p += sprintf(p,"s"); 00160 00161 if (debug_reg1 & dMIPS32_DEBUG_HW_DATA_LD_IMP_BKPT) 00162 p += sprintf(p,"L"); 00163 00164 if (debug_reg1 & dMIPS32_DEBUG_HW_DATA_ST_IMP_BKPT) 00165 p += sprintf(p,"S"); 00166 00167 if(debug_reg1 & (dMIPS32_DEBUG_HW_DATA_LD_BKPT|dMIPS32_DEBUG_HW_DATA_ST_BKPT|dMIPS32_DEBUG_HW_DATA_LD_IMP_BKPT|dMIPS32_DEBUG_HW_DATA_ST_IMP_BKPT)) 00168 { 00169 /*clear data breakpoint*/ 00170 tgt_exec( 00171 "1:\n" 00172 "mtc0 $15, $31;\n" 00173 "lui $15,0xFF30;\n" 00174 "sw $0,0x2000($15);\n" 00175 "mfc0 $15, $31;\n" 00176 "b 1b;\n" \ 00177 "nop;\n" \ 00178 ,0x80000); 00179 } 00180 00181 if (debug_reg1 & dMIPS32_DEBUG_SINGLE_STEP_BKPT) 00182 p += sprintf(p," step"); 00183 00184 if (debug_reg1 & dMIPS32_DEBUG_JTAG_BKPT) 00185 p += sprintf(p,"user "); 00186 if (debug_reg1 & 0x100000) 00187 p += sprintf(p," exp"); 00188 00189 p += sprintf(p,"\n"); 00190 md_disasm (p, codebuf[5], codebuf[6]); 00191 *debug_reg = debug_reg1; 00192 00193 } 00194 else 00195 { 00196 p += sprintf(p,"not in debug mode"); 00197 *debug_reg = 0; 00198 } 00199 00200 00201 return ui_result; 00202 }
| static int cmd_awatch | ( | int | argc, | |
| char ** | argv | |||
| ) | [static] |
Definition at line 1862 of file gdbrdp.c.
References ACTION_ALL, set_data_breakpoint(), and unset_data_breakpoint().
01863 { 01864 int size; 01865 if(argc > 3) size = strtoul(argv[2],0,0); 01866 else size = 4; 01867 01868 if(argv[0][0] != 'u') 01869 set_data_breakpoint(strtoul(argv[1],0,0),size,ACTION_ALL); 01870 else 01871 unset_data_breakpoint(strtoul(argv[1],0,0)); 01872 return 0; 01873 }
| static int cmd_b | ( | int | argc, | |
| char ** | argv | |||
| ) | [static] |
Definition at line 1827 of file gdbrdp.c.
References set_soft_breakpoint(), and unset_soft_breakpoint().
01828 { 01829 if(argv[0][0] != 'u') 01830 set_soft_breakpoint(strtoul(argv[1],0,0)); 01831 else 01832 unset_soft_breakpoint(strtoul(argv[1],0,0)); 01833 return 0; 01834 }
| static int cmd_hb | ( | int | argc, | |
| char ** | argv | |||
| ) | [static] |
Definition at line 1818 of file gdbrdp.c.
References set_inst_breakpoint(), and unset_inst_breakpoint().
01819 { 01820 if(argv[0][0] != 'u') 01821 set_inst_breakpoint(strtoul(argv[1],0,0)); 01822 else 01823 unset_inst_breakpoint(strtoul(argv[1],0,0)); 01824 return 0; 01825 }
| static int cmd_rwatch | ( | int | argc, | |
| char ** | argv | |||
| ) | [static] |
Definition at line 1849 of file gdbrdp.c.
References ACTION_READ, set_data_breakpoint(), and unset_data_breakpoint().
01850 { 01851 int size; 01852 if(argc > 3) size = strtoul(argv[2],0,0); 01853 else size = 4; 01854 01855 if(argv[0][0] != 'u') 01856 set_data_breakpoint(strtoul(argv[1],0,0),size,ACTION_READ); 01857 else 01858 unset_data_breakpoint(strtoul(argv[1],0,0)); 01859 return 0; 01860 }
| static int cmd_si | ( | int | argc, | |
| char ** | argv | |||
| ) | [static] |
Definition at line 1877 of file gdbrdp.c.
References aui_singlestepclear_code, aui_singlestepset_code, check_ejtag(), debug_reg, dMIPS32_DEBUG_SINGLE_STEP_BKPT, fMIPS32_ExecuteDebugModule(), and jtag_quit().
01878 { 01879 extern unsigned int aui_singlestepclear_code[]; 01880 int count=1; 01881 int debug_reg = 0; 01882 char buf[256]; 01883 if(argc > 1) count = strtoul(argv[1],0,0); 01884 01885 if(argv[0][0] != 'u') 01886 { 01887 fMIPS32_ExecuteDebugModule(aui_singlestepset_code,0x80000,1); 01888 while(count--) 01889 { 01890 jtag_quit(); 01891 if(count) 01892 { 01893 do 01894 check_ejtag(buf,&debug_reg); 01895 while ((debug_reg & dMIPS32_DEBUG_SINGLE_STEP_BKPT) == 0); 01896 printf("%s\n",buf); 01897 } 01898 } 01899 } 01900 else 01901 fMIPS32_ExecuteDebugModule(aui_singlestepclear_code,0x80000,1); 01902 return 0; 01903 }
| static int cmd_watch | ( | int | argc, | |
| char ** | argv | |||
| ) | [static] |
Definition at line 1836 of file gdbrdp.c.
References ACTION_WRITE, set_data_breakpoint(), and unset_data_breakpoint().
01837 { 01838 int size; 01839 if(argc > 3) size = strtoul(argv[2],0,0); 01840 else size = 4; 01841 01842 if(argv[0][0] != 'u') 01843 set_data_breakpoint(strtoul(argv[1],0,0),size,ACTION_WRITE); 01844 else 01845 unset_data_breakpoint(strtoul(argv[1],0,0)); 01846 return 0; 01847 }
| char fGDBRDP_CalculateNibble | ( | int | i_nibble | ) |
Definition at line 1026 of file gdbrdp.c.
Referenced by fGDBRDP_SendToGDB().
01027 { 01028 switch(i_nibble) 01029 { 01030 case 0x00: return('0'); 01031 case 0x01: return('1'); 01032 case 0x02: return('2'); 01033 case 0x03: return('3'); 01034 case 0x04: return('4'); 01035 case 0x05: return('5'); 01036 case 0x06: return('6'); 01037 case 0x07: return('7'); 01038 case 0x08: return('8'); 01039 case 0x09: return('9'); 01040 case 0x0A: return('a'); 01041 case 0x0B: return('b'); 01042 case 0x0C: return('c'); 01043 case 0x0D: return('d'); 01044 case 0x0E: return('e'); 01045 case 0x0F: return('f'); 01046 default: return('0'); 01047 } 01048 }
| int fGDBRDP_CommandInterpreter | ( | int | i_socket, | |
| char * | pc_command, | |||
| unsigned int | ui_size | |||
| ) |
Definition at line 369 of file gdbrdp.c.
References aui_readbyte_code, aui_readregisters_code, aui_readword_code, aui_registers, aui_singlestepset_code, aui_writebyte_code, aui_writehalf_code, aui_writeregisters_code, aui_writeword_code, dGDBRDP_MAX_CMD_BUFFER, dMIPS32_EJTAG_EXIT_DEBUG_MODE, dMIPS32_EJTAG_WAIT_FOR_CONTINUE, dMIPS32_NUM_DEBUG_REGISTERS, do_cmd(), fGDBRDP_ConvertNibble(), fGDBRDP_HandleHardwareDataBreakpoint(), fGDBRDP_HandleHardwareInstBreakpoint(), fGDBRDP_HandleSoftwareBreakpoint(), fGDBRDP_SendToGDB(), fMIPS32_ExecuteDebugModule(), gdb_little_endian, help_access(), tgt_compile, tgt_exec, ui_datamem, ui_ejtag_state, ui_fifomem, ui_last_signal, uififo_raddr, and uififo_waddr.
Referenced by fGDBRDP_InputHandler().
00370 { 00371 unsigned int ui_responsesize; 00372 unsigned int ui_address; 00373 unsigned int ui_count; 00374 unsigned int count; 00375 unsigned int ui_index; 00376 unsigned int entrylo0; 00377 char ac_responsebuffer[dGDBRDP_MAX_CMD_BUFFER]; 00378 int num; 00379 pc_command[ui_size]=0; 00380 { 00381 int i; 00382 printf("mydebug:receive "); 00383 for(i=0;i<ui_size;i++) 00384 printf("%c",pc_command[i]); 00385 printf("\n"); 00386 } 00387 00388 // Evaluate each command received from GDB 00389 switch(*pc_command) 00390 { 00391 case 'k': // GDB is exiting - Kill thread 00392 // We are currently using this as indication that GDB is exiting. 00393 if (ui_ejtag_state == dMIPS32_EJTAG_WAIT_FOR_CONTINUE) 00394 ui_ejtag_state = dMIPS32_EJTAG_EXIT_DEBUG_MODE; 00395 sprintf(ac_responsebuffer, "OK"); 00396 ui_responsesize = 2; 00397 // fGDBRDP_SendToGDB(i_socket, &ac_responsebuffer[0], ui_responsesize); 00398 //printf("K-K-K-K-K-K-K-K-\n"); 00399 return(-1); // Forces exit 00400 break; 00401 00402 case 'D': //detach 00403 if (ui_ejtag_state == dMIPS32_EJTAG_WAIT_FOR_CONTINUE) 00404 ui_ejtag_state = dMIPS32_EJTAG_EXIT_DEBUG_MODE; 00405 sprintf(ac_responsebuffer, "OK"); 00406 ui_responsesize = 2; 00407 fGDBRDP_SendToGDB(i_socket, &ac_responsebuffer[0], ui_responsesize); 00408 return(-1); // Forces exit 00409 break; 00410 00411 case '?': // Get last signal 00412 // This is used to query the debug hardware as to what the last exception was 00413 // that entered debug mode. We always use 05 as of now which is ABORT. 00414 sprintf(ac_responsebuffer, "S%02x", ui_last_signal); 00415 ui_responsesize=3; 00416 break; 00417 00418 case 'g': // Read general registers 00419 // This command reads all the registers from the processor and returns them 00420 00421 // Go read all the registers from the processor 00422 uififo_raddr=0; 00423 uififo_waddr=0; 00424 memset(ui_fifomem,0,38*4); 00425 fMIPS32_ExecuteDebugModule(aui_readregisters_code,0x80000,1); 00426 00427 // Now the register array is accurate, pump it out 00428 for (ui_responsesize=0; ui_responsesize<(dMIPS32_NUM_DEBUG_REGISTERS*8); ui_responsesize+=8) 00429 { 00430 sprintf(&ac_responsebuffer[ui_responsesize], "%08x", gdb_little_endian(ui_fifomem[ui_responsesize/8])); 00431 } 00432 memcpy(aui_registers,ui_fifomem,dMIPS32_NUM_DEBUG_REGISTERS*4); 00433 break; 00434 case 'p': //this command is for 64bit regs 00435 { 00436 int regnum; 00437 if(pc_command[2]) regnum=(fGDBRDP_ConvertNibble(pc_command[1])<<4)+fGDBRDP_ConvertNibble(pc_command[2]); 00438 else regnum=fGDBRDP_ConvertNibble(pc_command[1]); 00439 // Go read all the registers from the processor 00440 00441 if(regnum<31) 00442 { 00443 int reg32code[]=tgt_compile(\ 00444 "sw $0,($31);\n" \ 00445 "sw $1,($31);\n" \ 00446 ); 00447 reg32code[1]=reg32code[0]+regnum*0x10000; 00448 tgt_exec(\ 00449 "mtc0 $31, $31;\n" \ 00450 "lui $31,0xFF20;\n" \ 00451 ,8); 00452 fMIPS32_ExecuteDebugModule(®32code[1],4,1); 00453 tgt_exec("mfc0 $31, $31;\n",4); 00454 } 00455 else if(regnum==31) 00456 tgt_exec(\ 00457 "mtc0 $2, $31;\n" \ 00458 "lui $2,0xFF20;\n" \ 00459 "sw $31, ($2);\n" \ 00460 "mfc0 $2, $31;\n" \ 00461 ,16); 00462 else if(regnum<38) //sr 00463 { 00464 int cpxbuf[]=tgt_compile(\ 00465 "mfc0 $2, $12;\n" \ 00466 "mflo $2;\n" \ 00467 "mfhi $2;\n" \ 00468 "mfc0 $2, $8;\n" \ 00469 "mfc0 $2, $13;\n" \ 00470 "mfc0 $2, $24;\n" \ 00471 ); 00472 00473 tgt_exec(\ 00474 "mtc0 $15, $31;\n" \ 00475 "lui $15,0xFF20;\n" \ 00476 "sw $2, 0x1fc($15);\n" \ 00477 ,12); 00478 fMIPS32_ExecuteDebugModule(&cpxbuf[regnum-32],4,1); 00479 tgt_exec(\ 00480 "sw $2, ($15);\n" \ 00481 "lw $2, 0x1fc($15);\n" \ 00482 "mfc0 $15, $31;\n" \ 00483 ,12); 00484 } 00485 else 00486 ui_datamem[0]=0; 00487 00488 if(ui_datamem[0]&0x80000000) 00489 sprintf(ac_responsebuffer, "%08xffffffff", gdb_little_endian(ui_datamem[0])); 00490 else 00491 sprintf(ac_responsebuffer, "%08x00000000", gdb_little_endian(ui_datamem[0])); 00492 ui_responsesize=16; 00493 } 00494 break; 00495 00496 case 'P': // Write a single register 00497 // Format is Pxx=12345678 where xx is the register number 00498 pc_command++; // Get past the 'P' 00499 00500 // Get the register number 00501 if(pc_command[1]=='=') ui_index = fGDBRDP_ConvertNibble(*pc_command++); 00502 else 00503 { 00504 ui_index = fGDBRDP_ConvertNibble(*pc_command++) << 4; 00505 ui_index += fGDBRDP_ConvertNibble(*pc_command++); 00506 } 00507 00508 pc_command++; 00509 00510 00511 if (ui_index < dMIPS32_NUM_DEBUG_REGISTERS) 00512 { 00513 // Valid register number so go ahead and update 00514 ui_datamem[0] = fGDBRDP_ConvertNibble(*pc_command++) << 4; 00515 ui_datamem[0] += fGDBRDP_ConvertNibble(*pc_command++); 00516 ui_datamem[0] += fGDBRDP_ConvertNibble(*pc_command++) << 12; 00517 ui_datamem[0] += fGDBRDP_ConvertNibble(*pc_command++) << 8; 00518 ui_datamem[0] += fGDBRDP_ConvertNibble(*pc_command++) << 20; 00519 ui_datamem[0] += fGDBRDP_ConvertNibble(*pc_command++) << 16; 00520 ui_datamem[0] += fGDBRDP_ConvertNibble(*pc_command++) << 28; 00521 ui_datamem[0] += fGDBRDP_ConvertNibble(*pc_command++) << 24; 00522 if(ui_index<31) 00523 { 00524 int reg32code[]=tgt_compile(\ 00525 "lw $0,($31);\n" \ 00526 "lw $1,($31);\n" \ 00527 ); 00528 reg32code[1]=reg32code[0]+ui_index*0x10000; 00529 tgt_exec(\ 00530 "mtc0 $31, $31;\n" \ 00531 "lui $31,0xFF20;\n" \ 00532 ,8); 00533 fMIPS32_ExecuteDebugModule(®32code[1],4,1); 00534 tgt_exec("mfc0 $31, $31;\n",4); 00535 } 00536 else if(ui_index==31) 00537 tgt_exec(\ 00538 "mtc0 $2, $31;\n" \ 00539 "lui $2,0xFF20;\n" \ 00540 "lw $31, ($2);\n" \ 00541 "mfc0 $2, $31;\n" \ 00542 ,16); 00543 else if(ui_index<38) //sr 00544 { 00545 int cpxbuf[]=tgt_compile(\ 00546 "mtc0 $2, $12;\n" \ 00547 "mtlo $2;\n" \ 00548 "mthi $2;\n" \ 00549 "mtc0 $2, $8;\n" \ 00550 "mtc0 $2, $13;\n" \ 00551 "mtc0 $2, $24;\n" \ 00552 ); 00553 00554 tgt_exec(\ 00555 "mtc0 $15, $31;\n" \ 00556 "lui $15,0xFF20;\n" \ 00557 "sw $2, 0x1fc($15);\n" \ 00558 "lw $2, ($15);\n" \ 00559 ,16); 00560 fMIPS32_ExecuteDebugModule(&cpxbuf[ui_index-32],4,1); 00561 tgt_exec(\ 00562 "lw $2, 0x1fc($15);\n" \ 00563 "mfc0 $15, $31;\n" \ 00564 ,8); 00565 } 00566 00567 sprintf(ac_responsebuffer, "OK"); 00568 ui_responsesize = 2; 00569 } 00570 else 00571 { 00572 printf("JTAGEMUL: Invalid register number %d.\n", ui_index); 00573 } 00574 break; 00575 case 'G': // Write general registers 00576 // This command writes all the registers in the processor 00577 pc_command++; 00578 00579 for (ui_index=0; ui_index<dMIPS32_NUM_DEBUG_REGISTERS; ui_index++) 00580 { 00581 aui_registers[ui_index] = fGDBRDP_ConvertNibble(*pc_command++) << 4; 00582 aui_registers[ui_index] += fGDBRDP_ConvertNibble(*pc_command++); 00583 aui_registers[ui_index] += fGDBRDP_ConvertNibble(*pc_command++) << 12; 00584 aui_registers[ui_index] += fGDBRDP_ConvertNibble(*pc_command++) << 8; 00585 aui_registers[ui_index] += fGDBRDP_ConvertNibble(*pc_command++) << 20; 00586 aui_registers[ui_index] += fGDBRDP_ConvertNibble(*pc_command++) << 16; 00587 aui_registers[ui_index] += fGDBRDP_ConvertNibble(*pc_command++) << 28; 00588 aui_registers[ui_index] += fGDBRDP_ConvertNibble(*pc_command++) << 24; 00589 } 00590 uififo_raddr=0; 00591 uififo_waddr=0; 00592 memcpy(ui_fifomem,aui_registers,dMIPS32_NUM_DEBUG_REGISTERS*4); 00593 fMIPS32_ExecuteDebugModule(aui_writeregisters_code,0x80000,1); 00594 00595 sprintf(ac_responsebuffer, "OK"); 00596 ui_responsesize = 2; 00597 break; 00598 00599 case 'H': // Set thread 00600 // For now just say OK! 00601 sprintf(ac_responsebuffer, "OK"); 00602 ui_responsesize = 2; 00603 break; 00604 00605 case 'q': // Get a general query 00606 // For now only support 'qC' that returns the current thread ID 16bit 00607 pc_command++; 00608 switch(*pc_command) 00609 { 00610 case 'C': 00611 // Just return a made up thread ID 00612 sprintf(ac_responsebuffer, "QC5A5A"); 00613 ui_responsesize = 6; 00614 break; 00615 00616 default: 00617 // Unsupported general query 00618 ui_responsesize = 0; 00619 break; 00620 } 00621 break; 00622 00623 case 'm': // Read memory 00624 // OK - This command comes formatted m<addr>,<length> with both components 00625 // encoded ascii hex MSB to LSB. 00626 ui_address = 0x00; 00627 ui_count = 0x00; 00628 00629 // Calculate the address 00630 for (ui_index=1; *(pc_command+ui_index)!=','; ui_index++) 00631 { 00632 ui_address = ui_address << 4; 00633 ui_address = ui_address + fGDBRDP_ConvertNibble(*(pc_command+ui_index)); 00634 } 00635 00636 // Increment the index past the ',' 00637 ui_index++; 00638 00639 // Calculate the count 00640 for ( ; ui_index<ui_size; ui_index++) 00641 { 00642 ui_count = ui_count << 4; 00643 ui_count = ui_count + fGDBRDP_ConvertNibble(*(pc_command+ui_index)); 00644 } 00645 00646 // Ok, now we have the address and count for the read. For speed we want to 00647 // read as much as fast as we can. We WANT to do 32 bit aligned WORD accesses 00648 // but we can't always do that. What we will do is perform BYTE reads until 00649 // we are WORD aligned. Then we will perform WORD reads as long as we can. 00650 // Then we will finish up with more BYTE reads until we have the entire range. 00651 00652 ui_responsesize=0x00; 00653 00654 if(ui_address < 0x80000000 || ui_address >= 0xc0000000) 00655 { 00656 00657 if(help_access(ui_address,-1,0,0) != 0) 00658 { 00659 int i; 00660 for(i=0;i<ui_count;i++) 00661 { 00662 sprintf(&ac_responsebuffer[ui_responsesize], "%02x", 0); 00663 00664 ui_responsesize += 2; 00665 } 00666 break; 00667 } 00668 } 00669 00670 00671 // Check to see if we are WORD aligned, if not then do BYTE reads 00672 while (0x00 != ui_address % 0x04) // A word aligned address will result in 0 modulus 00673 { 00674 // Non zero means we are not WORD aligned and need to do byte reads 00675 ui_datamem[0]=ui_address; 00676 fMIPS32_ExecuteDebugModule(aui_readbyte_code,0x80000,1); 00677 sprintf(&ac_responsebuffer[ui_responsesize], "%02x", ui_datamem[1]); 00678 00679 ui_responsesize = ui_responsesize + 2; 00680 ui_address = ui_address + 1; 00681 ui_count = ui_count - 1; 00682 00683 // Now we have to check to see if we are finished (for small accesses) 00684 if (0x00 == ui_count) 00685 { 00686 // All done, go ahead and exit 00687 break; 00688 } 00689 } 00690 00691 // Now we are WORD aligned, we need to read WORDs as long as we have at least 00692 // WORDSIZE count of bytes left to read. 00693 while (ui_count > 0x03) 00694 { 00695 ui_datamem[0]=ui_address; 00696 fMIPS32_ExecuteDebugModule(aui_readword_code,0x80000,1); 00697 sprintf(&ac_responsebuffer[ui_responsesize], "%08x", gdb_little_endian(ui_datamem[1])); 00698 00699 ui_responsesize = ui_responsesize + 8; 00700 ui_address = ui_address + 4; 00701 ui_count = ui_count - 4; 00702 } 00703 00704 // Now we need to perform any BYTE reads necessary to finish the read block. 00705 while(ui_count) 00706 { 00707 ui_datamem[0]=ui_address; 00708 fMIPS32_ExecuteDebugModule(aui_readbyte_code,0x80000,1); 00709 sprintf(&ac_responsebuffer[ui_responsesize], "%02x", ui_datamem[1]); 00710 00711 ui_responsesize = ui_responsesize + 2; 00712 ui_address = ui_address + 1; 00713 ui_count = ui_count - 1; 00714 } 00715 00716 // Finished. Successful read of the entire block. 00717 break; 00718 00719 case 'M': // Write memory 00720 // OK - This command comes formatted M<addr>,<length>:VALUE with all components 00721 // encoded ascii hex MSB to LSB. 00722 ui_address = 0x00; 00723 ui_count = 0x00; 00724 00725 // Calculate the address 00726 for (ui_index=1; *(pc_command+ui_index)!=','; ui_index++) 00727 { 00728 ui_address = ui_address << 4; 00729 ui_address = ui_address + fGDBRDP_ConvertNibble(*(pc_command+ui_index)); 00730 } 00731 00732 // Increment the index past the ',' 00733 ui_index++; 00734 00735 // Calculate the count 00736 for ( ; *(pc_command+ui_index)!=':'; ui_index++) 00737 { 00738 ui_count = ui_count << 4; 00739 ui_count = ui_count + fGDBRDP_ConvertNibble(*(pc_command+ui_index)); 00740 } 00741 00742 if(help_access(ui_address,0,4,&entrylo0) != 0) 00743 { 00744 sprintf(ac_responsebuffer, "OK"); 00745 ui_responsesize = 2; 00746 break; 00747 } 00748 00749 // Increment the index past the ':' 00750 ui_index++; 00751 while(ui_count) 00752 { 00753 if(((ui_address&3)==0)&&(ui_count>=0x04)) count=0x04; 00754 else if(((ui_address&1)==0)&&(ui_count>=0x02)) count=0x02; 00755 else count=1; 00756 00757 switch(count) 00758 { 00759 case 0x01: // Byte write 00760 ui_datamem[0]=ui_address; 00761 00762 ui_datamem[1] = fGDBRDP_ConvertNibble(*(pc_command+ui_index++)) << 4; 00763 ui_datamem[1] += fGDBRDP_ConvertNibble(*(pc_command+ui_index)); 00764 00765 fMIPS32_ExecuteDebugModule(aui_writebyte_code,0x80000,1); 00766 ui_address+=1; 00767 ui_count-=1; 00768 break; 00769 00770 case 0x02: // Half word write 00771 ui_datamem[0]=ui_address; 00772 00773 ui_datamem[1] = fGDBRDP_ConvertNibble(*(pc_command+ui_index++)) << 4; 00774 ui_datamem[1] += fGDBRDP_ConvertNibble(*(pc_command+ui_index++)); 00775 ui_datamem[1] += fGDBRDP_ConvertNibble(*(pc_command+ui_index++)) << 12; 00776 ui_datamem[1] += fGDBRDP_ConvertNibble(*(pc_command+ui_index)) << 8; 00777 00778 fMIPS32_ExecuteDebugModule(aui_writehalf_code,0x80000,1); 00779 ui_address+=2; 00780 ui_count-=2; 00781 break; 00782 00783 case 0x04: // Word write 00784 ui_datamem[0]=ui_address; 00785 00786 ui_datamem[1] = fGDBRDP_ConvertNibble(*(pc_command+ui_index++)) << 4; 00787 ui_datamem[1] += fGDBRDP_ConvertNibble(*(pc_command+ui_index++)); 00788 ui_datamem[1] += fGDBRDP_ConvertNibble(*(pc_command+ui_index++)) << 12; 00789 ui_datamem[1] += fGDBRDP_ConvertNibble(*(pc_command+ui_index++)) << 8; 00790 ui_datamem[1] += fGDBRDP_ConvertNibble(*(pc_command+ui_index++)) << 20; 00791 ui_datamem[1] += fGDBRDP_ConvertNibble(*(pc_command+ui_index++)) << 16; 00792 ui_datamem[1] += fGDBRDP_ConvertNibble(*(pc_command+ui_index++)) << 28; 00793 ui_datamem[1] += fGDBRDP_ConvertNibble(*(pc_command+ui_index)) << 24; 00794 00795 fMIPS32_ExecuteDebugModule(aui_writeword_code,0x80000,1); 00796 ui_address+=4; 00797 ui_count-=4; 00798 break; 00799 00800 default: // Unsupported 00801 printf("GDBRDP ERROR: Unsupported write size of %d.\n", ui_count); 00802 ui_responsesize=0; 00803 break; 00804 } 00805 } 00806 help_access(ui_address,entrylo0&4?-1:~4,0,&entrylo0); 00807 sprintf(ac_responsebuffer, "OK"); 00808 ui_responsesize = 2; 00809 break; 00810 00811 00812 case 'S': // This one has signal to step in it (ignore for now, just step) 00813 case 's': // Step (possible at address) 00814 // All we need to do is set the single step bit and continue - The chip will 00815 // only execute 1 instruction and then return to debug mode. Just execute 00816 // the code to set the single step bit and then fall through into the continue 00817 // code that takes care of the rest. 00818 fMIPS32_ExecuteDebugModule(aui_singlestepset_code,0x80000,1); 00819 goto continue_now; 00820 00821 // *** NOTE *** FALL THROUGH ON PURPOSE! 00822 00823 case 'C': // This one has signal to resume in it (ignore for now, just continue) 00824 { 00825 int signal=(fGDBRDP_ConvertNibble(pc_command[1])<<4)+fGDBRDP_ConvertNibble(pc_command[2]); 00826 if(signal==0x14) 00827 { 00828 sprintf(ac_responsebuffer,"T02"); //send sigint 00829 ui_responsesize = strlen(ac_responsebuffer); 00830 break; 00831 } 00832 } 00833 case 'c': // Continue (possible at address) 00834 // Continue is a different animal because it has no response back to GDB 00835 // until something happens that halts the system. (such as a breakpoint or 00836 // signal) All we need to do is have the machine exit debug mode at this 00837 // point. If it ever comes out on its own the debug mode catcher will 00838 // notifiy GDB. 00839 continue_now: 00840 if (ui_ejtag_state == dMIPS32_EJTAG_WAIT_FOR_CONTINUE) 00841 { 00842 // Let the catcher take care of exiting debug mode. 00843 ui_ejtag_state = dMIPS32_EJTAG_EXIT_DEBUG_MODE; 00844 return(1); 00845 } 00846 else 00847 { 00848 // Processor was NOT in debug mode. Shouldn't be getting this. 00849 printf("JTAGEMUL: Received continue while NOT debugging.\n"); 00850 return(1); 00851 } 00852 break; 00853 00854 case 'z': // The 'z' packet is for removing breakpoints 00855 case 'Z': // The 'Z' packet is for setting breakpoints 00856 // Z0 is for software breakpoints, Z1 is for hardware breakpoints 00857 if ('0' == *(pc_command+1)) 00858 { 00859 // Handle software breakpoint 00860 if (1 == fGDBRDP_HandleSoftwareBreakpoint(pc_command, ui_size)) 00861 { 00862 // Success 00863 sprintf(ac_responsebuffer, "OK"); 00864 ui_responsesize = 2; 00865 break; 00866 } 00867 else 00868 { 00869 // Failure 00870 sprintf(ac_responsebuffer, "E00"); 00871 ui_responsesize = 3; 00872 break; 00873 } 00874 } 00875 if ('1' == *(pc_command+1)) 00876 { 00877 // Handle hardware breakpoint 00878 if (1 == fGDBRDP_HandleHardwareInstBreakpoint(pc_command, ui_size)) 00879 { 00880 // Success 00881 sprintf(ac_responsebuffer, "OK"); 00882 ui_responsesize = 2; 00883 break; 00884 } 00885 else 00886 { 00887 // Failure 00888 sprintf(ac_responsebuffer, "E00"); 00889 ui_responsesize = 3; 00890 break; 00891 } 00892 } 00893 else if (('2' == *(pc_command+1))||('3' == *(pc_command+1))||('4' == *(pc_command+1))) 00894 { 00895 // Handle hardware breakpoint 00896 if (1 == fGDBRDP_HandleHardwareDataBreakpoint(pc_command, ui_size)) 00897 { 00898 // Success 00899 sprintf(ac_responsebuffer, "OK"); 00900 ui_responsesize = 2; 00901 break; 00902 } 00903 else 00904 { 00905 // Failure 00906 sprintf(ac_responsebuffer, "E00"); 00907 ui_responsesize = 3; 00908 break; 00909 } 00910 } 00911 else 00912 { 00913 // Unknown - report error 00914 sprintf(ac_responsebuffer, "E00"); 00915 ui_responsesize = 3; 00916 break; 00917 } 00918 break; 00919 case 'a': 00920 do_cmd(&pc_command[1]); 00921 00922 default: // Command not handled. 00923 // Unhandled commands should be responded with $#00. What we will do here 00924 // is set the response size to 0 and call the respond routine. The respond 00925 // routine will send the $ first, then the message of nothing, then the # 00926 // and the calculated checksum which will be 00. 00927 ui_responsesize=0; 00928 break; 00929 } 00930 00931 // We always send a response to these processed commands. If it fell through 00932 // to default we will send an empty packet which the spec says is correct for 00933 // unsupported options. 00934 fGDBRDP_SendToGDB(i_socket, &ac_responsebuffer[0], ui_responsesize); 00935 00936 return(1); 00937 }
| int fGDBRDP_ConvertNibble | ( | char | c_nibble | ) |
Definition at line 990 of file gdbrdp.c.
Referenced by fGDBRDP_CommandInterpreter(), fGDBRDP_HandleHardwareDataBreakpoint(), fGDBRDP_HandleHardwareInstBreakpoint(), fGDBRDP_HandleSoftwareBreakpoint(), and fGDBRDP_InputHandler().
00991 { 00992 switch(c_nibble) 00993 { 00994 case '0': return(0); 00995 case '1': return(1); 00996 case '2': return(2); 00997 case '3': return(3); 00998 case '4': return(4); 00999 case '5': return(5); 01000 case '6': return(6); 01001 case '7': return(7); 01002 case '8': return(8); 01003 case '9': return(9); 01004 case 'a': return(10); 01005 case 'A': return(10); 01006 case 'b': return(11); 01007 case 'B': return(11); 01008 case 'c': return(12); 01009 case 'C': return(12); 01010 case 'd': return(13); 01011 case 'D': return(13); 01012 case 'e': return(14); 01013 case 'E': return(14); 01014 case 'f': return(15); 01015 case 'F': return(15); 01016 default: return(0); 01017 } 01018 }
| int fGDBRDP_HandleHardwareDataBreakpoint | ( | char * | pc_command, | |
| unsigned int | ui_size | |||
| ) |
Definition at line 1430 of file gdbrdp.c.
References fGDBRDP_ConvertNibble(), set_data_breakpoint(), and unset_data_breakpoint().
Referenced by fGDBRDP_CommandInterpreter().
01431 { 01432 unsigned int ui_index; 01433 unsigned int ui_address; 01434 unsigned int ui_addrsize; 01435 01436 // Calculate the address now - Its the same location for all packets. 01437 // Packet is formated <z/Z><0/1><,><ADDR><,><LENGTH> 01438 // Z2: watch wrote 01439 // Z3: rwatch read 01440 // Z4: accessed 01441 ui_address = 0x00; 01442 for (ui_index=3;*(pc_command+ui_index) != ','; ui_index++) 01443 { 01444 ui_address = ui_address << 4; 01445 ui_address = ui_address + fGDBRDP_ConvertNibble(*(pc_command+ui_index)); 01446 } 01447 01448 ui_addrsize = fGDBRDP_ConvertNibble(pc_command[ui_index+1]); 01449 01450 // Check to see if it is a SET or REMOVE breakpoint command 01451 if ('Z' == *pc_command) // Then its a set command 01452 return set_data_breakpoint(ui_address,ui_addrsize,pc_command[1] - '1'); 01453 else if ('z' == *pc_command) // Then its a remove command 01454 return unset_data_breakpoint(ui_address); 01455 01456 // Should never get here 01457 return (-1); 01458 }
| int fGDBRDP_HandleHardwareInstBreakpoint | ( | char * | pc_command, | |
| unsigned int | ui_size | |||
| ) |
Definition at line 1194 of file gdbrdp.c.
References fGDBRDP_ConvertNibble(), set_inst_breakpoint(), and unset_inst_breakpoint().
Referenced by fGDBRDP_CommandInterpreter().
01195 { 01196 unsigned int ui_index; 01197 unsigned int ui_address; 01198 01199 // Calculate the address now - Its the same location for all packets. 01200 // Packet is formated <z/Z><0/1><,><ADDR><,><LENGTH> 01201 ui_address = 0x00; 01202 for (ui_index=3; *(pc_command+ui_index) != ','; ui_index++) 01203 { 01204 ui_address = ui_address << 4; 01205 ui_address = ui_address + fGDBRDP_ConvertNibble(*(pc_command+ui_index)); 01206 } 01207 01208 // Make sure address is 32bit aligned 01209 if (0x00 != (ui_address % 4)) 01210 { 01211 // Unaligned, not allowed 01212 printf("BREAKPOINT NOT ALIGNED!\n"); 01213 return(-1); 01214 } 01215 01216 // Check to see if it is a SET or REMOVE breakpoint command 01217 if ('Z' == *pc_command) // Then its a set command 01218 return set_inst_breakpoint(ui_address); 01219 else if ('z' == *pc_command) // Then its a remove command 01220 return unset_inst_breakpoint(ui_address); 01221 01222 // Should never get here 01223 return (-1); 01224 }
| int fGDBRDP_Handler | ( | int | i_socket | ) |
Definition at line 113 of file gdbrdp.c.
References config_gdbserver_quitgdb, dGDBRDP_INPUT_IDLE, dGDBRDP_MAX_SW_BREAKPOINTS, dMIPS32_MAX_HARDWARE_BKPTS, do_cmd(), fGDBRDP_InputHandler(), fGDBRDP_SendToGDB(), fJTAGSOCK_ReadByte(), fMIPS32_EJTAG_Machine(), quit(), si_inputhandlerstate, _hw_breakpoint_.uc_enabled, _sw_breakpoint_.uc_enabled, and ui_last_signal.
Referenced by cmd_gdbserver().
00114 { 00115 char c_byte; 00116 int i_result; 00117 char ac_responsebuffer[0x03]; // Only signal ever sent in this buffer 00118 00119 // Mark all breakpoints disabled - Just use i_result 00120 for (i_result=0; i_result<dGDBRDP_MAX_SW_BREAKPOINTS; i_result++) 00121 { 00122 swb_array[i_result].uc_enabled=0x00; 00123 } 00124 for (i_result=0; i_result<dMIPS32_MAX_HARDWARE_BKPTS; i_result++) 00125 { 00126 hwb_inst_array[i_result].uc_enabled=0x00; 00127 hwb_data_array[i_result].uc_enabled=0x00; 00128 } 00129 00130 // Init the target specific code and all code below it 00131 //fMIPS32_Init(); 00132 00133 si_inputhandlerstate = dGDBRDP_INPUT_IDLE; 00134 00135 // This routine does not return until the socket is closed 00136 for (;;) 00137 { 00138 int quit=0; 00139 i_result = fJTAGSOCK_ReadByte(i_socket, &c_byte); 00140 if (i_result > 0) 00141 { 00142 if (-1 == fGDBRDP_InputHandler(i_socket, c_byte)) 00143 quit=1; 00144 } 00145 else 00146 { 00147 int n; 00148 char buf[100]; 00149 00150 ioctl(0,FIONREAD,&n); 00151 if(n) 00152 { 00153 read(0,buf,n); 00154 buf[n] = 0; 00155 do_cmd(buf); 00156 } 00157 if(config_gdbserver_quitgdb > 1) return 0; 00158 } 00159 00160 // Run JTAG exception catcher task 00161 if (-1 == fMIPS32_EJTAG_Machine()) 00162 { 00163 // -1 == Target entered debug mode - report to GDB a user break (0x12) 00164 sprintf(ac_responsebuffer, "S%02x", ui_last_signal); 00165 fGDBRDP_SendToGDB(i_socket, &ac_responsebuffer[0], 0x03); 00166 } 00167 00168 if(quit) 00169 { 00170 // End of debug statement received - Kill this socket 00171 // and return back waiting on another GDB session. 00172 close(i_socket); 00173 printf("GDB DETACHED.\n"); 00174 return(1); 00175 } 00176 } 00177 }
| int fGDBRDP_HandleSoftwareBreakpoint | ( | char * | pc_command, | |
| unsigned int | ui_size | |||
| ) |
Definition at line 1781 of file gdbrdp.c.
References fGDBRDP_ConvertNibble(), set_soft_breakpoint(), and unset_soft_breakpoint().
Referenced by fGDBRDP_CommandInterpreter().
01782 { 01783 unsigned int ui_index; 01784 unsigned int ui_address; 01785 01786 // Calculate the address now - Its the same location for all packets. 01787 // Packet is formated <z/Z><0/1><,><ADDR><,><LENGTH> 01788 ui_address = 0x00; 01789 for (ui_index=3; *(pc_command+ui_index) != ','; ui_index++) 01790 { 01791 ui_address = ui_address << 4; 01792 ui_address = ui_address + fGDBRDP_ConvertNibble(*(pc_command+ui_index)); 01793 } 01794 01795 // Make sure address is 32bit aligned 01796 if (0x00 != (ui_address % 4)) 01797 { 01798 // Unaligned, not allowed 01799 printf("BREAKPOINT NOT ALIGNED!\n"); 01800 return(-1); 01801 } 01802 01803 // Check to see if it is a SET or REMOVE breakpoint command 01804 if ('Z' == *pc_command) // Then its a set command 01805 return set_soft_breakpoint(ui_address); 01806 else if ('z' == *pc_command) // Then its a remove command 01807 return unset_soft_breakpoint(ui_address); 01808 else // Should never reach this 01809 { 01810 // Error 01811 return(-1); 01812 } 01813 01814 // Should never reach here 01815 return(-1); 01816 }
| int fGDBRDP_InputHandler | ( | int | i_socket, | |
| char | c_byte | |||
| ) |
Definition at line 185 of file gdbrdp.c.
References dGDBRDP_ACK, dGDBRDP_CTRLC, dGDBRDP_END_OF_COMMAND, dGDBRDP_GET_CHECKSUM, dGDBRDP_GET_CHECKSUM_2, dGDBRDP_INPUT_IDLE, dGDBRDP_NACK, dGDBRDP_OUT_OF_SYNC, dGDBRDP_OUT_OF_SYNC_2, dGDBRDP_RECEIVE_COMMAND, dGDBRDP_START_OF_COMMAND, dMIPS32_EJTAG_EXIT_DEBUG_MODE, dMIPS32_EJTAG_FORCE_DEBUG_MODE, dMIPS32_EJTAG_WAIT_FOR_DEBUG_MODE, fGDBRDP_CommandInterpreter(), fGDBRDP_ConvertNibble(), fJTAGSOCK_WriteByte(), sac_commandbuffer, si_inputhandlerstate, suc_calculatedchecksum, suc_receivedchecksum, sui_numbytesreceived, and ui_ejtag_state.
Referenced by fGDBRDP_Handler().
00186 { 00187 // Input processing machine 00188 switch(si_inputhandlerstate) 00189 { 00190 case dGDBRDP_INPUT_IDLE: 00191 if (c_byte == dGDBRDP_START_OF_COMMAND) // Start of command 00192 { 00193 si_inputhandlerstate = dGDBRDP_RECEIVE_COMMAND; 00194 sui_numbytesreceived=0; 00195 suc_calculatedchecksum=0; 00196 break; 00197 } 00198 else if (c_byte == dGDBRDP_CTRLC) 00199 { 00200 if (ui_ejtag_state == dMIPS32_EJTAG_WAIT_FOR_DEBUG_MODE) 00201 { 00202 // Make the catcher perform a debug break 00203 ui_ejtag_state = dMIPS32_EJTAG_FORCE_DEBUG_MODE; 00204 return(1); 00205 } 00206 else 00207 { 00208 // Processor was IN debug mode. Shouldn't be getting this. 00209 printf("JTAGEMUL: Received CTRL-C while not running.\n"); 00210 ui_ejtag_state = dMIPS32_EJTAG_EXIT_DEBUG_MODE; 00211 return(-1); 00212 } 00213 } 00214 else if (c_byte == dGDBRDP_END_OF_COMMAND) // Somehow in the middle of a command 00215 { 00216 si_inputhandlerstate = dGDBRDP_OUT_OF_SYNC; 00217 break; 00218 } 00219 // All other data just throw away (out of sync) 00220 break; 00221 00222 case dGDBRDP_OUT_OF_SYNC: 00223 // When out of sync we need to receive the 2 checksum 00224 // bytes and then send a NACK. This is the first byte. 00225 si_inputhandlerstate = dGDBRDP_OUT_OF_SYNC_2; 00226 break; 00227 00228 case dGDBRDP_OUT_OF_SYNC_2: 00229 // Last byte of checksum of a command that we are not 00230 // in sync with. Just send the NACK. 00231 fJTAGSOCK_WriteByte(i_socket, dGDBRDP_NACK); 00232 si_inputhandlerstate = dGDBRDP_INPUT_IDLE; 00233 break; 00234 00235 case dGDBRDP_RECEIVE_COMMAND: 00236 // Receive data into buffer until '#' is received 00237 if (c_byte == dGDBRDP_END_OF_COMMAND) 00238 { 00239 si_inputhandlerstate = dGDBRDP_GET_CHECKSUM; 00240 break; 00241 } 00242 00243 // New data received 00244 suc_calculatedchecksum = suc_calculatedchecksum + c_byte; 00245 sac_commandbuffer[sui_numbytesreceived++]=c_byte; 00246 break; 00247 00248 case dGDBRDP_GET_CHECKSUM: 00249 // Receive the first nibble of the checksum 00250 suc_receivedchecksum = fGDBRDP_ConvertNibble(c_byte) << 4; 00251 si_inputhandlerstate = dGDBRDP_GET_CHECKSUM_2; 00252 break; 00253 00254 case dGDBRDP_GET_CHECKSUM_2: 00255 // Receive the second nibble of the checksum and check it. 00256 suc_receivedchecksum = suc_receivedchecksum + fGDBRDP_ConvertNibble(c_byte); 00257 00258 // Back to idle regardless of checksum 00259 si_inputhandlerstate = dGDBRDP_INPUT_IDLE; 00260 00261 if (suc_receivedchecksum != suc_calculatedchecksum) 00262 { 00263 // Bad checksum calculation - Report NACK 00264 fJTAGSOCK_WriteByte(i_socket, dGDBRDP_NACK); 00265 break; 00266 } 00267 00268 // We have a valid command, ACK it and run the handler. 00269 fJTAGSOCK_WriteByte(i_socket, dGDBRDP_ACK); 00270 return(fGDBRDP_CommandInterpreter(i_socket, &sac_commandbuffer[0], sui_numbytesreceived)); 00271 break; 00272 } 00273 00274 return(1); 00275 }
| void fGDBRDP_SendToGDB | ( | int | i_socket, | |
| char * | pc_message, | |||
| unsigned int | ui_length | |||
| ) |
Definition at line 945 of file gdbrdp.c.
References dGDBRDP_END_OF_COMMAND, dGDBRDP_START_OF_COMMAND, fGDBRDP_CalculateNibble(), fJTAGSOCK_WriteByte(), and Z_DEBUG.
Referenced by fGDBRDP_CommandInterpreter(), and fGDBRDP_Handler().
00946 { 00947 unsigned char uc_calculatedchecksum; 00948 00949 // Start checksum at 0 00950 uc_calculatedchecksum = 0; 00951 00952 Z_DEBUG 00953 // Send the leader 00954 fJTAGSOCK_WriteByte(i_socket, dGDBRDP_START_OF_COMMAND); 00955 00956 Z_DEBUG 00957 while(ui_length--) 00958 { 00959 Z_DEBUG 00960 // Send each byte in the message while calculating checksum. 00961 fJTAGSOCK_WriteByte(i_socket, *pc_message); 00962 Z_DEBUG 00963 uc_calculatedchecksum = uc_calculatedchecksum + *pc_message++; 00964 } 00965 00966 Z_DEBUG 00967 // Send the trailer 00968 fJTAGSOCK_WriteByte(i_socket, dGDBRDP_END_OF_COMMAND); 00969 Z_DEBUG 00970 00971 // Send the upper nibble of the checksum 00972 fJTAGSOCK_WriteByte(i_socket, fGDBRDP_CalculateNibble(uc_calculatedchecksum >> 4)); 00973 Z_DEBUG 00974 00975 // Send the lower nibble of the checksum 00976 fJTAGSOCK_WriteByte(i_socket, fGDBRDP_CalculateNibble(uc_calculatedchecksum & 0x0F)); 00977 Z_DEBUG 00978 00979 // Forget about the ACK or NACK - Hope this is good enough. Time will tell. The input 00980 // handler will throw out the ack/nack while waiting on a leader. 00981 return; 00982 }
| int help_access | ( | unsigned int | ui_address, | |
| int | andlo0, | |||
| int | orlo0, | |||
| int * | entrylo0 | |||
| ) |
Definition at line 277 of file gdbrdp.c.
References aui_readregisters_code, fMIPS32_ExecuteDebugModule(), and tgt_compile.
Referenced by fGDBRDP_CommandInterpreter().
00278 { 00279 unsigned int codebuf[] = tgt_compile( 00280 ".set noat;\n" 00281 ".set mips3;\n" 00282 "1:\n" 00283 "mtc0 ra, $31;\n" 00284 "bal 2f;\n" 00285 "nop;\n" 00286 ".space 44;\n" 00287 "2:sw $1, 0(ra);\n" 00288 "sw $2, 4(ra);\n" 00289 00290 "mfc0 $2, c0_index;\n" 00291 "sw $2, 8(ra);\n" 00292 00293 "mfc0 $2, c0_entryhi;\n" 00294 "sw $2, 12(ra);\n" 00295 00296 "mfc0 $2, c0_entrylo0;\n" 00297 "sw $2, 16(ra);\n" 00298 00299 00300 "mfc0 $2, c0_entrylo1;\n" 00301 "sw $2, 20(ra);\n" 00302 00303 "mfc0 $2, c0_entryhi;\n" 00304 "andi $2,0xff;\n" 00305 "lw $1, 24(ra);\n" /*input address*/ 00306 "ori $1,0x1fff;\n" 00307 "xori $1,0x1fff;\n" 00308 "or $2,$1;\n" 00309 "mtc0 $2,c0_entryhi;\n" 00310 "tlbp;\n" 00311 00312 "mfc0 $2, c0_index;\n" /*not in tlb,just ignore*/ 00313 "sw $2, 28(ra);\n" /*return index*/ 00314 "slt $2,$2,$0;\n" 00315 "bnez $2,2f;\n" 00316 "nop;\n" 00317 "tlbr;\n" 00318 "mfc0 $2,c0_entrylo0;\n" 00319 "sw $2, 32(ra);\n" /*return lo0*/ 00320 "and $1,$2,2;\n" 00321 "beqz $1,2f;\n" 00322 "nop;\n" 00323 "sw $0,36(ra);\n" /*return success*/ 00324 "lw $1,40(ra);\n" /*andlo0*/ 00325 "and $2,$1;\n" 00326 "lw $1,44(ra);\n" /*orlo0*/ 00327 "or $2,$1;\n" 00328 "mtc0 $2,c0_entrylo0;\n" 00329 "tlbwi;\n" 00330 "2:lw $2, 20(ra);\n" 00331 "mtc0 $2, c0_entrylo1;\n" 00332 00333 "lw $2, 16(ra);\n" 00334 "mtc0 $2, c0_entrylo0;\n" 00335 00336 "lw $2, 12(ra);\n" 00337 "mtc0 $2, c0_entryhi;\n" 00338 00339 "lw $2, 8(ra);\n" 00340 "mtc0 $2, c0_index;\n" 00341 00342 "lw $2, 4(ra);\n" 00343 "lw $1, 0(ra);\n" 00344 "mfc0 ra, $31;\n" 00345 "b 1b;\n" 00346 "nop;\n" 00347 ); 00348 00349 codebuf[9] = ui_address; 00350 codebuf[12] = 1; /*1:access error,0:access ok*/ 00351 codebuf[13] = andlo0; 00352 codebuf[14] = orlo0; 00353 fMIPS32_ExecuteDebugModule(aui_readregisters_code,sizeof(codebuf),1); 00354 if(entrylo0) 00355 *entrylo0 = codebuf[11]; 00356 return codebuf[12]; 00357 }
| mycmd_init | ( | unsi | , | |
| cmd_si | , | |||
| "unsi" | , | |||
| "unset single step" | ||||
| ) |
| mycmd_init | ( | si | , | |
| cmd_si | , | |||
| "si" | , | |||
| "single step" | ||||
| ) |
| mycmd_init | ( | unawatch | , | |
| cmd_awatch | , | |||
| "uawatch addr " | [size], | |||
| "unset databeakpoint on addr for all access" | ||||
| ) |
| mycmd_init | ( | awatch | , | |
| cmd_awatch | , | |||
| "awatch addr " | [size], | |||
| "set databeakpoint on addr for all access" | ||||
| ) |
| mycmd_init | ( | unrwatch | , | |
| cmd_rwatch | , | |||
| "unrwatch addr " | [size], | |||
| "unset databeakpoint on addr for read access" | ||||
| ) |
| mycmd_init | ( | rwatch | , | |
| cmd_rwatch | , | |||
| "rwatch addr " | [size], | |||
| "set databeakpoint on addr for read access" | ||||
| ) |
| mycmd_init | ( | unwatch | , | |
| cmd_watch | , | |||
| "unwatch addr " | [size], | |||
| "unset databeakpoint on addr for write access" | ||||
| ) |
| mycmd_init | ( | watch | , | |
| cmd_watch | , | |||
| "watch addr " | [size], | |||
| "set databeakpoint on addr for write access" | ||||
| ) |
| mycmd_init | ( | unhb | , | |
| cmd_hb | , | |||
| "unbh addr" | , | |||
| "unset hardbeakpoint on addr" | ||||
| ) |
| mycmd_init | ( | hb | , | |
| cmd_hb | , | |||
| "bh addr" | , | |||
| "set hardbeakpoint on addr" | ||||
| ) |
| mycmd_init | ( | unb | , | |
| cmd_b | , | |||
| "unb addr" | , | |||
| "unset softbeakpoint on addr" | ||||
| ) |
| mycmd_init | ( | b | , | |
| cmd_b | , | |||
| "b addr" | , | |||
| "set softbeakpoint on addr" | ||||
| ) |
| myconfig_init | ( | "gdbserver.quitgdb" | , | |
| config_gdbserver_quitgdb | , | |||
| CONFIG_I | , | |||
| "quit gdb" | ||||
| ) |
| myconfig_init | ( | "gdbserver.compareadata.val" | , | |
| config_gdbserver_comparedata_val | , | |||
| CONFIG_I | , | |||
| "gdbserver compare data val" | ||||
| ) |
| myconfig_init | ( | "gdbserver.compareadata" | , | |
| config_gdbserver_comparedata | , | |||
| CONFIG_I | , | |||
| "gdbserver compare data" | ||||
| ) |
| myconfig_init | ( | "gdbserver.compareasid" | , | |
| config_gdbserver_compareasid | , | |||
| CONFIG_I | , | |||
| "gdbserver compare asid" | ||||
| ) |
| int set_data_breakpoint | ( | unsigned int | ui_address, | |
| unsigned int | ui_addrsize, | |||
| int | action | |||
| ) |
Definition at line 1226 of file gdbrdp.c.
References ACTION_READ, ACTION_WRITE, config_gdbserver_compareasid, config_gdbserver_comparedata, config_gdbserver_comparedata_val, dMIPS32_DATA_BKPT_ADDR, dMIPS32_MAX_HARDWARE_BKPTS, tgt_exec, _hw_breakpoint_.uc_enabled, _hw_breakpoint_.ui_address, and ui_datamem.
Referenced by cmd_awatch(), cmd_rwatch(), cmd_watch(), and fGDBRDP_HandleHardwareDataBreakpoint().
01227 { 01228 // action: 01229 // 1: watch wrote 01230 // 2: rwatch read 01231 // 3: accessed 01232 #define ACTION_WRITE 1 01233 #define ACTION_READ 2 01234 #define ACTION_ALL 3 01235 01236 unsigned int ui_index; 01237 // Set breakpoint - First check to make sure this address doesn't already 01238 // have a software breakpoint. We only allow 1 breakpoint per address. 01239 for(ui_index=0; ui_index<dMIPS32_MAX_HARDWARE_BKPTS; ui_index++) 01240 { 01241 if (hwb_data_array[ui_index].uc_enabled) 01242 { 01243 // Breakpoint is enabled, check to see the address 01244 if (hwb_data_array[ui_index].ui_address == ui_address) 01245 { 01246 // Bad bad bad! Already have a breakpoint at this address! 01247 printf("DUPLICATE HARDWARE BREAKPOINT!\n"); 01248 return(-1); 01249 } 01250 } 01251 } 01252 01253 // OK - Breakpoint is NOT a duplicate - Find an open slot 01254 for(ui_index=0; ui_index<dMIPS32_MAX_HARDWARE_BKPTS; ui_index++) 01255 { 01256 if (!(hwb_data_array[ui_index].uc_enabled)) 01257 { 01258 unsigned int tmpdbs,tmpdbcn,tmpdbm,value,asid; 01259 // Ok - This is an open slot - Mark enabled - Read old value - 01260 // Write new value - Store address 01261 hwb_data_array[ui_index].uc_enabled = 0x01; 01262 hwb_data_array[ui_index].ui_address = ui_address; 01263 01264 if(config_gdbserver_compareasid) 01265 { 01266 tgt_exec(\ 01267 ".set noat;\n" \ 01268 "1:\n" \ 01269 "mtc0 $15, $31;\n" \ 01270 "lui $15,0xFF20;\n" \ 01271 "sw $2, 0x1fc($15);\n" \ 01272 "mfc0 $2, $10;\n" \ 01273 "sw $2, ($15);\n" \ 01274 "lw $2, 0x1fc($15);\n" \ 01275 "mfc0 $15, $31;\n" \ 01276 "b 1b;\n" \ 01277 "nop;\n" \ 01278 ,0x80000); 01279 01280 asid=ui_datamem[0]&0xff; 01281 } 01282 01283 01284 value = config_gdbserver_comparedata_val; 01285 01286 01287 tmpdbcn=1; //set BE 01288 tmpdbm=0x00000000; //all address bit are compared 01289 switch (ui_addrsize) { 01290 case 4: 01291 break; 01292 case 2: 01293 switch (ui_address%4){ 01294 case 0: 01295 tmpdbcn=tmpdbcn|((0xf^0x3)<<14); //BAI; ignore access on which bytes 1100 01296 tmpdbcn=tmpdbcn|((0xf^0x3)<<4); //BLM 01297 break; 01298 case 2: 01299 tmpdbcn=tmpdbcn|((0xf^0xc)<<14); //BAI; 01300 tmpdbcn=tmpdbcn|((0xf^0xc)<<4); //BLM 01301 break; 01302 default: 01303 printf("half word insert db went error!\n"); 01304 return 0; 01305 } 01306 break; 01307 case 1: 01308 switch (ui_address%4) { 01309 case 0: 01310 tmpdbcn=tmpdbcn|((0xf^0x1)<<14); //BAI 01311 tmpdbcn=tmpdbcn|((0xf^0x1)<<4); //BLM 01312 break; 01313 case 1: 01314 tmpdbcn=tmpdbcn|((0xf^0x2)<<14); //BAI 01315 tmpdbcn=tmpdbcn|((0xf^0x2)<<4); //BLM 01316 //value = value << 8; 01317 break; 01318 case 2: 01319 tmpdbcn=tmpdbcn|((0xf^0x4)<<14); //BAI 01320 tmpdbcn=tmpdbcn|((0xf^0x4)<<4); //BLM 01321 //value = value << 16; 01322 break; 01323 case 3: 01324 tmpdbcn=tmpdbcn|((0xf^0x8)<<14); //BAI 01325 tmpdbcn=tmpdbcn|((0xf^0x8)<<4); //BLM 01326 //value = value << 24; 01327 break; 01328 default: 01329 printf("something went error\n"); 01330 } 01331 break; 01332 default: 01333 printf("insert db went wrong! \n"); 01334 break; 01335 }; 01336 01337 if(config_gdbserver_compareasid) 01338 tmpdbcn |= (1<<23); //comare asid also 01339 if(!config_gdbserver_comparedata) 01340 tmpdbcn |= (0xff<<4); //BAI, byte access ignore data bus 01341 if(action == ACTION_WRITE) 01342 tmpdbcn |= (1<<12); //NOLB 01343 else if(action == ACTION_READ) 01344 tmpdbcn |= (1<<13); //NOSB 01345 01346 // Now we need to set the enable bit in the watch register which is 01347 // in bit 2 with the address. Just OR this bit right into the register. 01348 ui_datamem[0] = dMIPS32_DATA_BKPT_ADDR(ui_index); 01349 ui_datamem[1] = ui_address; 01350 ui_datamem[2] = tmpdbm; 01351 ui_datamem[3] = asid; 01352 ui_datamem[4] = tmpdbcn; 01353 ui_datamem[5] = value; 01354 01355 tgt_exec(\ 01356 ".set noat;\n" \ 01357 "1:\n" \ 01358 "mtc0 $15, $31;\n" \ 01359 "lui $15,0xFF20;\n" \ 01360 "sw $2, 0x1fc($15);\n" \ 01361 "sw $3, 0x1fc($15);\n" \ 01362 "lw $2, ($15);\n" \ 01363 "lw $3, 0x4($15);\n" \ 01364 "sw $3, ($2);\n" \ 01365 "lw $3, 8($15);\n" \ 01366 "sw $3, 0x8($2);\n" \ 01367 "lw $3, 0xc($15);\n" \ 01368 "sw $3, 0x10($2);\n" \ 01369 "lw $3, 0x10($15);\n" \ 01370 "sw $3, 0x18($2);\n" \ 01371 "lw $3, 0x14($15);\n" \ 01372 "sw $3, 0x20($2);\n" \ 01373 "lw $3, 0x1fc($15);\n" \ 01374 "lw $2, 0x1fc($15);\n" \ 01375 "mfc0 $15, $31;\n" \ 01376 "b 1b;\n" \ 01377 "nop;\n" \ 01378 ,0x80000); 01379 return(1); // Success! 01380 } 01381 } 01382 01383 // No open slots! 01384 printf("NO OPEN HARDWARE BREAKPOINT SLOTS!\n"); 01385 return(-1); 01386 }
| int set_inst_breakpoint | ( | unsigned int | ui_address | ) |
Definition at line 1050 of file gdbrdp.c.
References config_gdbserver_compareasid, dMIPS32_INST_BKPT_ADDR, dMIPS32_MAX_HARDWARE_BKPTS, tgt_exec, _hw_breakpoint_.uc_enabled, _hw_breakpoint_.ui_address, and ui_datamem.
Referenced by cmd_hb(), and fGDBRDP_HandleHardwareInstBreakpoint().
01051 { 01052 unsigned int ui_index; 01053 unsigned int tmpibc,asid; 01054 // Set breakpoint - First check to make sure this address doesn't already 01055 // have a software breakpoint. We only allow 1 breakpoint per address. 01056 for(ui_index=0; ui_index<dMIPS32_MAX_HARDWARE_BKPTS; ui_index++) 01057 { 01058 if (hwb_inst_array[ui_index].uc_enabled) 01059 { 01060 // Breakpoint is enabled, check to see the address 01061 if (hwb_inst_array[ui_index].ui_address == ui_address) 01062 { 01063 // Bad bad bad! Already have a breakpoint at this address! 01064 printf("DUPLICATE HARDWARE BREAKPOINT!\n"); 01065 return(-1); 01066 } 01067 } 01068 } 01069 01070 // OK - Breakpoint is NOT a duplicate - Find an open slot 01071 for(ui_index=0; ui_index<dMIPS32_MAX_HARDWARE_BKPTS; ui_index++) 01072 { 01073 if (!(hwb_inst_array[ui_index].uc_enabled)) 01074 { 01075 // Ok - This is an open slot - Mark enabled - Read old value - 01076 // Write new value - Store address 01077 hwb_inst_array[ui_index].uc_enabled = 0x01; 01078 hwb_inst_array[ui_index].ui_address = ui_address; 01079 01080 if(config_gdbserver_compareasid) 01081 { 01082 tgt_exec(\ 01083 ".set noat;\n" \ 01084 "1:\n" \ 01085 "mtc0 $15, $31;\n" \ 01086 "lui $15,0xFF20;\n" \ 01087 "sw $2, 0x1fc($15);\n" \ 01088 "mfc0 $2, $10;\n" \ 01089 "sw $2, ($15);\n" \ 01090 "lw $2, 0x1fc($15);\n" \ 01091 "mfc0 $15, $31;\n" \ 01092 "b 1b;\n" \ 01093 "nop;\n" \ 01094 ,0x80000); 01095 01096 asid=ui_datamem[0]&0xff; 01097 } 01098 01099 tmpibc = 1; 01100 if(config_gdbserver_compareasid) 01101 tmpibc |= 1<<23; 01102 01103 // Now we need to set the enable bit in the watch register which is 01104 // in bit 2 with the address. Just OR this bit right into the register. 01105 ui_datamem[0] =dMIPS32_INST_BKPT_ADDR(ui_index); //set 1 to this address to set BE 01106 ui_datamem[1] = ui_address; 01107 ui_datamem[2] = asid; 01108 ui_datamem[3] = tmpibc; 01109 01110 // Write out the breakpoint registers 01111 tgt_exec(\ 01112 ".set noat;\n" \ 01113 "1:\n" \ 01114 "mtc0 $15, $31;\n" \ 01115 "lui $15,0xFF20;\n" \ 01116 "sw $2, 0x1fc($15);\n" \ 01117 "sw $3, 0x1fc($15);\n" \ 01118 "lw $2, ($15);\n" \ 01119 "lw $3, 4($15);\n" \ 01120 "sw $3, ($2);\n" \ 01121 "lw $3, 8($15);\n" \ 01122 "sw $3, 0x10($2);\n" \ 01123 "lw $3, 12($15);\n" \ 01124 "sw $3, 0x18($2);\n" \ 01125 "lw $3, 0x1fc($15);\n" \ 01126 "lw $2, 0x1fc($15);\n" \ 01127 "mfc0 $15, $31;\n" \ 01128 "b 1b;\n" \ 01129 "nop;\n" \ 01130 ,0x80000); 01131 01132 return(1); // Success! 01133 } 01134 } 01135 01136 // No open slots! 01137 printf("NO OPEN HARDWARE BREAKPOINT SLOTS!\n"); 01138 return(-1); 01139 }
| int set_soft_breakpoint | ( | unsigned | ui_address | ) |
Definition at line 1461 of file gdbrdp.c.
References dGDBRDP_MAX_SW_BREAKPOINTS, dMIPS32_SW_BREAKPOINT_INSTRUCTION, tgt_exec, _sw_breakpoint_.uc_enabled, _sw_breakpoint_.ui_address, ui_datamem, ui_fifomem, _sw_breakpoint_.ui_original_memory, and uififo_raddr.
Referenced by cmd_b(), and fGDBRDP_HandleSoftwareBreakpoint().
01462 { 01463 unsigned int ui_index; 01464 // Set breakpoint - First check to make sure this address doesn't already 01465 // have a software breakpoint. We only allow 1 breakpoint per address. 01466 for(ui_index=0; ui_index<dGDBRDP_MAX_SW_BREAKPOINTS; ui_index++) 01467 { 01468 if (swb_array[ui_index].uc_enabled) 01469 { 01470 // Breakpoint is enabled, check to see the address 01471 if (swb_array[ui_index].ui_address == ui_address) 01472 { 01473 // Bad bad bad! Already have a breakpoint at this address! 01474 printf("DUPLICATE BREAKPOINT!\n"); 01475 return(-1); 01476 } 01477 } 01478 } 01479 01480 // OK - Breakpoint is NOT a duplicate - Find an open slot 01481 for(ui_index=0; ui_index<dGDBRDP_MAX_SW_BREAKPOINTS; ui_index++) 01482 { 01483 if (!(swb_array[ui_index].uc_enabled)) 01484 { 01485 // Ok - This is an open slot - Mark enabled - Read old value - 01486 // Write new value - Store address 01487 swb_array[ui_index].uc_enabled = 0x01; 01488 01489 ui_datamem[0]=ui_address; 01490 ui_datamem[1] = dMIPS32_SW_BREAKPOINT_INSTRUCTION; 01491 if(ui_address >= 0x80000000 && ui_address < 0xc0000000) 01492 { 01493 tgt_exec(\ 01494 ".set noat;\n" \ 01495 ".set mips3;\n" \ 01496 "1:\n" \ 01497 "mtc0 $15, $31;\n" \ 01498 "lui $15,0xFF20;\n" \ 01499 "sw $1, 0x1fc($15);\n" \ 01500 "sw $2, 0x1fc($15);\n" \ 01501 "lw $2, ($15);\n" \ 01502 "lw $1, ($2);\n" \ 01503 "sw $1, 8($2);\n" \ 01504 "lw $1, 4($15);\n" \ 01505 "sw $1, ($2);\n" \ 01506 "cache 0x15,($2);\n" \ 01507 "cache 1, 0($2);\n" \ 01508 "cache 1, 1($2);\n" \ 01509 "cache 1, 2($2);\n" \ 01510 "cache 1, 3($2);\n" \ 01511 "cache 0x10,($2);\n" \ 01512 "cache 0, ($2);\n" \ 01513 "cache 0, 1($2);\n" \ 01514 "cache 0, 2($2);\n" \ 01515 "cache 0, 3($2);\n" \ 01516 "lw $2, 0x1fc($15);\n" \ 01517 "lw $1, 0x1fc($15);\n" \ 01518 "mfc0 $15, $31;\n" \ 01519 "b 1b;\n" \ 01520 "nop;\n" \ 01521 ,0x80000); 01522 swb_array[ui_index].ui_original_memory = ui_datamem[2]; 01523 swb_array[ui_index].ui_address = ui_address; 01524 } 01525 else 01526 { 01527 uififo_raddr = 0; 01528 ui_datamem[3] = 1; 01529 tgt_exec( 01530 ".set noat;\n" 01531 ".set mips3;\n" 01532 "1:\n" 01533 "mtc0 $15, $31;\n" 01534 "lui $15,0xFF20;\n" 01535 "sw $1, 0x1fc($15);\n" 01536 "sw $2, 0x1fc($15);\n" 01537 01538 "mfc0 $2, c0_index;\n" 01539 "sw $2, 0x1fc($15);\n" 01540 01541 "mfc0 $2, c0_entryhi;\n" 01542 "sw $2, 0x1fc($15);\n" 01543 01544 "mfc0 $2, c0_entrylo0;\n" 01545 "sw $2, 0x1fc($15);\n" 01546 01547 01548 "mfc0 $2, c0_entrylo1;\n" 01549 "sw $2, 0x1fc($15);\n" 01550 01551 "mfc0 $2, c0_entryhi;\n" 01552 "andi $2,0xff;\n" 01553 "lw $1, ($15);\n" 01554 "ori $1,0x1fff;\n" 01555 "xori $1,0x1fff;\n" 01556 "or $2,$1;\n" 01557 "mtc0 $2,c0_entryhi;\n" 01558 "tlbp;\n" 01559 01560 "mfc0 $2, c0_index;\n" /*not in tlb,just ignore*/ 01561 "sw $2, 0x1f8($15);\n" 01562 "slt $2,$2,$0;\n" 01563 "bnez $2,2f;\n" 01564 "nop;\n" 01565 "tlbr;\n" 01566 "mfc0 $2,c0_entrylo0;\n" 01567 "sw $2, 0x1f8($15);\n" 01568 "and $1,$2,2;\n" 01569 "beqz $1,2f;\n" 01570 "nop;\n" 01571 "sw $2, 0x1fc($15);\n" 01572 "or $2,4;\n" 01573 "mtc0 $2,c0_entrylo0;\n" 01574 "tlbwi;\n" 01575 01576 "sw $0, 12($15);\n" /*Success*/ 01577 "lw $2, ($15);\n" 01578 "lw $1, ($2);\n" 01579 "sw $1, 8($15);\n" 01580 "lw $1, 4($15);\n" 01581 "sw $1, ($2);\n" 01582 "cache 0x15,($2);\n" 01583 "cache 1, 0($2);\n" 01584 "cache 1, 1($2);\n" 01585 "cache 1, 2($2);\n" 01586 "cache 1, 3($2);\n" 01587 "cache 0x10,($2);\n" 01588 "cache 0, ($2);\n" 01589 "cache 0, 1($2);\n" 01590 "cache 0, 2($2);\n" 01591 "cache 0, 3($2);\n" 01592 01593 "lw $2, 0x1fc($15);\n" 01594 "mtc0 $2, c0_entrylo0;\n" 01595 "tlbwi;\n" 01596 01597 "2:lw $2, 0x1fc($15);\n" 01598 "mtc0 $2, c0_entrylo1;\n" 01599 01600 "lw $2, 0x1fc($15);\n" 01601 "mtc0 $2, c0_entrylo0;\n" 01602 01603 "lw $2, 0x1fc($15);\n" 01604 "mtc0 $2, c0_entryhi;\n" 01605 01606 "lw $2, 0x1fc($15);\n" 01607 "mtc0 $2, c0_index;\n" 01608 01609 "lw $2, 0x1fc($15);\n" 01610 "lw $1, 0x1fc($15);\n" 01611 "mfc0 $15, $31;\n" 01612 "b 1b;\n" 01613 "nop;\n" 01614 ,0x80000); 01615 printf("index=%x,c0_datalo0=%x\n",ui_fifomem[0],ui_fifomem[1]); 01616 if(!ui_datamem[3]) 01617 { 01618 swb_array[ui_index].ui_original_memory = ui_datamem[2]; 01619 swb_array[ui_index].ui_address = ui_address; 01620 } 01621 } 01622 01623 01624 return(1); // Success! 01625 } 01626 } 01627 printf("NO OPEN SLOTS!\n"); 01628 return -2; 01629 }
| int unset_data_breakpoint | ( | unsigned int | ui_address | ) |
Definition at line 1388 of file gdbrdp.c.
References dMIPS32_DATA_BKPT_CONTROL, dMIPS32_DATA_BKPT_STATUS, dMIPS32_MAX_HARDWARE_BKPTS, tgt_exec, _hw_breakpoint_.uc_enabled, and ui_datamem.
Referenced by cmd_awatch(), cmd_rwatch(), cmd_watch(), and fGDBRDP_HandleHardwareDataBreakpoint().
01389 { 01390 unsigned int ui_index; 01391 // Search for the breakpoint 01392 for(ui_index=0; ui_index<dMIPS32_MAX_HARDWARE_BKPTS; ui_index++) 01393 { 01394 if (hwb_data_array[ui_index].uc_enabled) 01395 { 01396 if (hwb_data_array[ui_index].ui_address == ui_address) 01397 { 01398 // Found the breakpoint - Mark unused - Delete - Disable 01399 hwb_data_array[ui_index].uc_enabled = 0x00; 01400 01401 ui_datamem[0] = dMIPS32_DATA_BKPT_STATUS; //clear BS[14:0] on DBS 01402 ui_datamem[1] = dMIPS32_DATA_BKPT_CONTROL(ui_index); //set 0 to this address to disable BE 01403 // Write out the breakpoint registers 01404 tgt_exec(\ 01405 ".set noat;\n" \ 01406 "1:\n" \ 01407 "mtc0 $15, $31;\n" \ 01408 "lui $15,0xFF20;\n" \ 01409 "sw $2, 0x1fc($15);\n" \ 01410 "lw $2, ($15);\n" \ 01411 "sw $0, ($2);\n" \ 01412 "lw $2, 4($15);\n" \ 01413 "sw $0, ($2);\n" \ 01414 "lw $2, 0x1fc($15);\n" \ 01415 "mfc0 $15, $31;\n" \ 01416 "b 1b;\n" \ 01417 "nop;\n" \ 01418 ,0x80000); 01419 01420 return(1); 01421 } 01422 } 01423 } 01424 01425 // Never found the breakpoint 01426 printf("BREAKPOINT NOT FOUND!\n"); 01427 return(-1); 01428 }
| int unset_inst_breakpoint | ( | unsigned int | ui_address | ) |
Definition at line 1141 of file gdbrdp.c.
References dMIPS32_INST_BKPT_ADDR, dMIPS32_INST_BKPT_CONTROL, dMIPS32_MAX_HARDWARE_BKPTS, tgt_exec, _hw_breakpoint_.uc_enabled, and ui_datamem.
Referenced by cmd_hb(), and fGDBRDP_HandleHardwareInstBreakpoint().
01142 { 01143 unsigned int ui_index; 01144 // Search for the breakpoint 01145 for(ui_index=0; ui_index<dMIPS32_MAX_HARDWARE_BKPTS; ui_index++) 01146 { 01147 if (hwb_inst_array[ui_index].uc_enabled) 01148 { 01149 if (hwb_inst_array[ui_index].ui_address == ui_address) 01150 { 01151 // Found the breakpoint - Mark unused - Delete - Disable 01152 hwb_inst_array[ui_index].uc_enabled = 0x00; 01153 01154 ui_datamem[0] =dMIPS32_INST_BKPT_CONTROL(ui_index); //set 1 to this address to set BE 01155 ui_datamem[1] = 0; 01156 ui_datamem[2] = dMIPS32_INST_BKPT_ADDR(ui_index); 01157 ui_datamem[3] = ui_address; 01158 // Write out the breakpoint registers 01159 tgt_exec(\ 01160 ".set noat;\n" \ 01161 "1:\n" \ 01162 "mtc0 $15, $31;\n" \ 01163 "lui $15,0xFF20;\n" \ 01164 "sw $2, 0x1fc($15);\n" \ 01165 "sw $3, 0x1fc($15);\n" \ 01166 "lw $2, ($15);\n" \ 01167 "lw $3, 0x4($15);\n" \ 01168 "sw $3, ($2);\n" \ 01169 "lw $2, 8($15);\n" \ 01170 "lw $3, 0xc($15);\n" \ 01171 "sw $3, ($2);\n" \ 01172 "lw $3, 0x1fc($15);\n" \ 01173 "lw $2, 0x1fc($15);\n" \ 01174 "mfc0 $15, $31;\n" \ 01175 "b 1b;\n" \ 01176 "nop;\n" \ 01177 ,0x80000); 01178 01179 return(1); 01180 } 01181 } 01182 } 01183 01184 // Never found the breakpoint 01185 printf("BREAKPOINT NOT FOUND!\n"); 01186 return(-1); 01187 }
| int unset_soft_breakpoint | ( | unsigned | ui_address | ) |
Definition at line 1631 of file gdbrdp.c.
References dGDBRDP_MAX_SW_BREAKPOINTS, tgt_exec, _sw_breakpoint_.uc_enabled, ui_datamem, ui_fifomem, _sw_breakpoint_.ui_original_memory, and uififo_raddr.
Referenced by cmd_b(), and fGDBRDP_HandleSoftwareBreakpoint().
01632 { 01633 unsigned int ui_index; 01634 // Search for the breakpoint 01635 for(ui_index=0; ui_index<dGDBRDP_MAX_SW_BREAKPOINTS; ui_index++) 01636 { 01637 if (swb_array[ui_index].uc_enabled) 01638 { 01639 if (swb_array[ui_index].ui_address == ui_address) 01640 { 01641 // Found the breakpoint - Replace memory - Mark unused 01642 ui_datamem[0] = ui_address; 01643 ui_datamem[1] = swb_array[ui_index].ui_original_memory; 01644 01645 if(ui_address >= 0x80000000 && ui_address < 0xc0000000) 01646 { 01647 tgt_exec(\ 01648 ".set noat;\n" \ 01649 ".set mips3;\n" \ 01650 "1:\n" \ 01651 "mtc0 $15, $31;\n" \ 01652 "lui $15,0xFF20;\n" \ 01653 "sw $1, 0x1fc($15);\n" \ 01654 "sw $2, 0x1fc($15);\n" \ 01655 "lw $2, ($15);\n" \ 01656 "lw $1, 4($15);\n" \ 01657 "sw $1, ($2);\n" \ 01658 "cache 0x15,($2);\n" \ 01659 "cache 1, 0($2);\n" \ 01660 "cache 1, 1($2);\n" \ 01661 "cache 1, 2($2);\n" \ 01662 "cache 1, 3($2);\n" \ 01663 "cache 0x10,($2);\n" \ 01664 "cache 0, ($2);\n" \ 01665 "cache 0, 1($2);\n" \ 01666 "cache 0, 2($2);\n" \ 01667 "cache 0, 3($2);\n" \ 01668 "lw $2, 0x1fc($15);\n" \ 01669 "lw $1, 0x1fc($15);\n" \ 01670 "mfc0 $15, $31;\n" \ 01671 "b 1b;\n" \ 01672 "nop;\n" \ 01673 ,0x80000); 01674 } 01675 else 01676 { 01677 uififo_raddr = 0; 01678 tgt_exec( 01679 ".set noat;\n" 01680 ".set mips3;\n" 01681 "1:\n" 01682 "mtc0 $15, $31;\n" 01683 "lui $15,0xFF20;\n" 01684 "sw $1, 0x1fc($15);\n" 01685 "sw $2, 0x1fc($15);\n" 01686 01687 "mfc0 $2, c0_index;\n" 01688 "sw $2, 0x1fc($15);\n" 01689 01690 "mfc0 $2, c0_entryhi;\n" 01691 "sw $2, 0x1fc($15);\n" 01692 01693 "mfc0 $2, c0_entrylo0;\n" 01694 "sw $2, 0x1fc($15);\n" 01695 01696 01697 "mfc0 $2, c0_entrylo1;\n" 01698 "sw $2, 0x1fc($15);\n" 01699 01700 "mfc0 $2, c0_entryhi;\n" 01701 "andi $2,0xff;\n" 01702 "lw $1, ($15);\n" 01703 "ori $1,0x1fff;\n" 01704 "xori $1,0x1fff;\n" 01705 "or $2,$1;\n" 01706 "mtc0 $2,c0_entryhi;\n" 01707 "tlbp;\n" 01708 01709 "mfc0 $2, c0_index;\n" /*not in tlb,just ignore*/ 01710 "sw $2, 0x1f8($15);\n" 01711 "slt $2,$2,$0;\n" 01712 "bnez $2,2f;\n" 01713 "nop;\n" 01714 "tlbr;\n" 01715 "mfc0 $2,c0_entrylo0;\n" 01716 "sw $2, 0x1f8($15);\n" 01717 "and $1,$2,2;\n" 01718 "beqz $1,2f;\n" 01719 "nop;\n" 01720 "sw $2, 0x1fc($15);\n" 01721 "or $2,4;\n" 01722 "mtc0 $2,c0_entrylo0;\n" 01723 "tlbwi;\n" 01724 01725 "lw $2, ($15);\n" 01726 "lw $1, 4($15);\n" 01727 "sw $1, ($2);\n" 01728 "cache 0x15,($2);\n" 01729 "cache 1, 0($2);\n" 01730 "cache 1, 1($2);\n" 01731 "cache 1, 2($2);\n" 01732 "cache 1, 3($2);\n" 01733 "cache 0x10,($2);\n" 01734 "cache 0, ($2);\n" 01735 "cache 0, 1($2);\n" 01736 "cache 0, 2($2);\n" 01737 "cache 0, 3($2);\n" 01738 01739 "lw $2, 0x1fc($15);\n" 01740 "mtc0 $2, c0_entrylo0;\n" 01741 "tlbwi;\n" 01742 01743 "2:lw $2, 0x1fc($15);\n" 01744 "mtc0 $2, c0_entrylo1;\n" 01745 01746 "lw $2, 0x1fc($15);\n" 01747 "mtc0 $2, c0_entrylo0;\n" 01748 01749 "lw $2, 0x1fc($15);\n" 01750 "mtc0 $2, c0_entryhi;\n" 01751 01752 "lw $2, 0x1fc($15);\n" 01753 "mtc0 $2, c0_index;\n" 01754 01755 "lw $2, 0x1fc($15);\n" 01756 "lw $1, 0x1fc($15);\n" 01757 "mfc0 $15, $31;\n" 01758 "b 1b;\n" 01759 "nop;\n" 01760 ,0x80000); 01761 printf("index=%x,c0_datalo0=%x\n",ui_fifomem[0],ui_fifomem[1]); 01762 } 01763 01764 swb_array[ui_index].uc_enabled = 0x00; 01765 01766 return(1); 01767 } 01768 } 01769 } 01770 01771 // Never found the breakpoint 01772 printf("BREAKPOINT NOT FOUND!\n"); 01773 return(-1); 01774 }
unsigned int aui_registers[dMIPS32_NUM_DEBUG_REGISTERS] [static] |
int config_gdbserver_compareasid = 0 [static] |
Definition at line 97 of file gdbrdp.c.
Referenced by set_data_breakpoint(), and set_inst_breakpoint().
int config_gdbserver_comparedata = 0 [static] |
int config_gdbserver_comparedata_val = 0 [static] |
| int config_gdbserver_quitgdb = 0 |
Definition at line 100 of file gdbrdp.c.
Referenced by cmd_gdbserver(), cmd_quitgdb(), fGDBRDP_Handler(), and fJTAGSOCK_GetConnection().
hw_breakpoint hwb_data_array[dMIPS32_MAX_HARDWARE_BKPTS] [static] |
hw_breakpoint hwb_inst_array[dMIPS32_MAX_HARDWARE_BKPTS] [static] |
char sac_commandbuffer[dGDBRDP_MAX_CMD_BUFFER] [static] |
int si_inputhandlerstate [static] |
Definition at line 85 of file gdbrdp.c.
Referenced by fGDBRDP_Handler(), and fGDBRDP_InputHandler().
unsigned char suc_calculatedchecksum [static] |
unsigned char suc_receivedchecksum [static] |
unsigned int sui_numbytesreceived [static] |
sw_breakpoint swb_array[dGDBRDP_MAX_SW_BREAKPOINTS] [static] |
1.5.6