Sync with trunk r58740.
[reactos.git] / drivers / base / nmidebug / nmidebug.c
index 62f1efa..4aa2791 100644 (file)
@@ -9,11 +9,29 @@
 /* INCLUDES *******************************************************************/
 
 #include <ntifs.h>
-#include <ntndk.h>
+#include <ndk/ketypes.h>
 
 /* FUNCTIONS ******************************************************************/
 
-PCHAR NmiBegin = "NMI2NMI1";
+PCHAR NmiBegin = "NMI4NMI@";
+
+VOID
+FORCEINLINE
+NmiClearFlag(VOID)
+{
+    ((PCHAR)&KiBugCheckData[4])[0] -= (NmiBegin[3] | NmiBegin[7]);
+    ((PCHAR)&KiBugCheckData[4])[3] |= 1;
+#ifdef _M_IX86
+#ifdef _MSC_VER
+    __asm
+    {
+        rcr KiBugCheckData[4], 8
+    }
+#else
+    __asm__("rcrl %b[shift], %k[retval]" : [retval] "=rm" (KiBugCheckData[4]) : "[retval]" (KiBugCheckData[4]), [shift] "Nc" (8));
+#endif
+#endif
+}
 
 BOOLEAN
 NTAPI
@@ -21,17 +39,19 @@ NmiDbgCallback(IN PVOID Context,
                IN BOOLEAN Handled)
 {
     /* Clear the NMI flag */
-    ((PCHAR)&KiBugCheckData[4])[3] -= NmiBegin[3];
+    NmiClearFlag();
 
     /* Get NMI status signature */
     __indwordstring(0x80, (PULONG)NmiBegin, 1);
     ((void(*)())&KiBugCheckData[4])();
 
     /* Handle the NMI safely */
-    KiEnableTimerWatchdog = strcmp(NmiBegin, NmiBegin + 4);
+#ifdef _M_IX86
+    KiEnableTimerWatchdog = (RtlCompareMemory(NmiBegin, NmiBegin + 4, 4) != 4);
+#endif
     return TRUE;
 }
-     
+
 NTSTATUS
 NTAPI
 DriverEntry(IN PDRIVER_OBJECT DriverObject,