[ros-diffs] [sginsberg] 36876: - Fix various compilation errors in SMP assembly (typos, missing jump labels and specifiers) - Implement the SMP case in KiDispatchInterrupt -- on SMP we must raise IRQL to SYNCH_LEVEL, set the thread context swap busy flag and acquire the PRCB lock before calling KiQueueReadyThread and KiSwapContextInternal

sginsberg at svn.reactos.org sginsberg at svn.reactos.org
Tue Oct 21 20:34:06 CEST 2008


Author: sginsberg
Date: Tue Oct 21 13:34:06 2008
New Revision: 36876

URL: http://svn.reactos.org/svn/reactos?rev=36876&view=rev
Log:
- Fix various compilation errors in SMP assembly (typos, missing jump labels and specifiers)
- Implement the SMP case in KiDispatchInterrupt -- on SMP we must raise IRQL to SYNCH_LEVEL, set the thread context swap busy flag and acquire the PRCB lock before calling KiQueueReadyThread and KiSwapContextInternal

Modified:
    trunk/reactos/ntoskrnl/ke/i386/ctxswitch.S
    trunk/reactos/ntoskrnl/ke/i386/trap.s

Modified: trunk/reactos/ntoskrnl/ke/i386/ctxswitch.S
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ke/i386/ctxswitch.S?rev=36876&r1=36875&r2=36876&view=diff
==============================================================================
--- trunk/reactos/ntoskrnl/ke/i386/ctxswitch.S [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/ke/i386/ctxswitch.S [iso-8859-1] Tue Oct 21 13:34:06 2008
@@ -13,6 +13,7 @@
 #include <ndk/asm.h>
 .intel_syntax noprefix
 
+#define Ready 1
 #define Running 2
 #define WrDispatchInt 0x1F
 
@@ -346,7 +347,7 @@
 #ifdef CONFIG_SMP
 GetSwapLock:
     /* Acquire the swap lock */
-    cmp [esi+KTHREAD_SWAP_BUSY], 0
+    cmp byte ptr [esi+KTHREAD_SWAP_BUSY], 0
     jz NotBusy
     pause
     jmp GetSwapLock
@@ -559,6 +560,16 @@
     mov cr0, ecx
     jmp StackOk
 
+#ifdef CONFIG_SMP
+NpxLoaded:
+
+    /* FIXME: TODO */
+    int 3
+
+    /* Jump back */
+    jmp SetStack
+#endif
+
 WmiTrace:
 
     /* No WMI support yet */
@@ -696,8 +707,7 @@
 
 #ifdef CONFIG_SMP
     /* There is, raise IRQL to synch level */
-    mov ecx, SYNCH_LEVEL
-    call @KfRaiseIrql at 4
+    call _KeRaiseIrqlToSynchLevel at 0
 #endif
     sti
 
@@ -707,7 +717,7 @@
     mov byte ptr [edi+KTHREAD_SWAP_BUSY], 1
 
     /* Acquire the PRCB Lock */
-    lock bts [ebx+KPCR_PRCB_PRCB_LOCK], 0
+    lock bts dword ptr [ebx+KPCR_PRCB_PRCB_LOCK], 0
     jnb CheckNext
     lea ecx, [ebx+KPCR_PRCB_PRCB_LOCK]
     call @KefAcquireSpinLockAtDpcLevel at 4
@@ -731,7 +741,7 @@
 #ifdef CONFIG_SMP
     /* Disable the idle scheduler and release the PRCB lock */
     and byte ptr [ebx+KPCR_PRCB_IDLE_SCHEDULE], 0
-    and [ebx+KPCR_PRCB_PRCB_LOCK], 0
+    and dword ptr [ebx+KPCR_PRCB_PRCB_LOCK], 0
 #endif
 
 SwapContext:
@@ -764,7 +774,7 @@
     jz CpuIdle
 
     /* It is, so call the scheduler */
-    lea ecx, [ebx+KPCR_PRCBDATA]
+    lea ecx, [ebx+KPCR_PRCB_DATA]
     call @KiIdleSchedule at 4
     test eax, eax
 

Modified: trunk/reactos/ntoskrnl/ke/i386/trap.s
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ke/i386/trap.s?rev=36876&r1=36875&r2=36876&view=diff
==============================================================================
--- trunk/reactos/ntoskrnl/ke/i386/trap.s [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/ke/i386/trap.s [iso-8859-1] Tue Oct 21 13:34:06 2008
@@ -2455,9 +2455,20 @@
     mov edi, [ebx+KPCR_CURRENT_THREAD]
 
 #ifdef CONFIG_SMP
-    #error SMP Interrupt not handled!
+    /* Raise to synch level */
+    call _KeRaiseIrqlToSynchLevel at 0
+
+    /* Set context swap busy */
+    mov byte ptr [edi+KTHREAD_SWAP_BUSY], 1
+
+    /* Acquire the PRCB Lock */
+    lock bts dword ptr [ebx+KPCR_PRCB_PRCB_LOCK], 0
+    jnb GetNext
+    lea ecx, [ebx+KPCR_PRCB_PRCB_LOCK]
+    call @KefAcquireSpinLockAtDpcLevel at 4
 #endif
 
+GetNext:
     /* Get the next thread and clear it */
     mov esi, [ebx+KPCR_PRCB_NEXT_THREAD]
     and dword ptr [ebx+KPCR_PRCB_NEXT_THREAD], 0
@@ -2475,6 +2486,12 @@
     /* Set APC_LEVEL and do the swap */
     mov cl, APC_LEVEL
     call @KiSwapContextInternal at 0
+
+#ifdef CONFIG_SMP
+    /* Lower IRQL back to dispatch */
+    mov cl, DISPATCH_LEVEL
+    call @KfLowerIrql at 4
+#endif
 
     /* Restore registers */
     mov ebp, [esp+0]
@@ -2617,7 +2634,7 @@
 
 #ifdef CONFIG_SMP
 IntSpin:
-    SPIN_ON_LOCK esi, GetIntLock
+    SPIN_ON_LOCK(esi, GetIntLock)
 #endif
 
 IsrTimeout:



More information about the Ros-diffs mailing list