2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS kernel
4 * FILE: ntoskrnl/ke/bug.c
5 * PURPOSE: Graceful system shutdown if a bug is detected
6 * PROGRAMMER: David Welch (welch@cwcom.net)
9 * Phillip Susi: 12/8/99: Minor fix
12 /* INCLUDES *****************************************************************/
14 #include <ddk/ntddk.h>
15 #include <internal/ke.h>
17 #include <internal/debug.h>
19 /* GLOBALS ******************************************************************/
21 static LIST_ENTRY BugcheckCallbackListHead
= {NULL
,NULL
};
23 VOID
PsDumpThreads(VOID
);
25 /* FUNCTIONS *****************************************************************/
27 BOOLEAN
KeDeregisterBugCheckCallback(PKBUGCHECK_CALLBACK_RECORD CallbackRecord
)
32 VOID
KeInitializeBugCheck(VOID
)
34 InitializeListHead(&BugcheckCallbackListHead
);
37 VOID
KeInitializeCallbackRecord(PKBUGCHECK_CALLBACK_RECORD CallbackRecord
)
42 BOOLEAN
KeRegisterBugCheckCallback(PKBUGCHECK_CALLBACK_RECORD CallbackRecord
,
43 PKBUGCHECK_CALLBACK_ROUTINE CallbackRoutine
,
48 InsertTailList(&BugcheckCallbackListHead
,&CallbackRecord
->Entry
);
49 CallbackRecord
->Length
=Length
;
50 CallbackRecord
->Buffer
=Buffer
;
51 CallbackRecord
->Component
=Component
;
52 CallbackRecord
->CallbackRoutine
=CallbackRoutine
;
56 VOID
KeBugCheckEx(ULONG BugCheckCode
,
57 ULONG BugCheckParameter1
,
58 ULONG BugCheckParameter2
,
59 ULONG BugCheckParameter3
,
60 ULONG BugCheckParameter4
)
62 * FUNCTION: Brings the system down in a controlled manner when an
63 * inconsistency that might otherwise cause corruption has been detected
65 * BugCheckCode = Specifies the reason for the bug check
66 * BugCheckParameter[1-4] = Additional information about bug
70 __asm__("cli\n\t"); //PJS: disable interrupts first, then do the rest
71 DbgPrint("Bug detected (code %x param %x %x %x %x)\n",BugCheckCode
,
72 BugCheckParameter1
,BugCheckParameter2
,BugCheckParameter3
,
75 KeDumpStackFrames(0,64);
78 __asm__("hlt\n\t"); //PJS: use HLT instruction, rather than busy wait
81 VOID
KeBugCheck(ULONG BugCheckCode
)
83 * FUNCTION: Brings the system down in a controlled manner when an
84 * inconsistency that might otherwise cause corruption has been detected
86 * BugCheckCode = Specifies the reason for the bug check
90 KeBugCheckEx(BugCheckCode
,0,0,0,0);