- 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

svn path=/trunk/; revision=36876
This commit is contained in:
Stefan Ginsberg 2008-10-21 18:34:06 +00:00
parent a9f8e09aa6
commit 42d35acde0
2 changed files with 35 additions and 8 deletions

View file

@ -13,6 +13,7 @@
#include <ndk/asm.h>
.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

View file

@ -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: