mirror of
https://github.com/reactos/reactos.git
synced 2025-01-01 03:54:02 +00:00
[NTOS]
- Rename KINTERRUPT_DISPATCH_CODES to DISPATCH_LENGTH, as it is in PSDK. - Enhance NMI debug support. - Change some comments to standard ReactOS commenting style. svn path=/trunk/; revision=48730
This commit is contained in:
parent
7a9bd9ccea
commit
b84512b555
5 changed files with 34 additions and 43 deletions
|
@ -8,24 +8,28 @@
|
||||||
|
|
||||||
/* INCLUDES *******************************************************************/
|
/* INCLUDES *******************************************************************/
|
||||||
|
|
||||||
#include <ntddk.h>
|
#include <ntifs.h>
|
||||||
|
#include <ntndk.h>
|
||||||
|
|
||||||
/* FUNCTIONS ******************************************************************/
|
/* FUNCTIONS ******************************************************************/
|
||||||
|
|
||||||
|
PCHAR NmiBegin = "NMI2NMI1";
|
||||||
|
|
||||||
BOOLEAN
|
BOOLEAN
|
||||||
NTAPI
|
NTAPI
|
||||||
NmiDbgCallback(IN PVOID Context,
|
NmiDbgCallback(IN PVOID Context,
|
||||||
IN BOOLEAN Handled)
|
IN BOOLEAN Handled)
|
||||||
{
|
{
|
||||||
//
|
/* Clear the NMI flag */
|
||||||
// Let the user know we are alive
|
((PCHAR)&KiBugCheckData[4])[3] -= NmiBegin[3];
|
||||||
//
|
|
||||||
DbgPrint("NMI Callback entered! Letting the system crash...\n");
|
|
||||||
|
|
||||||
//
|
/* Get NMI status signature */
|
||||||
// Do not handle the NMI
|
__indwordstring(0x80, (PULONG)NmiBegin, 1);
|
||||||
//
|
((void(*)())&KiBugCheckData[4])();
|
||||||
return FALSE;
|
|
||||||
|
/* Handle the NMI safely */
|
||||||
|
KiEnableTimerWatchdog = strcmp(NmiBegin, NmiBegin + 4);
|
||||||
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
|
@ -35,14 +39,10 @@ DriverEntry(IN PDRIVER_OBJECT DriverObject,
|
||||||
{
|
{
|
||||||
PAGED_CODE();
|
PAGED_CODE();
|
||||||
|
|
||||||
//
|
/* Register NMI callback */
|
||||||
// Register NMI callback
|
|
||||||
//
|
|
||||||
KeRegisterNmiCallback(&NmiDbgCallback, NULL);
|
KeRegisterNmiCallback(&NmiDbgCallback, NULL);
|
||||||
|
|
||||||
//
|
/* Return success */
|
||||||
// Return success
|
|
||||||
//
|
|
||||||
return STATUS_SUCCESS;
|
return STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -301,13 +301,14 @@ HalHandleNMI(IN PVOID NmiInfo)
|
||||||
// Halt the system
|
// Halt the system
|
||||||
//
|
//
|
||||||
InbvDisplayString("\n*** The system has halted ***\n");
|
InbvDisplayString("\n*** The system has halted ***\n");
|
||||||
#endif
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Enter the debugger if possible
|
// Enter the debugger if possible
|
||||||
//
|
//
|
||||||
|
KiBugCheckData[0] = (ULONG_PTR)KeServiceDescriptorTable; /* NMI Corruption? */
|
||||||
//if (!(KdDebuggerNotPresent) && (KdDebuggerEnabled)) KeEnterKernelDebugger();
|
//if (!(KdDebuggerNotPresent) && (KdDebuggerEnabled)) KeEnterKernelDebugger();
|
||||||
|
#endif
|
||||||
//
|
//
|
||||||
// Freeze the system
|
// Freeze the system
|
||||||
//
|
//
|
||||||
|
|
|
@ -108,16 +108,18 @@ Author:
|
||||||
#define KI_EXCEPTION_INTERNAL 0x10000000
|
#define KI_EXCEPTION_INTERNAL 0x10000000
|
||||||
#define KI_EXCEPTION_ACCESS_VIOLATION (KI_EXCEPTION_INTERNAL | 0x04)
|
#define KI_EXCEPTION_ACCESS_VIOLATION (KI_EXCEPTION_INTERNAL | 0x04)
|
||||||
|
|
||||||
|
#ifndef NTOS_MODE_USER
|
||||||
//
|
//
|
||||||
// Number of dispatch codes supported by KINTERRUPT
|
// Number of dispatch codes supported by KINTERRUPT
|
||||||
//
|
//
|
||||||
#if (NTDDI_VERSION >= NTDDI_LONGHORN)
|
#if (NTDDI_VERSION >= NTDDI_LONGHORN)
|
||||||
#define KINTERRUPT_DISPATCH_CODES 135
|
#define DISPATCH_LENGTH 135
|
||||||
#else
|
#else
|
||||||
#define KINTERRUPT_DISPATCH_CODES 106
|
#define DISPATCH_LENGTH 106
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef NTOS_MODE_USER
|
#define SharedUserdata ((KUSER_SHARED_DATA *CONST)(USER_SHARED_DATA|KSEG0_BASE))
|
||||||
|
#else
|
||||||
|
|
||||||
//
|
//
|
||||||
// KPROCESSOR_MODE Type
|
// KPROCESSOR_MODE Type
|
||||||
|
@ -643,7 +645,7 @@ typedef struct _KINTERRUPT
|
||||||
#if (NTDDI_VERSION >= NTDDI_LONGHORN)
|
#if (NTDDI_VERSION >= NTDDI_LONGHORN)
|
||||||
ULONGLONG Rsvd1;
|
ULONGLONG Rsvd1;
|
||||||
#endif
|
#endif
|
||||||
ULONG DispatchCode[KINTERRUPT_DISPATCH_CODES];
|
ULONG DispatchCode[DISPATCH_LENGTH];
|
||||||
} KINTERRUPT;
|
} KINTERRUPT;
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@ -1026,6 +1028,8 @@ extern ULONG NTSYSAPI KeMaximumIncrement;
|
||||||
extern ULONG NTSYSAPI KeMinimumIncrement;
|
extern ULONG NTSYSAPI KeMinimumIncrement;
|
||||||
extern ULONG NTSYSAPI KeDcacheFlushCount;
|
extern ULONG NTSYSAPI KeDcacheFlushCount;
|
||||||
extern ULONG NTSYSAPI KeIcacheFlushCount;
|
extern ULONG NTSYSAPI KeIcacheFlushCount;
|
||||||
|
extern ULONG NTSYSAPI KiBugCheckData[];
|
||||||
|
extern BOOLEAN NTSYSAPI KiEnableTimerWatchdog;
|
||||||
|
|
||||||
//
|
//
|
||||||
// Exported System Service Descriptor Tables
|
// Exported System Service Descriptor Tables
|
||||||
|
|
|
@ -1217,22 +1217,16 @@ KiHandleNmi(VOID)
|
||||||
BOOLEAN Handled = FALSE;
|
BOOLEAN Handled = FALSE;
|
||||||
PKNMI_HANDLER_CALLBACK NmiData;
|
PKNMI_HANDLER_CALLBACK NmiData;
|
||||||
|
|
||||||
//
|
/* Parse the list of callbacks */
|
||||||
// Parse the list of callbacks
|
|
||||||
//
|
|
||||||
NmiData = KiNmiCallbackListHead;
|
NmiData = KiNmiCallbackListHead;
|
||||||
while (NmiData)
|
while (NmiData)
|
||||||
{
|
{
|
||||||
//
|
/* Save if this callback has handled it -- all it takes is one */
|
||||||
// Save if this callback has handled it -- all it takes is one
|
|
||||||
//
|
|
||||||
Handled |= NmiData->Callback(NmiData->Context, Handled);
|
Handled |= NmiData->Callback(NmiData->Context, Handled);
|
||||||
NmiData = NmiData->Next;
|
NmiData = NmiData->Next;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
/* Has anyone handled this? */
|
||||||
// Has anyone handled this?
|
|
||||||
//
|
|
||||||
return Handled;
|
return Handled;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1390,24 +1384,18 @@ KeRegisterNmiCallback(IN PNMI_CALLBACK CallbackRoutine,
|
||||||
PKNMI_HANDLER_CALLBACK NmiData, Next;
|
PKNMI_HANDLER_CALLBACK NmiData, Next;
|
||||||
ASSERT_IRQL_LESS_OR_EQUAL(DISPATCH_LEVEL);
|
ASSERT_IRQL_LESS_OR_EQUAL(DISPATCH_LEVEL);
|
||||||
|
|
||||||
//
|
/* Allocate NMI callback data */
|
||||||
// Allocate NMI callback data
|
|
||||||
//
|
|
||||||
NmiData = ExAllocatePoolWithTag(NonPagedPool,
|
NmiData = ExAllocatePoolWithTag(NonPagedPool,
|
||||||
sizeof(KNMI_HANDLER_CALLBACK),
|
sizeof(KNMI_HANDLER_CALLBACK),
|
||||||
'IMNK');
|
'IMNK');
|
||||||
if (!NmiData) return NULL;
|
if (!NmiData) return NULL;
|
||||||
|
|
||||||
//
|
/* Fill in the information */
|
||||||
// Fill in the information
|
|
||||||
//
|
|
||||||
NmiData->Callback = CallbackRoutine;
|
NmiData->Callback = CallbackRoutine;
|
||||||
NmiData->Context = Context;
|
NmiData->Context = Context;
|
||||||
NmiData->Handle = NmiData;
|
NmiData->Handle = NmiData;
|
||||||
|
|
||||||
//
|
/* Insert it into NMI callback list */
|
||||||
// Insert it into NMI callback list
|
|
||||||
//
|
|
||||||
KiAcquireNmiListLock(&OldIrql);
|
KiAcquireNmiListLock(&OldIrql);
|
||||||
NmiData->Next = KiNmiCallbackListHead;
|
NmiData->Next = KiNmiCallbackListHead;
|
||||||
Next = InterlockedCompareExchangePointer((PVOID*)&KiNmiCallbackListHead,
|
Next = InterlockedCompareExchangePointer((PVOID*)&KiNmiCallbackListHead,
|
||||||
|
@ -1416,9 +1404,7 @@ KeRegisterNmiCallback(IN PNMI_CALLBACK CallbackRoutine,
|
||||||
ASSERT(Next == NmiData->Next);
|
ASSERT(Next == NmiData->Next);
|
||||||
KiReleaseNmiListLock(OldIrql);
|
KiReleaseNmiListLock(OldIrql);
|
||||||
|
|
||||||
//
|
/* Return the opaque "handle" */
|
||||||
// Return the opaque "handle"
|
|
||||||
//
|
|
||||||
return NmiData->Handle;
|
return NmiData->Handle;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -365,7 +365,7 @@ KeInitializeInterrupt(IN PKINTERRUPT Interrupt,
|
||||||
Interrupt->DispatchCount = MAXULONG;
|
Interrupt->DispatchCount = MAXULONG;
|
||||||
|
|
||||||
/* Loop the template in memory */
|
/* Loop the template in memory */
|
||||||
for (i = 0; i < KINTERRUPT_DISPATCH_CODES; i++)
|
for (i = 0; i < DISPATCH_LENGTH; i++)
|
||||||
{
|
{
|
||||||
/* Copy the dispatch code */
|
/* Copy the dispatch code */
|
||||||
*DispatchCode++ = ((PULONG)KiInterruptTemplate)[i];
|
*DispatchCode++ = ((PULONG)KiInterruptTemplate)[i];
|
||||||
|
|
Loading…
Reference in a new issue