From 082af2ff8a16d254aead1556b7f1947c0c40307d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herv=C3=A9=20Poussineau?= Date: Tue, 6 Nov 2007 14:34:32 +0000 Subject: [PATCH] Fix some compilation errors in ntkrnlmp (code has not been tested, so it is probably wrong) svn path=/trunk/; revision=30223 --- reactos/ntoskrnl/ke/ipi.c | 28 +++++++++++++--------------- reactos/ntoskrnl/ke/spinlock.c | 28 +++++++++++++--------------- reactos/ntoskrnl/ke/thrdobj.c | 2 +- reactos/ntoskrnl/mm/i386/page.c | 19 ++++++++++--------- 4 files changed, 37 insertions(+), 40 deletions(-) diff --git a/reactos/ntoskrnl/ke/ipi.c b/reactos/ntoskrnl/ke/ipi.c index b1a88fcd298..9e2cd98ef93 100644 --- a/reactos/ntoskrnl/ke/ipi.c +++ b/reactos/ntoskrnl/ke/ipi.c @@ -24,17 +24,18 @@ KiIpiSendRequest(IN KAFFINITY TargetSet, IN ULONG IpiRequest) { #ifdef CONFIG_SMP -#error VerifyMe! LONG i; - PKPCR Pcr; + PKPRCB Prcb; KAFFINITY Current; for (i = 0, Current = 1; i < KeNumberProcessors; i++, Current <<= 1) { if (TargetSet & Current) { - Pcr = (PKPCR)(KPCR_BASE + i * PAGE_SIZE); - Ke386TestAndSetBit(IpiRequest, (PULONG)&Pcr->Prcb->IpiFrozen); + /* Get the PRCB for this CPU */ + Prcb = ((PKPCR)(KIP0PCRADDRESS + i * PAGE_SIZE))->Prcb; + + InterlockedBitTestAndSet((PLONG)&Prcb->IpiFrozen, IpiRequest); HalRequestIpi(i); } } @@ -50,13 +51,11 @@ KiIpiSendPacket(IN KAFFINITY TargetSet, IN BOOLEAN Synchronize) { #ifdef CONFIG_SMP -#error VerifyMe! KAFFINITY Processor; LONG i; PKPRCB Prcb, CurrentPrcb; KIRQL oldIrql; - ASSERT(KeGetCurrentIrql() == SYNCH_LEVEL); CurrentPrcb = KeGetCurrentPrcb(); @@ -70,9 +69,9 @@ KiIpiSendPacket(IN KAFFINITY TargetSet, { if (TargetSet & Processor) { - Prcb = ((PKPCR)(KPCR_BASE + i * PAGE_SIZE))->Prcb; - while(0 != InterlockedCompareExchangeUL(&Prcb->SignalDone, (LONG)CurrentPrcb, 0)); - Ke386TestAndSetBit(IPI_SYNCH_REQUEST, (PULONG)&Prcb->IpiFrozen); + Prcb = ((PKPCR)(KIP0PCRADDRESS + i * PAGE_SIZE))->Prcb; + while (0 != InterlockedCompareExchangeUL(&Prcb->SignalDone, (LONG)CurrentPrcb, 0)); + InterlockedBitTestAndSet((PLONG)&Prcb->IpiFrozen, IPI_SYNCH_REQUEST); if (Processor != CurrentPrcb->SetMember) { HalRequestIpi(i); @@ -99,32 +98,31 @@ KiIpiServiceRoutine(IN PKTRAP_FRAME TrapFrame, IN PVOID ExceptionFrame) { #ifdef CONFIG_SMP -#error VerifyMe! PKPRCB Prcb; ASSERT(KeGetCurrentIrql() == IPI_LEVEL); Prcb = KeGetCurrentPrcb(); - if (Ke386TestAndClearBit(IPI_APC, (PULONG)&Prcb->IpiFrozen)) + if (InterlockedBitTestAndReset((PLONG)&Prcb->IpiFrozen, IPI_APC)) { HalRequestSoftwareInterrupt(APC_LEVEL); } - if (Ke386TestAndClearBit(IPI_DPC, (PULONG)&Prcb->IpiFrozen)) + if (InterlockedBitTestAndReset((PLONG)&Prcb->IpiFrozen, IPI_DPC)) { Prcb->DpcInterruptRequested = TRUE; HalRequestSoftwareInterrupt(DISPATCH_LEVEL); } - if (Ke386TestAndClearBit(IPI_SYNCH_REQUEST, (PULONG)&Prcb->IpiFrozen)) + if (InterlockedBitTestAndReset((PLONG)&Prcb->IpiFrozen, IPI_SYNCH_REQUEST)) { (void)InterlockedDecrementUL(&Prcb->SignalDone->CurrentPacket[1]); if (InterlockedCompareExchangeUL(&Prcb->SignalDone->CurrentPacket[2], 0, 0)) { while (0 != InterlockedCompareExchangeUL(&Prcb->SignalDone->CurrentPacket[1], 0, 0)); } - ((VOID (STDCALL*)(PVOID))(Prcb->SignalDone->WorkerRoutine))(Prcb->SignalDone->CurrentPacket[0]); - Ke386TestAndClearBit(KeGetCurrentProcessorNumber(), (PULONG)&Prcb->SignalDone->TargetSet); + ((VOID (NTAPI*)(PVOID))(Prcb->SignalDone->WorkerRoutine))(Prcb->SignalDone->CurrentPacket[0]); + InterlockedBitTestAndReset((PLONG)&Prcb->SignalDone->TargetSet, KeGetCurrentProcessorNumber()); if (InterlockedCompareExchangeUL(&Prcb->SignalDone->CurrentPacket[2], 0, 0)) { while (0 != InterlockedCompareExchangeUL(&Prcb->SignalDone->TargetSet, 0, 0)); diff --git a/reactos/ntoskrnl/ke/spinlock.c b/reactos/ntoskrnl/ke/spinlock.c index a97158b34d7..84ed9307c5f 100644 --- a/reactos/ntoskrnl/ke/spinlock.c +++ b/reactos/ntoskrnl/ke/spinlock.c @@ -26,24 +26,24 @@ KeAcquireQueuedSpinLockAtDpcLevel(IN PKSPIN_LOCK_QUEUE LockHandle) /* Set the new lock */ Prev = (PKSPIN_LOCK_QUEUE) - InterlockedExchange((PLONG)LockHandle->LockQueue.Lock, + InterlockedExchange((PLONG)LockHandle->Next, (LONG)LockHandle); if (!Prev) { /* There was nothing there before. We now own it */ - *(ULONG_PTR*)&LockHandle->LockQueue.Lock |= LQ_OWN; + *LockHandle->Lock |= LQ_OWN; return; } /* Set the wait flag */ - *(ULONG_PTR*)&LockHandle->LockQueue.Lock |= LQ_WAIT; + *LockHandle->Lock |= LQ_WAIT; /* Link us */ Prev->Next = (PKSPIN_LOCK_QUEUE)LockHandle; /* Loop and wait */ - while ( *(ULONG_PTR*)&LockHandle->LockQueue.Lock & LQ_WAIT) YieldProcessor(); - return; + while (*LockHandle->Lock & LQ_WAIT) + YieldProcessor(); #endif } @@ -56,31 +56,31 @@ KeReleaseQueuedSpinLockFromDpcLevel(IN PKSPIN_LOCK_QUEUE LockHandle) PKSPIN_LOCK_QUEUE Waiter; /* Remove own and wait flags */ - *(ULONG_PTR*)&LockHandle->LockQueue.Lock &= ~(LQ_OWN | LQ_WAIT); - LockVal = *LockHandle->LockQueue.Lock; + *LockHandle->Lock &= ~(LQ_OWN | LQ_WAIT); + LockVal = *LockHandle->Lock; /* Check if we already own it */ if (LockVal == (KSPIN_LOCK)LockHandle) { /* Disown it */ LockVal = (KSPIN_LOCK) - InterlockedCompareExchangePointer(LockHandle->LockQueue.Lock, + InterlockedCompareExchangePointer(LockHandle->Lock, NULL, LockHandle); } if (LockVal == (KSPIN_LOCK)LockHandle) return; /* Need to wait for it */ - Waiter = LockHandle->LockQueue.Next; + Waiter = LockHandle->Next; while (!Waiter) { YieldProcessor(); - Waiter = LockHandle->LockQueue.Next; + Waiter = LockHandle->Next; } /* It's gone */ *(ULONG_PTR*)&Waiter->Lock ^= (LQ_OWN | LQ_WAIT); - LockHandle->LockQueue.Next = NULL; + LockHandle->Next = NULL; #endif } @@ -211,8 +211,7 @@ KeAcquireInStackQueuedSpinLockAtDpcLevel(IN PKSPIN_LOCK SpinLock, /* Set it up properly */ LockHandle->LockQueue.Next = NULL; LockHandle->LockQueue.Lock = SpinLock; - KeAcquireQueuedSpinLockAtDpcLevel((PKLOCK_QUEUE_HANDLE) - &LockHandle->LockQueue.Next); + KeAcquireQueuedSpinLockAtDpcLevel(LockHandle->LockQueue.Next); #endif } @@ -225,8 +224,7 @@ KeReleaseInStackQueuedSpinLockFromDpcLevel(IN PKLOCK_QUEUE_HANDLE LockHandle) { #ifdef CONFIG_SMP /* Call the internal function */ - KeReleaseQueuedSpinLockFromDpcLevel((PKLOCK_QUEUE_HANDLE) - &LockHandle->LockQueue.Next); + KeReleaseQueuedSpinLockFromDpcLevel(LockHandle->LockQueue.Next); #endif } diff --git a/reactos/ntoskrnl/ke/thrdobj.c b/reactos/ntoskrnl/ke/thrdobj.c index 0309a14e942..528aa728297 100644 --- a/reactos/ntoskrnl/ke/thrdobj.c +++ b/reactos/ntoskrnl/ke/thrdobj.c @@ -480,7 +480,7 @@ KeStartThread(IN OUT PKTHREAD Thread) #ifdef CONFIG_SMP /* Get the KNODE and its PRCB */ Node = KeNodeBlock[Process->IdealNode]; - NodePrcb = (PKPRCB)(KPCR_BASE + (Process->ThreadSeed * PAGE_SIZE)); + NodePrcb = ((PKPCR)(KIP0PCRADDRESS + Process->ThreadSeed * PAGE_SIZE))->Prcb; /* Calculate affinity mask */ Set = ~NodePrcb->MultiThreadProcessorSet; diff --git a/reactos/ntoskrnl/mm/i386/page.c b/reactos/ntoskrnl/mm/i386/page.c index 43fcd616181..73a453f65a2 100644 --- a/reactos/ntoskrnl/mm/i386/page.c +++ b/reactos/ntoskrnl/mm/i386/page.c @@ -75,22 +75,23 @@ extern BOOLEAN Ke386NoExecute; BOOLEAN MmUnmapPageTable(PULONG Pt); -VOID -STDCALL -MiFlushTlbIpiRoutine(PVOID Address) +ULONG_PTR +NTAPI +MiFlushTlbIpiRoutine(ULONG_PTR Address) { - if (Address == (PVOID)0xffffffff) + if (Address == (ULONG_PTR)-1) { KeFlushCurrentTb(); } - else if (Address == (PVOID)0xfffffffe) + else if (Address == (ULONG_PTR)-2) { KeFlushCurrentTb(); } else { - __invlpg(Address); + __invlpg((PVOID)Address); } + return 0; } VOID @@ -101,13 +102,13 @@ MiFlushTlb(PULONG Pt, PVOID Address) { MmUnmapPageTable(Pt); } - if (KeNumberProcessors>1) + if (KeNumberProcessors > 1) { - KeIpiGenericCall(MiFlushTlbIpiRoutine, Address); + KeIpiGenericCall(MiFlushTlbIpiRoutine, (ULONG_PTR)Address); } else { - MiFlushTlbIpiRoutine(Address); + MiFlushTlbIpiRoutine((ULONG_PTR)Address); } #else if ((Pt && MmUnmapPageTable(Pt)) || Address >= MmSystemRangeStart)