Author: cgutman
Date: Sun Jun 6 20:09:25 2010
New Revision: 47630
URL:
http://svn.reactos.org/svn/reactos?rev=47630&view=rev
Log:
[NDIS]
- Implement miniport timer queuing
- Add some BUGCODE_ID_DRIVER bug check cases for missing interrupt deregistration, missing
timer cancellation, and invalid IRQL when calling NdisMAllocateSharedMemory
Modified:
trunk/reactos/drivers/network/ndis/ndis/memory.c
trunk/reactos/drivers/network/ndis/ndis/miniport.c
trunk/reactos/drivers/network/ndis/ndis/time.c
Modified: trunk/reactos/drivers/network/ndis/ndis/memory.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/network/ndis/ndis/…
==============================================================================
--- trunk/reactos/drivers/network/ndis/ndis/memory.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/network/ndis/ndis/memory.c [iso-8859-1] Sun Jun 6 20:09:25
2010
@@ -171,6 +171,15 @@
NDIS_DbgPrint(MAX_TRACE,("Called.\n"));
+ if (KeGetCurrentIrql() != PASSIVE_LEVEL)
+ {
+ KeBugCheckEx(BUGCODE_ID_DRIVER,
+ (ULONG_PTR)MiniportAdapterHandle,
+ Length,
+ 0,
+ 1);
+ }
+
*VirtualAddress =
Adapter->NdisMiniportBlock.SystemAdapterObject->DmaOperations->AllocateCommonBuffer(
Adapter->NdisMiniportBlock.SystemAdapterObject, Length, PhysicalAddress,
Cached);
}
Modified: trunk/reactos/drivers/network/ndis/ndis/miniport.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/network/ndis/ndis/…
==============================================================================
--- trunk/reactos/drivers/network/ndis/ndis/miniport.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/network/ndis/ndis/miniport.c [iso-8859-1] Sun Jun 6 20:09:25
2010
@@ -364,6 +364,15 @@
NdisMIndicateStatusComplete(Adapter);
KeAcquireSpinLock(&Adapter->NdisMiniportBlock.Lock, &OldIrql);
+
+ if (Adapter->NdisMiniportBlock.ResetStatus != NDIS_STATUS_PENDING)
+ {
+ KeBugCheckEx(BUGCODE_ID_DRIVER,
+ (ULONG_PTR)MiniportAdapterHandle,
+ (ULONG_PTR)Status,
+ (ULONG_PTR)AddressingReset,
+ 0);
+ }
Adapter->NdisMiniportBlock.ResetStatus = Status;
@@ -1959,6 +1968,22 @@
{
NDIS_DbgPrint(MIN_TRACE, ("MiniportInitialize() failed for an
adapter.\n"));
ExInterlockedRemoveEntryList( &Adapter->ListEntry, &AdapterListLock );
+ if (Adapter->NdisMiniportBlock.Interrupt)
+ {
+ KeBugCheckEx(BUGCODE_ID_DRIVER,
+ (ULONG_PTR)Adapter,
+ (ULONG_PTR)Adapter->NdisMiniportBlock.Interrupt,
+ (ULONG_PTR)Adapter->NdisMiniportBlock.TimerQueue,
+ 1);
+ }
+ if (Adapter->NdisMiniportBlock.TimerQueue)
+ {
+ KeBugCheckEx(BUGCODE_ID_DRIVER,
+ (ULONG_PTR)Adapter,
+ (ULONG_PTR)Adapter->NdisMiniportBlock.Interrupt,
+ (ULONG_PTR)Adapter->NdisMiniportBlock.TimerQueue,
+ 1);
+ }
return NdisStatus;
}
Modified: trunk/reactos/drivers/network/ndis/ndis/time.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/network/ndis/ndis/…
==============================================================================
--- trunk/reactos/drivers/network/ndis/ndis/time.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/network/ndis/ndis/time.c [iso-8859-1] Sun Jun 6 20:09:25 2010
@@ -95,6 +95,32 @@
KeInitializeDpc (&Timer->Dpc, (PKDEFERRED_ROUTINE)TimerFunction,
FunctionContext);
}
+VOID DequeueMiniportTimer(PNDIS_MINIPORT_TIMER Timer)
+{
+ PNDIS_MINIPORT_TIMER CurrentTimer;
+
+ ASSERT(Timer->Miniport->TimerQueue);
+
+ if (Timer->Miniport->TimerQueue == Timer)
+ {
+ Timer->Miniport->TimerQueue = Timer->NextDeferredTimer;
+ }
+ else
+ {
+ CurrentTimer = Timer->Miniport->TimerQueue;
+ while (CurrentTimer->NextDeferredTimer)
+ {
+ if (CurrentTimer->NextDeferredTimer == Timer)
+ {
+ CurrentTimer->NextDeferredTimer = Timer->NextDeferredTimer;
+ return;
+ }
+ CurrentTimer = CurrentTimer->NextDeferredTimer;
+ }
+ ASSERT(FALSE);
+ }
+}
+
/*
* @implemented
@@ -118,6 +144,25 @@
ASSERT(Timer);
*TimerCancelled = KeCancelTimer (&Timer->Timer);
+
+ DequeueMiniportTimer(Timer);
+}
+
+VOID NTAPI
+MiniTimerDpcFunction(PKDPC Dpc,
+ PVOID DeferredContext,
+ PVOID SystemArgument1,
+ PVOID SystemArgument2)
+{
+ PNDIS_MINIPORT_TIMER Timer = DeferredContext;
+
+ Timer->MiniportTimerFunction(Dpc,
+ Timer->MiniportTimerContext,
+ SystemArgument1,
+ SystemArgument2);
+
+ /* FIXME: We can't call this if we have a periodic timer */
+ //DequeueMiniportTimer(Timer);
}
@@ -145,9 +190,14 @@
{
PAGED_CODE();
ASSERT(Timer);
+
KeInitializeTimer (&Timer->Timer);
-
- KeInitializeDpc (&Timer->Dpc, (PKDEFERRED_ROUTINE)TimerFunction,
FunctionContext);
+ KeInitializeDpc (&Timer->Dpc, MiniTimerDpcFunction, Timer);
+
+ Timer->MiniportTimerFunction = TimerFunction;
+ Timer->MiniportTimerContext = FunctionContext;
+ Timer->Miniport =
&((PLOGICAL_ADAPTER)MiniportAdapterHandle)->NdisMiniportBlock;
+ Timer->NextDeferredTimer = NULL;
}
@@ -177,6 +227,10 @@
/* relative delays are negative, absolute are positive; resolution is 100ns */
Timeout.QuadPart = Int32x32To64(MillisecondsPeriod, -10000);
+ /* Add the timer at the head of the timer queue */
+ Timer->NextDeferredTimer = Timer->Miniport->TimerQueue;
+ Timer->Miniport->TimerQueue = Timer;
+
KeSetTimerEx (&Timer->Timer, Timeout, MillisecondsPeriod, &Timer->Dpc);
}
@@ -207,6 +261,10 @@
/* relative delays are negative, absolute are positive; resolution is 100ns */
Timeout.QuadPart = Int32x32To64(MillisecondsToDelay, -10000);
+
+ /* Add the timer at the head of the timer queue */
+ Timer->NextDeferredTimer = Timer->Miniport->TimerQueue;
+ Timer->Miniport->TimerQueue = Timer;
KeSetTimer (&Timer->Timer, Timeout, &Timer->Dpc);
}