mirror of
https://github.com/reactos/reactos.git
synced 2024-11-10 08:43:28 +00:00
1fb94b1cb5
sync with trunk (r49230) svn path=/branches/cmake-bringup/; revision=49246
58 lines
1.4 KiB
C
58 lines
1.4 KiB
C
/*
|
|
* PROJECT: ReactOS NMI Debug Driver
|
|
* LICENSE: BSD - See COPYING.ARM in the top level directory
|
|
* FILE: drivers/base/nmidebug/nmidebug.c
|
|
* PURPOSE: Driver Code
|
|
* PROGRAMMERS: ReactOS Portable Systems Group
|
|
*/
|
|
|
|
/* INCLUDES *******************************************************************/
|
|
|
|
#include <ntifs.h>
|
|
#include <ntndk.h>
|
|
|
|
/* FUNCTIONS ******************************************************************/
|
|
|
|
PCHAR NmiBegin = "NMI4NMI@";
|
|
|
|
VOID
|
|
FORCEINLINE
|
|
NmiClearFlag(VOID)
|
|
{
|
|
((PCHAR)&KiBugCheckData[4])[0] -= (NmiBegin[3] | NmiBegin[7]);
|
|
((PCHAR)&KiBugCheckData[4])[3] |= 1;
|
|
__asm__("rcrl %b[shift], %k[retval]" : [retval] "=rm" (KiBugCheckData[4]) : "[retval]" (KiBugCheckData[4]), [shift] "Nc" (8));
|
|
}
|
|
|
|
BOOLEAN
|
|
NTAPI
|
|
NmiDbgCallback(IN PVOID Context,
|
|
IN BOOLEAN Handled)
|
|
{
|
|
/* Clear the NMI flag */
|
|
NmiClearFlag();
|
|
|
|
/* Get NMI status signature */
|
|
__indwordstring(0x80, (PULONG)NmiBegin, 1);
|
|
((void(*)())&KiBugCheckData[4])();
|
|
|
|
/* Handle the NMI safely */
|
|
KiEnableTimerWatchdog = (RtlCompareMemory(NmiBegin, NmiBegin + 4, 4) != 4);
|
|
return TRUE;
|
|
}
|
|
|
|
NTSTATUS
|
|
NTAPI
|
|
DriverEntry(IN PDRIVER_OBJECT DriverObject,
|
|
IN PUNICODE_STRING RegistryPath)
|
|
{
|
|
PAGED_CODE();
|
|
|
|
/* Register NMI callback */
|
|
KeRegisterNmiCallback(&NmiDbgCallback, NULL);
|
|
|
|
/* Return success */
|
|
return STATUS_SUCCESS;
|
|
}
|
|
|
|
/* EOF */
|