ReactOS 0.4.15-dev-7942-gd23573b
i386bug.c File Reference
#include <freeldr.h>
#include <debug.h>
Include dependency graph for i386bug.c:

Go to the source code of this file.

Classes

struct  _FRAME
 

Macros

#define SCREEN_ATTR   0x1F
 

Typedefs

typedef struct _FRAME FRAME
 

Functions

static void i386PrintText (CHAR *pszText)
 
static void PrintTextV (const CHAR *Format, va_list args)
 
static void PrintText (const CHAR *Format,...)
 
static void i386PrintFrames (PKTRAP_FRAME TrapFrame)
 
void NTAPI i386PrintExceptionText (ULONG TrapIndex, PKTRAP_FRAME TrapFrame, PKSPECIAL_REGISTERS Special)
 
VOID FrLdrBugCheckWithMessage (ULONG BugCode, PCHAR File, ULONG Line, PSTR Format,...)
 
void NTAPI FrLdrBugCheckEx (ULONG BugCode, PCHAR File, ULONG Line)
 
void NTAPI FrLdrBugCheck (ULONG BugCode)
 

Variables

static const CHARi386ExceptionDescriptionText []
 
static ULONG i386_ScreenPosX = 0
 
static ULONG i386_ScreenPosY = 0
 

Macro Definition Documentation

◆ SCREEN_ATTR

#define SCREEN_ATTR   0x1F

Definition at line 35 of file i386bug.c.

Typedef Documentation

◆ FRAME

typedef struct _FRAME FRAME

Function Documentation

◆ FrLdrBugCheck()

void NTAPI FrLdrBugCheck ( ULONG  BugCode)

Definition at line 260 of file i386bug.c.

261{
262 FrLdrBugCheckEx(BugCode, 0, 0);
263}
void NTAPI FrLdrBugCheckEx(ULONG BugCode, PCHAR File, ULONG Line)
Definition: i386bug.c:231

◆ FrLdrBugCheckEx()

void NTAPI FrLdrBugCheckEx ( ULONG  BugCode,
PCHAR  File,
ULONG  Line 
)

Definition at line 231 of file i386bug.c.

235{
238 i386_ScreenPosX = 0;
239 i386_ScreenPosY = 0;
240
241 PrintText("A problem has been detected and FreeLoader boot has been aborted.\n\n");
242
243 PrintText("%ld: %s\n\n", BugCode, BugCodeStrings[BugCode]);
244
245 if (File)
246 {
247 PrintText("Location: %s:%ld\n\n", File, Line);
248 }
249
250 PrintText("Bug Information:\n %p\n %p\n %p\n %p\n %p\n\n",
252
253 _disable();
254 __halt();
255 for (;;);
256}
ULONG_PTR BugCheckInfo[5]
Definition: debug.c:531
char * BugCodeStrings[]
Definition: debug.c:520
#define MachVideoClearScreen(Attr)
Definition: machine.h:92
#define MachVideoHideShowTextCursor(Show)
Definition: machine.h:104
Definition: File.h:16
#define FALSE
Definition: types.h:117
#define SCREEN_ATTR
Definition: i386bug.c:35
static ULONG i386_ScreenPosY
Definition: i386bug.c:39
static ULONG i386_ScreenPosX
Definition: i386bug.c:38
static void PrintText(const CHAR *Format,...)
Definition: i386bug.c:79
void __cdecl _disable(void)
Definition: intrin_arm.h:365
__INTRIN_INLINE void __halt(void)
Definition: intrin_x86.h:1714
Definition: ncftp.h:79

Referenced by FrLdrBugCheck().

◆ FrLdrBugCheckWithMessage()

VOID FrLdrBugCheckWithMessage ( ULONG  BugCode,
PCHAR  File,
ULONG  Line,
PSTR  Format,
  ... 
)

Definition at line 197 of file i386bug.c.

203{
204 va_list argptr;
205
208 i386_ScreenPosX = 0;
209 i386_ScreenPosY = 0;
210
211 PrintText("A problem has been detected and FreeLoader boot has been aborted.\n\n");
212
213 PrintText("%ld: %s\n\n", BugCode, BugCodeStrings[BugCode]);
214
215 if (File)
216 {
217 PrintText("Location: %s:%ld\n\n", File, Line);
218 }
219
220 va_start(argptr, Format);
221 PrintTextV(Format, argptr);
222 va_end(argptr);
223
224 _disable();
225 __halt();
226 for (;;);
227}
char * va_list
Definition: acmsvcex.h:78
#define va_end(ap)
Definition: acmsvcex.h:90
#define va_start(ap, A)
Definition: acmsvcex.h:91
static void PrintTextV(const CHAR *Format, va_list args)
Definition: i386bug.c:68

◆ i386PrintExceptionText()

void NTAPI i386PrintExceptionText ( ULONG  TrapIndex,
PKTRAP_FRAME  TrapFrame,
PKSPECIAL_REGISTERS  Special 
)

Definition at line 109 of file i386bug.c.

110{
111 PUCHAR InstructionPointer;
112
115 i386_ScreenPosX = 0;
116 i386_ScreenPosY = 0;
117
118 PrintText("An error occured in " VERSION "\n"
119 "Report this error on the ReactOS Bug Tracker: https://jira.reactos.org\n\n"
120 "0x%02lx: %s\n\n", TrapIndex, i386ExceptionDescriptionText[TrapIndex]);
121
122#ifdef _M_IX86
123 PrintText("EAX: %.8lx ESP: %.8lx CR0: %.8lx DR0: %.8lx\n",
124 TrapFrame->Eax, TrapFrame->HardwareEsp, Special->Cr0, TrapFrame->Dr0);
125 PrintText("EBX: %.8lx EBP: %.8lx CR1: ???????? DR1: %.8lx\n",
126 TrapFrame->Ebx, TrapFrame->Ebp, TrapFrame->Dr1);
127 PrintText("ECX: %.8lx ESI: %.8lx CR2: %.8lx DR2: %.8lx\n",
128 TrapFrame->Ecx, TrapFrame->Esi, Special->Cr2, TrapFrame->Dr2);
129 PrintText("EDX: %.8lx EDI: %.8lx CR3: %.8lx DR3: %.8lx\n",
130 TrapFrame->Edx, TrapFrame->Edi, Special->Cr3, TrapFrame->Dr3);
131 PrintText("%*s CR4: %.8lx DR6: %.8lx\n",
132 41, "", Special->Cr4, TrapFrame->Dr6);
133 PrintText("%*s DR7: %.8lx\n",
134 62, "", TrapFrame->Dr7);
135
136 /* NOTE: Segment registers are intrinsically 16 bits. Even if the x86
137 * KTRAP_FRAME structure stores them as ULONG, only their lower 16 bits
138 * are initialized. We thus cast them to USHORT before display. */
139 PrintText(" CS: %.4lx EIP: %.8lx\n",
140 (USHORT)TrapFrame->SegCs, TrapFrame->Eip);
141 PrintText(" DS: %.4lx ERROR CODE: %.8lx\n",
142 (USHORT)TrapFrame->SegDs, TrapFrame->ErrCode);
143 PrintText(" ES: %.4lx EFLAGS: %.8lx\n",
144 (USHORT)TrapFrame->SegEs, TrapFrame->EFlags);
145 PrintText(" FS: %.4lx GDTR Base: %.8lx Limit: %.4x\n",
146 // " FS: %.4lx GDTR: Base %.8lx Limit %.4x\n"
147 (USHORT)TrapFrame->SegFs, Special->Gdtr.Base, Special->Gdtr.Limit);
148 PrintText(" GS: %.4lx IDTR Base: %.8lx Limit: %.4x\n",
149 // " GS: %.4lx IDTR: Base %.8lx Limit %.4x\n",
150 (USHORT)TrapFrame->SegGs, Special->Idtr.Base, Special->Idtr.Limit);
151 PrintText(" SS: %.4lx LDTR: %.4lx TR: %.4lx\n\n",
152 (USHORT)TrapFrame->HardwareSegSs, Special->Ldtr, Special->Tr);
153#else
154 PrintText("RAX: %.8lx R8: %.8lx R12: %.8lx RSI: %.8lx\n",
155 TrapFrame->Rax, TrapFrame->R8, 0, TrapFrame->Rsi);
156 PrintText("RBX: %.8lx R9: %.8lx R13: %.8lx RDI: %.8lx\n",
157 TrapFrame->Rbx, TrapFrame->R9, 0, TrapFrame->Rdi);
158 PrintText("RCX: %.8lx R10: %.8lx R14: %.8lx RBP: %.8lx\n",
159 TrapFrame->Rcx, TrapFrame->R10, 0, TrapFrame->Rbp);
160 PrintText("RDX: %.8lx R11: %.8lx R15: %.8lx RSP: %.8lx\n",
161 TrapFrame->Rdx, TrapFrame->R11, 0, TrapFrame->Rsp);
162
163 PrintText(" CS: %.4lx RIP: %.8lx\n",
164 TrapFrame->SegCs, TrapFrame->Rip);
165 PrintText(" DS: %.4lx ERROR CODE: %.8lx\n",
166 TrapFrame->SegDs, TrapFrame->ErrorCode);
167 PrintText(" ES: %.4lx EFLAGS: %.8lx\n",
168 TrapFrame->SegEs, TrapFrame->EFlags);
169 PrintText(" FS: %.4lx GDTR Base: %.8lx Limit: %.4x\n",
170 TrapFrame->SegFs, Special->Gdtr.Base, Special->Gdtr.Limit);
171 PrintText(" GS: %.4lx IDTR Base: %.8lx Limit: %.4x\n",
172 TrapFrame->SegGs, Special->Idtr.Base, Special->Idtr.Limit);
173 PrintText(" SS: %.4lx LDTR: %.4lx TR: %.4lx\n\n",
174 TrapFrame->SegSs, Special->Ldtr, Special->Tr);
175#endif
176
177 /* Display the stack frames */
178 i386PrintFrames(TrapFrame);
179
180#ifdef _M_IX86
181 InstructionPointer = (PUCHAR)TrapFrame->Eip;
182#else
183 InstructionPointer = (PUCHAR)TrapFrame->Rip;
184#endif
185 /* Adjust IP for #BP (INT 03) or #OF to point to the offending instruction */
186 if ((TrapIndex == 3) || (TrapIndex == 4))
187 InstructionPointer--;
188
189 PrintText("\nInstruction stream: %.2x %.2x %.2x %.2x %.2x %.2x %.2x %.2x\n",
190 InstructionPointer[0], InstructionPointer[1],
191 InstructionPointer[2], InstructionPointer[3],
192 InstructionPointer[4], InstructionPointer[5],
193 InstructionPointer[6], InstructionPointer[7]);
194}
#define VERSION
Definition: rdesktop.h:45
static void i386PrintFrames(PKTRAP_FRAME TrapFrame)
Definition: i386bug.c:89
static const CHAR * i386ExceptionDescriptionText[]
Definition: i386bug.c:12
unsigned short USHORT
Definition: pedump.c:61
ULONG Base
Definition: ketypes.h:450
USHORT Limit
Definition: ketypes.h:449
KDESCRIPTOR Gdtr
Definition: ketypes.h:591
KDESCRIPTOR Idtr
Definition: ketypes.h:592
UINT64 Rsp
Definition: ketypes.h:471
ULONG HardwareSegSs
Definition: ketypes.h:325
UINT64 Dr6
Definition: ketypes.h:431
UINT64 Rdi
Definition: ketypes.h:455
ULONG Edi
Definition: ketypes.h:316
UINT64 Rbp
Definition: ketypes.h:457
UINT64 Rsi
Definition: ketypes.h:456
UINT64 Rdx
Definition: ketypes.h:405
ULONG EFlags
Definition: ketypes.h:469
ULONG Ebp
Definition: ketypes.h:319
ULONG Ebx
Definition: ketypes.h:318
ULONG ErrCode
Definition: ketypes.h:320
UINT64 Dr0
Definition: ketypes.h:427
ULONG HardwareEsp
Definition: ketypes.h:324
ULONG Ecx
Definition: ketypes.h:311
UINT64 Rbx
Definition: ketypes.h:454
UINT64 Dr7
Definition: ketypes.h:432
USHORT SegSs
Definition: ketypes.h:472
UINT64 Dr1
Definition: ketypes.h:428
ULONG Eip
Definition: ketypes.h:321
USHORT SegCs
Definition: ketypes.h:465
UINT64 Rax
Definition: ketypes.h:403
UINT64 Dr3
Definition: ketypes.h:430
UINT64 R10
Definition: ketypes.h:408
UINT64 Rip
Definition: ketypes.h:464
USHORT SegEs
Definition: ketypes.h:450
USHORT SegFs
Definition: ketypes.h:451
UINT64 ErrorCode
Definition: ketypes.h:460
USHORT SegGs
Definition: ketypes.h:452
UINT64 Dr2
Definition: ketypes.h:429
UINT64 R9
Definition: ketypes.h:407
ULONG Eax
Definition: ketypes.h:312
USHORT SegDs
Definition: ketypes.h:449
UINT64 R8
Definition: ketypes.h:406
UINT64 Rcx
Definition: ketypes.h:404
ULONG Esi
Definition: ketypes.h:317
ULONG Edx
Definition: ketypes.h:310
UINT64 R11
Definition: ketypes.h:409
unsigned char * PUCHAR
Definition: typedefs.h:53

◆ i386PrintFrames()

static void i386PrintFrames ( PKTRAP_FRAME  TrapFrame)
static

Definition at line 89 of file i386bug.c.

90{
91 FRAME* Frame;
92
93 PrintText("Frames:\n");
94 for (Frame =
95#ifdef _M_IX86
96 (FRAME*)TrapFrame->Ebp;
97#else
98 (FRAME*)TrapFrame->TrapFrame;
99#endif
100 Frame != NULL && (ULONG_PTR)Frame < STACKADDR;
101 Frame = Frame->Next)
102 {
103 PrintText("%p ", Frame->Address);
104 }
105}
#define NULL
Definition: types.h:112
Definition: i386bug.c:7
PVOID Address
Definition: i386bug.c:9
struct _FRAME * Next
Definition: i386bug.c:8
UINT64 TrapFrame
Definition: ketypes.h:453
else
Definition: tritemp.h:161
uint32_t ULONG_PTR
Definition: typedefs.h:65
#define STACKADDR
Definition: x86common.h:16

Referenced by i386PrintExceptionText().

◆ i386PrintText()

static void i386PrintText ( CHAR pszText)
static

Definition at line 42 of file i386bug.c.

43{
45
47
48 for (; *pszText != ANSI_NULL; ++pszText)
49 {
50 if (*pszText == '\n')
51 {
54 continue;
55 }
56
58 if (++i386_ScreenPosX >= Width)
59 {
62 }
63 // FIXME: Implement vertical screen scrolling if we are at the end of the screen.
64 }
65}
#define MachVideoGetDisplaySize(W, H, D)
Definition: machine.h:96
#define MachVideoPutChar(Ch, Attr, X, Y)
Definition: machine.h:106
#define Unused(x)
Definition: atlwin.h:28
#define ANSI_NULL
uint32_t ULONG
Definition: typedefs.h:59
_In_ HFONT _Out_ PUINT _Out_ PUINT Width
Definition: font.h:89

Referenced by PrintTextV().

◆ PrintText()

static void PrintText ( const CHAR Format,
  ... 
)
static

Definition at line 79 of file i386bug.c.

80{
81 va_list argptr;
82
83 va_start(argptr, Format);
84 PrintTextV(Format, argptr);
85 va_end(argptr);
86}

Referenced by FrLdrBugCheckEx(), FrLdrBugCheckWithMessage(), i386PrintExceptionText(), and i386PrintFrames().

◆ PrintTextV()

static void PrintTextV ( const CHAR Format,
va_list  args 
)
static

Definition at line 68 of file i386bug.c.

69{
70 CHAR Buffer[512];
71
73 Buffer[sizeof(Buffer) - 1] = ANSI_NULL;
74
76}
Definition: bufpool.h:45
static void i386PrintText(CHAR *pszText)
Definition: i386bug.c:42
Definition: match.c:390
#define _vsnprintf
Definition: xmlstorage.h:202
char CHAR
Definition: xmlstorage.h:175

Referenced by FrLdrBugCheckWithMessage(), and PrintText().

Variable Documentation

◆ i386_ScreenPosX

ULONG i386_ScreenPosX = 0
static

◆ i386_ScreenPosY

ULONG i386_ScreenPosY = 0
static

◆ i386ExceptionDescriptionText

const CHAR* i386ExceptionDescriptionText[]
static
Initial value:
=
{
"Exception 00: DIVIDE BY ZERO",
"Exception 01: DEBUG EXCEPTION",
"Exception 02: NON-MASKABLE INTERRUPT EXCEPTION",
"Exception 03: BREAKPOINT (INT 3)",
"Exception 04: OVERFLOW",
"Exception 05: BOUND EXCEPTION",
"Exception 06: INVALID OPCODE",
"Exception 07: FPU NOT AVAILABLE",
"Exception 08: DOUBLE FAULT",
"Exception 09: COPROCESSOR SEGMENT OVERRUN",
"Exception 0A: INVALID TSS",
"Exception 0B: SEGMENT NOT PRESENT",
"Exception 0C: STACK EXCEPTION",
"Exception 0D: GENERAL PROTECTION FAULT",
"Exception 0E: PAGE FAULT",
"Exception 0F: Reserved",
"Exception 10: COPROCESSOR ERROR",
"Exception 11: ALIGNMENT CHECK",
"Exception 12: MACHINE CHECK"
}

Definition at line 12 of file i386bug.c.

Referenced by i386PrintExceptionText().