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