- Use inlined guarded region routines instead of duplicating code.

- Add @implemented tags.

svn path=/trunk/; revision=24088
This commit is contained in:
Alex Ionescu 2006-09-13 00:35:56 +00:00
parent d99f96a295
commit a614833b08
3 changed files with 58 additions and 65 deletions

View file

@ -9,43 +9,43 @@
//
// Enters a Guarded Region
//
#define KeEnterGuardedRegion() \
{ \
PKTHREAD Thread = KeGetCurrentThread(); \
\
/* Sanity checks */ \
ASSERT_IRQL_LESS_OR_EQUAL(APC_LEVEL); \
ASSERT(Thread == KeGetCurrentThread()); \
ASSERT((Thread->SpecialApcDisable <= 0) && \
(Thread->SpecialApcDisable != -32768)); \
\
/* Disable Special APCs */ \
Thread->SpecialApcDisable--; \
#define KeEnterGuardedRegion() \
{ \
PKTHREAD Thread = KeGetCurrentThread(); \
\
/* Sanity checks */ \
ASSERT_IRQL_LESS_OR_EQUAL(APC_LEVEL); \
ASSERT(Thread == KeGetCurrentThread()); \
ASSERT((Thread->SpecialApcDisable <= 0) && \
(Thread->SpecialApcDisable != -32768)); \
\
/* Disable Special APCs */ \
Thread->SpecialApcDisable--; \
}
//
// Leaves a Guarded Region
//
#define KeLeaveGuardedRegion() \
{ \
PKTHREAD Thread = KeGetCurrentThread(); \
\
/* Sanity checks */ \
ASSERT_IRQL_LESS_OR_EQUAL(APC_LEVEL); \
ASSERT(Thread == KeGetCurrentThread()); \
ASSERT(Thread->SpecialApcDisable < 0); \
\
/* Leave region and check if APCs are OK now */ \
if (!(++Thread->SpecialApcDisable)) \
{ \
/* Check for Kernel APCs on the list */ \
if (!IsListEmpty(&Thread->ApcState. \
ApcListHead[KernelMode])) \
{ \
/* Check for APC Delivery */ \
KiCheckForKernelApcDelivery(); \
} \
} \
#define KeLeaveGuardedRegion() \
{ \
PKTHREAD Thread = KeGetCurrentThread(); \
\
/* Sanity checks */ \
ASSERT_IRQL_LESS_OR_EQUAL(APC_LEVEL); \
ASSERT(Thread == KeGetCurrentThread()); \
ASSERT(Thread->SpecialApcDisable < 0); \
\
/* Leave region and check if APCs are OK now */ \
if (!(++Thread->SpecialApcDisable)) \
{ \
/* Check for Kernel APCs on the list */ \
if (!IsListEmpty(&Thread->ApcState. \
ApcListHead[KernelMode])) \
{ \
/* Check for APC Delivery */ \
KiCheckForKernelApcDelivery(); \
} \
} \
}
//

View file

@ -131,6 +131,9 @@ KiReleaseGuardedMutex(IN OUT PKGUARDED_MUTEX GuardedMutex)
/* PUBLIC FUNCTIONS **********************************************************/
/*
* @implemented
*/
VOID
FASTCALL
KeInitializeGuardedMutex(OUT PKGUARDED_MUTEX GuardedMutex)
@ -144,6 +147,9 @@ KeInitializeGuardedMutex(OUT PKGUARDED_MUTEX GuardedMutex)
KeInitializeGate(&GuardedMutex->Gate);
}
/*
* @implemented
*/
VOID
FASTCALL
KeAcquireGuardedMutexUnsafe(IN OUT PKGUARDED_MUTEX GuardedMutex)
@ -164,6 +170,9 @@ KeAcquireGuardedMutexUnsafe(IN OUT PKGUARDED_MUTEX GuardedMutex)
GuardedMutex->Owner = Thread;
}
/*
* @implemented
*/
VOID
FASTCALL
KeReleaseGuardedMutexUnsafe(IN OUT PKGUARDED_MUTEX GuardedMutex)
@ -179,6 +188,9 @@ KeReleaseGuardedMutexUnsafe(IN OUT PKGUARDED_MUTEX GuardedMutex)
KiReleaseGuardedMutex(GuardedMutex);
}
/*
* @implemented
*/
VOID
FASTCALL
KeAcquireGuardedMutex(IN PKGUARDED_MUTEX GuardedMutex)
@ -200,6 +212,9 @@ KeAcquireGuardedMutex(IN PKGUARDED_MUTEX GuardedMutex)
GuardedMutex->SpecialApcDisable = Thread->SpecialApcDisable;
}
/*
* @implemented
*/
VOID
FASTCALL
KeReleaseGuardedMutex(IN OUT PKGUARDED_MUTEX GuardedMutex)
@ -217,6 +232,9 @@ KeReleaseGuardedMutex(IN OUT PKGUARDED_MUTEX GuardedMutex)
KeLeaveGuardedRegion();
}
/*
* @implemented
*/
BOOLEAN
FASTCALL
KeTryToAcquireGuardedMutex(IN OUT PKGUARDED_MUTEX GuardedMutex)
@ -251,21 +269,12 @@ KeTryToAcquireGuardedMutex(IN OUT PKGUARDED_MUTEX GuardedMutex)
* Enters a guarded region. This causes all (incl. special kernel) APCs
* to be disabled.
*/
#undef KeEnterGuardedRegion
VOID
NTAPI
KeEnterGuardedRegion(VOID)
_KeEnterGuardedRegion(VOID)
{
PKTHREAD Thread = KeGetCurrentThread();
/* Sanity checks */
ASSERT_IRQL_LESS_OR_EQUAL(APC_LEVEL);
ASSERT(Thread == KeGetCurrentThread());
ASSERT((Thread->SpecialApcDisable <= 0) &&
(Thread->SpecialApcDisable != -32768));
/* Disable Special APCs */
Thread->SpecialApcDisable--;
/* Use the inlined version */
KeEnterGuardedRegion();
}
/**
@ -273,28 +282,12 @@ KeEnterGuardedRegion(VOID)
*
* Leaves a guarded region and delivers pending APCs if possible.
*/
#undef KeLeaveGuardedRegion
VOID
NTAPI
KeLeaveGuardedRegion(VOID)
_KeLeaveGuardedRegion(VOID)
{
PKTHREAD Thread = KeGetCurrentThread();
/* Sanity checks */
ASSERT_IRQL_LESS_OR_EQUAL(APC_LEVEL);
ASSERT(Thread == KeGetCurrentThread());
ASSERT(Thread->SpecialApcDisable < 0);
/* Boost the enable count and check if Special APCs are enabled */
if (!(++Thread->SpecialApcDisable))
{
/* Check if there are Kernel APCs on the list */
if (!IsListEmpty(&Thread->ApcState.ApcListHead[KernelMode]))
{
/* Check for APC Delivery */
KiCheckForKernelApcDelivery();
}
}
/* Use the inlined version */
KeLeaveGuardedRegion();
}
/* EOF */

View file

@ -535,7 +535,7 @@ KeDeregisterBugCheckReasonCallback@4
KeDetachProcess@0
KeDisconnectInterrupt@4
KeEnterCriticalRegion@0=_KeEnterCriticalRegion@0
KeEnterGuardedRegion@0
KeEnterGuardedRegion@0=_KeEnterGuardedRegion@0
KeEnterKernelDebugger@0
KeFindConfigurationEntry@16
KeFindConfigurationNextEntry@20
@ -577,7 +577,7 @@ KeInsertQueueDpc@12
KeIsAttachedProcess@0
KeIsExecutingDpc@0
KeLeaveCriticalRegion@0=_KeLeaveCriticalRegion@0
KeLeaveGuardedRegion@0
KeLeaveGuardedRegion@0=_KeLeaveGuardedRegion@0
KeLoaderBlock DATA
KeNumberProcessors DATA
KeProfileInterrupt@4