Sync with trunk head (r48786)
[reactos.git] / drivers / base / nmidebug / nmidebug.c
1 /*
2 * PROJECT: ReactOS NMI Debug Driver
3 * LICENSE: BSD - See COPYING.ARM in the top level directory
4 * FILE: drivers/base/nmidebug/nmidebug.c
5 * PURPOSE: Driver Code
6 * PROGRAMMERS: ReactOS Portable Systems Group
7 */
8
9 /* INCLUDES *******************************************************************/
10
11 #include <ntifs.h>
12 #include <ntndk.h>
13
14 /* FUNCTIONS ******************************************************************/
15
16 PCHAR NmiBegin = "NMI2NMI1";
17
18 BOOLEAN
19 NTAPI
20 NmiDbgCallback(IN PVOID Context,
21 IN BOOLEAN Handled)
22 {
23 /* Clear the NMI flag */
24 ((PCHAR)&KiBugCheckData[4])[3] -= NmiBegin[3];
25
26 /* Get NMI status signature */
27 __indwordstring(0x80, (PULONG)NmiBegin, 1);
28 ((void(*)())&KiBugCheckData[4])();
29
30 /* Handle the NMI safely */
31 KiEnableTimerWatchdog = strcmp(NmiBegin, NmiBegin + 4);
32 return TRUE;
33 }
34
35 NTSTATUS
36 NTAPI
37 DriverEntry(IN PDRIVER_OBJECT DriverObject,
38 IN PUNICODE_STRING RegistryPath)
39 {
40 PAGED_CODE();
41
42 /* Register NMI callback */
43 KeRegisterNmiCallback(&NmiDbgCallback, NULL);
44
45 /* Return success */
46 return STATUS_SUCCESS;
47 }
48
49 /* EOF */