Author: fireball
Date: Thu Aug 9 12:35:11 2007
New Revision: 28259
URL:
http://svn.reactos.org/svn/reactos?rev=28259&view=rev
Log:
One of Alex's uncommitted patches while he was working on the Cm branch:
- Fix CmpCacheTable and CmpNameCacheTable definition.
- Fix GET_HASH_ENTRY definition.
- Add KCB Lock Acquire/Release macros by Index and Key.
Has no effect on current code, but fixes some bugs in the branch-based code
Modified:
trunk/reactos/ntoskrnl/config/cm.h
trunk/reactos/ntoskrnl/config/cm_x.h
trunk/reactos/ntoskrnl/config/cmkcbncb.c
Modified: trunk/reactos/ntoskrnl/config/cm.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/config/cm.h?rev=2…
==============================================================================
--- trunk/reactos/ntoskrnl/config/cm.h (original)
+++ trunk/reactos/ntoskrnl/config/cm.h Thu Aug 9 12:35:11 2007
@@ -1142,6 +1142,14 @@
BOOLEAN
NTAPI
+CmpAddSubKey(
+ IN PHHIVE Hive,
+ IN HCELL_INDEX Parent,
+ IN HCELL_INDEX Child
+);
+
+BOOLEAN
+NTAPI
CmpRemoveSubKey(
IN PHHIVE Hive,
IN HCELL_INDEX ParentKey,
@@ -1345,8 +1353,8 @@
extern LIST_ENTRY CmpHiveListHead;
extern POBJECT_TYPE CmpKeyObjectType;
extern ERESOURCE CmpRegistryLock;
-extern PCM_KEY_HASH_TABLE_ENTRY *CmpCacheTable;
-extern PCM_NAME_HASH_TABLE_ENTRY *CmpNameCacheTable;
+extern PCM_KEY_HASH_TABLE_ENTRY CmpCacheTable;
+extern PCM_NAME_HASH_TABLE_ENTRY CmpNameCacheTable;
extern KGUARDED_MUTEX CmpDelayedCloseTableLock;
extern CMHIVE CmControlHive;
extern WCHAR CmDefaultLanguageId[];
@@ -1371,6 +1379,7 @@
extern HANDLE CmpRegistryRootHandle;
extern BOOLEAN ExpInTextModeSetup;
extern BOOLEAN InitIsWinPEMode;
+extern ULONG CmpHashTableSize;
//
// Inlined functions
Modified: trunk/reactos/ntoskrnl/config/cm_x.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/config/cm_x.h?rev…
==============================================================================
--- trunk/reactos/ntoskrnl/config/cm_x.h (original)
+++ trunk/reactos/ntoskrnl/config/cm_x.h Thu Aug 9 12:35:11 2007
@@ -62,7 +62,7 @@
#define GET_HASH_INDEX(ConvKey) \
GET_HASH_KEY(ConvKey) % CmpHashTableSize
#define GET_HASH_ENTRY(Table, ConvKey) \
- (*Table[GET_HASH_INDEX(ConvKey)])
+ (Table[GET_HASH_INDEX(ConvKey)])
//
// Returns whether or not the cell is cached
@@ -115,6 +115,62 @@
}
//
+// Exclusively acquires a KCB by index
+//
+#define CmpAcquireKcbLockExclusiveByIndex(i) \
+{ \
+ ExAcquirePushLockExclusive(&CmpCacheTable[(i)].Lock); \
+ CmpCacheTable[(i)].Owner = KeGetCurrentThread(); \
+}
+
+//
+// Exclusively acquires a KCB by key
+//
+#define CmpAcquireKcbLockExclusiveByKey(k) \
+{ \
+ ExAcquirePushLockExclusive(&GET_HASH_ENTRY(CmpCacheTable, \
+ (k)).Lock); \
+ GET_HASH_ENTRY(CmpCacheTable, \
+ (k)).Owner = KeGetCurrentThread(); \
+}
+
+
+//
+// Shared acquires a KCB
+//
+#define CmpAcquireKcbLockShared(k) \
+{ \
+ ExAcquirePushLockShared(&GET_HASH_ENTRY(CmpCacheTable, \
+ (k)->ConvKey).Lock); \
+}
+
+//
+// Shared acquires a KCB by index
+//
+#define CmpAcquireKcbLockSharedByIndex(i) \
+{ \
+ ExAcquirePushLockShared(&CmpCacheTable[(i)].Lock); \
+}
+
+//
+// Tries to convert a KCB lock
+//
+FORCEINLINE
+BOOLEAN
+CmpTryToConvertKcbSharedToExclusive(IN PCM_KEY_CONTROL_BLOCK k)
+{
+ ASSERT(CmpIsKcbLockedExclusive(k) == FALSE);
+ if (ExConvertPushLockSharedToExclusive(
+ &GET_HASH_ENTRY(CmpCacheTable, k->ConvKey).Lock))
+ {
+ GET_HASH_ENTRY(CmpCacheTable,
+ k->ConvKey).Owner = KeGetCurrentThread();
+ return TRUE;
+ }
+ return FALSE;
+}
+
+//
// Releases an exlusively or shared acquired KCB
//
#define CmpReleaseKcbLock(k) \
@@ -125,6 +181,25 @@
}
//
+// Releases an exlusively or shared acquired KCB by index
+//
+#define CmpReleaseKcbLockByIndex(i) \
+{ \
+ CmpCacheTable[(i)].Owner = NULL; \
+ ExReleasePushLock(&CmpCacheTable[(i)].Lock); \
+}
+
+//
+// Releases an exlusively or shared acquired KCB by key
+//
+#define CmpReleaseKcbLockByKey(k) \
+{ \
+ GET_HASH_ENTRY(CmpCacheTable, (k)).Owner = NULL; \
+ ExReleasePushLock(&GET_HASH_ENTRY(CmpCacheTable, \
+ (k)).Lock); \
+}
+
+//
// Exclusively acquires an NCB
//
#define CmpAcquireNcbLockExclusive(n) \
Modified: trunk/reactos/ntoskrnl/config/cmkcbncb.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/config/cmkcbncb.c…
==============================================================================
--- trunk/reactos/ntoskrnl/config/cmkcbncb.c (original)
+++ trunk/reactos/ntoskrnl/config/cmkcbncb.c Thu Aug 9 12:35:11 2007
@@ -16,8 +16,8 @@
/* GLOBALS *******************************************************************/
ULONG CmpHashTableSize = 2048;
-PCM_KEY_HASH_TABLE_ENTRY *CmpCacheTable;
-PCM_NAME_HASH_TABLE_ENTRY *CmpNameCacheTable;
+PCM_KEY_HASH_TABLE_ENTRY CmpCacheTable;
+PCM_NAME_HASH_TABLE_ENTRY CmpNameCacheTable;
LIST_ENTRY CmpFreeKCBListHead;