[ros-diffs] [sginsberg] 37126: - Disable old and unused IPI code, add new NT compatible stubs - KiIpiSendRequest should be a fastcall named KiIpiSend, fix this and fix callers - Implement most of SMP KeIpiGenericCall. Also use KiReverseStallIpiLock instead of an uninitialized "KiIpiLock" - Fix KiIpiServiceRoutine -- 2nd argument should be PKEXCEPTION_FRAME

sginsberg at svn.reactos.org sginsberg at svn.reactos.org
Sat Nov 1 12:44:05 CET 2008


Author: sginsberg
Date: Sat Nov  1 06:44:04 2008
New Revision: 37126

URL: http://svn.reactos.org/svn/reactos?rev=37126&view=rev
Log:
- Disable old and unused IPI code, add new NT compatible stubs
- KiIpiSendRequest should be a fastcall named KiIpiSend, fix this and fix callers
- Implement most of SMP KeIpiGenericCall. Also use KiReverseStallIpiLock instead of an uninitialized "KiIpiLock"
- Fix KiIpiServiceRoutine -- 2nd argument should be PKEXCEPTION_FRAME

Modified:
    trunk/reactos/include/ndk/kefuncs.h
    trunk/reactos/ntoskrnl/ex/shutdown.c
    trunk/reactos/ntoskrnl/include/internal/ke.h
    trunk/reactos/ntoskrnl/include/internal/ke_x.h
    trunk/reactos/ntoskrnl/ke/bug.c
    trunk/reactos/ntoskrnl/ke/dpc.c
    trunk/reactos/ntoskrnl/ke/ipi.c
    trunk/reactos/ntoskrnl/ke/thrdschd.c

Modified: trunk/reactos/include/ndk/kefuncs.h
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/include/ndk/kefuncs.h?rev=37126&r1=37125&r2=37126&view=diff
==============================================================================
--- trunk/reactos/include/ndk/kefuncs.h [iso-8859-1] (original)
+++ trunk/reactos/include/ndk/kefuncs.h [iso-8859-1] Sat Nov  1 06:44:04 2008
@@ -205,7 +205,7 @@
 NTAPI
 KiIpiServiceRoutine(
     IN PKTRAP_FRAME TrapFrame,
-    IN PVOID ExceptionFrame
+    IN PKEXCEPTION_FRAME ExceptionFrame
 );
 
 //

Modified: trunk/reactos/ntoskrnl/ex/shutdown.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ex/shutdown.c?rev=37126&r1=37125&r2=37126&view=diff
==============================================================================
--- trunk/reactos/ntoskrnl/ex/shutdown.c [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/ex/shutdown.c [iso-8859-1] Sat Nov  1 06:44:04 2008
@@ -190,7 +190,7 @@
 		KeInitializeDpc(Dpc, KiHaltProcessorDpcRoutine, (PVOID)Dpc);
 		KeSetTargetProcessorDpc(Dpc, i);
 		KeInsertQueueDpc(Dpc, NULL, NULL);
-		KiIpiSendRequest(1 << i, IPI_DPC);
+		KiIpiSend(1 << i, IPI_DPC);
 	      }
 	  }
         KeLowerIrql(OldIrql);

Modified: trunk/reactos/ntoskrnl/include/internal/ke.h
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/include/internal/ke.h?rev=37126&r1=37125&r2=37126&view=diff
==============================================================================
--- trunk/reactos/ntoskrnl/include/internal/ke.h [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/include/internal/ke.h [iso-8859-1] Sat Nov  1 06:44:04 2008
@@ -327,10 +327,33 @@
 /* ipi.c ********************************************************************/
 
 VOID
-NTAPI
-KiIpiSendRequest(
+FASTCALL
+KiIpiSend(
     KAFFINITY TargetSet,
     ULONG IpiRequest
+);
+
+VOID
+NTAPI
+KiIpiSendPacket(
+    IN KAFFINITY TargetProcessors,
+    IN PKIPI_WORKER WorkerFunction,
+    IN PKIPI_BROADCAST_WORKER BroadcastFunction,
+    IN ULONG_PTR Context,
+    IN PULONG Count
+);
+
+VOID
+FASTCALL
+KiIpiSignalPacketDone(
+    IN PKIPI_CONTEXT PacketContext
+);
+
+VOID
+FASTCALL
+KiIpiSignalPacketDoneAndStall(
+    IN PKIPI_CONTEXT PacketContext,
+    IN volatile PULONG ReverseStall
 );
 
 /* next file ***************************************************************/

Modified: trunk/reactos/ntoskrnl/include/internal/ke_x.h
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/include/internal/ke_x.h?rev=37126&r1=37125&r2=37126&view=diff
==============================================================================
--- trunk/reactos/ntoskrnl/include/internal/ke_x.h [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/include/internal/ke_x.h [iso-8859-1] Sat Nov  1 06:44:04 2008
@@ -594,7 +594,7 @@
     if ((NewThread) && !(KeGetPcr()->Number == Cpu))
     {
         /* Send an IPI to request delivery */
-        KiIpiSendRequest(AFFINITY_MASK(Cpu), IPI_DPC);
+        KiIpiSend(AFFINITY_MASK(Cpu), IPI_DPC);
     }
 }
 
@@ -751,7 +751,7 @@
         if (KeGetPcr()->Number != Processor)
         {
             /* Send an IPI to request delivery */
-            KiIpiSendRequest(AFFINITY_MASK(Processor), IPI_APC);
+            KiIpiSend(AFFINITY_MASK(Processor), IPI_APC);
         }
         else
         {

Modified: trunk/reactos/ntoskrnl/ke/bug.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ke/bug.c?rev=37126&r1=37125&r2=37126&view=diff
==============================================================================
--- trunk/reactos/ntoskrnl/ke/bug.c [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/ke/bug.c [iso-8859-1] Sat Nov  1 06:44:04 2008
@@ -1130,7 +1130,7 @@
             if (i != (LONG)KeGetCurrentProcessorNumber())
             {
                 /* Send the IPI and give them one second to catch up */
-                KiIpiSendRequest(1 << i, IPI_FREEZE);
+                KiIpiSend(1 << i, IPI_FREEZE);
                 KeStallExecutionProcessor(1000000);
             }
         }

Modified: trunk/reactos/ntoskrnl/ke/dpc.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ke/dpc.c?rev=37126&r1=37125&r2=37126&view=diff
==============================================================================
--- trunk/reactos/ntoskrnl/ke/dpc.c [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/ke/dpc.c [iso-8859-1] Sat Nov  1 06:44:04 2008
@@ -683,7 +683,7 @@
         if (Prcb != CurrentPrcb)
         {
             /* It was, request and IPI */
-            KiIpiSendRequest(AFFINITY_MASK(Cpu), IPI_DPC);
+            KiIpiSend(AFFINITY_MASK(Cpu), IPI_DPC);
         }
         else
         {

Modified: trunk/reactos/ntoskrnl/ke/ipi.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ke/ipi.c?rev=37126&r1=37125&r2=37126&view=diff
==============================================================================
--- trunk/reactos/ntoskrnl/ke/ipi.c [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/ke/ipi.c [iso-8859-1] Sat Nov  1 06:44:04 2008
@@ -14,10 +14,60 @@
 
 /* GLOBALS *******************************************************************/
 
-KSPIN_LOCK KiIpiLock;
+extern KSPIN_LOCK KiReverseStallIpiLock;
 
 /* PRIVATE FUNCTIONS *********************************************************/
 
+VOID
+NTAPI
+KiIpiGenericCallTarget(IN PKIPI_CONTEXT PacketContext,
+                       IN PVOID BroadcastFunction,
+                       IN PVOID Argument,
+                       IN PVOID Count)
+{
+    /* FIXME: TODO */
+    ASSERTMSG("Not yet implemented\n", FALSE);
+}
+
+VOID
+FASTCALL
+KiIpiSend(IN KAFFINITY TargetProcessors,
+          IN ULONG IpiRequest)
+{
+    /* FIXME: TODO */
+    ASSERTMSG("Not yet implemented\n", FALSE);
+}
+
+VOID
+NTAPI
+KiIpiSendPacket(IN KAFFINITY TargetProcessors,
+                IN PKIPI_WORKER WorkerFunction,
+                IN PKIPI_BROADCAST_WORKER BroadcastFunction,
+                IN ULONG_PTR Context,
+                IN PULONG Count)
+{
+    /* FIXME: TODO */
+    ASSERTMSG("Not yet implemented\n", FALSE);
+}
+
+VOID
+FASTCALL
+KiIpiSignalPacketDone(IN PKIPI_CONTEXT PacketContext)
+{
+    /* FIXME: TODO */
+    ASSERTMSG("Not yet implemented\n", FALSE);
+}
+
+VOID
+FASTCALL
+KiIpiSignalPacketDoneAndStall(IN PKIPI_CONTEXT PacketContext,
+                              IN volatile PULONG ReverseStall)
+{
+    /* FIXME: TODO */
+    ASSERTMSG("Not yet implemented\n", FALSE);
+}
+
+#if 0
 VOID
 NTAPI
 KiIpiSendRequest(IN KAFFINITY TargetSet,
@@ -86,6 +136,7 @@
     }
 #endif
 }
+#endif
 
 /* PUBLIC FUNCTIONS **********************************************************/
 
@@ -95,7 +146,7 @@
 BOOLEAN
 NTAPI
 KiIpiServiceRoutine(IN PKTRAP_FRAME TrapFrame,
-                    IN PVOID ExceptionFrame)
+                    IN PKEXCEPTION_FRAME ExceptionFrame)
 {
 #ifdef CONFIG_SMP
     PKPRCB Prcb;
@@ -141,32 +192,73 @@
 KeIpiGenericCall(IN PKIPI_BROADCAST_WORKER Function,
                  IN ULONG_PTR Argument)
 {
-#ifdef CONFIG_SMP
-#error Not yet implemented!
-#else
     ULONG_PTR Status;
     KIRQL OldIrql, OldIrql2;
+#ifdef CONFIG_SMP
+    KAFFINITY Affinity;
+    ULONG Count;
+    PKPRCB Prcb = KeGetCurrentPrcb();
+#endif
 
     /* Raise to DPC level if required */
     OldIrql = KeGetCurrentIrql();
     if (OldIrql < DISPATCH_LEVEL) KeRaiseIrql(DISPATCH_LEVEL, &OldIrql);
 
+#ifdef CONFIG_SMP
+    /* Get current processor count and affinity */
+    Count = KeNumberProcessors;
+    Affinity = KeActiveProcessors;
+
+    /* Exclude ourselves */
+    Affinity &= ~KeGetCurrentPrcb()->SetMember;
+#endif
+
     /* Acquire the IPI lock */
-    KefAcquireSpinLockAtDpcLevel(&KiIpiLock);
+    KeAcquireSpinLockAtDpcLevel(&KiReverseStallIpiLock);
+
+#ifdef CONFIG_SMP
+    /* Make sure this is MP */
+    if (Affinity)
+    {
+        /* Send an IPI */
+        KiIpiSendPacket(Affinity,
+                        KiIpiGenericCallTarget,
+                        Function,
+                        Argument,
+                        &Count);
+
+        /* Spin until the other processors are ready */
+        while ((volatile ULONG)Count != 1) YieldProcessor();
+    }
+#endif
 
     /* Raise to IPI level */
     KeRaiseIrql(IPI_LEVEL, &OldIrql2);
 
+#ifdef CONFIG_SMP
+    /* Let the other processors know it is time */
+    Count = 0;
+#endif
+
     /* Call the function */
     Status = Function(Argument);
 
+#ifdef CONFIG_SMP
+    /* If this is MP, wait for the other processors to finish */
+    if (Affinity)
+    {
+        /* Sanity check */
+        ASSERT(Prcb == (volatile PKPRCB)KeGetCurrentPrcb());
+
+        /* FIXME: TODO */
+        ASSERTMSG("Not yet implemented\n", FALSE);
+    }
+#endif
+
     /* Release the lock */
-    KefReleaseSpinLockFromDpcLevel(&KiIpiLock);
+    KeReleaseSpinLockFromDpcLevel(&KiReverseStallIpiLock);
 
     /* Lower IRQL back */
     KeLowerIrql(OldIrql);
     return Status;
-#endif
-}
-
-/* EOF */
+}

Modified: trunk/reactos/ntoskrnl/ke/thrdschd.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ke/thrdschd.c?rev=37126&r1=37125&r2=37126&view=diff
==============================================================================
--- trunk/reactos/ntoskrnl/ke/thrdschd.c [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/ke/thrdschd.c [iso-8859-1] Sat Nov  1 06:44:04 2008
@@ -253,7 +253,7 @@
             if (KeGetCurrentProcessorNumber() != Thread->NextProcessor)
             {
                 /* We are, send an IPI */
-                KiIpiSendRequest(AFFINITY_MASK(Thread->NextProcessor), IPI_DPC);
+                KiIpiSend(AFFINITY_MASK(Thread->NextProcessor), IPI_DPC);
             }
             return;
         }
@@ -612,7 +612,7 @@
                         if (KeGetCurrentProcessorNumber() != Processor)
                         {
                             /* We are, send an IPI */
-                            KiIpiSendRequest(AFFINITY_MASK(Processor), IPI_DPC);
+                            KiIpiSend(AFFINITY_MASK(Processor), IPI_DPC);
                         }
                     }
                 }



More information about the Ros-diffs mailing list