diff --git a/reactos/ntoskrnl/ke/i386/ctxswitch.S b/reactos/ntoskrnl/ke/i386/ctxswitch.S index 45abea5e421..7d3447ebfeb 100644 --- a/reactos/ntoskrnl/ke/i386/ctxswitch.S +++ b/reactos/ntoskrnl/ke/i386/ctxswitch.S @@ -13,6 +13,7 @@ #include .intel_syntax noprefix +#define Ready 1 #define Running 2 #define WrDispatchInt 0x1F @@ -346,7 +347,7 @@ BadThread: #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 @@ NewCr0: 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 @@ CheckSchedule: #ifdef CONFIG_SMP /* There is, raise IRQL to synch level */ - mov ecx, SYNCH_LEVEL - call @KfRaiseIrql@4 + call _KeRaiseIrqlToSynchLevel@0 #endif sti @@ -707,7 +717,7 @@ CheckSchedule: 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@4 @@ -731,7 +741,7 @@ CheckNext: #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 @@ NoNextThread: jz CpuIdle /* It is, so call the scheduler */ - lea ecx, [ebx+KPCR_PRCBDATA] + lea ecx, [ebx+KPCR_PRCB_DATA] call @KiIdleSchedule@4 test eax, eax diff --git a/reactos/ntoskrnl/ke/i386/trap.s b/reactos/ntoskrnl/ke/i386/trap.s index 2f3aec94e87..d438650c2f3 100644 --- a/reactos/ntoskrnl/ke/i386/trap.s +++ b/reactos/ntoskrnl/ke/i386/trap.s @@ -2455,9 +2455,20 @@ CheckQuantum: mov edi, [ebx+KPCR_CURRENT_THREAD] #ifdef CONFIG_SMP - #error SMP Interrupt not handled! + /* Raise to synch level */ + call _KeRaiseIrqlToSynchLevel@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@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 @@ -2476,6 +2487,12 @@ CheckQuantum: mov cl, APC_LEVEL call @KiSwapContextInternal@0 +#ifdef CONFIG_SMP + /* Lower IRQL back to dispatch */ + mov cl, DISPATCH_LEVEL + call @KfLowerIrql@4 +#endif + /* Restore registers */ mov ebp, [esp+0] mov edi, [esp+4] @@ -2617,7 +2634,7 @@ SpuriousInt: #ifdef CONFIG_SMP IntSpin: - SPIN_ON_LOCK esi, GetIntLock + SPIN_ON_LOCK(esi, GetIntLock) #endif IsrTimeout: