mirror of
https://github.com/reactos/reactos.git
synced 2024-12-26 17:14:41 +00:00
86 lines
2 KiB
C
86 lines
2 KiB
C
/*
|
|
* PROJECT: ReactOS Kernel
|
|
* LICENSE: GPL - See COPYING in the top level directory
|
|
* FILE: ntoskrnl/ke/freeze.c
|
|
* PURPOSE: Routines for freezing and unfreezing processors for
|
|
* kernel debugger synchronization.
|
|
* PROGRAMMERS: Alex Ionescu (alex.ionescu@reactos.org)
|
|
*/
|
|
|
|
/* INCLUDES *******************************************************************/
|
|
|
|
#include <ntoskrnl.h>
|
|
#define NDEBUG
|
|
#include <debug.h>
|
|
|
|
/* GLOBALS ********************************************************************/
|
|
|
|
/* Freeze data */
|
|
KIRQL KiOldIrql;
|
|
ULONG KiFreezeFlag;
|
|
|
|
/* FUNCTIONS ******************************************************************/
|
|
|
|
BOOLEAN
|
|
NTAPI
|
|
KeFreezeExecution(IN PKTRAP_FRAME TrapFrame,
|
|
IN PKEXCEPTION_FRAME ExceptionFrame)
|
|
{
|
|
BOOLEAN Enable;
|
|
KIRQL OldIrql;
|
|
|
|
#ifndef CONFIG_SMP
|
|
UNREFERENCED_PARAMETER(TrapFrame);
|
|
UNREFERENCED_PARAMETER(ExceptionFrame);
|
|
#endif
|
|
|
|
/* Disable interrupts, get previous state and set the freeze flag */
|
|
Enable = KeDisableInterrupts();
|
|
KiFreezeFlag = 4;
|
|
|
|
#ifndef CONFIG_SMP
|
|
/* Raise IRQL if we have to */
|
|
OldIrql = KeGetCurrentIrql();
|
|
if (OldIrql < DISPATCH_LEVEL)
|
|
OldIrql = KeRaiseIrqlToDpcLevel();
|
|
#else
|
|
/* Raise IRQL to HIGH_LEVEL */
|
|
KeRaiseIrql(HIGH_LEVEL, &OldIrql);
|
|
#endif
|
|
|
|
#ifdef CONFIG_SMP
|
|
/* Architecture specific freeze code */
|
|
KxFreezeExecution();
|
|
#endif
|
|
|
|
/* Save the old IRQL to be restored on unfreeze */
|
|
KiOldIrql = OldIrql;
|
|
|
|
/* Return whether interrupts were enabled */
|
|
return Enable;
|
|
}
|
|
|
|
VOID
|
|
NTAPI
|
|
KeThawExecution(IN BOOLEAN Enable)
|
|
{
|
|
#ifdef CONFIG_SMP
|
|
/* Architecture specific thaw code */
|
|
KxThawExecution();
|
|
#endif
|
|
|
|
/* Clear the freeze flag */
|
|
KiFreezeFlag = 0;
|
|
|
|
/* Cleanup CPU caches */
|
|
KeFlushCurrentTb();
|
|
|
|
/* Restore the old IRQL */
|
|
#ifndef CONFIG_SMP
|
|
if (KiOldIrql < DISPATCH_LEVEL)
|
|
#endif
|
|
KeLowerIrql(KiOldIrql);
|
|
|
|
/* Re-enable interrupts */
|
|
KeRestoreInterrupts(Enable);
|
|
}
|