[NTOSKRNL] ExfReleaseRundownProtectionCacheAware*() functions don't return anything
[reactos.git] / ntoskrnl / ex / rundown.c
index bdbca49..e413fa2 100644 (file)
@@ -376,8 +376,6 @@ ExfWaitForRundownProtectionRelease(IN PEX_RUNDOWN_REF RunRef)
     ASSERT(WaitBlock.Count == 0);
 }
 
-/* FIXME: STUBS **************************************************************/
-
 /*
  * @implemented NT5.2
  */
@@ -387,7 +385,7 @@ ExfAcquireRundownProtectionCacheAware(IN PEX_RUNDOWN_REF_CACHE_AWARE RunRefCache
 {
     PEX_RUNDOWN_REF RunRef;
 
-    RunRef = ExGetRunRefForCurrentProcessor(RunRefCacheAware);
+    RunRef = ExGetRunRefForGivenProcessor(RunRefCacheAware, KeGetCurrentProcessorNumber());
     return _ExAcquireRundownProtection(RunRef);
 }
 
@@ -401,7 +399,7 @@ ExfAcquireRundownProtectionCacheAwareEx(IN PEX_RUNDOWN_REF_CACHE_AWARE RunRefCac
 {
     PEX_RUNDOWN_REF RunRef;
 
-    RunRef = ExGetRunRefForCurrentProcessor(RunRefCacheAware);
+    RunRef = ExGetRunRefForGivenProcessor(RunRefCacheAware, KeGetCurrentProcessorNumber());
     return ExfAcquireRundownProtectionEx(RunRef, Count);
 }
 
@@ -414,8 +412,8 @@ ExfReleaseRundownProtectionCacheAware(IN PEX_RUNDOWN_REF_CACHE_AWARE RunRefCache
 {
     PEX_RUNDOWN_REF RunRef;
 
-    RunRef = ExGetRunRefForCurrentProcessor(RunRefCacheAware);
-    return _ExReleaseRundownProtection(RunRef);
+    RunRef = ExGetRunRefForGivenProcessor(RunRefCacheAware, KeGetCurrentProcessorNumber());
+    _ExReleaseRundownProtection(RunRef);
 }
 
 /*
@@ -428,8 +426,8 @@ ExfReleaseRundownProtectionCacheAwareEx(IN PEX_RUNDOWN_REF_CACHE_AWARE RunRefCac
 {
     PEX_RUNDOWN_REF RunRef;
 
-    RunRef = ExGetRunRefForCurrentProcessor(RunRefCacheAware);
-    return ExfReleaseRundownProtectionEx(RunRef, Count);
+    RunRef = ExGetRunRefForGivenProcessor(RunRefCacheAware, KeGetCurrentProcessorNumber());
+    ExfReleaseRundownProtectionEx(RunRef, Count);
 }
 
 /*
@@ -459,10 +457,7 @@ ExfWaitForRundownProtectionReleaseCacheAware(IN PEX_RUNDOWN_REF_CACHE_AWARE RunR
     for (Current = 0; Current < ProcCount; ++Current)
     {
         /* Get the runref for the proc */
-        RunRef = (PEX_RUNDOWN_REF)((ULONG_PTR)RunRefCacheAware->RunRefs +
-                                   RunRefCacheAware->RunRefSize *
-                                   (Current % RunRefCacheAware->Number));
-
+        RunRef = ExGetRunRefForGivenProcessor(RunRefCacheAware, Current);
         /* Loop for setting the wait block */
         do
         {
@@ -504,25 +499,59 @@ ExfWaitForRundownProtectionReleaseCacheAware(IN PEX_RUNDOWN_REF_CACHE_AWARE RunR
 }
 
 /*
- * @unimplemented NT5.2
+ * @implemented NT5.2
  */
 VOID
 FASTCALL
 ExfRundownCompletedCacheAware(IN PEX_RUNDOWN_REF_CACHE_AWARE RunRefCacheAware)
 {
-    DBG_UNREFERENCED_PARAMETER(RunRefCacheAware);
-    UNIMPLEMENTED;
+    PEX_RUNDOWN_REF RunRef;
+    ULONG ProcCount, Current;
+
+    ProcCount = RunRefCacheAware->Number;
+    /* No proc, nothing to do */
+    if (ProcCount == 0)
+    {
+        return;
+    }
+
+    /* We will mark all our runrefs active */
+    for (Current = 0; Current < ProcCount; ++Current)
+    {
+        /* Get the runref for the proc */
+        RunRef = ExGetRunRefForGivenProcessor(RunRefCacheAware, Current);
+        ASSERT((RunRef->Count & EX_RUNDOWN_ACTIVE) != 0);
+
+        ExpSetRundown(RunRef, EX_RUNDOWN_ACTIVE);
+    }
 }
 
 /*
- * @unimplemented NT5.2
+ * @implemented NT5.2
  */
 VOID
 FASTCALL
 ExfReInitializeRundownProtectionCacheAware(IN PEX_RUNDOWN_REF_CACHE_AWARE RunRefCacheAware)
 {
-    DBG_UNREFERENCED_PARAMETER(RunRefCacheAware);
-    UNIMPLEMENTED;
+    PEX_RUNDOWN_REF RunRef;
+    ULONG ProcCount, Current;
+
+    ProcCount = RunRefCacheAware->Number;
+    /* No proc, nothing to do */
+    if (ProcCount == 0)
+    {
+        return;
+    }
+
+    /* We will mark all our runrefs inactive */
+    for (Current = 0; Current < ProcCount; ++Current)
+    {
+        /* Get the runref for the proc */
+        RunRef = ExGetRunRefForGivenProcessor(RunRefCacheAware, Current);
+        ASSERT((RunRef->Count & EX_RUNDOWN_ACTIVE) != 0);
+
+        ExpSetRundown(RunRef, 0);
+    }
 }
 
 /*
@@ -535,7 +564,7 @@ ExAllocateCacheAwareRundownProtection(IN POOL_TYPE PoolType,
 {
     PEX_RUNDOWN_REF RunRef;
     PVOID PoolToFree, RunRefs;
-    ULONG RunRefSize, Count, Offset, Align;
+    ULONG RunRefSize, Count, Align;
     PEX_RUNDOWN_REF_CACHE_AWARE RunRefCacheAware;
 
     PAGED_CODE();
@@ -601,8 +630,7 @@ ExAllocateCacheAwareRundownProtection(IN POOL_TYPE PoolType,
     {
         for (Count = 0; Count < RunRefCacheAware->Number; ++Count)
         {
-            Offset = RunRefCacheAware->RunRefSize * Count;
-            RunRef = (PEX_RUNDOWN_REF)((ULONG_PTR)RunRefCacheAware->RunRefs + Offset);
+            RunRef = ExGetRunRefForGivenProcessor(RunRefCacheAware, Count);
             _ExInitializeRundownProtection(RunRef);
         }
     }
@@ -641,7 +669,7 @@ ExInitializeRundownProtectionCacheAware(IN PEX_RUNDOWN_REF_CACHE_AWARE RunRefCac
 {
     PVOID Pool;
     PEX_RUNDOWN_REF RunRef;
-    ULONG Count, RunRefSize, Offset, Align;
+    ULONG Count, RunRefSize, Align;
 
     PAGED_CODE();
 
@@ -683,8 +711,7 @@ ExInitializeRundownProtectionCacheAware(IN PEX_RUNDOWN_REF_CACHE_AWARE RunRefCac
     {
         for (Count = 0; Count < RunRefCacheAware->Number; ++Count)
         {
-            Offset = RunRefCacheAware->RunRefSize * Count;
-            RunRef = (PEX_RUNDOWN_REF)((ULONG_PTR)RunRefCacheAware->RunRefs + Offset);
+            RunRef = ExGetRunRefForGivenProcessor(RunRefCacheAware, Count);
             _ExInitializeRundownProtection(RunRef);
         }
     }