public static Error ( string message ) : void | ||
message | string | |
Результат | void |
/// <summary> /// Helps to track memroy changes. Checks if memroy has changed between two calls. /// </summary> /// <param name="startAddress"></param> /// <param name="bytes"></param> /// <param name="panic">Halt the kernel</param> /// <param name="message">Display a custom message</param> /// <returns></returns> public static bool MemoryChanged(uint startAddress, uint bytes, bool panic = false, string message = null) { //Improvement: Allocate memory for multiple items and check for different input values. var checksum = FlechterChecksum.Fletcher16(startAddress, bytes); memoyChangedItem.beforeLastCheckum = memoyChangedItem.lastChecksum; memoyChangedItem.lastChecksum = checksum; memoyChangedItem.checks++; if (memoyChangedItem.checks > 1 && memoyChangedItem.beforeLastCheckum != memoyChangedItem.lastChecksum) { if (panic) { if (message == null) { Panic.Error("Memory Changed Exception"); } else { Panic.Error(message); } } return(true); } else { return(false); } }
/// <summary> /// Interrupts the handler. /// </summary> /// <param name="stackStatePointer">The stack state pointer.</param> private unsafe static void ProcessInterrupt(uint stackStatePointer) { //KernelMessage.WriteLine("Interrupt occured"); var stack = (IDTStack *)stackStatePointer; var irq = stack->Interrupt; var info = IDTManager.handlers[irq]; IDTManager.RaisedCount++; if (info.CountStatistcs) { IDTManager.RaisedCountCustom++; } if (info.Trace) { KernelMessage.WriteLine("Interrupt: {0}", irq); } var col = Screen.column; var row = Screen.row; Screen.column = 0; Screen.Goto(2, 35); Screen.Write("Interrupts: "); Screen.Write(IDTManager.RaisedCount); Screen.Goto(3, 35); Screen.Write("IntNoClock: "); Screen.Write(IDTManager.RaisedCountCustom); Screen.row = row; Screen.column = col; if (irq < 0 || irq > 255) { Panic.Error("Invalid Interrupt"); } if (info.Handler == null) { //Panic.Error("Handlr is null"); } else { } info.Handler(stack); PIC.SendEndOfInterrupt(irq); }
private unsafe static void Error(IDTStack *stack, string message) { Panic.ESP = stack->ESP; Panic.EBP = stack->EBP; Panic.EIP = stack->EIP; Panic.EAX = stack->EAX; Panic.EBX = stack->EBX; Panic.ECX = stack->ECX; Panic.EDX = stack->EDX; Panic.EDI = stack->EDI; Panic.ESI = stack->ESI; Panic.CS = stack->CS; Panic.ErrorCode = stack->ErrorCode; Panic.EFLAGS = stack->EFLAGS; Panic.Interrupt = stack->Interrupt; Panic.Error(message); }
private static void Error(uint ebp, uint eip, string message) { Panic.SetStackPointer(ebp, eip); Panic.Error(message); }
/// <summary> /// Interrupts the handler. /// </summary> /// <param name="stack">The stack.</param> private unsafe static void ProcessInterrupt(IDTStack *stack) { DebugClient.Process(); switch (stack->Interrupt) { case 0: Error(stack->EBP, stack->EIP, "Divide Error"); break; case 4: Error(stack->EBP, stack->EIP, "Arithmetic Overflow Exception"); break; case 5: Error(stack->EBP, stack->EIP, "Bound Check Error"); break; case 6: Error(stack->EBP, stack->EIP, "Invalid Opcode"); break; case 7: Error(stack->EBP, stack->EIP, "Co-processor Not Available"); break; case 8: //TODO: Analyze the double fault Error(stack->EBP, stack->EIP, "Double Fault"); break; case 9: Error(stack->EBP, stack->EIP, "Co-processor Segment Overrun"); break; case 10: Error(stack->EBP, stack->EIP, "Invalid TSS"); break; case 11: Error(stack->EBP, stack->EIP, "Segment Not Present"); break; case 12: Error(stack->EBP, stack->EIP, "Stack Exception"); break; case 13: Error(stack->EBP, stack->EIP, "General Protection Exception"); break; case 14: // Check if Null Pointer Exception // Otherwise handle as Page Fault var cr2 = Native.GetCR2() >> 5; if (cr2 < 0x1000) { Error(stack->EBP, stack->EIP, "Null Pointer Exception"); } //spinLock.Enter(ref taken); uint physicalpage = PageFrameAllocator.Allocate(); if (physicalpage == 0x0) { // Panic! Out of memory Panic.SetStackPointer(stack->EBP, stack->EIP); Panic.Error(cr2); } PageTable.MapVirtualAddressToPhysical(Native.GetCR2(), physicalpage); //spinLock.Exit(); break; case 16: Error(stack->EBP, stack->EIP, "Co-processor Error"); break; case 19: Error(stack->EBP, stack->EIP, "SIMD Floating-Point Exception"); break; default: if (interruptHandler != null) { interruptHandler(stack->Interrupt, stack->ErrorCode); } break; } PIC.SendEndOfInterrupt(stack->Interrupt); }
/// <summary> /// Interrupts the handler. /// </summary> /// <param name="stack">The stack.</param> private unsafe static void ProcessInterrupt(IDTStack *stack) { DebugClient.Process(); switch (stack->Interrupt) { case 0: Error(stack->EBP, stack->EIP, "Divide Error"); break; case 4: Error(stack->EBP, stack->EIP, "Arithmetic Overflow Exception"); break; case 5: Error(stack->EBP, stack->EIP, "Bound Check Error"); break; case 6: Error(stack->EBP, stack->EIP, "Invalid Opcode"); break; case 7: Error(stack->EBP, stack->EIP, "Coprocessor Not Available"); break; case 8: //TODO: Analyze the double fault Error(stack->EBP, stack->EIP, "Double Fault"); break; case 9: Error(stack->EBP, stack->EIP, "Coprocessor Segment Overrun"); break; case 10: Error(stack->EBP, stack->EIP, "Invalid TSS"); break; case 11: Error(stack->EBP, stack->EIP, "Segment Not Present"); break; case 12: Error(stack->EBP, stack->EIP, "Stack Exception"); break; case 13: Error(stack->EBP, stack->EIP, "General Protection Exception"); break; case 14: // Page Fault! var cr2 = Native.GetCR2() >> 5; if (cr2 < 0x1000) { Error(stack->EBP, stack->EIP, "Null Pointer Exception"); break; } //PageFaultHandler.Fault(errorCode); Panic.SetStackPointer(stack->EBP, stack->EIP); Panic.Error(cr2); break; case 16: Error(stack->EBP, stack->EIP, "Coprocessor Error"); break; case 19: Error(stack->EBP, stack->EIP, "SIMD Floating-Point Exception"); break; default: if (interruptHandler != null) { interruptHandler(stack->Interrupt, stack->ErrorCode); } break; } PIC.SendEndOfInterrupt(stack->Interrupt); }