2009-11-08 21:10:23 +00:00
|
|
|
/*
|
|
|
|
* 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.
|
2009-11-10 16:42:31 +00:00
|
|
|
* PROGRAMMERS: Alex Ionescu (alex.ionescu@reactos.org)
|
2009-11-08 21:10:23 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
/* 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;
|
2021-09-05 00:48:20 +00:00
|
|
|
KIRQL OldIrql;
|
2009-11-08 21:10:23 +00:00
|
|
|
|
2021-09-05 00:48:20 +00:00
|
|
|
#ifndef CONFIG_SMP
|
|
|
|
UNREFERENCED_PARAMETER(TrapFrame);
|
|
|
|
UNREFERENCED_PARAMETER(ExceptionFrame);
|
|
|
|
#endif
|
2009-11-08 21:10:23 +00:00
|
|
|
|
2021-09-05 00:48:20 +00:00
|
|
|
/* Disable interrupts, get previous state and set the freeze flag */
|
|
|
|
Enable = KeDisableInterrupts();
|
2009-11-08 21:10:23 +00:00
|
|
|
KiFreezeFlag = 4;
|
|
|
|
|
2021-09-05 00:48:20 +00:00
|
|
|
#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
|
2023-11-29 18:01:31 +00:00
|
|
|
/* Architecture specific freeze code */
|
|
|
|
KxFreezeExecution();
|
2021-09-05 00:48:20 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
/* Save the old IRQL to be restored on unfreeze */
|
|
|
|
KiOldIrql = OldIrql;
|
2009-11-08 21:10:23 +00:00
|
|
|
|
|
|
|
/* Return whether interrupts were enabled */
|
|
|
|
return Enable;
|
|
|
|
}
|
|
|
|
|
|
|
|
VOID
|
|
|
|
NTAPI
|
|
|
|
KeThawExecution(IN BOOLEAN Enable)
|
|
|
|
{
|
2021-09-05 00:48:20 +00:00
|
|
|
#ifdef CONFIG_SMP
|
2023-11-29 18:01:31 +00:00
|
|
|
/* Architecture specific thaw code */
|
|
|
|
KxThawExecution();
|
2021-09-05 00:48:20 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
/* Clear the freeze flag */
|
|
|
|
KiFreezeFlag = 0;
|
|
|
|
|
2009-11-08 21:10:23 +00:00
|
|
|
/* Cleanup CPU caches */
|
|
|
|
KeFlushCurrentTb();
|
|
|
|
|
2021-09-05 00:48:20 +00:00
|
|
|
/* Restore the old IRQL */
|
|
|
|
#ifndef CONFIG_SMP
|
|
|
|
if (KiOldIrql < DISPATCH_LEVEL)
|
|
|
|
#endif
|
|
|
|
KeLowerIrql(KiOldIrql);
|
|
|
|
|
2009-11-08 21:10:23 +00:00
|
|
|
/* Re-enable interrupts */
|
2021-09-05 00:48:20 +00:00
|
|
|
KeRestoreInterrupts(Enable);
|
2009-11-08 21:10:23 +00:00
|
|
|
}
|