📄 debug.c
字号:
/* SCCSID @(#)debug.c 1.49 12/12/97 *//* * $Log$ */#include <stdio.h>#include <stdlib.h>#include <fcntl.h>#include "mvd.h"#include "common.h"#include "debug.h"#include "vp.h"#include "buffer.h"#include "display.h"#include "util.h"#include "vcxi.h"#ifdef FRACTINT#include "fractint.h"#endif#ifdef FADE#include "fade.h"#endif#define PRINTF(a)#ifdef DEBUG#undef VIEW/***************************************************************************** Local typedef *****************************************************************************/typedef struct { char *name; /* command name */ int (*proc)(); /* procedure function */} command;/***************************************************************************** Local variables *****************************************************************************/static char user_input[80];static char c_dummy[10];/***************************************************************************** Globals that needs to be exported *****************************************************************************/int vcx_on;/***************************************************************************** Local function prototypes *****************************************************************************/static int cmd_exe_sub(command *);static int proc_help(void);static int proc_cont(void);static int proc_dump(void);static int proc_edit(void);static int proc_fill(void);static int proc_r(void);static int proc_w(void);static int proc_rb(void);static int proc_wb(void);static int proc_save(void);static int proc_load(void);static int proc_vcxi(void);static int proc_ddp();static int proc_ddpcm();static int proc_dref();static int proc_wdp();static int proc_wdpcm();static int proc_savedp();static int proc_savedpcm();static int proc_loaddp();static int proc_loaddpcm();static int proc_load_ucode();static int proc_run_ucode();#ifdef VIEWstatic int proc_frame_define();static int proc_frame_read();static int proc_frame_run();#endif/********* SuperIO related ********/#if 0static int proc_InitSIO(void);static int proc_SIOSysRead(void);static int proc_SIOSysWrite(void);static int proc_SIOSysDump(void);static int proc_LoopBackTest(void);static int proc_XmitTest(void);static int proc_IntTest(void);#endifstatic int rdrlatchport(void);static int peekvp(void);static void ref_dump(void);static void dp_dm_dump(int);static void dp_dm_write(int, int, int, int);static void dp_dm_load(int);static void dp_dm_save(int);static int DBG_show_event_history(void);static int DBG_dump_event_history(void);static int DBG_print_event_history(FILE *);/***************************************************************************** System command table *****************************************************************************/command ctrl_com_tbl[] = { { "HELP", proc_help },{ "?", proc_help }, { "H", proc_help },{ "h", proc_help }, { "c", proc_cont },{ "C", proc_cont }, { "d", proc_dump },{ "D", proc_dump }, { "e", proc_edit },{ "E", proc_edit }, { "f", proc_fill },{ "F", proc_fill }, { "r", proc_r }, { "R", proc_r }, { "w", proc_w }, { "W", proc_w }, { "rb", proc_rb }, { "wb", proc_wb }, { "save", proc_save }, { "load", proc_load },#if 0 { "initsio", proc_InitSIO }, { "sior", proc_SIOSysRead }, { "siow", proc_SIOSysWrite }, { "siodump", proc_SIOSysDump }, { "loop", proc_LoopBackTest }, { "xmit", proc_XmitTest }, { "int", proc_IntTest },#endif { "vcxi", proc_vcxi }, { "dumpref", proc_dref }, { "dumpdp", proc_ddp }, { "dumpdpcm", proc_ddpcm }, { "writedp", proc_wdp }, { "writedpcm", proc_wdpcm }, { "savedp", proc_savedp }, { "savedpcm", proc_savedpcm }, { "loaddp", proc_loaddp }, { "loaddpcm", proc_loaddpcm }, { "loaducode", proc_load_ucode }, { "runucode", proc_run_ucode },#ifdef TRACE_ON { "t", DBG_show_event_history }, { "T", DBG_dump_event_history },#endif#ifdef VIEW { "frame", proc_frame_define }, { "read", proc_frame_read }, { "go", proc_frame_run },#endif { NULL, NULL }};/****************************************************************************** Command dispatcher. Returns 0 if successful. -1 if asked to quit. Error code: 1 - unknown command; 2 - execution failure. ******************************************************************************/static int cmd_exe_sub(table)command table[];{ register int i; if (user_input[0]==0) return (0 ); if ( strcmp( user_input, NULL ) == 0 ) return (0 ); for ( i = 0; table[i].name != NULL; i++ ) { if ( strcmp( table[i].name, user_input ) == 0 ) { return ( (*table[i].proc)() ); } } return(1);}/***************************************************************************** Make a wild guess *****************************************************************************/int AsciiHIToDw(char *szAscii){ int dwValue; if ((szAscii[0] == '0') && ( (szAscii[1] == 'x') || (szAscii[1] == 'X'))) /* data is ASCII hex: "0x*" */ (void) sscanf(szAscii + 2, "%lx", &dwValue); else /* data is ASCII decimal */ (void) sscanf(szAscii, "%ld", &dwValue); return(dwValue);}/***************************************************************************** Make a wild guess *****************************************************************************/static int proc_help(){ printf("HELP or H or ? : help message\n"); printf("c : continue\n"); printf("q : quit\n"); printf("r : read \n"); printf("w : write \n"); printf("rb : read byte \n"); printf("wb : write byte \n"); printf("d : dump \n"); printf("e : edit \n"); printf("f : fill \n");#ifdef TRACE_ON printf("t : dump trace buffer \n"); printf("T : dump trace buffer to file\n");#endif printf("save : dump memory to file \n"); printf("load : read from file to memory \n"); printf("dumpref : dump ref mem \n"); printf("dumpdp : dump dp mem \n"); printf("dumpdpcm : dump dpcm mem \n"); printf("writedpcm : dram->dpcm \n"); printf("writedp : dram->dp \n"); printf("savedpcm : dpcm->File \n"); printf("savedp : dp->File \n"); printf("loaddpcm : File->dpcm \n"); printf("loaddp : File->dp \n"); printf("loaducode : dram->vp ucode ram \n"); printf("runucode : run ucode \n"); printf("vcxi : goto vcxi\n");#if 0 printf("---more or 'q'----"); gets(user_input); if (user_input[0] == 'q') return(0); printf("initsio : Super IO initialize\n"); printf("sior : Super IO System reg read\n"); printf("siow : Super IO System reg write\n"); printf("siodump : Super IO System regs Dump\n"); printf("loop : 232c loop back test\n"); printf("xmit : 232c xmit test \n"); printf("int : 232c interrupt test \n");#endif return(0);}/***************************************************************************** Make a wild guess *****************************************************************************/static int proc_cont(){ return(-1);}/****************************************************************************** Write a dword ******************************************************************************/static int proc_w(){ int *address, value; puts("Write a dword. Enter byte adress(x), value(x): "); scanf("%lx,%lx", &address, &value); *address = value; return(0);}/****************************************************************************** Read a dword ******************************************************************************/static int proc_r(){ int *address; puts("Read a dword. Enter byte adress(x): "); scanf("%lx",&address); printf("[0x%08x] = 0x%08x (%ld)\n", address, *address, *address); return(0);}/****************************************************************************** Write a byte ******************************************************************************/static int proc_wb(){ unsigned char *address; int value; puts("Write a byte. Enter byte adress(x), value(x): "); scanf("%lx,%lx", &address, &value); *address = value & 0xff; return(0);}/****************************************************************************** Read a byte ******************************************************************************/static int proc_rb(){ unsigned char *address; printf("Read a byte. Enter byte adress(x): "); scanf("%lx", &address); printf("[0x%08x] = 0x%02x (%d)\n", address, *address, *address); return(0);}/****************************************************************************** Dump a block of memory ******************************************************************************/static int proc_dump(void){ int address; char keyin[40]; printf("Starting byte address: "); gets(keyin); address = AsciiHIToDw(keyin); while (1) { /* printf("%08x:\n", address); DBG_print_short(128, (short *)address); */ DBG_print_int(64, (int *)address); address += 64*4; printf("---more or 'q'----"); gets(user_input); if (user_input[0] == 'q') return(0); } return(0);}/****************************************************************************** Modify a block of memory ******************************************************************************/static int proc_edit(){ int *address; printf("Starting byte address in hex: "); scanf("%lx", &address); user_input[0] = 0; gets(c_dummy); while (1) { printf("%08x: %08x -> ", address, *address); gets(user_input); if (user_input[0] == 'q' ) return(0); sscanf(user_input, "%x", address); address++; } return(0);}/****************************************************************************** Fill a block of memory ******************************************************************************/static int proc_fill(){ int value; int count; int *address; printf(" Enter starting byte address(x), count(d), value(x): "); scanf("%x,%d,%x",&address, &count, &value); while (count-- > 0) { *address++ = value; } return(0);}/****************************************************************************** read memory & write to file ******************************************************************************/static int proc_save(){ int length; unsigned char *address; char fname[20]; int fp; printf("Filname: "); scanf("%s", fname); fp = open(fname, O_BINARY | O_RDONLY ); if (fp != -1) { close(fp); printf("File: %s already exist. Overwrite (Y/N)? ", fname); (void) getchar(); if ((getchar()&0xdf)!='Y') return(0); } printf("Enter starting byte address(x), count in bytes(d): "); scanf("%lx,%ld", &address, &length); fp = DBG_dump_memory(address, length, -1, fname); if (fp != -1) close(fp);}/****************************************************************************** read from file and write to memory. ******************************************************************************/static int proc_load(){ int length, offset; unsigned char *address; char fname[20]; int fp; printf("Filname: "); scanf("%s", fname); /* Everything in bytes */ printf("Mem addr(x), count(d), file offset(d): "); scanf("%lx,%ld,%ld", &address, &length, &offset); fp = DBG_load_memory(address, length, offset, -1, fname); if (fp != -1) close(fp);}/***************************************************************************** SUPER IO control entry. *****************************************************************************/#if 0static int proc_InitSIO(void){ InitSIO(); return(0);}static int proc_SIOSysRead(void){ SIOSysRead(); return(0);}static int proc_SIOSysWrite(void){ SIOSysWrite(); return(0);}static int proc_SIOSysDump(void){ SIOSysDump(); return(0);}static int proc_LoopBackTest(void){ LoopBackTest(); return(0);}static int proc_XmitTest(void){ XmitTest(); return(0);}static int proc_IntTest(void){ IntTest(); return(0);}#endif/***************************************************************************** Gateway to vcxi. *****************************************************************************/static int proc_vcxi(void){ printf("Entering vcxi. To exit set vcx_on to 0.\n"); vcx_on = 1; while(vcx_on){ VCX_service();#ifdef FRACTINT if (FRACT_display_on) FRACT_set_palette(); if (FRACT_process_on) FRACT_paint_a_block();#endif#ifdef FADE if (FADE_in_process) Fade();#endif } return(0);}/***************************************************************************** Save dp to a file. *****************************************************************************/static int proc_savedp(){ dp_dm_save(1); return(0);}/***************************************************************************** Save dpcm to a file. *****************************************************************************/static int proc_savedpcm(){ dp_dm_save(0); return(0);}/***************************************************************************** Load dp. *****************************************************************************/static int proc_loaddp(){ dp_dm_load(1); return(0);}/***************************************************************************** Load dpcm. *****************************************************************************/static int proc_loaddpcm(){ dp_dm_load(0); return(0);}/***************************************************************************** Write dp. *****************************************************************************/static int proc_wdp(){ int sadr; char keyin[40]; int where, n; printf("DRAM offset(x), VP address in shorts(d), n in dwords(d): "); gets(keyin); sscanf(keyin,"%x,%d,%d",&where,&sadr,&n); dp_dm_write(1, where, n, sadr); return(0);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -