[NTOSKRNL/CONFIG]
authorAleksey Bragin <aleksey@reactos.org>
Wed, 31 Mar 2010 13:25:51 +0000 (13:25 +0000)
committerAleksey Bragin <aleksey@reactos.org>
Wed, 31 Mar 2010 13:25:51 +0000 (13:25 +0000)
- Add more assert macros for registry operations: locked or loading, exclusively locked or loading, hash and KCB locks, locked for flushing.
- Add macros for getting alloc page from KCB and delay alloc item.

svn path=/trunk/; revision=46617

reactos/ntoskrnl/include/internal/cm_x.h

index 581a336..02e8421 100644 (file)
@@ -91,6 +91,14 @@ CmpIsKeyValueBig(IN PHHIVE Hive,
     ASSERT((CmpSpecialBootCondition == TRUE) ||                     \
            (CmpTestRegistryLock() == TRUE))
 
+//
+// Makes sure that the registry is locked or loading
+//
+#define CMP_ASSERT_REGISTRY_LOCK_OR_LOADING(h)                      \
+    ASSERT((CmpSpecialBootCondition == TRUE) ||                     \
+           (((PCMHIVE)h)->HiveIsLoading == TRUE) ||                 \
+           (CmpTestRegistryLock() == TRUE))
+
 //
 // Makes sure that the registry is exclusively locked
 //
@@ -98,6 +106,14 @@ CmpIsKeyValueBig(IN PHHIVE Hive,
     ASSERT((CmpSpecialBootCondition == TRUE) ||                     \
            (CmpTestRegistryLockExclusive() == TRUE))
 
+//
+// Makes sure that the registry is exclusively locked or loading
+//
+#define CMP_ASSERT_EXCLUSIVE_REGISTRY_LOCK_OR_LOADING(h)            \
+    ASSERT((CmpSpecialBootCondition == TRUE) ||                     \
+           (((PCMHIVE)h)->HiveIsLoading == TRUE) ||                 \
+           (CmpTestRegistryLockExclusive() == TRUE))
+
 //
 // Makes sure this is a valid KCB
 //
@@ -255,6 +271,47 @@ CmpConvertKcbSharedToExclusive(IN PCM_KEY_CONTROL_BLOCK k)
                                       (k)).Lock);                   \
 }
 
+//
+// Asserts that either the registry or the hash entry is locked
+//
+#define CMP_ASSERT_HASH_ENTRY_LOCK(k)                               \
+{                                                                   \
+    ASSERT(((GET_HASH_ENTRY(CmpCacheTable, k).Owner ==              \
+            KeGetCurrentThread())) ||                               \
+           (CmpTestRegistryLockExclusive() == TRUE));               \
+}
+
+//
+// Asserts that either the registry or the KCB is locked
+//
+#define CMP_ASSERT_KCB_LOCK(k)                                      \
+{                                                                   \
+    ASSERT((CmpIsKcbLockedExclusive(k) == TRUE) ||                  \
+           (CmpTestRegistryLockExclusive() == TRUE));               \
+}
+
+//
+// Gets the page attached to the KCB
+//
+#define CmpGetAllocPageFromKcb(k)                                   \
+    (PCM_ALLOC_PAGE)(((ULONG_PTR)(k)) & ~(PAGE_SIZE - 1))
+
+//
+// Gets the page attached to the delayed allocation
+//
+#define CmpGetAllocPageFromDelayAlloc(a)                            \
+    (PCM_ALLOC_PAGE)(((ULONG_PTR)(a)) & ~(PAGE_SIZE - 1))
+
+//
+// Makes sure that the registry is locked for flushes
+//
+#define CMP_ASSERT_FLUSH_LOCK(h)                                    \
+    ASSERT((CmpSpecialBootCondition == TRUE) ||                     \
+           (((PCMHIVE)h)->HiveIsLoading == TRUE) ||                 \
+           (CmpTestHiveFlusherLockShared((PCMHIVE)h) == TRUE) ||    \
+           (CmpTestHiveFlusherLockExclusive((PCMHIVE)h) == TRUE) || \
+           (CmpTestRegistryLockExclusive() == TRUE));
+
 //
 // Asserts that either the registry or the KCB is locked
 //