public static unsafe void DispatchInterrupt(InterruptContext *context) { #if false DebugStub.WriteLine("---------------------------------------------------------------\n"); DebugStub.WriteLine("DispatchInterrupt (vector={0:x2})", __arglist(context->vector)); context->Display(); DebugStub.WriteLine("---------------------------------------------------------------\n"); #endif // This count is stored in the Singularity Processor object, since that is where singx86 // looks for it. Need to move at some point. Singularity.Processor p = Singularity.Processor.CurrentProcessor; if (p != null) { p.IncrementInterruptCounts(context->ExceptionId); } if (context->IsException()) { // All exceptions get reported to the debugger (as first chance.) DispatchDebugger(ref GetCurrentCpu()->spill, context->ExceptionId); // TBD: eventually we want to actually have OS logic to do something with // hardware exceptions... } else { // Reset context for interrupt code (this affects the fpu) // @todo: investigate details here; this seems wrong -SET SpillContext.ResetCurrent(); HalPlatform.CurrentCpu.DispatchInterrupt(context); } }
private static void DispatchDebugger(ref SpillContext context, int exception) { #if ISA_IX // TBD: factor this special case into debugger abstraction if (exception == EVectors.Nmi) { if (Microsoft.Singularity.MpExecution.FreezeRequested) { Singularity.MpExecution.FreezeProcessor(ref context); } else { DebugStub.WriteLine("******************* NMI Interrupt **********************\n"); Singularity.DebugStub.Trap(ref context, exception); } } else { // TBD: we should factor the debugger support into the HAL. Singularity.DebugStub.Trap(ref context, exception); } #elif ISA_ARM // Fix up pc for some software exceptions, regardless of debugger attachment. if (exception == ExceptionVector.SoftwareInterrupt) { // Move pc forward to resume after interrupting instruction. if (context.instruction != 0x0efffff01) { // Don't move pc forward for debugger-inserted breakpoints. context.pc += 4; } } else if (exception == ExceptionVector.UndefinedInstruction) { // Move pc forward to resume after interrupting instruction. context.pc += 4; } // TBD: we should factor the debugger support into the HAL. Singularity.DebugStub.Trap(ref context, exception); #endif context.Resume(); }