mirror of
https://github.com/reactos/reactos.git
synced 2024-12-28 01:55:19 +00:00
- Fix KeEnterCriticalRegion/KeLeaveCriticalRegion by moving to ke_x and adding ASSERTs, and change the code in apc.c to call these inlined versions instead. Also fix comment headers for these functions in apc.c to match the official standard.
svn path=/trunk/; revision=24049
This commit is contained in:
parent
38759195cb
commit
4d94e0557f
5 changed files with 83 additions and 81 deletions
|
@ -146,25 +146,6 @@ extern VOID KiTrap2(VOID);
|
|||
InitializeListHead(&((Header)->WaitListHead)); \
|
||||
}
|
||||
|
||||
#define KeEnterCriticalRegion() \
|
||||
{ \
|
||||
PKTHREAD _Thread = KeGetCurrentThread(); \
|
||||
if (_Thread) _Thread->KernelApcDisable--; \
|
||||
}
|
||||
|
||||
#define KeLeaveCriticalRegion() \
|
||||
{ \
|
||||
PKTHREAD _Thread = KeGetCurrentThread(); \
|
||||
if((_Thread) && (++_Thread->KernelApcDisable == 0)) \
|
||||
{ \
|
||||
if (!IsListEmpty(&_Thread->ApcState.ApcListHead[KernelMode]) && \
|
||||
(_Thread->SpecialApcDisable == 0)) \
|
||||
{ \
|
||||
KiCheckForKernelApcDelivery(); \
|
||||
} \
|
||||
} \
|
||||
}
|
||||
|
||||
#define KEBUGCHECKWITHTF(a,b,c,d,e,f) \
|
||||
DbgPrint("KeBugCheckWithTf at %s:%i\n",__FILE__,__LINE__), \
|
||||
KeBugCheckWithTf(a,b,c,d,e,f)
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
*/
|
||||
|
||||
//
|
||||
// Enters a Critical Region
|
||||
// Enters a Guarded Region
|
||||
//
|
||||
#define KeEnterGuardedRegion() \
|
||||
{ \
|
||||
|
@ -24,7 +24,7 @@
|
|||
}
|
||||
|
||||
//
|
||||
// Leaves a Critical Region
|
||||
// Leaves a Guarded Region
|
||||
//
|
||||
#define KeLeaveGuardedRegion() \
|
||||
{ \
|
||||
|
@ -53,8 +53,51 @@
|
|||
//
|
||||
|
||||
//
|
||||
// TODO: Critical Region Routines
|
||||
// Enters a Critical Region
|
||||
//
|
||||
#define KeEnterCriticalRegion() \
|
||||
{ \
|
||||
PKTHREAD Thread = KeGetCurrentThread(); \
|
||||
if (Thread) \
|
||||
{ \
|
||||
/* Sanity checks */ \
|
||||
ASSERT(Thread == KeGetCurrentThread()); \
|
||||
ASSERT((Thread->KernelApcDisable <= 0) && \
|
||||
(Thread->KernelApcDisable != -32768)); \
|
||||
\
|
||||
/* Disable Kernel APCs */ \
|
||||
Thread->KernelApcDisable--; \
|
||||
} \
|
||||
}
|
||||
|
||||
//
|
||||
// Leaves a Critical Region
|
||||
//
|
||||
#define KeLeaveCriticalRegion() \
|
||||
{ \
|
||||
PKTHREAD Thread = KeGetCurrentThread(); \
|
||||
if (Thread) \
|
||||
{ \
|
||||
/* Sanity checks */ \
|
||||
ASSERT(Thread == KeGetCurrentThread()); \
|
||||
ASSERT(Thread->KernelApcDisable < 0); \
|
||||
\
|
||||
/* Enable Kernel APCs */ \
|
||||
Thread->KernelApcDisable++; \
|
||||
\
|
||||
/* Check if Kernel APCs are now enabled */ \
|
||||
if (!(Thread->KernelApcDisable)) \
|
||||
{ \
|
||||
/* Check if we need to request an APC Delivery */ \
|
||||
if (!(IsListEmpty(&Thread->ApcState.ApcListHead[KernelMode])) && \
|
||||
!(Thread->KernelApcDisable)) \
|
||||
{ \
|
||||
/* Check for the right environment */ \
|
||||
KiCheckForKernelApcDelivery(); \
|
||||
} \
|
||||
} \
|
||||
} \
|
||||
}
|
||||
|
||||
//
|
||||
// Satisfies the wait of any dispatcher object
|
||||
|
|
|
@ -1,11 +1,9 @@
|
|||
/*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS kernel
|
||||
* PROJECT: ReactOS Kernel
|
||||
* LICENSE: GPL - See COPYING in the top level directory
|
||||
* FILE: ntoskrnl/ke/apc.c
|
||||
* PURPOSE: NT Implementation of APCs
|
||||
*
|
||||
* PROGRAMMERS: Alex Ionescu (alex@relsoft.net)
|
||||
* Phillip Susi
|
||||
* PURPOSE: Implements the Asyncronous Procedure Call mechanism
|
||||
* PROGRAMMERS: Alex Ionescu (alex.ionescu@reactos.org)
|
||||
*/
|
||||
|
||||
/* INCLUDES *****************************************************************/
|
||||
|
@ -17,27 +15,24 @@
|
|||
/* FUNCTIONS *****************************************************************/
|
||||
|
||||
/*++
|
||||
* KiCheckForKernelApcDelivery
|
||||
* @name KiCheckForKernelApcDelivery
|
||||
* @implemented NT 5.2
|
||||
*
|
||||
* The KiCheckForKernelApcDelivery routine is called whenever APCs have just
|
||||
* been re-enabled in Kernel Mode, such as after leaving a Critical or
|
||||
* Guarded Region. It delivers APCs if the environment is right.
|
||||
*
|
||||
* Params:
|
||||
* None.
|
||||
* @param None.
|
||||
*
|
||||
* Returns:
|
||||
* None.
|
||||
* @return None.
|
||||
*
|
||||
* Remarks:
|
||||
* This routine allows KeLeave/EnterCritical/GuardedRegion to be used as a
|
||||
* macro from inside WIN32K or other Drivers, which will then only have to
|
||||
* do an Import API call in the case where APCs are enabled again.
|
||||
* @remarks This routine allows KeLeave/EnterCritical/GuardedRegion to be used
|
||||
* as macro from inside WIN32K or other Drivers, which will then only
|
||||
* have do an Import API call in the case where APCs are enabled again.
|
||||
*
|
||||
*--*/
|
||||
VOID
|
||||
STDCALL
|
||||
NTAPI
|
||||
KiCheckForKernelApcDelivery(VOID)
|
||||
{
|
||||
/* We should only deliver at passive */
|
||||
|
@ -63,34 +58,31 @@ KiCheckForKernelApcDelivery(VOID)
|
|||
}
|
||||
|
||||
/*++
|
||||
* KeEnterCriticalRegion
|
||||
* @name KeEnterCriticalRegion
|
||||
* @implemented NT4
|
||||
*
|
||||
* The KeEnterCriticalRegion routine temporarily disables the delivery of
|
||||
* normal kernel APCs; special kernel-mode APCs are still delivered.
|
||||
*
|
||||
* Params:
|
||||
* None.
|
||||
* @param None.
|
||||
*
|
||||
* Returns:
|
||||
* None.
|
||||
* @return None.
|
||||
*
|
||||
* Remarks:
|
||||
* Highest-level drivers can call this routine while running in the context
|
||||
* of the thread that requested the current I/O operation. Any caller of
|
||||
* this routine should call KeLeaveCriticalRegion as quickly as possible.
|
||||
* @remarks Highest-level drivers can call this routine while running in the
|
||||
* context of the thread that requested the current I/O operation.
|
||||
* Any caller of this routine should call KeLeaveCriticalRegion as
|
||||
* quickly as possible.
|
||||
*
|
||||
* Callers of KeEnterCriticalRegion must be running at IRQL <= APC_LEVEL.
|
||||
* Callers of KeEnterCriticalRegion must be running at IRQL <=
|
||||
* APC_LEVEL.
|
||||
*
|
||||
*--*/
|
||||
#undef KeEnterCriticalRegion
|
||||
VOID
|
||||
STDCALL
|
||||
KeEnterCriticalRegion(VOID)
|
||||
NTAPI
|
||||
_KeEnterCriticalRegion(VOID)
|
||||
{
|
||||
/* Disable Kernel APCs */
|
||||
PKTHREAD Thread = KeGetCurrentThread();
|
||||
if (Thread) Thread->KernelApcDisable--;
|
||||
/* Use inlined function */
|
||||
KeEnterCriticalRegion();
|
||||
}
|
||||
|
||||
/*++
|
||||
|
@ -100,37 +92,23 @@ KeEnterCriticalRegion(VOID)
|
|||
* The KeLeaveCriticalRegion routine reenables the delivery of normal
|
||||
* kernel-mode APCs that were disabled by a call to KeEnterCriticalRegion.
|
||||
*
|
||||
* Params:
|
||||
* None.
|
||||
* @param None.
|
||||
*
|
||||
* Returns:
|
||||
* None.
|
||||
* @return None.
|
||||
*
|
||||
* Remarks:
|
||||
* Highest-level drivers can call this routine while running in the context
|
||||
* of the thread that requested the current I/O operation.
|
||||
* @remarks Highest-level drivers can call this routine while running in the
|
||||
* context of the thread that requested the current I/O operation.
|
||||
*
|
||||
* Callers of KeLeaveCriticalRegion must be running at IRQL <= DISPATCH_LEVEL.
|
||||
* Callers of KeLeaveCriticalRegion must be running at IRQL <=
|
||||
* DISPATCH_LEVEL.
|
||||
*
|
||||
*--*/
|
||||
#undef KeLeaveCriticalRegion
|
||||
VOID
|
||||
STDCALL
|
||||
KeLeaveCriticalRegion (VOID)
|
||||
NTAPI
|
||||
_KeLeaveCriticalRegion(VOID)
|
||||
{
|
||||
PKTHREAD Thread = KeGetCurrentThread();
|
||||
|
||||
/* Check if Kernel APCs are now enabled */
|
||||
if((Thread) && (++Thread->KernelApcDisable == 0))
|
||||
{
|
||||
/* Check if we need to request an APC Delivery */
|
||||
if ((!IsListEmpty(&Thread->ApcState.ApcListHead[KernelMode])) &&
|
||||
(Thread->SpecialApcDisable == 0))
|
||||
{
|
||||
/* Check for the right environment */
|
||||
KiCheckForKernelApcDelivery();
|
||||
}
|
||||
}
|
||||
/* Use inlined version */
|
||||
KeLeaveCriticalRegion();
|
||||
}
|
||||
|
||||
/*++
|
||||
|
|
|
@ -534,7 +534,7 @@ KeDeregisterBugCheckCallback@4
|
|||
KeDeregisterBugCheckReasonCallback@4
|
||||
KeDetachProcess@0
|
||||
KeDisconnectInterrupt@4
|
||||
KeEnterCriticalRegion@0
|
||||
KeEnterCriticalRegion@=_KeEnterCriticalRegion@0
|
||||
KeEnterGuardedRegion@0
|
||||
KeEnterKernelDebugger@0
|
||||
KeFindConfigurationEntry@16
|
||||
|
@ -576,7 +576,7 @@ KeInsertQueueApc@16
|
|||
KeInsertQueueDpc@12
|
||||
KeIsAttachedProcess@0
|
||||
KeIsExecutingDpc@0
|
||||
KeLeaveCriticalRegion@0
|
||||
KeLeaveCriticalRegion@0=_KeLeaveCriticalRegion@0
|
||||
KeLeaveGuardedRegion@0
|
||||
KeLoaderBlock DATA
|
||||
KeNumberProcessors DATA
|
||||
|
|
|
@ -583,7 +583,7 @@ PspCreateProcess(OUT PHANDLE ProcessHandle,
|
|||
PROCESS_PRIORITY_NORMAL,
|
||||
Affinity,
|
||||
&DirectoryTableBase,
|
||||
Process->DefaultHardErrorProcessing & 4);
|
||||
(BOOLEAN)(Process->DefaultHardErrorProcessing & 4));
|
||||
|
||||
/* Duplicate Parent Token */
|
||||
Status = PspInitializeProcessSecurity(Process, Parent);
|
||||
|
|
Loading…
Reference in a new issue