/** * Set up the signal handlers for CTRL-C. */ void SignalHandler::setupSignalHandlers() { if (signal((int) SIGINT, SignalHandler::exitSignalHandler) == SIG_ERR) { throw SignalException("!!!!! Error setting up signal handlers !!!!!"); } }
void SignalHandler::throwSignalException(int sig) { switch (sig) { case SIGILL: throw SignalException("Illegal instruction"); case SIGBUS: throw SignalException("Bus error"); case SIGSEGV: throw SignalException("Segmentation violation"); case SIGSYS: throw SignalException("Invalid system call"); default: throw SignalException(NumberFormatter::formatHex(sig)); } }
void Connection::negotiateCompleted(const NegotiateResponse* negotiateResponse, SignalException* error) { if(!error) { if( !(negotiateResponse->protocolVersion == "1.3" || negotiateResponse->protocolVersion == "1.2") ) { onError(SignalException("Invalid protocol version", SignalException::InvalidProtocolVersion)); stop(); } else { if(negotiateResponse->keepAliveTimeout > 0) { _keepAliveData = new KeepAliveData(negotiateResponse->keepAliveTimeout); } setConnectionState(*negotiateResponse); connect(_transport, SIGNAL(transportStarted(SignalException*)), this, SLOT(transportStarted(SignalException*))); getTransport()->start(""); } } else { if(_autoReconnect)
Value* mouse_track_cf(Value** arg_list, int count) { // mouseTrack [on:node|#any] [prompt:"msg"] [snap:#2D|#3D] [trackCallback:fn|#(fn,arg)] // set up value local array to hold mouse tracker command mode Value*'s Value** vavl; value_local_array(vavl, sizeof(tmvl) / sizeof(Value*)); tmvl* vl = (tmvl*)vavl; // show any prompt Value* pv = key_arg(prompt); const TCHAR* prompt = NULL; if (pv != &unsupplied) { prompt = pv->to_string(); mprintf(_T("%s "), prompt); mflush(); } // setup snap Value* sv = key_arg_or_default(snap, n_2D); if (sv != n_2D && sv != n_3D) throw RuntimeError (MaxSDK::GetResourceStringAsMSTR(IDS_BAD_SNAP_MODE), sv); // setup track callback fn Value* tcb = NULL; Value* tcbarg = NULL; Value *tcbv = key_arg(trackCallback); if (tcbv != &unsupplied) { if (is_array(tcbv)) // an array, #(fn, arg), dig out fn & arg { Array* tcba = (Array*)tcbv; if (tcba->size != 2) throw RuntimeError (MaxSDK::GetResourceStringAsMSTR(IDS_BAD_MOVE_CALLBACK_ARGS), tcbv); tcb = tcba->data[0]; if (!is_function(tcb)) throw RuntimeError (MaxSDK::GetResourceStringAsMSTR(IDS_BAD_MOVE_CALLBACK_ARGS), tcb); tcbarg = tcba->data[1]; } else // just the fn { tcb = tcbv; if (!is_function(tcb)) throw RuntimeError (MaxSDK::GetResourceStringAsMSTR(IDS_BAD_MOVE_CALLBACK_ARGS), tcbv); } } // pickup any node to track on vl->node_val = key_arg(on); NodeTab& nodeTab = theTrackMouseCommandMode.proc.nodeTab; nodeTab.SetCount(0); if( vl->node_val->_is_collection() ) { //Multiple nodes specified Value* args[2] = { NULL, (Value*)&nodeTab }; node_map m = { NULL, collect_nodes, args, 2 }; vl->node_val->map(m); } else if( vl->node_val != &unsupplied ) { //Single node specified INode* node = vl->node_val->to_node(); nodeTab.Append( 1, &node ); } for( int i=(nodeTab.Count()-1); i>=0; i--) if( nodeTab[i]==NULL ) nodeTab.Delete(i,1); //Delete null nodes // set up pickpoint options, enter trackmouse command mode & wait for it to signal completion end_track_mouse = FALSE; theTrackMouseCommandMode.proc.vl = vl; theTrackMouseCommandMode.proc.snap_mode = sv; theTrackMouseCommandMode.proc.track_callback = tcb; theTrackMouseCommandMode.proc.track_callback_arg = tcbarg; theTrackMouseCommandMode.proc.start_track(); //Changed from Set to Push to prevent an exception when the maxscript code changes the command mode //Similar to fix done to MouseTool.cpp - line 661 MAXScript_interface->PushCommandMode(&theTrackMouseCommandMode); // process windows messages until point picked or canceled or keyboard message MSG wmsg; while (GetMessage(&wmsg, NULL, 0,0)) { if (wmsg.message == WM_KEYUP && (TCHAR)wmsg.wParam == VK_ESCAPE) end_track_mouse = TRUE; else if (wmsg.message == WM_KEYUP || wmsg.message == WM_KEYDOWN) continue; else if (wmsg.message != WM_RBUTTONUP) // ignore rmousebuttonup's - they mess focus MAXScript_interface->TranslateAndDispatchMAXMessage(wmsg); if (end_track_mouse) break; } if (!end_track_mouse) { // we came out of message loop because of a quit, repost the quit and throw a SignalException theTrackMouseCommandMode.proc.end_track(); MAXScript_interface->DeleteMode(&theTrackMouseCommandMode); throw SignalException(); } // pickup result value & dismiss input modes theTrackMouseCommandMode.proc.end_track(); MAXScript_interface->DeleteMode(&theTrackMouseCommandMode); Value* result = vl->result; pop_value_local_array(vavl); return_protected(result); }
main(int argc, char *argv[]) { CDReader *cdreaderP; FILEHANDLE image_file; UWORD audio_blklen, mode1_blklen, mode2_blklen; TCHAR image_filnam[_MAX_PATH + 1]; TCHAR cue_filnam[_MAX_PATH + 1]; TCHAR cdtext_filnam[_MAX_PATH + 1]; TCHAR *image_filnamP = NULL, *cue_filnamP = NULL, *cdtext_filnamP = NULL; // Enable exception handling. EXCEPTION_HANDLER_START // Initialize and check the protection. ProtInitialize (NULL, FALSE); // Get the environment variables. GetEnvironmentVariables(); // Parse the command line arguments. ParseCommandLine (argc, argv); // Register the event callback function. EventRegisterCallback (ConsoleEventCallback); // Startup the ASPI manager. ASPIAdapter::StartupManager (FALSE, FALSE, TRUE); // Find a CDROM device... if (cdreader_id_specified) { if ((cdreaderP = (CDReader *)ASPIAdapter::FindDeviceObject ( ASPI_M_DEVTYPE_CDROM | ASPI_M_DEVTYPE_WORM, cdreader_adapter, cdreader_id, cdreader_lun)) == NULL) { fprintf (stderr, "\nError: Specified device (%u:%u:%u) is not a CDROM!\n", cdreader_adapter, cdreader_id, cdreader_lun); exit (1); } } else { if ((cdreaderP = (CDReader *)ASPIAdapter::FindDeviceObject ( ASPI_M_DEVTYPE_CDROM | ASPI_M_DEVTYPE_WORM)) == NULL) { fprintf (stderr, "\nError: Unable to find a known CDROM device!\n"); exit (1); } } if (log_flag) { printf ("CDROM device found...\n"); printf (" HA #%u - ASPI ID #%u - %-8s %-16s %-4s\n\n", cdreaderP->GetAdapter(), cdreaderP->GetId(), cdreaderP->GetVendorId(), cdreaderP->GetProductId(), cdreaderP->GetFirmwareLevel()); } if (cdreaderP->GetModel() == GENERIC_CDROM_SCSI) { fprintf (stderr, "Warning: CDROM device model is unknown to this program!\n"); fprintf (stderr, "The generic CDROM device driver will be used...\n\n"); } // If necessary, check that this device supports the reading of SUBCODEs. if ((scan_subcode_mode == SCAN_SUBCODE_QUICK) || (scan_subcode_mode == SCAN_SUBCODE_FULL)) { if (! cdreaderP->IsFlagSet(CDReader::crfReadSUBQ)) { fprintf (stderr, "Error: CDROM device does not support the reading of subcodes!\n"); exit (1); } } // If necessary, check that this device supports the reading of CD+G discs. if (cdg_flag && (! cdreaderP->IsFlagSet(CDReader::crfReadCDG))) { fprintf (stderr, "Error: CDROM device does not support the reading of CD+G discs!\n"); exit (1); } // Analyze the disc layout. auto_ptr<DiscLayout> disclayoutP(new DiscLayout ( cdreaderP, read_speed, scan_subcode_mode, mcn_isrc_flag, cdtext_flag, log_flag)); if (log_flag) { printf ("\nDisc Statistics:\n"); printf (" Audio track count - %u\n", disclayoutP->m_nAudioTrackCount); printf (" Mode1 data track count - %u\n", disclayoutP->m_nMode1TrackCount); printf (" Mode2 data track count - %u\n", disclayoutP->m_nMode2TrackCount); } // Is the disc too long? if (disclayoutP->m_nLastLBA > CDROM_80MIN_BLKCNT) fprintf (stderr, "\nWARNING: Disc is longer than 80 minutes!\n"); // Check the disc layout. if (! disclayoutP->Check()) { fprintf (stderr, "\nWARNING: Disc contains one or more tracks that are shorter than \n"); fprintf (stderr, "four seconds. This is a violation of the CDROM specification.\n"); } // Determine the block lengths. audio_blklen = (cdg_flag ? SECTOR_CDDA_SUBPW_BLKLEN : SECTOR_CDDA_BLKLEN); if (cooked_flag) {mode1_blklen = SECTOR_MODE1_BLKLEN; mode2_blklen = SECTOR_MODE2_BLKLEN;} else {mode1_blklen = SECTOR_RAW_BLKLEN; mode2_blklen = SECTOR_RAW_BLKLEN;} // Set the block length for each track. DiscInfo *discinfoP = disclayoutP->m_pDiscInfo; for (int i = 0; i < discinfoP->m_nTrackCount; i++) { TRACKINFO *trackinfoP = &discinfoP->m_TrackInfo[i]; switch (trackinfoP->datatype) { case DATATYPE_CDDA: trackinfoP->blklen = audio_blklen; break; case DATATYPE_CDROM: trackinfoP->blklen = mode1_blklen; break; case DATATYPE_CDROMXA: case DATATYPE_CDI: trackinfoP->blklen = mode2_blklen; break; } } // Build the cuesheet filename. StringCopy (cue_filnam, base_filnamP); FileAddExtension (cue_filnam, ".cue", (! cueonly_flag)); cue_filnamP = cue_filnam; // If we're not just writing a cuesheet, then build the image and CD-TEXT filenames. if (! cueonly_flag) { StringCopy (image_filnam, base_filnamP); FileAddExtension (image_filnam, ".bin", FALSE); image_filnamP = image_filnam; if (cdtext_flag && (discinfoP->m_pCDTextPackVec != NULL)) { StringCopy (cdtext_filnam, base_filnamP); FileAddExtension (cdtext_filnam, ".cdt", TRUE); cdtext_filnamP = cdtext_filnam; } // Display image file stats? if (log_flag) { // Compute the amount of disc space required. ULONG blkcnt = disclayoutP->m_nLastLBA + 1; printf ("\nImage file will require approximately %luMb of disk space.\n", CDIV (blkcnt * SECTOR_RAW_BLKLEN, 0x100000)); } // Prompt to begin copy? if (confirm_flag) { printf ("\nHit <ENTER> to copy disc (or CTRL/C to exit)..."); getchar (); printf ("\n"); } } // Generate the CUE SHEET file. disclayoutP->GenerateCuesheetFile (cue_filnamP, image_filnamP, cdtext_filnamP); // Generate the CD-TEXT data file? if (cdtext_filnamP != NULL) { FILEHANDLE handle; ULONG null = 0; if ((handle = FileCreate (cdtext_filnamP)) == NULL) SignalException (E_CreateFile, 1, 0, 0, HeapString(cdtext_filnamP)); FileWrite ( handle, discinfoP->m_pCDTextPackVec, discinfoP->m_nCDTextPackCount * sizeof(CDTEXTPACK)); FileWrite (handle, &null, 1); FileClose (handle); } // Generate the image file? if (image_filnamP != NULL) { // Make sure the device is ready. cdreaderP->LoadDisc (TRUE); // Create the output image file. if ((image_file = FileCreate (image_filnamP)) == NULL) { fprintf (stderr, "\nError creating image file \"%s\"\n", image_filnamP); exit (1); } // Loop through the "copy instructions"... for (int i = 0; i < disclayoutP->m_nCopyInstrCount; i++) { COPYINSTR *copyinstrP = &disclayoutP->m_CopyInstr[i]; // Set the block length. UWORD blklen = ((copyinstrP->datatype == DATATYPE_CDDA) ? audio_blklen : ((copyinstrP->datatype == DATATYPE_CDROM) ? mode1_blklen : mode2_blklen)); // Select operation... switch (copyinstrP->opcode) { // Read a range of audio/data sectors. case CI_READ_SECTORS: { if (copyinstrP->datatype == DATATYPE_CDDA) { // Set the reading speed. cdreaderP->SetSpindleSpeed (read_speed, FALSE, FALSE); // Extract the audio sectors. cdreaderP->ExtractSectorsToFile ( image_file, DATATYPE_CDDA, blklen, copyinstrP->lba, copyinstrP->blkcnt, jitter_mode, 0, error_mode, FALSE, log_flag); } else { // Set the reading speed to maximum. cdreaderP->SetSpindleSpeed (SPEED_MAX, TRUE, FALSE); // Extract the data sectors. cdreaderP->ExtractSectorsToFile ( image_file, copyinstrP->datatype, blklen, copyinstrP->lba, copyinstrP->blkcnt, JITTER_MODE_DISABLE, 0, error_mode, FALSE, log_flag); } break; } // Generate replacements for unreadable blocks at the end of a track. case CI_GENERATE_SECTORS: { WriteEmptySectors ( image_file, copyinstrP->datatype, blklen, copyinstrP->lba, copyinstrP->blkcnt); break; } // Ignore PREGAP instructions. case CI_GENERATE_PREGAP: case CI_GENERATE_PREGAP2: break; default: SignalException (E_BugCheck); } } // Reset the reading speed. cdreaderP->SetSpindleSpeed (SPEED_MAX, FALSE, FALSE); // Close the image file. FileClose (image_file); // Success! if (log_flag) printf ("\nCopy completed successfully!\n"); // Notify user of completion? if (beep_flag) BeepUser(); } // Shutdown the ASPI manager. ASPIAdapter::ShutdownManager(); // End exception handling. EXCEPTION_HANDLER_EXIT return (0); }
void store_fpr (sim_cpu *cpu, address_word cia, int fpr, FP_formats fmt, uword64 value) { int err = 0; #ifdef DEBUG printf ("DBG: StoreFPR: fpr = %d, fmt = %s, value = 0x%s : PC = 0x%s : SizeFGR () = %d, \n", fpr, fpu_format_name (fmt), pr_uword64 (value), pr_addr (cia), SizeFGR ()); #endif /* DEBUG */ if (SizeFGR () == 64) { switch (fmt) { case fmt_uninterpreted_32: fmt = fmt_uninterpreted; case fmt_single: case fmt_word: if (STATE_VERBOSE_P (SD)) sim_io_eprintf (SD, "Warning: PC 0x%s: interp.c store_fpr DEADCODE\n", pr_addr (cia)); FGR[fpr] = (((uword64) 0xDEADC0DE << 32) | (value & 0xFFFFFFFF)); FPR_STATE[fpr] = fmt; break; case fmt_uninterpreted_64: fmt = fmt_uninterpreted; case fmt_uninterpreted: case fmt_double: case fmt_long: case fmt_ps: FGR[fpr] = value; FPR_STATE[fpr] = fmt; break; default: FPR_STATE[fpr] = fmt_unknown; err = -1; break; } } else { switch (fmt) { case fmt_uninterpreted_32: fmt = fmt_uninterpreted; case fmt_single: case fmt_word: FGR[fpr] = (value & 0xFFFFFFFF); FPR_STATE[fpr] = fmt; break; case fmt_uninterpreted_64: fmt = fmt_uninterpreted; case fmt_uninterpreted: case fmt_double: case fmt_long: if ((fpr & 1) == 0) { /* Even register numbers only. */ FGR[fpr+1] = (value >> 32); FGR[fpr] = (value & 0xFFFFFFFF); FPR_STATE[fpr + 1] = fmt; FPR_STATE[fpr] = fmt; } else { FPR_STATE[fpr] = fmt_unknown; FPR_STATE[fpr ^ 1] = fmt_unknown; SignalException (ReservedInstruction, 0); } break; case fmt_ps: FPR_STATE[fpr] = fmt_unknown; SignalException (ReservedInstruction, 0); break; default: FPR_STATE[fpr] = fmt_unknown; err = -1; break; }
uword64 value_fpr (sim_cpu *cpu, address_word cia, int fpr, FP_formats fmt) { uword64 value = 0; int err = 0; /* Treat unused register values, as fixed-point 64bit values. */ if (fmt == fmt_unknown) { #if 1 /* If request to read data as "unknown", then use the current encoding: */ fmt = FPR_STATE[fpr]; #else fmt = fmt_long; #endif } /* For values not yet accessed, set to the desired format. */ if (fmt < fmt_uninterpreted) { if (FPR_STATE[fpr] == fmt_uninterpreted) { FPR_STATE[fpr] = fmt; #ifdef DEBUG printf ("DBG: Register %d was fmt_uninterpreted. Now %s\n", fpr, fpu_format_name (fmt)); #endif /* DEBUG */ } else if (fmt != FPR_STATE[fpr]) { sim_io_eprintf (SD, "FPR %d (format %s) being accessed with format %s - setting to unknown (PC = 0x%s)\n", fpr, fpu_format_name (FPR_STATE[fpr]), fpu_format_name (fmt), pr_addr (cia)); FPR_STATE[fpr] = fmt_unknown; } } if (FPR_STATE[fpr] == fmt_unknown) { /* Set QNaN value: */ switch (fmt) { case fmt_single: value = FPQNaN_SINGLE; break; case fmt_double: value = FPQNaN_DOUBLE; break; case fmt_word: value = FPQNaN_WORD; break; case fmt_long: value = FPQNaN_LONG; break; case fmt_ps: value = FPQNaN_PS; break; default: err = -1; break; } } else if (SizeFGR () == 64) { switch (fmt) { case fmt_uninterpreted_32: case fmt_single: case fmt_word: value = (FGR[fpr] & 0xFFFFFFFF); break; case fmt_uninterpreted_64: case fmt_uninterpreted: case fmt_double: case fmt_long: case fmt_ps: value = FGR[fpr]; break; default: err = -1; break; } } else { switch (fmt) { case fmt_uninterpreted_32: case fmt_single: case fmt_word: value = (FGR[fpr] & 0xFFFFFFFF); break; case fmt_uninterpreted_64: case fmt_uninterpreted: case fmt_double: case fmt_long: if ((fpr & 1) == 0) { /* Even register numbers only. */ #ifdef DEBUG printf ("DBG: ValueFPR: FGR[%d] = %s, FGR[%d] = %s\n", fpr + 1, pr_uword64 ((uword64) FGR[fpr+1]), fpr, pr_uword64 ((uword64) FGR[fpr])); #endif value = ((((uword64) FGR[fpr+1]) << 32) | (FGR[fpr] & 0xFFFFFFFF)); } else { SignalException (ReservedInstruction, 0); } break; case fmt_ps: SignalException (ReservedInstruction, 0); break; default: err = -1; break; } } if (err) SignalExceptionSimulatorFault ("Unrecognised FP format in ValueFPR ()"); #ifdef DEBUG printf ("DBG: ValueFPR: fpr = %d, fmt = %s, value = 0x%s : PC = 0x%s : SizeFGR () = %d\n", fpr, fpu_format_name (fmt), pr_uword64 (value), pr_addr (cia), SizeFGR ()); #endif /* DEBUG */ return (value); }