/** * Reset ST emulator states, chips, interrupts and registers. * Return zero or negative TOS image load error code. */ static const char* Reset_ST(bool bCold) { if (bCold) { const char* error_str; error_str=memory_init(ConfigureParams.Memory.nMemoryBankSize); if (error_str!=NULL) { return error_str; } } CycInt_Reset(); /* Reset interrupts */ Video_Reset(); /* Reset video */ TMC_Reset(); /* Reset TMC Registers */ SCR_Reset(); /* Reset System Control Registers */ nvram_init(); /* Reset NVRAM */ SCSI_Reset(); /* Reset SCSI disks */ MO_Reset(); /* Reset MO disks */ Floppy_Reset(); /* Reset Floppy disks */ SCC_Reset(2); /* Reset SCC */ Ethernet_Reset(true); /* Reset Ethernet */ Sound_Reset(); /* Reset Sound */ Screen_Reset(); /* Reset screen */ DSP_Reset(); /* Reset DSP */ M68000_Reset(bCold); /* Reset CPU */ DebugCpu_SetDebugging(); /* Re-set debugging flag if needed */ return NULL; }
/** * Remote/parallel debugger line usage API. * Return false for failed command, true for success. */ bool DebugUI_ParseLine(const char *input) { char *expanded; int ret = 0; DebugUI_Init(); /* returns new string if input needed expanding! */ expanded = DebugUI_EvaluateExpressions(input); if (expanded) { fprintf(stderr, "> %s\n", expanded); ret = DebugUI_ParseCommand(expanded); free(expanded); DebugCpu_SetDebugging(); DebugDsp_SetDebugging(); } return (ret == DEBUGGER_CMDDONE); }
/** * Reset ST emulator states, chips, interrupts and registers. * Return zero or negative TOS image load error code. */ static int Reset_ST(bool bCold) { if (bCold) { int ret; Floppy_GetBootDrive(); /* Find which device to boot from (A: or C:) */ ret = TOS_LoadImage(); /* Load TOS, writes into cartridge memory */ if (ret) return ret; /* If we can not load a TOS image, return now! */ Cart_ResetImage(); /* Load cartridge program into ROM memory. */ Cart_Patch(); } CycInt_Reset(); /* Reset interrupts */ MFP_Reset(); /* Setup MFP chip */ Video_Reset(); /* Reset video */ VDI_Reset(); /* Reset internal VDI variables */ NvRam_Reset(); /* reset NvRAM (video) settings */ GemDOS_Reset(); /* Reset GEMDOS emulation */ if (bCold) { FDC_Reset( bCold ); /* Reset FDC */ } Floppy_Reset(); /* Reset Floppy */ if (ConfigureParams.System.nMachineType == MACHINE_FALCON || ConfigureParams.System.nMachineType == MACHINE_TT) { Ncr5380_Reset(); } if (ConfigureParams.System.nMachineType == MACHINE_FALCON) { DSP_Reset(); /* Reset the DSP */ Crossbar_Reset(bCold); /* Reset Crossbar sound */ } else DmaSnd_Reset(bCold); /* Reset DMA sound */ PSG_Reset(); /* Reset PSG */ Sound_Reset(); /* Reset Sound */ ACIA_Reset( ACIA_Array ); /* ACIA */ IKBD_Reset(bCold); /* Keyboard (after ACIA) */ if (ConfigureParams.System.nMachineType == MACHINE_FALCON && !bUseVDIRes) VIDEL_reset(); else Screen_Reset(); /* Reset screen */ M68000_Reset(bCold); /* Reset CPU */ DebugCpu_SetDebugging(); /* Re-set debugging flag if needed */ DebugDsp_SetDebugging(); Midi_Reset(); #if defined(__linux__) nf_scsidrv_reset(); #endif /* Start HBL, Timer B and VBL interrupts with a 0 cycle delay */ Video_StartInterrupts( 0 ); return 0; }
/** * Read debugger commands from a file. If 'reinit' is set * (as it normally should), reinitialize breakpoints etc. * afterwards. return false for error, true for success. */ bool DebugUI_ParseFile(const char *path, bool reinit) { char *olddir, *dir, *cmd, *input, *expanded, *slash; FILE *fp; fprintf(stderr, "Reading debugger commands from '%s'...\n", path); if (!(fp = fopen(path, "r"))) { perror("ERROR"); return false; } /* change to directory where the debugger file resides */ olddir = NULL; dir = strdup(path); slash = strrchr(dir, PATHSEP); if (slash) { olddir = malloc(FILENAME_MAX); if (olddir) { if (!getcwd(olddir, FILENAME_MAX)) strcpy(olddir, "."); } *slash = '\0'; if (chdir(dir) != 0) { perror("ERROR"); if (olddir) free(olddir); free(dir); fclose(fp); return false; } fprintf(stderr, "Changed to input file dir '%s'.\n", dir); } free(dir); input = NULL; for (;;) { if (!input) { input = malloc(256); assert(input); } if (!fgets(input, 256, fp)) break; /* ignore empty and comment lines */ cmd = Str_Trim(input); if (!*cmd || *cmd == '#') continue; /* returns new string if input needed expanding! */ expanded = DebugUI_EvaluateExpressions(input); if (!expanded) continue; cmd = Str_Trim(expanded); fprintf(stderr, "> %s\n", cmd); DebugUI_ParseCommand(cmd); free(expanded); } free(input); fclose(fp); if (olddir) { if (chdir(olddir) != 0) perror("ERROR"); else fprintf(stderr, "Changed back to '%s' dir.\n", olddir); free(olddir); } if (reinit) { DebugCpu_SetDebugging(); DebugDsp_SetDebugging(); } return true; }
/** * Debugger user interface main function. */ void DebugUI(debug_reason_t reason) { int cmdret, alertLevel; char *expCmd, *psCmd = NULL; static const char *welcome = "\n----------------------------------------------------------------------" "\nYou have entered debug mode. Type c to continue emulation, h for help.\n"; History_Mark(reason); if (bInFullScreen) Screen_ReturnFromFullScreen(); /* Make sure mouse isn't grabbed regardless of where * this is invoked from. E.g. returning from fullscreen * enables grab if that was enabled on windowed mode. */ SDL_WM_GrabInput(SDL_GRAB_OFF); DebugUI_Init(); if (welcome) { fputs(welcome, stderr); welcome = NULL; } DebugCpu_InitSession(); DebugDsp_InitSession(); Symbols_LoadCurrentProgram(); DebugInfo_ShowSessionInfo(); /* override paused message so that user knows to look into console * on how to continue in case he invoked the debugger by accident. */ Statusbar_AddMessage("Console Debugger", 100); Statusbar_Update(sdlscrn, true); /* disable normal GUI alerts while on console */ alertLevel = Log_SetAlertLevel(LOG_FATAL); cmdret = DEBUGGER_CMDDONE; do { /* Read command from the keyboard and give previous * command for freeing / adding to history */ psCmd = DebugUI_GetCommand(psCmd); if (!psCmd) break; /* returns new expression expanded string */ if (!(expCmd = DebugUI_EvaluateExpressions(psCmd))) continue; /* Parse and execute the command string */ cmdret = DebugUI_ParseCommand(expCmd); free(expCmd); } while (cmdret != DEBUGGER_END); /* free exit command */ DebugUI_FreeCommand(psCmd); Log_SetAlertLevel(alertLevel); DebugUI_SetLogDefault(); DebugCpu_SetDebugging(); DebugDsp_SetDebugging(); }