Fix some compilation errors in ntkrnlmp

(code has not been tested, so it is probably wrong)

svn path=/trunk/; revision=30223
This commit is contained in:
Hervé Poussineau 2007-11-06 14:34:32 +00:00
parent 169a48594f
commit 082af2ff8a
4 changed files with 37 additions and 40 deletions

View file

@ -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));

View file

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

View file

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

View file

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