void DebuggerIPCServer::handleNext() { int id = data_manager->whoami(); Breakpoint bkpt(true); bkpt.addCondition(Breakpoint::BreakpointCondition::BREAK_ON_PACKET_ID, std::to_string(id)); bkpt.temp = true; data_manager->addBreakpoint(bkpt); // continue simulation handleContinue(-1); }
// Handle decoding incoming MIDI traffic a byte at a time -- remembers // what it needs to from one call to the next. // // This is a private function & not meant to be called from outside this class. // It's used whenever data is available from the serial port. // void Midi::recvByte(int value) { int tmp; int channel; int bigval; /* temp 14-bit value for pitch, song pos */ if (recvMode_ & MODE_PROPRIETARY && value != STATUS_END_PROPRIETARY) { /* If proprietary handling compiled in, just pass all data received * after a START_PROPRIETARY event to proprietary_decode * until get an END_PROPRIETARY event */ #ifdef CONFIG_MIDI_PROPRIETARY proprietaryDecode(value); #endif return; } if (value & 0x80) { /* All < 0xf0 events get at least 1 arg byte so * it's ok to mask off the low 4 bits to figure * out how to handle the event for < 0xf0 events. */ tmp = value; if (tmp < 0xf0) tmp &= 0xf0; switch (tmp) { /* These status events take 2 bytes as arguments */ case STATUS_EVENT_NOTE_OFF: case STATUS_EVENT_NOTE_ON: case STATUS_EVENT_VELOCITY_CHANGE: case STATUS_EVENT_CONTROL_CHANGE: case STATUS_PITCH_CHANGE: case STATUS_SONG_POSITION: recvBytesNeeded_ = 2; recvByteCount_ = 0; recvEvent_ = value; break; /* 1 byte arguments */ case STATUS_EVENT_PROGRAM_CHANGE: case STATUS_AFTER_TOUCH: case STATUS_SONG_SELECT: recvBytesNeeded_ = 1; recvByteCount_ = 0; recvEvent_ = value; return; /* No arguments ( > 0xf0 events) */ case STATUS_START_PROPRIETARY: recvMode_ |= MODE_PROPRIETARY; #ifdef CONFIG_MIDI_PROPRIETARY proprietaryDecodeStart(); #endif break; case STATUS_END_PROPRIETARY: recvMode_ &= ~MODE_PROPRIETARY; #ifdef CONFIG_MIDI_PROPRIETARY proprietaryDecodeEnd(); #endif break; case STATUS_TUNE_REQUEST: handleTuneRequest(); break; case STATUS_SYNC: handleSync(); break; case STATUS_START: handleStart(); break; case STATUS_CONTINUE: handleContinue(); break; case STATUS_STOP: handleStop(); break; case STATUS_ACTIVE_SENSE: handleActiveSense(); break; case STATUS_RESET: handleReset(); break; } return; } if (++recvByteCount_ == recvBytesNeeded_) { /* Copy out the channel (if applicable; in some cases this will be meaningless, * but in those cases the value will be ignored) */ channel = (recvEvent_ & 0x0f) + 1; tmp = recvEvent_; if (tmp < 0xf0) { tmp &= 0xf0; } /* See if this event matches our MIDI channel * (or we're accepting for all channels) */ if (!channelIn_ || (channel == channelIn_) || (tmp >= 0xf0)) { switch (tmp) { case STATUS_EVENT_NOTE_ON: /* If velocity is 0, it's actually a note off & should fall thru * to the note off case */ if (value) { handleNoteOn(channel, recvArg0_, value); break; } case STATUS_EVENT_NOTE_OFF: handleNoteOff(channel, recvArg0_, value); break; case STATUS_EVENT_VELOCITY_CHANGE: handleVelocityChange(channel, recvArg0_, value); break; case STATUS_EVENT_CONTROL_CHANGE: handleControlChange(channel, recvArg0_, value); break; case STATUS_EVENT_PROGRAM_CHANGE: handleProgramChange(channel, value); break; case STATUS_AFTER_TOUCH: handleAfterTouch(channel, value); break; case STATUS_PITCH_CHANGE: bigval = (value << 7) | recvArg0_; handlePitchChange(bigval); break; case STATUS_SONG_POSITION: bigval = (value << 7) | recvArg0_; handleSongPosition(bigval); break; case STATUS_SONG_SELECT: handleSongSelect(value); break; } } /* Just reset the byte count; keep the same event -- might get more messages trailing from current event. */ recvByteCount_ = 0; } recvArg0_ = value; }
void DebuggerIPCServer::parseRequest(PFPSimDebugger::DebugMsg *request) { switch (request->type()) { case PFPSimDebugger::DebugMsg_Type_Run: { if (!run_called) { run_called = true; PFPSimDebugger::RunMsg msg; msg.ParseFromString(request->message()); if (msg.has_time_ns()) { handleRun(stod(msg.time_ns())); } else { handleRun(); } } else { // TODO(eric): this is a temporary fix for the double run message problem SimulationEndMessage *msg = new SimulationEndMessage(); send(msg); delete msg; } break; } case PFPSimDebugger::DebugMsg_Type_GetCounter: { PFPSimDebugger::GetCounterMsg msg; msg.ParseFromString(request->message()); handleGetCounter(msg); break; } case PFPSimDebugger::DebugMsg_Type_GetAllCounters: { handleGetAllCounters(); break; } case PFPSimDebugger::DebugMsg_Type_SetBreakpoint: { PFPSimDebugger::SetBreakpointMsg msg; msg.ParseFromString(request->message()); handleSetBreakpoint(msg); break; } case PFPSimDebugger::DebugMsg_Type_Continue: { PFPSimDebugger::ContinueMsg msg; msg.ParseFromString(request->message()); if (msg.has_time_ns()) { handleContinue(stod(msg.time_ns())); // alternative to stod? } else { handleContinue(); } break; } case PFPSimDebugger::DebugMsg_Type_GetAllBreakpoints: { handleGetAllBreakpoints(); break; } case PFPSimDebugger::DebugMsg_Type_RemoveBreakpoint: { PFPSimDebugger::RemoveBreakpointMsg msg; msg.ParseFromString(request->message()); handleRemoveBreakpoint(msg); break; } case PFPSimDebugger::DebugMsg_Type_WhoAmI: { handleWhoAmI(); break; } case PFPSimDebugger::DebugMsg_Type_Next: { handleNext(); break; } case PFPSimDebugger::DebugMsg_Type_GetPacketList: { PFPSimDebugger::GetPacketListMsg msg; msg.ParseFromString(request->message()); handleGetPacketList(msg); break; } case PFPSimDebugger::DebugMsg_Type_SetWatchpoint: { PFPSimDebugger::SetWatchpointMsg msg; msg.ParseFromString(request->message()); handleSetWatchpoint(msg); break; } case PFPSimDebugger::DebugMsg_Type_GetAllWatchpoints: { handleGetAllWatchpoints(); break; } case PFPSimDebugger::DebugMsg_Type_RemoveWatchpoint: { PFPSimDebugger::RemoveWatchpointMsg msg; msg.ParseFromString(request->message()); handleRemoveWatchpoint(msg); break; } case PFPSimDebugger::DebugMsg_Type_Backtrace: { PFPSimDebugger::BacktraceMsg msg; msg.ParseFromString(request->message()); handleBacktrace(msg); break; } case PFPSimDebugger::DebugMsg_Type_EnableDisableBreakpoint: { PFPSimDebugger::EnableDisableBreakpointMsg msg; msg.ParseFromString(request->message()); handleEnableDisableBreakpoint(msg); break; } case PFPSimDebugger::DebugMsg_Type_EnableDisableWatchpoint: { PFPSimDebugger::EnableDisableWatchpointMsg msg; msg.ParseFromString(request->message()); handleEnableDisableWatchpoint(msg); break; } case PFPSimDebugger::DebugMsg_Type_IgnoreModule: { PFPSimDebugger::IgnoreModuleMsg msg; msg.ParseFromString(request->message()); handleIgnoreModule(msg); break; } case PFPSimDebugger::DebugMsg_Type_GetAllIgnoreModules: { handleGetAllIgnoreModules(); break; } case PFPSimDebugger::DebugMsg_Type_GetSimulationTime: { handleGetSimulationTime(); break; } case PFPSimDebugger::DebugMsg_Type_BreakOnPacketDrop: { PFPSimDebugger::BreakOnPacketDropMsg msg; msg.ParseFromString(request->message()); handleBreakOnPacketDrop(msg); break; } case PFPSimDebugger::DebugMsg_Type_GetDroppedPackets: { handleGetDroppedPackets(); break; } case PFPSimDebugger::DebugMsg_Type_CPCommand: { PFPSimDebugger::CPCommandMsg msg; msg.ParseFromString(request->message()); handleCPCommand(msg); break; } case PFPSimDebugger::DebugMsg_Type_GetTableEntries: { handleGetTableEntries(); break; } case PFPSimDebugger::DebugMsg_Type_GetPacketField: { PFPSimDebugger::GetPacketFieldMsg msg; msg.ParseFromString(request->message()); handleGetPacketField(msg.id(), msg.field_name()); break; } case PFPSimDebugger::DebugMsg_Type_GetRawPacket: { PFPSimDebugger::GetRawPacketMsg msg; msg.ParseFromString(request->message()); handleGetRawPacket(msg.id()); break; } case PFPSimDebugger::DebugMsg_Type_GetParsedPacket: { PFPSimDebugger::GetParsedPacketMsg msg; msg.ParseFromString(request->message()); handleGetParsedPacket(msg.id()); break; } case PFPSimDebugger::DebugMsg_Type_StartTracing: { PFPSimDebugger::StartTracingMsg msg; msg.ParseFromString(request->message()); handleStartTracing(msg); } default: { sendRequestFailed(); } } }
// Handle decoding incoming MIDI traffic a byte at a time -- remembers // what it needs to from one call to the next. // // This is a private function & not meant to be called from outside this class. // It's used whenever data is available from the serial port. // void USBMidi::dispatchPacket(uint32 p) { union EVENT_t e; e.i=p; // !!!!!!!!!!!!!!!! Add a sysex handler FIX THIS VERY VERY SHORTLY !!!!!!!!!!!!!! if (recvMode_ & MODE_PROPRIETARY && CIN_IS_SYSEX(e.p.cin)) { /* If sysex handling compiled in, just pass all data received * to the sysex handler */ #ifdef CONFIG_MIDI_PROPRIETARY // handleSysex(p); #endif return; } switch (e.p.cin) { case CIN_3BYTE_SYS_COMMON: if (e.p.midi0 == MIDIv1_SONG_POSITION_PTR) { handleSongPosition(((uint16)e.p.midi2)<<7|((uint16)e.p.midi1)); } break; case CIN_2BYTE_SYS_COMMON: switch (e.p.midi0) { case MIDIv1_SONG_SELECT: handleSongSelect(e.p.midi1); break; case MIDIv1_MTC_QUARTER_FRAME: // reference library doesnt handle quarter frame. break; } break; case CIN_NOTE_OFF: handleNoteOff(MIDIv1_VOICE_CHANNEL(e.p.midi0), e.p.midi1, e.p.midi2); break; case CIN_NOTE_ON: handleNoteOn(MIDIv1_VOICE_CHANNEL(e.p.midi0), e.p.midi1, e.p.midi2); break; case CIN_AFTER_TOUCH: handleVelocityChange(MIDIv1_VOICE_CHANNEL(e.p.midi0), e.p.midi1, e.p.midi2); break; case CIN_CONTROL_CHANGE: handleControlChange(MIDIv1_VOICE_CHANNEL(e.p.midi0), e.p.midi1, e.p.midi2); break; case CIN_PROGRAM_CHANGE: handleProgramChange(MIDIv1_VOICE_CHANNEL(e.p.midi0), e.p.midi1); break; case CIN_CHANNEL_PRESSURE: handleAfterTouch(MIDIv1_VOICE_CHANNEL(e.p.midi0), e.p.midi1); break; case CIN_PITCH_WHEEL: handlePitchChange(((uint16)e.p.midi2)<<7|((uint16)e.p.midi1)); break; case CIN_1BYTE: switch (e.p.midi0) { case MIDIv1_CLOCK: handleSync(); break; case MIDIv1_TICK: break; case MIDIv1_START: handleStart(); break; case MIDIv1_CONTINUE: handleContinue(); break; case MIDIv1_STOP: handleStop(); break; case MIDIv1_ACTIVE_SENSE: handleActiveSense(); break; case MIDIv1_RESET: handleReset(); break; case MIDIv1_TUNE_REQUEST: handleTuneRequest(); break; default: break; } break; } }