disable interrupts first, then do work. Use HLT also instead of busy wait
[reactos.git] / reactos / ntoskrnl / ke / bug.c
1 /*
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)
7 * UPDATE HISTORY:
8 * Created 22/05/98
9 * Phillip Susi: 12/8/99: Minor fix
10 */
11
12 /* INCLUDES *****************************************************************/
13
14 #include <ddk/ntddk.h>
15 #include <internal/ke.h>
16
17 #include <internal/debug.h>
18
19 /* GLOBALS ******************************************************************/
20
21 static LIST_ENTRY BugcheckCallbackListHead = {NULL,NULL};
22
23 VOID PsDumpThreads(VOID);
24
25 /* FUNCTIONS *****************************************************************/
26
27 BOOLEAN KeDeregisterBugCheckCallback(PKBUGCHECK_CALLBACK_RECORD CallbackRecord)
28 {
29 UNIMPLEMENTED;
30 }
31
32 VOID KeInitializeBugCheck(VOID)
33 {
34 InitializeListHead(&BugcheckCallbackListHead);
35 }
36
37 VOID KeInitializeCallbackRecord(PKBUGCHECK_CALLBACK_RECORD CallbackRecord)
38 {
39 UNIMPLEMENTED;
40 }
41
42 BOOLEAN KeRegisterBugCheckCallback(PKBUGCHECK_CALLBACK_RECORD CallbackRecord,
43 PKBUGCHECK_CALLBACK_ROUTINE CallbackRoutine,
44 PVOID Buffer,
45 ULONG Length,
46 PUCHAR Component)
47 {
48 InsertTailList(&BugcheckCallbackListHead,&CallbackRecord->Entry);
49 CallbackRecord->Length=Length;
50 CallbackRecord->Buffer=Buffer;
51 CallbackRecord->Component=Component;
52 CallbackRecord->CallbackRoutine=CallbackRoutine;
53 return(TRUE);
54 }
55
56 VOID KeBugCheckEx(ULONG BugCheckCode,
57 ULONG BugCheckParameter1,
58 ULONG BugCheckParameter2,
59 ULONG BugCheckParameter3,
60 ULONG BugCheckParameter4)
61 /*
62 * FUNCTION: Brings the system down in a controlled manner when an
63 * inconsistency that might otherwise cause corruption has been detected
64 * ARGUMENTS:
65 * BugCheckCode = Specifies the reason for the bug check
66 * BugCheckParameter[1-4] = Additional information about bug
67 * RETURNS: Doesn't
68 */
69 {
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,
73 BugCheckParameter4);
74 PsDumpThreads();
75 KeDumpStackFrames(0,64);
76
77 for(;;)
78 __asm__("hlt\n\t"); //PJS: use HLT instruction, rather than busy wait
79 }
80
81 VOID KeBugCheck(ULONG BugCheckCode)
82 /*
83 * FUNCTION: Brings the system down in a controlled manner when an
84 * inconsistency that might otherwise cause corruption has been detected
85 * ARGUMENTS:
86 * BugCheckCode = Specifies the reason for the bug check
87 * RETURNS: Doesn't
88 */
89 {
90 KeBugCheckEx(BugCheckCode,0,0,0,0);
91 }
92