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

View file

@ -131,6 +131,9 @@ KiReleaseGuardedMutex(IN OUT PKGUARDED_MUTEX GuardedMutex)
/* PUBLIC FUNCTIONS **********************************************************/ /* PUBLIC FUNCTIONS **********************************************************/
/*
* @implemented
*/
VOID VOID
FASTCALL FASTCALL
KeInitializeGuardedMutex(OUT PKGUARDED_MUTEX GuardedMutex) KeInitializeGuardedMutex(OUT PKGUARDED_MUTEX GuardedMutex)
@ -144,6 +147,9 @@ KeInitializeGuardedMutex(OUT PKGUARDED_MUTEX GuardedMutex)
KeInitializeGate(&GuardedMutex->Gate); KeInitializeGate(&GuardedMutex->Gate);
} }
/*
* @implemented
*/
VOID VOID
FASTCALL FASTCALL
KeAcquireGuardedMutexUnsafe(IN OUT PKGUARDED_MUTEX GuardedMutex) KeAcquireGuardedMutexUnsafe(IN OUT PKGUARDED_MUTEX GuardedMutex)
@ -164,6 +170,9 @@ KeAcquireGuardedMutexUnsafe(IN OUT PKGUARDED_MUTEX GuardedMutex)
GuardedMutex->Owner = Thread; GuardedMutex->Owner = Thread;
} }
/*
* @implemented
*/
VOID VOID
FASTCALL FASTCALL
KeReleaseGuardedMutexUnsafe(IN OUT PKGUARDED_MUTEX GuardedMutex) KeReleaseGuardedMutexUnsafe(IN OUT PKGUARDED_MUTEX GuardedMutex)
@ -179,6 +188,9 @@ KeReleaseGuardedMutexUnsafe(IN OUT PKGUARDED_MUTEX GuardedMutex)
KiReleaseGuardedMutex(GuardedMutex); KiReleaseGuardedMutex(GuardedMutex);
} }
/*
* @implemented
*/
VOID VOID
FASTCALL FASTCALL
KeAcquireGuardedMutex(IN PKGUARDED_MUTEX GuardedMutex) KeAcquireGuardedMutex(IN PKGUARDED_MUTEX GuardedMutex)
@ -200,6 +212,9 @@ KeAcquireGuardedMutex(IN PKGUARDED_MUTEX GuardedMutex)
GuardedMutex->SpecialApcDisable = Thread->SpecialApcDisable; GuardedMutex->SpecialApcDisable = Thread->SpecialApcDisable;
} }
/*
* @implemented
*/
VOID VOID
FASTCALL FASTCALL
KeReleaseGuardedMutex(IN OUT PKGUARDED_MUTEX GuardedMutex) KeReleaseGuardedMutex(IN OUT PKGUARDED_MUTEX GuardedMutex)
@ -217,6 +232,9 @@ KeReleaseGuardedMutex(IN OUT PKGUARDED_MUTEX GuardedMutex)
KeLeaveGuardedRegion(); KeLeaveGuardedRegion();
} }
/*
* @implemented
*/
BOOLEAN BOOLEAN
FASTCALL FASTCALL
KeTryToAcquireGuardedMutex(IN OUT PKGUARDED_MUTEX GuardedMutex) 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 * Enters a guarded region. This causes all (incl. special kernel) APCs
* to be disabled. * to be disabled.
*/ */
#undef KeEnterGuardedRegion
VOID VOID
NTAPI NTAPI
KeEnterGuardedRegion(VOID) _KeEnterGuardedRegion(VOID)
{ {
PKTHREAD Thread = KeGetCurrentThread(); /* Use the inlined version */
KeEnterGuardedRegion();
/* Sanity checks */
ASSERT_IRQL_LESS_OR_EQUAL(APC_LEVEL);
ASSERT(Thread == KeGetCurrentThread());
ASSERT((Thread->SpecialApcDisable <= 0) &&
(Thread->SpecialApcDisable != -32768));
/* Disable Special APCs */
Thread->SpecialApcDisable--;
} }
/** /**
@ -273,28 +282,12 @@ KeEnterGuardedRegion(VOID)
* *
* Leaves a guarded region and delivers pending APCs if possible. * Leaves a guarded region and delivers pending APCs if possible.
*/ */
#undef KeLeaveGuardedRegion
VOID VOID
NTAPI NTAPI
KeLeaveGuardedRegion(VOID) _KeLeaveGuardedRegion(VOID)
{ {
PKTHREAD Thread = KeGetCurrentThread(); /* Use the inlined version */
KeLeaveGuardedRegion();
/* 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();
}
}
} }
/* EOF */ /* EOF */

View file

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