示例#1
0
        /// <summary>
        /// Interrupts the handler.
        /// </summary>
        /// <param name="edi">The edi.</param>
        /// <param name="esi">The esi.</param>
        /// <param name="ebp">The ebp.</param>
        /// <param name="esp">The esp.</param>
        /// <param name="ebx">The ebx.</param>
        /// <param name="edx">The edx.</param>
        /// <param name="ecx">The ecx.</param>
        /// <param name="eax">The eax.</param>
        /// <param name="interrupt">The interrupt.</param>
        /// <param name="errorcode">The errorcode.</param>
        private static void InterruptHandler(uint edi, uint esi, uint ebp, uint esp, uint ebx, uint edx, uint ecx, uint eax, uint interrupt, uint errorCode)
        {
            uint c   = Screen.Column;
            uint r   = Screen.Row;
            byte col = Screen.Color;

            Screen.Column = 30;
            Screen.Row    = 0;
            Screen.Color  = 3;

            _counter++;
            Screen.Write(_counter, 10, 8);
            Screen.Write(':');
            Screen.Write(interrupt, 16, 2);

            if (interrupt == 14)
            {
                // Page Fault!
                PageFaultHandler.Fault(errorCode);
            }
            if (interrupt == 0x20)
            {
                // Timer Interrupt! Switch Tasks!
            }
            else
            {
                Screen.Write(':');
                Screen.Write(_counter, 10, 8);
                Screen.Write(':');
                Screen.Write(interrupt, 16, 2);
                Screen.Write('-');
                Screen.Write(errorCode, 16, 2);

                if (interrupt == 0x21)
                {
                    byte scancode = Keyboard.ReadScanCode();
                    Screen.Write('-');
                    Screen.Write(scancode, 16, 2);
                }
            }

            Screen.Column = c;
            Screen.Row    = r;
            Screen.Color  = col;

            PIC.SendEndOfInterrupt((byte)interrupt);
        }
示例#2
0
        /// <summary>
        /// Interrupts the handler.
        /// </summary>
        /// <param name="edi">The edi.</param>
        /// <param name="esi">The esi.</param>
        /// <param name="ebp">The ebp.</param>
        /// <param name="esp">The esp.</param>
        /// <param name="ebx">The ebx.</param>
        /// <param name="edx">The edx.</param>
        /// <param name="ecx">The ecx.</param>
        /// <param name="eax">The eax.</param>
        /// <param name="interrupt">The interrupt.</param>
        /// <param name="errorCode">The error code.</param>
        private static void ProcessInterrupt(uint edi, uint esi, uint ebp, uint esp, uint ebx, uint edx, uint ecx, uint eax, uint interrupt, uint errorCode, uint eip, uint cs, uint eflags)
        {
            DebugClient.Process();

            switch (interrupt)
            {
            case 0:
                Error(ebp, eip, "Divide Error");
                break;

            case 4:
                Error(ebp, eip, "Arithmetic Overflow Exception");
                break;

            case 5:
                Error(ebp, eip, "Bound Check Error");
                break;

            case 6:
                Error(ebp, eip, "Invalid Opcode");
                break;

            case 7:
                Error(ebp, eip, "Coprocessor Not Available");
                break;

            case 8:
                //TODO: Analyze the double fault
                Error(ebp, eip, "Double Fault");
                break;

            case 9:
                Error(ebp, eip, "Coprocessor Segment Overrun");
                break;

            case 10:
                Error(ebp, eip, "Invalid TSS");
                break;

            case 11:
                Error(ebp, eip, "Segment Not Present");
                break;

            case 12:
                Error(ebp, eip, "Stack Exception");
                break;

            case 13:
                Error(ebp, eip, "General Protection Exception");
                break;

            case 14:
                // Page Fault!
                var cr2 = Native.GetCR2() >> 5;
                if (cr2 < 0x1000)
                {
                    Error(ebp, eip, "Null Pointer Exception");
                    break;
                }

                PageFaultHandler.Fault(errorCode);
                break;

            case 16:
                Error(ebp, eip, "Coprocessor Error");
                break;

            case 19:
                Error(ebp, eip, "SIMD Floating-Point Exception");
                break;

            default:
                if (interruptHandler != null)
                {
                    interruptHandler(interrupt, errorCode);
                }
                break;
            }

            PIC.SendEndOfInterrupt(interrupt);
        }