Author: ion
Date: Mon Aug 21 07:01:47 2006
New Revision: 23634
URL:
http://svn.reactos.org/svn/reactos?rev=23634&view=rev
Log:
- Convert 8, 9, 10, 15/F
Modified:
trunk/reactos/ntoskrnl/ke/i386/exp.c
trunk/reactos/ntoskrnl/ke/i386/trap.s
Modified: trunk/reactos/ntoskrnl/ke/i386/exp.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ke/i386/exp.c?rev…
==============================================================================
--- trunk/reactos/ntoskrnl/ke/i386/exp.c (original)
+++ trunk/reactos/ntoskrnl/ke/i386/exp.c Mon Aug 21 07:01:47 2006
@@ -179,215 +179,6 @@
KiDispatchException(&Er, NULL, Tf, KernelMode, TRUE);
return(0);
-}
-
-VOID
-KiDoubleFaultHandler(VOID)
-{
-#if 0
- unsigned int cr2;
- ULONG StackLimit;
- ULONG StackBase;
- ULONG Esp0;
- ULONG ExceptionNr = 8;
- KTSS* OldTss;
- PULONG Frame;
- ULONG OldCr3;
-#if 0
- ULONG i, j;
- static PVOID StackTrace[MM_STACK_SIZE / sizeof(PVOID)];
- static ULONG StackRepeatCount[MM_STACK_SIZE / sizeof(PVOID)];
- static ULONG StackRepeatLength[MM_STACK_SIZE / sizeof(PVOID)];
- ULONG TraceLength;
- BOOLEAN FoundRepeat;
-#endif
-
- OldTss = KeGetCurrentKPCR()->TSS;
- Esp0 = OldTss->Esp0;
-
- /* Get CR2 */
- cr2 = Ke386GetCr2();
- if (PsGetCurrentThread() != NULL &&
- PsGetCurrentThread()->ThreadsProcess != NULL)
- {
- OldCr3 = (ULONG)
- PsGetCurrentThread()->ThreadsProcess->Pcb.DirectoryTableBase.QuadPart;
- }
- else
- {
- OldCr3 = 0xBEADF0AL;
- }
-
- /*
- * Check for stack underflow
- */
- if (PsGetCurrentThread() != NULL &&
- Esp0 < (ULONG)PsGetCurrentThread()->Tcb.StackLimit)
- {
- DbgPrint("Stack underflow (tf->esp %x Limit %x)\n",
- Esp0, (ULONG)PsGetCurrentThread()->Tcb.StackLimit);
- ExceptionNr = 12;
- }
-
- /*
- * Print out the CPU registers
- */
- if (ExceptionNr < ARRAY_SIZE(ExceptionTypeStrings))
- {
- DbgPrint("%s Exception: %d(%x)\n", ExceptionTypeStrings[ExceptionNr],
- ExceptionNr, 0);
- }
- else
- {
- DbgPrint("Exception: %d(%x)\n", ExceptionNr, 0);
- }
- DbgPrint("CS:EIP %x:%x ", OldTss->Cs, OldTss->Eip);
- KeRosPrintAddress((PVOID)OldTss->Eip);
- DbgPrint("\n");
- DbgPrint("cr2 %x cr3 %x ", cr2, OldCr3);
- DbgPrint("Proc: %x ",PsGetCurrentProcess());
- if (PsGetCurrentProcess() != NULL)
- {
- DbgPrint("Pid: %x <", PsGetCurrentProcess()->UniqueProcessId);
- DbgPrint("%.16s> ", PsGetCurrentProcess()->ImageFileName);
- }
- if (PsGetCurrentThread() != NULL)
- {
- DbgPrint("Thrd: %x Tid: %x",
- PsGetCurrentThread(),
- PsGetCurrentThread()->Cid.UniqueThread);
- }
- DbgPrint("\n");
- DbgPrint("DS %x ES %x FS %x GS %x\n", OldTss->Ds, OldTss->Es,
- OldTss->Fs, OldTss->Gs);
- DbgPrint("EAX: %.8x EBX: %.8x ECX: %.8x\n", OldTss->Eax,
OldTss->Ebx,
- OldTss->Ecx);
- DbgPrint("EDX: %.8x EBP: %.8x ESI: %.8x\nESP: %.8x ", OldTss->Edx,
- OldTss->Ebp, OldTss->Esi, Esp0);
- DbgPrint("EDI: %.8x EFLAGS: %.8x ", OldTss->Edi, OldTss->Eflags);
- if (OldTss->Cs == KGDT_R0_CODE)
- {
- DbgPrint("kESP %.8x ", Esp0);
- if (PsGetCurrentThread() != NULL)
- {
- DbgPrint("kernel stack base %x\n",
- PsGetCurrentThread()->Tcb.StackLimit);
-
- }
- }
- else
- {
- DbgPrint("User ESP %.8x\n", OldTss->Esp);
- }
- if ((OldTss->Cs & 0xffff) == KGDT_R0_CODE)
- {
- if (PsGetCurrentThread() != NULL)
- {
- StackLimit = (ULONG)PsGetCurrentThread()->Tcb.StackBase;
- StackBase = (ULONG)PsGetCurrentThread()->Tcb.StackLimit;
- }
- else
- {
- StackLimit = (ULONG)init_stack_top;
- StackBase = (ULONG)init_stack;
- }
-
- /*
- Change to an #if 0 to reduce the amount of information printed on
- a recursive stack trace.
- */
-#if 1
- DbgPrint("Frames: ");
- Frame = (PULONG)OldTss->Ebp;
- while (Frame != NULL && (ULONG)Frame >= StackBase)
- {
- KeRosPrintAddress((PVOID)Frame[1]);
- Frame = (PULONG)Frame[0];
- DbgPrint("\n");
- }
-#else
- DbgPrint("Frames: ");
- i = 0;
- Frame = (PULONG)OldTss->Ebp;
- while (Frame != NULL && (ULONG)Frame >= StackBase)
- {
- StackTrace[i] = (PVOID)Frame[1];
- Frame = (PULONG)Frame[0];
- i++;
- }
- TraceLength = i;
-
- i = 0;
- while (i < TraceLength)
- {
- StackRepeatCount[i] = 0;
- j = i + 1;
- FoundRepeat = FALSE;
- while ((j - i) <= (TraceLength - j) && FoundRepeat == FALSE)
- {
- if (memcmp(&StackTrace[i], &StackTrace[j],
- (j - i) * sizeof(PVOID)) == 0)
- {
- StackRepeatCount[i] = 2;
- StackRepeatLength[i] = j - i;
- FoundRepeat = TRUE;
- }
- else
- {
- j++;
- }
- }
- if (FoundRepeat == FALSE)
- {
- i++;
- continue;
- }
- j = j + StackRepeatLength[i];
- while ((TraceLength - j) >= StackRepeatLength[i] &&
- FoundRepeat == TRUE)
- {
- if (memcmp(&StackTrace[i], &StackTrace[j],
- StackRepeatLength[i] * sizeof(PVOID)) == 0)
- {
- StackRepeatCount[i]++;
- j = j + StackRepeatLength[i];
- }
- else
- {
- FoundRepeat = FALSE;
- }
- }
- i = j;
- }
-
- i = 0;
- while (i < TraceLength)
- {
- if (StackRepeatCount[i] == 0)
- {
- KeRosPrintAddress(StackTrace[i]);
- i++;
- }
- else
- {
- DbgPrint("{");
- if (StackRepeatLength[i] == 0)
- {
- for(;;);
-}
- for (j = 0; j < StackRepeatLength[i]; j++)
- {
- KeRosPrintAddress(StackTrace[i + j]);
- }
- DbgPrint("}*%d", StackRepeatCount[i]);
- i = i + StackRepeatLength[i] * StackRepeatCount[i];
- }
- }
-#endif
- }
-#endif
- DbgPrint("\n");
- for(;;);
}
VOID
Modified: trunk/reactos/ntoskrnl/ke/i386/trap.s
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ke/i386/trap.s?re…
==============================================================================
--- trunk/reactos/ntoskrnl/ke/i386/trap.s (original)
+++ trunk/reactos/ntoskrnl/ke/i386/trap.s Mon Aug 21 07:01:47 2006
@@ -41,7 +41,7 @@
idt _KiTrap12, INT_32_DPL0 /* INT 0C: Stack Fault Exception (#SS) */
idt _KiTrap13, INT_32_DPL0 /* INT 0D: General Protection (#GP) */
idt _KiTrap14, INT_32_DPL0 /* INT 0E: Page-Fault Exception (#PF) */
-idt _KiTrap15, INT_32_DPL0 /* INT 0F: RESERVED [FIXME: HBIRR HACK] */
+idt _KiTrap0F, INT_32_DPL0 /* INT 0F: RESERVED */
idt _KiTrap16, INT_32_DPL0 /* INT 10: x87 FPU Error (#MF) */
idt _KiTrap17, INT_32_DPL0 /* INT 11: Align Check Exception (#AC) */
idt _KiTrap0F, INT_32_DPL0 /* INT 12: Machine Check Exception (#MC)*/
@@ -1143,10 +1143,19 @@
.endfunc
.globl _KiTrap8
+.func KiTrap8
_KiTrap8:
- call _KiDoubleFaultHandler
- iret
-
+
+ /* Can't really do too much */
+ push 0
+ push 0
+ push 0
+ push 8
+ push UNEXPECTED_KERNEL_MODE_TRAP
+ call _KeBugCheckEx@20
+.endfunc
+
+.func KiTrap9
_KiTrap9:
/* Push error code */
push 0
@@ -1154,37 +1163,48 @@
/* Enter trap */
TRAP_PROLOG(9)
- /* Call the C exception handler */
+ /* Enable interrupts and bugcheck */
+ sti
+ push 0
+ push 0
+ push 0
push 9
- push ebp
- call _KiTrapHandler
- add esp, 8
-
- /* Check for v86 recovery */
- cmp eax, 1
-
- /* Return to caller */
- jne _Kei386EoiHelper@0
- jmp _KiV86Complete
-
-#if 1
+ push UNEXPECTED_KERNEL_MODE_TRAP
+ call _KeBugCheckEx@20
+.endfunc
+
+.func KiTrap10
_KiTrap10:
/* Enter trap */
TRAP_PROLOG(10)
- /* Call the C exception handler */
+ /* Check for V86 */
+ test dword ptr [ebp+KTRAP_FRAME_EFLAGS], EFLAGS_V86_MASK
+ jnz V86IntA
+
+ /* Check if the frame was from kernelmode */
+ test word ptr [ebp+KTRAP_FRAME_CS], MODE_MASK
+ jz Fatal
+
+V86IntA:
+ /* Check if OF was set during iretd */
+ test dword ptr [ebp+KTRAP_FRAME_EFLAGS], EFLAG_ZERO
+ sti
+ jz Fatal
+
+ /* It was, just mask it out */
+ and dword ptr [ebp+KTRAP_FRAME_EFLAGS], ~EFLAG_ZERO
+ jmp _Kei386EoiHelper@0
+
+Fatal:
+ /* TSS failure for some other reason: crash */
+ push 0
+ push 0
+ push 0
push 10
- push ebp
- call _KiTrapHandler
- add esp, 8
-
- /* Check for v86 recovery */
- cmp eax, 1
-
- /* Return to caller */
- jne _Kei386EoiHelper@0
- jmp _KiV86Complete
-#endif
+ push UNEXPECTED_KERNEL_MODE_TRAP
+ call _KeBugCheckEx@20
+.endfunc
_KiTrap11:
/* Enter trap */
@@ -1220,7 +1240,6 @@
jne _Kei386EoiHelper@0
jmp _KiV86Complete
-#if 1
_KiTrap13:
/* Enter trap */
TRAP_PROLOG(13)
@@ -1237,7 +1256,6 @@
/* Return to caller */
jne _Kei386EoiHelper@0
jmp _KiV86Complete
-#endif
_KiTrap14:
/* Enter trap */
@@ -1256,25 +1274,17 @@
jne _Kei386EoiHelper@0
jmp _KiV86Complete
-_KiTrap15:
+_KiTrap0F:
/* Push error code */
push 0
/* Enter trap */
TRAP_PROLOG(15)
-
- /* Call the C exception handler */
- push 15
- push ebp
- call _KiTrapHandler
- add esp, 8
-
- /* Check for v86 recovery */
- cmp eax, 1
-
- /* Return to caller */
- jne _Kei386EoiHelper@0
- jmp _KiV86Complete
+ sti
+
+ /* Raise a fatal exception */
+ mov eax, 15
+ jmp _KiSystemFatalException
_KiTrap16:
/* Push error code */
@@ -1316,18 +1326,6 @@
jne _Kei386EoiHelper@0
jmp _KiV86Complete
-_KiTrap0F:
- /* Push error code */
- push 0
-
- /* Enter trap */
- TRAP_PROLOG(15)
- sti
-
- /* Raise a fatal exception */
- mov eax, 15
- jmp _KiSystemFatalException
-
.func KiSystemFatalException
_KiSystemFatalException: