--- hatari/src/debug/debugInfo.c 2019/04/09 08:50:21 1.1.1.3 +++ hatari/src/debug/debugInfo.c 2019/04/09 08:54:21 1.1.1.6 @@ -1,8 +1,8 @@ /* Hatari - debuginfo.c - This file is distributed under the GNU Public License, version 2 or at - your option any later version. Read the file gpl.txt for details. + This file is distributed under the GNU General Public License, version 2 + or at your option any later version. Read the file gpl.txt for details. debuginfo.c - functions needed to show info about the atari HW & OS components and "lock" that info to be shown on entering the debugger. @@ -11,12 +11,18 @@ const char DebugInfo_fileid[] = "Hatari #include #include +#include + #include "main.h" +#include "bios.h" +#include "blitter.h" #include "configuration.h" +#include "crossbar.h" #include "debugInfo.h" #include "debugcpu.h" #include "debugdsp.h" #include "debugui.h" +#include "debug_priv.h" #include "dsp.h" #include "evaluate.h" #include "file.h" @@ -24,11 +30,16 @@ const char DebugInfo_fileid[] = "Hatari #include "history.h" #include "ioMem.h" #include "m68000.h" +#include "psg.h" #include "stMemory.h" #include "tos.h" #include "screen.h" #include "vdi.h" #include "video.h" +#include "videl.h" +#include "xbios.h" +#include "newcpu.h" +#include "68kDisass.h" /* ------------------------------------------------------------------ @@ -52,37 +63,48 @@ const char DebugInfo_fileid[] = "Hatari /** - * DebugInfo_GetSysbase: set osversion to given argument. - * return sysbase address on success and zero on failure. + * DebugInfo_GetSysbase: get and validate system base + * return on success sysbase address (+ set rombase), on failure return zero */ -static Uint32 DebugInfo_GetSysbase(Uint16 *osversion) +static Uint32 DebugInfo_GetSysbase(Uint32 *rombase) { Uint32 sysbase = STMemory_ReadLong(OS_SYSBASE); if (!STMemory_ValidArea(sysbase, OS_HEADER_SIZE)) { - fprintf(stderr, "Invalid TOS base address!\n"); + fprintf(stderr, "Invalid TOS sysbase RAM address (0x%x)!\n", sysbase); + return 0; + } + /* under TOS, sysbase = os_beg = TosAddress, but not under MiNT -> use os_beg */ + *rombase = STMemory_ReadLong(sysbase+0x08); + if (!STMemory_ValidArea(*rombase, OS_HEADER_SIZE)) { + fprintf(stderr, "Invalid TOS sysbase ROM address (0x%x)!\n", *rombase); return 0; } - if (sysbase != TosAddress || sysbase != STMemory_ReadLong(sysbase+0x08)) { - fprintf(stderr, "Sysbase and os_beg address in OS header mismatch!\n"); + if (*rombase != TosAddress) { + fprintf(stderr, "os_beg (0x%x) != TOS address (0x%x), header in RAM not set up yet?\n", + *rombase, TosAddress); return 0; } - *osversion = STMemory_ReadWord(sysbase+0x02); return sysbase; } /** - * DebugInfo_CurrentBasepage: get currently running TOS program basepage + * DebugInfo_CurrentBasepage: get and validate currently running program basepage. + * if given sysbase is zero, use system sysbase. */ -static Uint32 DebugInfo_CurrentBasepage(void) +static Uint32 DebugInfo_CurrentBasepage(Uint32 sysbase) { - Uint32 basepage, sysbase; + Uint32 basepage; Uint16 osversion, osconf; - sysbase = DebugInfo_GetSysbase(&osversion); if (!sysbase) { - return 0; + Uint32 rombase; + sysbase = DebugInfo_GetSysbase(&rombase); + if (!sysbase) { + return 0; + } } + osversion = STMemory_ReadWord(sysbase+0x02); if (osversion >= 0x0102) { basepage = STMemory_ReadLong(sysbase+0x28); } else { @@ -102,12 +124,12 @@ static Uint32 DebugInfo_CurrentBasepage( /** - * GetSegmentAddress: return segment address at given offset in + * GetBasepageValue: return basepage value at given offset in * TOS process basepage or zero if that is missing/invalid. */ -static Uint32 GetSegmentAddress(unsigned offset) +static Uint32 GetBasepageValue(unsigned offset) { - Uint32 basepage = DebugInfo_CurrentBasepage(); + Uint32 basepage = DebugInfo_CurrentBasepage(0); if (!basepage) { return 0; } @@ -125,7 +147,19 @@ static Uint32 GetSegmentAddress(unsigned */ Uint32 DebugInfo_GetTEXT(void) { - return GetSegmentAddress(0x08); + return GetBasepageValue(0x08); +} +/** + * DebugInfo_GetTEXTEnd: return current program TEXT segment end address + * or zero if basepage missing/invalid. For virtual debugger variable. + */ +Uint32 DebugInfo_GetTEXTEnd(void) +{ + Uint32 addr = GetBasepageValue(0x08); + if (addr) { + return addr + GetBasepageValue(0x0C) - 1; + } + return 0; } /** * DebugInfo_GetDATA: return current program DATA segment address @@ -133,7 +167,7 @@ Uint32 DebugInfo_GetTEXT(void) */ Uint32 DebugInfo_GetDATA(void) { - return GetSegmentAddress(0x010); + return GetBasepageValue(0x010); } /** * DebugInfo_GetBSS: return current program BSS segment address @@ -141,7 +175,7 @@ Uint32 DebugInfo_GetDATA(void) */ Uint32 DebugInfo_GetBSS(void) { - return GetSegmentAddress(0x18); + return GetBasepageValue(0x18); } @@ -156,7 +190,7 @@ static void DebugInfo_Basepage(Uint32 ba if (!basepage) { /* default to current process basepage */ - basepage = DebugInfo_CurrentBasepage(); + basepage = DebugInfo_CurrentBasepage(0); if (!basepage) { return; } @@ -200,11 +234,11 @@ static void DebugInfo_Basepage(Uint32 ba } /** - * DebugInfo_OSHeader: display TOS OS Header + * DebugInfo_PrintOSHeader: output OS Header information */ -static void DebugInfo_OSHeader(Uint32 dummy) +static void DebugInfo_PrintOSHeader(Uint32 sysbase) { - Uint32 sysbase, gemblock, basepage; + Uint32 gemblock, basepage; Uint16 osversion, osconf, langbits; const char *lang; static const char langs[][3] = { @@ -212,11 +246,7 @@ static void DebugInfo_OSHeader(Uint32 du "tr", "fi", "no", "dk", "sa", "nl", "cs", "hu" }; - sysbase = DebugInfo_GetSysbase(&osversion); - if (!sysbase) { - return; - } - fprintf(stderr, "TOS OS header information:\n"); + osversion = STMemory_ReadWord(sysbase+0x02); fprintf(stderr, "OS base addr : 0x%06x\n", sysbase); fprintf(stderr, "OS RAM end+1 : 0x%06x\n", STMemory_ReadLong(sysbase+0x0C)); fprintf(stderr, "TOS version : 0x%x\n", osversion); @@ -259,12 +289,32 @@ static void DebugInfo_OSHeader(Uint32 du fprintf(stderr, "Memory pool : 0x0056FA\n"); fprintf(stderr, "Kbshift addr : 0x000E1B\n"); } - basepage = DebugInfo_CurrentBasepage(); + basepage = DebugInfo_CurrentBasepage(sysbase); if (basepage) { fprintf(stderr, "Basepage : 0x%06x\n", basepage); } } +/** + * DebugInfo_OSHeader: display TOS OS Header and RAM one + * if their addresses differ + */ +static void DebugInfo_OSHeader(Uint32 dummy) +{ + Uint32 sysbase, rombase; + + sysbase = DebugInfo_GetSysbase(&rombase); + if (!sysbase) { + return; + } + fprintf(stderr, "OS header information:\n"); + DebugInfo_PrintOSHeader(sysbase); + if (sysbase != rombase) { + fprintf(stderr, "\nROM TOS OS header information:\n"); + DebugInfo_PrintOSHeader(rombase); + return; + } +} /** * DebugInfo_Cookiejar: display TOS Cookiejar content @@ -292,290 +342,6 @@ static void DebugInfo_Cookiejar(Uint32 d } -/** - * DebugInfo_Video: display video related information - */ -static void DebugInfo_Video(Uint32 dummy) -{ - const char *mode; - switch (OverscanMode) { - case OVERSCANMODE_NONE: - mode = "none"; - break; - case OVERSCANMODE_TOP: - mode = "top"; - break; - case OVERSCANMODE_BOTTOM: - mode = "bottom"; - break; - case OVERSCANMODE_TOP|OVERSCANMODE_BOTTOM: - mode = "top+bottom"; - break; - default: - mode = "unknown"; - } - fprintf(stderr, "Video base : 0x%x\n", VideoBase); - fprintf(stderr, "VBL counter : %d\n", nVBLs); - fprintf(stderr, "HBL line : %d\n", nHBL); - fprintf(stderr, "V-overscan : %s\n", mode); - fprintf(stderr, "Refresh rate : %d Hz\n", nScreenRefreshRate); - fprintf(stderr, "Frame skips : %d\n", nFrameSkips); -} - -/* ------------------------------------------------------------------ - * Falcon HW information - */ - -/** - * DebugInfo_Videl : display the Videl registers values. - */ -static void DebugInfo_Videl(Uint32 dummy) -{ - if (ConfigureParams.System.nMachineType != MACHINE_FALCON) { - fprintf(stderr, "Not Falcon - no Videl!\n"); - return; - } - - fprintf(stderr, "$FF8006.b : monitor type : %02x\n", IoMem_ReadByte(0xff8006)); - fprintf(stderr, "$FF8201.b : Video Base Hi : %02x\n", IoMem_ReadByte(0xff8201)); - fprintf(stderr, "$FF8203.b : Video Base Mi : %02x\n", IoMem_ReadByte(0xff8203)); - fprintf(stderr, "$FF8205.b : Video Count Hi : %02x\n", IoMem_ReadByte(0xff8205)); - fprintf(stderr, "$FF8207.b : Video Count Mi : %02x\n", IoMem_ReadByte(0xff8207)); - fprintf(stderr, "$FF8209.b : Video Count Lo : %02x\n", IoMem_ReadByte(0xff8209)); - fprintf(stderr, "$FF820A.b : Sync mode : %02x\n", IoMem_ReadByte(0xff820a)); - fprintf(stderr, "$FF820D.b : Video Base Lo : %02x\n", IoMem_ReadByte(0xff820d)); - fprintf(stderr, "$FF820E.w : offset to next line : %04x\n", IoMem_ReadWord(0xff820e)); - fprintf(stderr, "$FF8210.w : VWRAP - line width : %04x\n", IoMem_ReadWord(0xff8210)); - fprintf(stderr, "$FF8260.b : ST shift mode : %02x\n", IoMem_ReadByte(0xff8260)); - fprintf(stderr, "$FF8264.w : Horizontal scroll register : %04x\n", IoMem_ReadWord(0xff8264)); - fprintf(stderr, "$FF8266.w : Falcon shift mode : %04x\n", IoMem_ReadWord(0xff8266)); - fprintf(stderr, "\n"); - fprintf(stderr, "$FF8280.w : HHC - Horizontal Hold Counter : %04x\n", IoMem_ReadWord(0xff8280)); - fprintf(stderr, "$FF8282.w : HHT - Horizontal Hold Timer : %04x\n", IoMem_ReadWord(0xff8282)); - fprintf(stderr, "$FF8284.w : HBB - Horizontal Border Begin : %04x\n", IoMem_ReadWord(0xff8284)); - fprintf(stderr, "$FF8286.w : HBE - Horizontal Border End : %04x\n", IoMem_ReadWord(0xff8286)); - fprintf(stderr, "$FF8288.w : HDB - Horizontal Display Begin : %04x\n", IoMem_ReadWord(0xff8288)); - fprintf(stderr, "$FF828A.w : HDE - Horizontal Display End : %04x\n", IoMem_ReadWord(0xff828a)); - fprintf(stderr, "$FF828C.w : HSS - Horizontal SS : %04x\n", IoMem_ReadWord(0xff828c)); - fprintf(stderr, "$FF828E.w : HFS - Horizontal FS : %04x\n", IoMem_ReadWord(0xff828e)); - fprintf(stderr, "$FF8290.w : HEE - Horizontal EE : %04x\n", IoMem_ReadWord(0xff8290)); - fprintf(stderr, "\n"); - fprintf(stderr, "$FF82A0.w : VFC - Vertical Frequency Counter : %04x\n", IoMem_ReadWord(0xff82a0)); - fprintf(stderr, "$FF82A2.w : VFT - Vertical Frequency Timer : %04x\n", IoMem_ReadWord(0xff82a2)); - fprintf(stderr, "$FF82A4.w : VBB - Vertical Border Begin : %04x\n", IoMem_ReadWord(0xff82a4)); - fprintf(stderr, "$FF82A6.w : VBE - Vertical Border End : %04x\n", IoMem_ReadWord(0xff82a6)); - fprintf(stderr, "$FF82A8.w : VDB - Vertical Display Begin : %04x\n", IoMem_ReadWord(0xff82a8)); - fprintf(stderr, "$FF82AA.w : VDE - Vertical Display End : %04x\n", IoMem_ReadWord(0xff82aa)); - fprintf(stderr, "$FF82AC.w : VSS - Vertical SS : %04x\n", IoMem_ReadWord(0xff82ac)); - fprintf(stderr, "\n"); - fprintf(stderr, "$FF82C0.w : VCO - Video control : %04x\n", IoMem_ReadWord(0xff82c0)); - fprintf(stderr, "$FF82C2.w : VMD - Video mode : %04x\n", IoMem_ReadWord(0xff82c2)); - fprintf(stderr, "\n-------------------------\n"); - - fprintf(stderr, "Video base : %08x\n", (IoMem_ReadByte(0xff8201)<<16) + - (IoMem_ReadByte(0xff8203)<<8) + - IoMem_ReadByte(0xff820d)); - fprintf(stderr, "Video count : %08x\n", (IoMem_ReadByte(0xff8205)<<16) + - (IoMem_ReadByte(0xff8207)<<8) + - IoMem_ReadByte(0xff8209)); -} - -/** - * DebugInfo_Crossbar : display the Crossbar registers values. - */ -static void DebugInfo_Crossbar(Uint32 dummy) -{ - char matrixDMA[5], matrixDAC[5], matrixDSP[5], matrixEXT[5]; - char frqDMA[11], frqDAC[11], frqDSP[11], frqEXT[11]; - char frqSTE[30], frq25Mhz[30], frq32Mhz[30]; - char dataSize[15]; - - static const Uint32 Ste_SampleRates[4] = { - 6258, 12517, 25033, 50066 - }; - - static const Uint32 Falcon_SampleRates_25Mhz[15] = { - 49170, 32780, 24585, 19668, 16390, 14049, 12292, 10927, 9834, 8940, 8195, 7565, 7024, 6556, 6146 - }; - - static const Uint32 Falcon_SampleRates_32Mhz[15] = { - 62500, 41666, 31250, 25000, 20833, 17857, 15624, 13889, 12500, 11363, 10416, 9615, 8928, 8333, 7812 - }; - - if (ConfigureParams.System.nMachineType != MACHINE_FALCON) { - fprintf(stderr, "Not Falcon - no Crossbar!\n"); - return; - } - - fprintf(stderr, "$FF8900.b : Sound DMA control : %02x\n", IoMem_ReadByte(0xff8900)); - fprintf(stderr, "$FF8901.b : Sound DMA control : %02x\n", IoMem_ReadByte(0xff8901)); - fprintf(stderr, "$FF8903.b : Frame Start High : %02x\n", IoMem_ReadByte(0xff8903)); - fprintf(stderr, "$FF8905.b : Frame Start middle : %02x\n", IoMem_ReadByte(0xff8905)); - fprintf(stderr, "$FF8907.b : Frame Start low : %02x\n", IoMem_ReadByte(0xff8907)); - fprintf(stderr, "$FF8909.b : Frame Count High : %02x\n", IoMem_ReadByte(0xff8909)); - fprintf(stderr, "$FF890B.b : Frame Count middle : %02x\n", IoMem_ReadByte(0xff890b)); - fprintf(stderr, "$FF890D.b : Frame Count low : %02x\n", IoMem_ReadByte(0xff890d)); - fprintf(stderr, "$FF890F.b : Frame End High : %02x\n", IoMem_ReadByte(0xff890f)); - fprintf(stderr, "$FF8911.b : Frame End middle : %02x\n", IoMem_ReadByte(0xff8911)); - fprintf(stderr, "$FF8913.b : Frame End low : %02x\n", IoMem_ReadByte(0xff8913)); - fprintf(stderr, "\n"); - fprintf(stderr, "$FF8920.b : Sound Mode Control : %02x\n", IoMem_ReadByte(0xff8920)); - fprintf(stderr, "$FF8921.b : Sound Mode Control : %02x\n", IoMem_ReadByte(0xff8921)); - fprintf(stderr, "$FF8930.w : DMA Crossbar Input Select Controller : %04x\n", IoMem_ReadWord(0xff8930)); - fprintf(stderr, "$FF8932.w : DMA Crossbar Output Select Controller : %04x\n", IoMem_ReadWord(0xff8932)); - fprintf(stderr, "\n"); - fprintf(stderr, "$FF8934.b : External Sync Frequency Divider : %02x\n", IoMem_ReadByte(0xff8934)); - fprintf(stderr, "$FF8935.b : Internal Sync Frequency Divider : %02x\n", IoMem_ReadByte(0xff8935)); - fprintf(stderr, "$FF8936.b : Record Track select : %02x\n", IoMem_ReadByte(0xff8936)); - fprintf(stderr, "$FF8937.b : Codec Input Source : %02x\n", IoMem_ReadByte(0xff8937)); - fprintf(stderr, "$FF8938.b : Codec ADC Input : %02x\n", IoMem_ReadByte(0xff8938)); - fprintf(stderr, "$FF8939.b : Gain Settings Per Channel : %02x\n", IoMem_ReadByte(0xff8939)); - fprintf(stderr, "$FF893A.b : Attenuation Settings Per Channel : %02x\n", IoMem_ReadByte(0xff893a)); - fprintf(stderr, "$FF893C.w : Codec Status : %04x\n", IoMem_ReadWord(0xff893c)); - fprintf(stderr, "$FF8940.w : GPIO Data Direction : %04x\n", IoMem_ReadWord(0xff8940)); - fprintf(stderr, "$FF8942.w : GPIO Data : %04x\n", IoMem_ReadWord(0xff8942)); - fprintf(stderr, "\n"); - - /* DAC connexion */ - switch ((IoMem_ReadWord(0xff8932) >> 13) & 0x3) { - case 0 : - /* DAC connexion with DMA Playback */ - if ((IoMem_ReadWord(0xff8930) & 0x1) == 1) - strcpy(matrixDAC, "OOXO"); - else - strcpy(matrixDAC, "OOHO"); - break; - case 1 : - /* DAC connexion with DSP Transmit */ - if ((IoMem_ReadWord(0xff8930) & 0x10) == 0x10) - strcpy(matrixDAC, "OXOO"); - else - strcpy(matrixDAC, "OHOO"); - break; - case 2 : - /* DAC connexion with External Input */ - if ((IoMem_ReadWord(0xff8930) & 0x100) == 0x100) - strcpy(matrixDAC, "XOOO"); - else - strcpy(matrixDAC, "HOOO"); - break; - case 3 : - /* DAC connexion with ADC */ - strcpy(matrixDAC, "OOOX"); - break; - } - - /* DMA connexion */ - switch (IoMem_ReadWord(0xff8932) & 0x7) { - case 0 : strcpy(matrixDMA, "OOHO"); break; - case 1 : strcpy(matrixDMA, "OOXO"); break; - case 2 : strcpy(matrixDMA, "OHOO"); break; - case 3 : strcpy(matrixDMA, "OXOO"); break; - case 4 : strcpy(matrixDMA, "HOOO"); break; - case 5 : strcpy(matrixDMA, "XOOO"); break; - case 6 : strcpy(matrixDMA, "OOOH"); break; - case 7 : strcpy(matrixDMA, "OOOX"); break; - } - - /* DSP connexion */ - switch ((IoMem_ReadWord(0xff8932) >> 4) & 0x7) { - case 0 : strcpy(matrixDSP, "OOHO"); break; - case 1 : strcpy(matrixDSP, "OOXO"); break; - case 2 : strcpy(matrixDSP, "OHOO"); break; - case 3 : strcpy(matrixDSP, "OXOO"); break; - case 4 : strcpy(matrixDSP, "HOOO"); break; - case 5 : strcpy(matrixDSP, "XOOO"); break; - case 6 : strcpy(matrixDSP, "OOOH"); break; - case 7 : strcpy(matrixDSP, "OOOX"); break; - } - - /* External input connexion */ - switch ((IoMem_ReadWord(0xff8932) >> 8) & 0x7) { - case 0 : strcpy(matrixEXT, "OOHO"); break; - case 1 : strcpy(matrixEXT, "OOXO"); break; - case 2 : strcpy(matrixEXT, "OHOO"); break; - case 3 : strcpy(matrixEXT, "OXOO"); break; - case 4 : strcpy(matrixEXT, "HOOO"); break; - case 5 : strcpy(matrixEXT, "XOOO"); break; - case 6 : strcpy(matrixEXT, "OOOH"); break; - case 7 : strcpy(matrixEXT, "OOOX"); break; - } - - if ((IoMem_ReadByte(0xff8935) & 0xf) == 0) { - strcpy(frqDSP, "(STe Freq)"); - strcpy(frqDMA, "(STe Freq)"); - strcpy(frqEXT, "(STe Freq)"); - strcpy(frqDAC, "(STe Freq)"); - } - else { - /* DSP Clock */ - switch ((IoMem_ReadWord(0xff8930) >> 5) & 0x3) { - case 0: strcpy(frqDSP, " (25 Mhz) "); break; - case 1: strcpy(frqDSP, "(External)"); break; - case 2: strcpy(frqDSP, " (32 Mhz) "); break; - default: strcpy(frqDSP, "undefined "); break; - } - - /* DMA Clock */ - switch ((IoMem_ReadWord(0xff8930) >> 1) & 0x3) { - case 0: strcpy(frqDMA, " (25 Mhz) "); break; - case 1: strcpy(frqDMA, "(External)"); break; - case 2: strcpy(frqDMA, " (32 Mhz) "); break; - default: strcpy(frqDMA, "undefined "); break; - } - - /* External Clock */ - switch ((IoMem_ReadWord(0xff8930) >> 9) & 0x3) { - case 0: strcpy(frqEXT, " (25 Mhz) "); break; - case 1: strcpy(frqEXT, "(External)"); break; - case 2: strcpy(frqEXT, " (32 Mhz) "); break; - default: strcpy(frqEXT, "undefined "); break; - } - - /* DAC Clock */ - strcpy(frqDAC, " (25 Mhz) "); - } - - /* data size */ - switch ((IoMem_ReadByte(0xff8921) >> 6) & 0x3) { - case 0: strcpy (dataSize, "8 bits stereo"); break; - case 1: strcpy (dataSize, "16 bits stereo"); break; - case 2: strcpy (dataSize, "8 bits mono"); break; - default: strcpy (dataSize, "undefined"); break; - } - - /* STE, 25Mhz and 32 Mhz sound frequencies */ - if ((IoMem_ReadByte(0xff8935) & 0xf) == 0) { - sprintf(frqSTE, "Ste Freq : %d Khz", Ste_SampleRates[IoMem_ReadByte(0xff8921) & 0x3]); - strcpy (frq25Mhz, "25 Mhz Freq : - Khz"); - strcpy (frq32Mhz, "32 Mzh Freq : - Khz"); - } - else { - strcpy (frqSTE, "Ste Freq : - Khz"); - sprintf(frq25Mhz, "25 Mhz Freq : %d Khz", Falcon_SampleRates_25Mhz[(IoMem_ReadByte(0xff8935) & 0xf) - 1]); - sprintf(frq32Mhz, "32 Mzh Freq : %d Khz", Falcon_SampleRates_32Mhz[(IoMem_ReadByte(0xff8935) & 0xf) - 1]); - } - - /* Display the crossbar Matrix */ - fprintf(stderr, " INPUT\n"); - fprintf(stderr, "External Imp ---%c------%c------%c------%c\n", matrixDAC[0], matrixDMA[0], matrixDSP[0], matrixEXT[0]); - fprintf(stderr, "%s | | | | O = no connexion\n", frqEXT); - fprintf(stderr, " | | | | X = connexion\n"); - fprintf(stderr, "Dsp Transmit ---%c------%c------%c------%c H = Handshake connexion\n", matrixDAC[1], matrixDMA[1], matrixDSP[1], matrixEXT[1]); - fprintf(stderr, "%s | | | |\n", frqDSP); - fprintf(stderr, " | | | | %s\n", dataSize); - fprintf(stderr, "DMA PlayBack ---%c------%c------%c------%c\n", matrixDAC[2], matrixDMA[2], matrixDSP[2], matrixEXT[2]); - fprintf(stderr, "%s | | | | Sound Freq :\n", frqDMA); - fprintf(stderr, " | | | | %s\n", frqSTE); - fprintf(stderr, "ADC ---%c------%c------%c------%c %s\n", matrixDAC[3], matrixDMA[3], matrixDSP[3], matrixEXT[3], frq25Mhz); - fprintf(stderr, "%s | | | | %s\n", frqDAC, frq32Mhz); - fprintf(stderr, " | | | |\n"); - fprintf(stderr, " DAC DMA DSP External OUTPUT\n"); - fprintf(stderr, " Record Record Out\n"); - fprintf(stderr, "\n"); -} - - /* ------------------------------------------------------------------ * CPU and DSP information wrappers */ @@ -642,7 +408,7 @@ static Uint32 DebugInfo_DspMemArgs(int a if (argc != 2) { return 0; } - space = toupper(argv[0][0]); + space = toupper((unsigned char)argv[0][0]); if ((space != 'X' && space != 'Y' && space != 'P') || argv[0][1]) { fprintf(stderr, "ERROR: invalid DSP address space '%s'!\n", argv[0]); return 0; @@ -661,7 +427,7 @@ static void DebugInfo_RegAddr(Uint32 arg { bool forDsp; char regname[3]; - Uint32 *regvalue, mask; + Uint32 *reg32, regvalue, mask; char cmdbuf[12], addrbuf[6]; char *argv[] = { cmdbuf, addrbuf }; @@ -669,34 +435,48 @@ static void DebugInfo_RegAddr(Uint32 arg regname[1] = (arg>>16)&0xff; regname[2] = '\0'; - if (DebugCpu_GetRegisterAddress(regname, ®value)) { + if (DebugCpu_GetRegisterAddress(regname, ®32)) { + regvalue = *reg32; mask = 0xffffffff; forDsp = false; } else { - if (!DSP_GetRegisterAddress(regname, ®value, &mask)) { + int regsize = DSP_GetRegisterAddress(regname, ®32, &mask); + switch (regsize) { + /* currently regaddr supports only 32-bit Rx regs, but maybe later... */ + case 16: + regvalue = *((Uint16*)reg32); + break; + case 32: + regvalue = *reg32; + break; + default: fprintf(stderr, "ERROR: invalid address/data register '%s'!\n", regname); return; } forDsp = true; } - sprintf(addrbuf, "$%x", *regvalue & mask); + sprintf(addrbuf, "$%x", regvalue & mask); if ((arg & 0xff) == 'D') { - strcpy(cmdbuf, "disasm"); if (forDsp) { #if ENABLE_DSP_EMU + strcpy(cmdbuf, "dd"); DebugDsp_DisAsm(2, argv); #endif } else { + strcpy(cmdbuf, "d"); DebugCpu_DisAsm(2, argv); } } else { - strcpy(cmdbuf, "memdump"); if (forDsp) { #if ENABLE_DSP_EMU - DebugDsp_MemDump(2, argv); + /* use "Y" address space */ + char cmd[] = "dm"; char space[] = "y"; + char *dargv[] = { cmd, space, addrbuf }; + DebugDsp_MemDump(3, dargv); #endif } else { + strcpy(cmdbuf, "m"); DebugCpu_MemDump(2, argv); } } @@ -723,7 +503,8 @@ static Uint32 DebugInfo_RegAddrArgs(int if (strlen(argv[1]) != 2 || (!DebugCpu_GetRegisterAddress(argv[1], ®addr) && - (toupper(argv[1][0]) != 'R' || !isdigit(argv[1][1]) || argv[1][2]))) { + (toupper((unsigned char)argv[1][0]) != 'R' + || !isdigit((unsigned char)argv[1][1]) || argv[1][2]))) { /* not CPU register or Rx DSP register */ fprintf(stderr, "ERROR: invalid address/data register '%s'!\n", argv[1]); return 0; @@ -752,7 +533,7 @@ static char *parse_filename; static void DebugInfo_FileParse(Uint32 dummy) { if (parse_filename) { - DebugUI_ParseFile(parse_filename); + DebugUI_ParseFile(parse_filename, true); } else { fputs("ERROR: debugger input file name to parse isn't set!\n", stderr); } @@ -789,13 +570,17 @@ static Uint32 DebugInfo_FileArgs(int arg static void DebugInfo_Default(Uint32 dummy) { int hbl, fcycles, lcycles; + uaecptr nextpc, pc = M68000_GetPC(); Video_GetPosition(&fcycles, &hbl, &lcycles); + fprintf(stderr, "\nCPU=$%x, VBL=%d, FrameCycles=%d, HBL=%d, LineCycles=%d, DSP=", - M68000_GetPC(), nVBLs, fcycles, hbl, lcycles); + pc, nVBLs, fcycles, hbl, lcycles); if (bDspEnabled) fprintf(stderr, "$%x\n", DSP_GetPC()); else fprintf(stderr, "N/A\n"); + + Disasm(stderr, pc, &nextpc, 1); } static const struct { @@ -808,29 +593,34 @@ static const struct { const char *info; } infotable[] = { { false,"aes", AES_Info, NULL, "Show AES vector contents (with , show opcodes)" }, - { false,"basepage", DebugInfo_Basepage, NULL, "Show program basepage info at given
" }, + { false,"basepage", DebugInfo_Basepage, NULL, "Show program basepage contents at given
" }, + { false,"bios", Bios_Info, NULL, "Show BIOS opcodes" }, + { false,"blitter", Blitter_Info, NULL, "Show Blitter register contents" }, { false,"cookiejar", DebugInfo_Cookiejar, NULL, "Show TOS Cookiejar contents" }, - { false,"crossbar", DebugInfo_Crossbar, NULL, "Show Falcon crossbar HW register values" }, + { false,"crossbar", Crossbar_Info, NULL, "Show Falcon Crossbar register contents" }, { true, "default", DebugInfo_Default, NULL, "Show default debugger entry information" }, { true, "disasm", DebugInfo_CpuDisAsm, NULL, "Disasm CPU from PC or given
" }, #if ENABLE_DSP_EMU + { false, "dsp", DSP_Info, NULL, "Show misc. DSP core info (stack etc)" }, { true, "dspdisasm", DebugInfo_DspDisAsm, NULL, "Disasm DSP from given
" }, { true, "dspmemdump",DebugInfo_DspMemDump, DebugInfo_DspMemArgs, "Dump DSP memory from given
" }, - { true, "dspregs", DebugInfo_DspRegister,NULL, "Show DSP registers values" }, + { true, "dspregs", DebugInfo_DspRegister,NULL, "Show DSP register contents" }, #endif { true, "file", DebugInfo_FileParse, DebugInfo_FileArgs, "Parse commands from given debugger input " }, - { false,"gemdos", GemDOS_Info, NULL, "Show GEMDOS HDD emu info (with , show opcodes)" }, + { false,"gemdos", GemDOS_Info, NULL, "Show GEMDOS HDD emu information (with , show opcodes)" }, { true, "history", History_Show, NULL, "Show history of last instructions" }, { true, "memdump", DebugInfo_CpuMemDump, NULL, "Dump CPU memory from given
" }, - { false,"osheader", DebugInfo_OSHeader, NULL, "Show TOS OS header information" }, + { false,"osheader", DebugInfo_OSHeader, NULL, "Show TOS OS header contents" }, { true, "regaddr", DebugInfo_RegAddr, DebugInfo_RegAddrArgs, "Show from CPU/DSP address pointed by " }, - { true, "registers", DebugInfo_CpuRegister,NULL, "Show CPU registers values" }, + { true, "registers", DebugInfo_CpuRegister,NULL, "Show CPU register contents" }, { false,"vdi", VDI_Info, NULL, "Show VDI vector contents (with , show opcodes)" }, - { false,"videl", DebugInfo_Videl, NULL, "Show Falcon Videl HW registers values" }, - { false,"video", DebugInfo_Video, NULL, "Show Video related values" } + { false,"videl", Videl_Info, NULL, "Show Falcon Videl register contents" }, + { false,"video", Video_Info, NULL, "Show Video information" }, + { false,"xbios", XBios_Info, NULL, "Show XBIOS opcodes" }, + { false,"ym", PSG_Info, NULL, "Show YM-2149 register contents" }, }; -static int LockedFunction = 4; /* index for the "default" function */ +static int LockedFunction = 6; /* index for the "default" function */ static Uint32 LockedArgument; /** @@ -901,7 +691,7 @@ int DebugInfo_Command(int nArgc, char *p } } - if (infotable[sub].args) { + if (sub >= 0 && infotable[sub].args) { /* value needs callback specific conversion */ value = infotable[sub].args(nArgc-2, psArgs+2); ok = !!value;