ReactOS  0.4.15-dev-440-g5f37b68
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 253 of file i386bug.c.

254 {
255  FrLdrBugCheckEx(BugCode, 0, 0);
256 }
void NTAPI FrLdrBugCheckEx(ULONG BugCode, PCHAR File, ULONG Line)
Definition: i386bug.c:224

◆ FrLdrBugCheckEx()

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

Definition at line 224 of file i386bug.c.

228 {
231  i386_ScreenPosX = 0;
232  i386_ScreenPosY = 0;
233 
234  PrintText("A problem has been detected and FreeLoader boot has been aborted.\n\n");
235 
236  PrintText("%ld: %s\n\n", BugCode, BugCodeStrings[BugCode]);
237 
238  if (File)
239  {
240  PrintText("Location: %s:%ld\n\n", File, Line);
241  }
242 
243  PrintText("Bug Information:\n %p\n %p\n %p\n %p\n %p\n\n",
245 
246  _disable();
247  __halt();
248  for (;;);
249 }
char * BugCodeStrings[]
Definition: debug.c:515
__INTRIN_INLINE void __halt(void)
Definition: intrin_x86.h:1595
Definition: ncftp.h:79
#define MachVideoClearScreen(Attr)
Definition: machine.h:92
#define MachVideoHideShowTextCursor(Show)
Definition: machine.h:104
#define SCREEN_ATTR
Definition: i386bug.c:35
void __cdecl _disable(void)
Definition: intrin_arm.h:365
ULONG_PTR BugCheckInfo[5]
Definition: debug.c:523
static void PrintText(const CHAR *Format,...)
Definition: i386bug.c:87
Definition: File.h:15
static ULONG i386_ScreenPosY
Definition: i386bug.c:39
static ULONG i386_ScreenPosX
Definition: i386bug.c:38

Referenced by FrLdrBugCheck().

◆ FrLdrBugCheckWithMessage()

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

Definition at line 190 of file i386bug.c.

196 {
197  va_list argptr;
198 
201  i386_ScreenPosX = 0;
202  i386_ScreenPosY = 0;
203 
204  PrintText("A problem has been detected and FreeLoader boot has been aborted.\n\n");
205 
206  PrintText("%ld: %s\n\n", BugCode, BugCodeStrings[BugCode]);
207 
208  if (File)
209  {
210  PrintText("Location: %s:%ld\n\n", File, Line);
211  }
212 
213  va_start(argptr, Format);
214  PrintTextV(Format, argptr);
215  va_end(argptr);
216 
217  _disable();
218  __halt();
219  for (;;);
220 }
char * BugCodeStrings[]
Definition: debug.c:515
__INTRIN_INLINE void __halt(void)
Definition: intrin_x86.h:1595
#define va_end(ap)
Definition: acmsvcex.h:90
static void PrintTextV(const CHAR *Format, va_list args)
Definition: i386bug.c:76
char * va_list
Definition: acmsvcex.h:78
Definition: ncftp.h:79
#define MachVideoClearScreen(Attr)
Definition: machine.h:92
#define MachVideoHideShowTextCursor(Show)
Definition: machine.h:104
#define SCREEN_ATTR
Definition: i386bug.c:35
#define va_start(ap, A)
Definition: acmsvcex.h:91
void __cdecl _disable(void)
Definition: intrin_arm.h:365
static void PrintText(const CHAR *Format,...)
Definition: i386bug.c:87
Definition: File.h:15
static ULONG i386_ScreenPosY
Definition: i386bug.c:39
static ULONG i386_ScreenPosX
Definition: i386bug.c:38

◆ i386PrintExceptionText()

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

Definition at line 118 of file i386bug.c.

119 {
120  PUCHAR InstructionPointer;
121 
124  i386_ScreenPosX = 0;
125  i386_ScreenPosY = 0;
126 
127  PrintText("An error occured in " VERSION "\n"
128  "Report this error on the ReactOS Bug Tracker: https://jira.reactos.org\n\n"
129  "0x%02lx: %s\n", TrapIndex, i386ExceptionDescriptionText[TrapIndex]);
130 #ifdef _M_IX86
131  PrintText("EAX: %.8lx ESP: %.8lx CR0: %.8lx DR0: %.8lx\n",
132  TrapFrame->Eax, TrapFrame->HardwareEsp, Special->Cr0, TrapFrame->Dr0);
133  PrintText("EBX: %.8lx EBP: %.8lx CR1: ???????? DR1: %.8lx\n",
134  TrapFrame->Ebx, TrapFrame->Ebp, TrapFrame->Dr1);
135  PrintText("ECX: %.8lx ESI: %.8lx CR2: %.8lx DR2: %.8lx\n",
136  TrapFrame->Ecx, TrapFrame->Esi, Special->Cr2, TrapFrame->Dr2);
137  PrintText("EDX: %.8lx EDI: %.8lx CR3: %.8lx DR3: %.8lx\n",
138  TrapFrame->Edx, TrapFrame->Edi, Special->Cr3, TrapFrame->Dr3);
139  PrintText(" DR6: %.8lx\n",
140  TrapFrame->Dr6);
141  PrintText(" DR7: %.8lx\n\n",
142  TrapFrame->Dr7);
143  PrintText("CS: %.4lx EIP: %.8lx\n",
144  TrapFrame->SegCs, TrapFrame->Eip);
145  PrintText("DS: %.4lx ERROR CODE: %.8lx\n",
146  TrapFrame->SegDs, TrapFrame->ErrCode);
147  PrintText("ES: %.4lx EFLAGS: %.8lx\n",
148  TrapFrame->SegEs, TrapFrame->EFlags);
149  PrintText("FS: %.4lx GDTR Base: %.8lx Limit: %.4x\n",
150  TrapFrame->SegFs, Special->Gdtr.Base, Special->Gdtr.Limit);
151  PrintText("GS: %.4lx IDTR Base: %.8lx Limit: %.4x\n",
152  TrapFrame->SegGs, Special->Idtr.Base, Special->Idtr.Limit);
153  PrintText("SS: %.4lx LDTR: %.4lx TR: %.4lx\n\n",
154  TrapFrame->HardwareSegSs, Special->Ldtr, Special->Idtr.Limit);
155 
156  i386PrintFrames(TrapFrame); // Display frames
157  InstructionPointer = (PUCHAR)TrapFrame->Eip;
158 #else
159  PrintText("RAX: %.8lx R8: %.8lx R12: %.8lx RSI: %.8lx\n",
160  TrapFrame->Rax, TrapFrame->R8, 0, TrapFrame->Rsi);
161  PrintText("RBX: %.8lx R9: %.8lx R13: %.8lx RDI: %.8lx\n",
162  TrapFrame->Rbx, TrapFrame->R9, 0, TrapFrame->Rdi);
163  PrintText("RCX: %.8lx R10: %.8lx R14: %.8lx RBP: %.8lx\n",
164  TrapFrame->Rcx, TrapFrame->R10, 0, TrapFrame->Rbp);
165  PrintText("RDX: %.8lx R11: %.8lx R15: %.8lx RSP: %.8lx\n",
166  TrapFrame->Rdx, TrapFrame->R11, 0, TrapFrame->Rsp);
167 
168  PrintText("CS: %.4lx RIP: %.8lx\n",
169  TrapFrame->SegCs, TrapFrame->Rip);
170  PrintText("DS: %.4lx ERROR CODE: %.8lx\n",
171  TrapFrame->SegDs, TrapFrame->ErrorCode);
172  PrintText("ES: %.4lx EFLAGS: %.8lx\n",
173  TrapFrame->SegEs, TrapFrame->EFlags);
174  PrintText("FS: %.4lx GDTR Base: %.8lx Limit: %.4x\n",
175  TrapFrame->SegFs, Special->Gdtr.Base, Special->Gdtr.Limit);
176  PrintText("GS: %.4lx IDTR Base: %.8lx Limit: %.4x\n",
177  TrapFrame->SegGs, Special->Idtr.Base, Special->Idtr.Limit);
178  PrintText("SS: %.4lx LDTR: %.4lx TR: %.4lx\n\n",
179  TrapFrame->SegSs, Special->Ldtr, Special->Idtr.Limit);
180  InstructionPointer = (PUCHAR)TrapFrame->Rip;
181 #endif
182  PrintText("\nInstruction stream: %.2x %.2x %.2x %.2x %.2x %.2x %.2x %.2x \n",
183  InstructionPointer[0], InstructionPointer[1],
184  InstructionPointer[2], InstructionPointer[3],
185  InstructionPointer[4], InstructionPointer[5],
186  InstructionPointer[6], InstructionPointer[7]);
187 }
UINT64 R8
Definition: ketypes.h:321
UINT64 Rbp
Definition: ketypes.h:372
UINT64 R10
Definition: ketypes.h:323
UINT64 Rbx
Definition: ketypes.h:369
UINT64 R9
Definition: ketypes.h:322
unsigned char * PUCHAR
Definition: retypes.h:3
USHORT SegFs
Definition: ketypes.h:366
ULONG HardwareSegSs
Definition: ketypes.h:271
ULONG Esi
Definition: ketypes.h:263
PVOID Base
Definition: ketypes.h:486
ULONG Edi
Definition: ketypes.h:262
USHORT Limit
Definition: ketypes.h:485
UINT64 Dr2
Definition: ketypes.h:344
ULONG Eax
Definition: ketypes.h:258
UINT64 Rsi
Definition: ketypes.h:371
USHORT SegGs
Definition: ketypes.h:367
UINT64 Rax
Definition: ketypes.h:318
USHORT SegEs
Definition: ketypes.h:365
USHORT SegCs
Definition: ketypes.h:380
KDESCRIPTOR Gdtr
Definition: ketypes.h:506
ULONG HardwareEsp
Definition: ketypes.h:270
UINT64 Dr6
Definition: ketypes.h:346
static void i386PrintFrames(PKTRAP_FRAME TrapFrame)
Definition: i386bug.c:97
UINT64 Dr3
Definition: ketypes.h:345
#define MachVideoClearScreen(Attr)
Definition: machine.h:92
UINT64 Rdx
Definition: ketypes.h:320
UINT64 Dr1
Definition: ketypes.h:343
#define MachVideoHideShowTextCursor(Show)
Definition: machine.h:104
USHORT SegDs
Definition: ketypes.h:364
ULONG Ecx
Definition: ketypes.h:257
ULONG Eip
Definition: ketypes.h:267
UINT64 Dr0
Definition: ketypes.h:342
UINT64 R11
Definition: ketypes.h:324
USHORT SegSs
Definition: ketypes.h:387
ULONG Ebx
Definition: ketypes.h:264
UINT64 Rsp
Definition: ketypes.h:386
#define SCREEN_ATTR
Definition: i386bug.c:35
UINT64 Rdi
Definition: ketypes.h:370
UINT64 ErrorCode
Definition: ketypes.h:375
UINT64 Rip
Definition: ketypes.h:379
static void PrintText(const CHAR *Format,...)
Definition: i386bug.c:87
UINT64 Dr7
Definition: ketypes.h:347
static const CHAR * i386ExceptionDescriptionText[]
Definition: i386bug.c:12
UINT64 Rcx
Definition: ketypes.h:319
static ULONG i386_ScreenPosY
Definition: i386bug.c:39
static ULONG i386_ScreenPosX
Definition: i386bug.c:38
ULONG ErrCode
Definition: ketypes.h:266
ULONG EFlags
Definition: ketypes.h:384
#define VERSION
Definition: rdesktop.h:45
ULONG Edx
Definition: ketypes.h:256
ULONG Ebp
Definition: ketypes.h:265
KDESCRIPTOR Idtr
Definition: ketypes.h:507

◆ i386PrintFrames()

static void i386PrintFrames ( PKTRAP_FRAME  TrapFrame)
static

Definition at line 97 of file i386bug.c.

98 {
99  FRAME *Frame;
100 
101  PrintText("Frames:\n");
102 #ifdef _M_IX86
103  for (Frame = (FRAME*)TrapFrame->Ebp;
104  Frame != 0 && (ULONG_PTR)Frame < STACKADDR;
105  Frame = Frame->Next)
106 #else
107  for (Frame = (FRAME*)TrapFrame->TrapFrame;
108  Frame != 0 && (ULONG_PTR)Frame < STACKADDR;
109  Frame = Frame->Next)
110 #endif
111  {
112  PrintText("%p ", Frame->Address);
113  }
114 }
uint32_t ULONG_PTR
Definition: typedefs.h:64
#define STACKADDR
Definition: x86common.h:16
struct _FRAME * Next
Definition: i386bug.c:8
static void PrintText(const CHAR *Format,...)
Definition: i386bug.c:87
void * Address
Definition: i386bug.c:9
UINT64 TrapFrame
Definition: ketypes.h:368
ULONG Ebp
Definition: ketypes.h:265
Definition: i386bug.c:6

Referenced by i386PrintExceptionText().

◆ i386PrintText()

static void i386PrintText ( CHAR pszText)
static

Definition at line 50 of file i386bug.c.

51 {
52  ULONG Width, Unused;
53 
55 
56  for (; *pszText != ANSI_NULL; ++pszText)
57  {
58  if (*pszText == '\n')
59  {
60  i386_ScreenPosX = 0;
62  continue;
63  }
64 
66  if (++i386_ScreenPosX >= Width)
67  {
68  i386_ScreenPosX = 0;
70  }
71  // FIXME: Implement vertical screen scrolling if we are at the end of the screen.
72  }
73 }
_Must_inspect_result_ typedef _In_ PVOID Unused
Definition: iotypes.h:1129
#define MachVideoGetDisplaySize(W, H, D)
Definition: machine.h:96
#define ANSI_NULL
#define MachVideoPutChar(Ch, Attr, X, Y)
Definition: machine.h:106
#define SCREEN_ATTR
Definition: i386bug.c:35
unsigned int ULONG
Definition: retypes.h:1
static ULONG i386_ScreenPosY
Definition: i386bug.c:39
static ULONG i386_ScreenPosX
Definition: i386bug.c:38

Referenced by PrintTextV().

◆ PrintText()

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

Definition at line 87 of file i386bug.c.

88 {
89  va_list argptr;
90 
91  va_start(argptr, Format);
92  PrintTextV(Format, argptr);
93  va_end(argptr);
94 }
#define va_end(ap)
Definition: acmsvcex.h:90
static void PrintTextV(const CHAR *Format, va_list args)
Definition: i386bug.c:76
char * va_list
Definition: acmsvcex.h:78
#define va_start(ap, A)
Definition: acmsvcex.h:91

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

◆ PrintTextV()

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

Definition at line 76 of file i386bug.c.

77 {
78  CHAR Buffer[512];
79 
80  _vsnprintf(Buffer, sizeof(Buffer), Format, args);
81  Buffer[sizeof(Buffer) - 1] = ANSI_NULL;
82 
84 }
char CHAR
Definition: xmlstorage.h:175
Definition: match.c:390
#define ANSI_NULL
Definition: bufpool.h:45
#define _vsnprintf
Definition: xmlstorage.h:202
IN BOOLEAN OUT PSTR Buffer
Definition: progress.h:34
static void i386PrintText(CHAR *pszText)
Definition: i386bug.c:50

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\n\n",
"Exception 01: DEBUG EXCEPTION\n\n",
"Exception 02: NON-MASKABLE INTERRUPT EXCEPTION\n\n",
"Exception 03: BREAKPOINT (INT 3)\n\n",
"Exception 04: OVERFLOW\n\n",
"Exception 05: BOUND EXCEPTION\n\n",
"Exception 06: INVALID OPCODE\n\n",
"Exception 07: FPU NOT AVAILABLE\n\n",
"Exception 08: DOUBLE FAULT\n\n",
"Exception 09: COPROCESSOR SEGMENT OVERRUN\n\n",
"Exception 0A: INVALID TSS\n\n",
"Exception 0B: SEGMENT NOT PRESENT\n\n",
"Exception 0C: STACK EXCEPTION\n\n",
"Exception 0D: GENERAL PROTECTION FAULT\n\n",
"Exception 0E: PAGE FAULT\n\n",
"Exception 0F: Reserved\n\n",
"Exception 10: COPROCESSOR ERROR\n\n",
"Exception 11: ALIGNMENT CHECK\n\n",
"Exception 12: MACHINE CHECK\n\n"
}

Definition at line 12 of file i386bug.c.

Referenced by i386PrintExceptionText().