Author: tkreuzer
Date: Sun Jul 8 15:33:53 2012
New Revision: 56851
URL:
http://svn.reactos.org/svn/reactos?rev=56851&view=rev
Log:
[FREELDR]
Add code to dump amd64 cpu state. Add a bugcheck function.
Modified:
trunk/reactos/boot/freeldr/freeldr/arch/i386/i386bug.c
Modified: trunk/reactos/boot/freeldr/freeldr/arch/i386/i386bug.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/arch/…
==============================================================================
--- trunk/reactos/boot/freeldr/freeldr/arch/i386/i386bug.c [iso-8859-1] (original)
+++ trunk/reactos/boot/freeldr/freeldr/arch/i386/i386bug.c [iso-8859-1] Sun Jul 8
15:33:53 2012
@@ -51,7 +51,7 @@
while (1)
{
chr = *pszText++;
-
+
if (chr == 0) break;
if (chr == '\n')
{
@@ -59,7 +59,7 @@
i386_ScreenPosX = 0;
continue;
}
-
+
MachVideoPutChar(chr, SCREEN_ATTR, i386_ScreenPosX, i386_ScreenPosY);
i386_ScreenPosX++;
}
@@ -70,7 +70,7 @@
{
va_list argptr;
char buffer[256];
-
+
va_start(argptr, format);
_vsnprintf(buffer, sizeof(buffer), format, argptr);
buffer[sizeof(buffer) - 1] = 0;
@@ -84,10 +84,15 @@
FRAME *Frame;
PrintText("Frames:\n");
-
+#ifdef _M_IX86
for (Frame = (FRAME*)TrapFrame->Ebp;
Frame != 0 && (ULONG_PTR)Frame < STACK32ADDR;
Frame = Frame->Next)
+#else
+ for (Frame = (FRAME*)TrapFrame->TrapFrame;
+ Frame != 0 && (ULONG_PTR)Frame < STACK32ADDR;
+ Frame = Frame->Next)
+#endif
{
PrintText("%p ", Frame->Address);
}
@@ -105,31 +110,96 @@
VERSION"\n"
"Report this error to the ReactOS Development mailing list
<ros-dev(a)reactos.org>\n\n"
"%s\n", i386ExceptionDescriptionText[TrapIndex]);
-
- PrintText("EAX: %.8lx ESP: %.8lx CR0: %.8lx DR0:
%.8lx\n",
+#ifdef _M_IX86
+ PrintText("EAX: %.8lx ESP: %.8lx CR0: %.8lx DR0:
%.8lx\n",
TrapFrame->Eax, TrapFrame->HardwareEsp, Special->Cr0,
TrapFrame->Dr0);
- PrintText("EBX: %.8lx EBP: %.8lx CR1: ???????? DR1:
%.8lx\n",
+ PrintText("EBX: %.8lx EBP: %.8lx CR1: ???????? DR1:
%.8lx\n",
TrapFrame->Ebx, TrapFrame->Ebp, TrapFrame->Dr1);
- PrintText("ECX: %.8lx ESI: %.8lx CR2: %.8lx DR2:
%.8lx\n",
+ PrintText("ECX: %.8lx ESI: %.8lx CR2: %.8lx DR2:
%.8lx\n",
TrapFrame->Ecx, TrapFrame->Esi, Special->Cr2, TrapFrame->Dr2);
- PrintText("EDX: %.8lx EDI: %.8lx CR3: %.8lx DR3:
%.8lx\n",
+ PrintText("EDX: %.8lx EDI: %.8lx CR3: %.8lx DR3:
%.8lx\n",
TrapFrame->Edx, TrapFrame->Edi, Special->Cr3, TrapFrame->Dr3);
- PrintText(" DR6:
%.8lx\n",
+ PrintText(" DR6:
%.8lx\n",
TrapFrame->Dr6);
- PrintText(" DR7:
%.8lx\n\n",
+ PrintText(" DR7:
%.8lx\n\n",
TrapFrame->Dr7);
- PrintText("CS: %.4lx EIP: %.8lx\n",
+ PrintText("CS: %.4lx EIP: %.8lx\n",
TrapFrame->SegCs, TrapFrame->Eip);
- PrintText("DS: %.4lx ERROR CODE: %.8lx\n",
- TrapFrame->SegDs, TrapFrame->Eip);
- PrintText("ES: %.4lx EFLAGS: %.8lx\n",
+ PrintText("DS: %.4lx ERROR CODE: %.8lx\n",
+ TrapFrame->SegDs, TrapFrame->ErrCode);
+ PrintText("ES: %.4lx EFLAGS: %.8lx\n",
TrapFrame->SegEs, TrapFrame->EFlags);
- PrintText("FS: %.4lx GDTR Base: %.8lx Limit: %.4x\n",
+ PrintText("FS: %.4lx GDTR Base: %.8lx Limit: %.4x\n",
TrapFrame->SegFs, Special->Gdtr.Base, Special->Gdtr.Limit);
- PrintText("GS: %.4lx IDTR Base: %.8lx Limit: %.4x\n",
+ PrintText("GS: %.4lx IDTR Base: %.8lx Limit: %.4x\n",
TrapFrame->SegGs, Special->Idtr.Base, Special->Idtr.Limit);
- PrintText("SS: %.4lx LDTR: %.4lx TR: %.4lx\n\n",
+ PrintText("SS: %.4lx LDTR: %.4lx TR: %.4lx\n\n",
TrapFrame->HardwareSegSs, Special->Ldtr, Special->Idtr.Limit);
i386PrintFrames(TrapFrame); // Display frames
-}
+#else
+ PrintText("RAX: %.8lx R8: %.8lx R12: %.8lx RSI:
%.8lx\n",
+ TrapFrame->Rax, TrapFrame->R8, 0, TrapFrame->Rsi);
+ PrintText("RBX: %.8lx R9: %.8lx R13: %.8lx RDI:
%.8lx\n",
+ TrapFrame->Rbx, TrapFrame->R9, 0, TrapFrame->Rdi);
+ PrintText("RCX: %.8lx R10: %.8lx R14: %.8lx RBP:
%.8lx\n",
+ TrapFrame->Rcx, TrapFrame->R10, 0, TrapFrame->Rbp);
+ PrintText("RDX: %.8lx R11: %.8lx R15: %.8lx RSP:
%.8lx\n",
+ TrapFrame->Rdx, TrapFrame->R11, 0, TrapFrame->Rsp);
+
+ PrintText("CS: %.4lx RIP: %.8lx\n",
+ TrapFrame->SegCs, TrapFrame->Rip);
+ PrintText("DS: %.4lx ERROR CODE: %.8lx\n",
+ TrapFrame->SegDs, TrapFrame->ErrorCode);
+ PrintText("ES: %.4lx EFLAGS: %.8lx\n",
+ TrapFrame->SegEs, TrapFrame->EFlags);
+ PrintText("FS: %.4lx GDTR Base: %.8lx Limit: %.4x\n",
+ TrapFrame->SegFs, Special->Gdtr.Base, Special->Gdtr.Limit);
+ PrintText("GS: %.4lx IDTR Base: %.8lx Limit: %.4x\n",
+ TrapFrame->SegGs, Special->Idtr.Base, Special->Idtr.Limit);
+ PrintText("SS: %.4lx LDTR: %.4lx TR: %.4lx\n\n",
+ TrapFrame->SegSs, Special->Ldtr, Special->Idtr.Limit);
+#endif
+}
+
+char *BugCodeStrings[] =
+{
+ "TEST_BUGCHECK",
+ "MISSING_HARDWARE_REQUIREMENTS",
+};
+
+ULONG_PTR BugCheckInfo[5];
+
+void
+NTAPI
+FrLdrBugCheckEx(
+ ULONG BugCode,
+ PCHAR File,
+ ULONG Line)
+{
+ MachVideoClearScreen(SCREEN_ATTR);
+ i386_ScreenPosX = 0;
+ i386_ScreenPosY = 0;
+
+ PrintText("A problem has been detected and FreeLoader boot has been
aborted.\n\n");
+
+ PrintText("%ld: %s\n\n", BugCode, BugCodeStrings[BugCode]);
+
+ if (File)
+ {
+ PrintText("Location: %s:%ld\n\n", File, Line);
+ }
+
+ PrintText("Bug Information:\n %p\n %p\n %p\n %p\n %p\n\n",
+ BugCheckInfo[0], BugCheckInfo[1], BugCheckInfo[2], BugCheckInfo[3],
BugCheckInfo[4]);
+
+ for (;;);
+}
+
+void
+NTAPI
+FrLdrBugCheck(ULONG BugCode)
+{
+ FrLdrBugCheckEx(BugCode, 0, 0);
+}
+