Author: cgutman
Date: Wed Sep 24 18:39:17 2008
New Revision: 36497
URL:
http://svn.reactos.org/svn/reactos?rev=36497&view=rev
Log:
Merge aicom-network-fixes up to r36496
- We now call the MiniportCheckForHang handler every two seconds
- We reset the miniport if it has detected a hang
- Added some IRQL checks
Modified:
trunk/reactos/drivers/network/dd/ne2000/include/debug.h
trunk/reactos/drivers/network/dd/ne2000/ne2000/main.c
trunk/reactos/drivers/network/dd/pcnet/pcnet.c
trunk/reactos/drivers/network/dd/pcnet/pcnet.h
trunk/reactos/drivers/network/dd/pcnet/requests.c
trunk/reactos/drivers/network/ndis/ndis/io.c
trunk/reactos/drivers/network/ndis/ndis/memory.c
trunk/reactos/drivers/network/ndis/ndis/miniport.c
Modified: trunk/reactos/drivers/network/dd/ne2000/include/debug.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/network/dd/ne2000/…
==============================================================================
--- trunk/reactos/drivers/network/dd/ne2000/include/debug.h [iso-8859-1] (original)
+++ trunk/reactos/drivers/network/dd/ne2000/include/debug.h [iso-8859-1] Wed Sep 24
18:39:17 2008
@@ -56,12 +56,14 @@
#endif /* NASSERT */
#endif
#define ASSERT_IRQL(x) ASSERT(KeGetCurrentIrql() <= (x))
+#define ASSERT_IRQL_EQUAL(x) ASSERT(KeGetCurrentIrql() == (x))
#else /* DBG */
#define NDIS_DbgPrint(_t_, _x_)
#define ASSERT_IRQL(x)
+#define ASSERT_IRQL_EQUAL(x)
/* #define ASSERT(x) */ /* ndis.h */
#endif /* DBG */
Modified: trunk/reactos/drivers/network/dd/ne2000/ne2000/main.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/network/dd/ne2000/…
==============================================================================
--- trunk/reactos/drivers/network/dd/ne2000/ne2000/main.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/network/dd/ne2000/ne2000/main.c [iso-8859-1] Wed Sep 24 18:39:17
2008
@@ -62,8 +62,7 @@
NDIS_PHYSICAL_ADDRESS HighestAcceptableMax = NDIS_PHYSICAL_ADDRESS_CONST(-1, -1);
-#if 0
-static BOOLEAN MiniportCheckForHang(
+static BOOLEAN STDCALL MiniportCheckForHang(
IN NDIS_HANDLE MiniportAdapterContext)
/*
* FUNCTION: Examines if an adapter has hung
@@ -77,7 +76,6 @@
return FALSE;
}
-#endif
static VOID STDCALL MiniportDisableInterrupt(
@@ -119,6 +117,8 @@
*/
{
PNIC_ADAPTER Adapter = (PNIC_ADAPTER)MiniportAdapterContext;
+
+ ASSERT_IRQL_EQUAL(PASSIVE_LEVEL);
NDIS_DbgPrint(MAX_TRACE, ("Called.\n"));
#ifndef NOCARD
@@ -224,6 +224,8 @@
UINT i;
NDIS_STATUS Status;
PNIC_ADAPTER Adapter;
+
+ ASSERT_IRQL_EQUAL(PASSIVE_LEVEL);
NDIS_DbgPrint(MAX_TRACE, ("Called (Adapter %X).\n",
MiniportAdapterHandle));
@@ -472,6 +474,8 @@
NDIS_MEDIUM Medium = NdisMedium802_3;
PNIC_ADAPTER Adapter = (PNIC_ADAPTER)MiniportAdapterContext;
+ ASSERT_IRQL_EQUAL(DISPATCH_LEVEL);
+
NDIS_DbgPrint(MAX_TRACE, ("Called. Oid (0x%X).\n", Oid));
Status = NDIS_STATUS_SUCCESS;
@@ -638,6 +642,8 @@
* Status of operation
*/
{
+ ASSERT_IRQL_EQUAL(DISPATCH_LEVEL);
+
NDIS_DbgPrint(MAX_TRACE, ("Called.\n"));
return NDIS_STATUS_FAILURE;
@@ -660,6 +666,8 @@
*/
{
PNIC_ADAPTER Adapter = (PNIC_ADAPTER)MiniportAdapterContext;
+
+ ASSERT_IRQL_EQUAL(DISPATCH_LEVEL);
NDIS_DbgPrint(MID_TRACE, ("Queueing packet.\n"));
@@ -709,6 +717,8 @@
ULONG GenericULONG;
NDIS_STATUS Status = NDIS_STATUS_SUCCESS;
PNIC_ADAPTER Adapter = (PNIC_ADAPTER)MiniportAdapterContext;
+
+ ASSERT_IRQL_EQUAL(DISPATCH_LEVEL);
NDIS_DbgPrint(MAX_TRACE, ("Called. Oid (0x%X).\n", Oid));
@@ -819,6 +829,8 @@
UINT RecvStop;
PNIC_ADAPTER Adapter = (PNIC_ADAPTER)MiniportAdapterContext;
+ ASSERT_IRQL_EQUAL(DISPATCH_LEVEL);
+
NDIS_DbgPrint(MAX_TRACE, ("Called. Packet (0x%X) ByteOffset (0x%X)
BytesToTransfer (%d).\n",
Packet, ByteOffset, BytesToTransfer));
@@ -903,7 +915,7 @@
NdisZeroMemory(&Miniport, sizeof(Miniport));
Miniport.MajorNdisVersion = DRIVER_NDIS_MAJOR_VERSION;
Miniport.MinorNdisVersion = DRIVER_NDIS_MINOR_VERSION;
- Miniport.CheckForHangHandler = NULL; //MiniportCheckForHang;
+ Miniport.CheckForHangHandler = MiniportCheckForHang;
Miniport.DisableInterruptHandler = MiniportDisableInterrupt;
Miniport.EnableInterruptHandler = MiniportEnableInterrupt;
Miniport.HaltHandler = MiniportHalt;
@@ -922,6 +934,11 @@
RegistryPath,
NULL);
+ if (!NdisWrapperHandle) {
+ NDIS_DbgPrint(MIN_TRACE, ("NdisMInitializeWrapper() failed\n"));
+ return STATUS_UNSUCCESSFUL;
+ }
+
DriverInfo.NdisWrapperHandle = NdisWrapperHandle;
DriverInfo.NdisMacHandle = NULL;
InitializeListHead(&DriverInfo.AdapterListHead);
Modified: trunk/reactos/drivers/network/dd/pcnet/pcnet.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/network/dd/pcnet/p…
==============================================================================
--- trunk/reactos/drivers/network/dd/pcnet/pcnet.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/network/dd/pcnet/pcnet.c [iso-8859-1] Wed Sep 24 18:39:17 2008
@@ -69,6 +69,8 @@
DPRINT("Called\n");
+ ASSERT_IRQL_EQUAL(DISPATCH_LEVEL);
+
NdisDprAcquireSpinLock(&Adapter->Lock);
NdisRawWritePortUshort(Adapter->PortOffset + RAP, CSR0);
@@ -624,6 +626,8 @@
{
PADAPTER Adapter = (PADAPTER)FunctionContext;
+ ASSERT_IRQL_EQUAL(DISPATCH_LEVEL);
+
if (NdisMSynchronizeWithInterrupt(&Adapter->InterruptObject,
MiSyncMediaDetection,
FunctionContext))
@@ -812,6 +816,8 @@
NDIS_STATUS Status = NDIS_STATUS_FAILURE;
BOOLEAN InterruptRegistered = FALSE;
+ ASSERT_IRQL_EQUAL(PASSIVE_LEVEL);
+
/* Pick a medium */
for(i = 0; i < MediumArraySize; i++)
if(MediumArray[i] == NdisMedium802_3)
@@ -1023,6 +1029,8 @@
{
DPRINT("Called\n");
+ ASSERT_IRQL_EQUAL(PASSIVE_LEVEL);
+
/* MiniportReset doesn't do anything at the moment... perhaps this should be fixed.
*/
*AddressingReset = FALSE;
@@ -1071,6 +1079,8 @@
UINT TotalPacketLength, SourceLength, Position = 0;
DPRINT("Called\n");
+
+ ASSERT_IRQL_EQUAL(DISPATCH_LEVEL);
NdisDprAcquireSpinLock(&Adapter->Lock);
Modified: trunk/reactos/drivers/network/dd/pcnet/pcnet.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/network/dd/pcnet/p…
==============================================================================
--- trunk/reactos/drivers/network/dd/pcnet/pcnet.h [iso-8859-1] (original)
+++ trunk/reactos/drivers/network/dd/pcnet/pcnet.h [iso-8859-1] Wed Sep 24 18:39:17 2008
@@ -141,8 +141,10 @@
#if DBG
#define BREAKPOINT DbgBreakPoint();
+#define ASSERT_IRQL_EQUAL(x) ASSERT(KeGetCurrentIrql() == x)
#else
#define BREAKPOINT
+#define ASSERT_IRQL_EQUAL(x)
#endif
#ifndef TAG
Modified: trunk/reactos/drivers/network/dd/pcnet/requests.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/network/dd/pcnet/r…
==============================================================================
--- trunk/reactos/drivers/network/dd/pcnet/requests.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/network/dd/pcnet/requests.c [iso-8859-1] Wed Sep 24 18:39:17
2008
@@ -103,7 +103,7 @@
* RETURNS:
* NDIS_STATUS_SUCCESS on all queries
* NOTES:
- * - Called by NDIS at PASSIVE_LEVEL
+ * - Called by NDIS at DISPATCH_LEVEL
* - If InformationBufferLength is insufficient to store the results, return the
amount
* needed in BytesNeeded and return NDIS_STATUS_INVALID_LENGTH
* TODO:
@@ -118,9 +118,11 @@
DPRINT("Called. OID 0x%x\n", Oid);
+ ASSERT_IRQL_EQUAL(DISPATCH_LEVEL);
+
ASSERT(Adapter);
- NdisAcquireSpinLock(&Adapter->Lock);
+ NdisDprAcquireSpinLock(&Adapter->Lock);
Status = NDIS_STATUS_SUCCESS;
CopyFrom = (PVOID)&GenericULONG;
@@ -361,7 +363,7 @@
}
}
- NdisReleaseSpinLock(&Adapter->Lock);
+ NdisDprReleaseSpinLock(&Adapter->Lock);
DPRINT("Leaving. Status is 0x%x\n", Status);
@@ -390,7 +392,7 @@
* RETURNS:
* NDIS_STATUS_SUCCESS on all requests
* NOTES:
- * - Called by NDIS at PASSIVE_LEVEL
+ * - Called by NDIS at DISPATCH_LEVEL
* - verify buffer space as mentioned in previous function notes
*/
{
@@ -400,9 +402,11 @@
ASSERT(Adapter);
+ ASSERT_IRQL_EQUAL(DISPATCH_LEVEL);
+
DPRINT("Called, OID 0x%x\n", Oid);
- NdisAcquireSpinLock(&Adapter->Lock);
+ NdisDprAcquireSpinLock(&Adapter->Lock);
switch (Oid)
{
@@ -501,7 +505,7 @@
*BytesNeeded = 0;
}
- NdisReleaseSpinLock(&Adapter->Lock);
+ NdisDprReleaseSpinLock(&Adapter->Lock);
DPRINT("Leaving. Status (0x%X).\n", Status);
Modified: trunk/reactos/drivers/network/ndis/ndis/io.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/network/ndis/ndis/…
==============================================================================
--- trunk/reactos/drivers/network/ndis/ndis/io.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/network/ndis/ndis/io.c [iso-8859-1] Wed Sep 24 18:39:17 2008
@@ -268,7 +268,7 @@
UINT MapRegistersPerBaseRegister = 0;
ULONG AvailableMapRegisters;
NTSTATUS NtStatus;
- PNDIS_MINIPORT_BLOCK Adapter = 0;
+ PLOGICAL_ADAPTER Adapter;
PDEVICE_OBJECT DeviceObject = 0;
KEVENT AllocationEvent;
KIRQL OldIrql;
@@ -278,19 +278,19 @@
memset(&Description,0,sizeof(Description));
- Adapter = (PNDIS_MINIPORT_BLOCK)MiniportAdapterHandle;
+ Adapter = (PLOGICAL_ADAPTER)MiniportAdapterHandle;
ASSERT(Adapter);
/* only bus masters may call this routine */
- ASSERT(Adapter->Flags & NDIS_ATTRIBUTE_BUS_MASTER);
- if(!(Adapter->Flags & NDIS_ATTRIBUTE_BUS_MASTER))
+ ASSERT(Adapter->NdisMiniportBlock.Flags & NDIS_ATTRIBUTE_BUS_MASTER);
+ if(!(Adapter->NdisMiniportBlock.Flags & NDIS_ATTRIBUTE_BUS_MASTER))
return NDIS_STATUS_SUCCESS;
- DeviceObject = Adapter->DeviceObject;
+ DeviceObject = Adapter->NdisMiniportBlock.DeviceObject;
KeInitializeEvent(&AllocationEvent, NotificationEvent, FALSE);
- Adapter->AllocationEvent = &AllocationEvent;
+ Adapter->NdisMiniportBlock.AllocationEvent = &AllocationEvent;
/*
* map registers correlate to physical pages. ndis documents a
@@ -310,12 +310,12 @@
Description.Master = TRUE; /* implied by calling this function
*/
Description.ScatterGather = TRUE; /* XXX UNTRUE: All BM DMA are S/G
(ms seems to do this) */
Description.Dma32BitAddresses = DmaSize;
- Description.BusNumber = Adapter->BusNumber;
- Description.InterfaceType = Adapter->BusType;
+ Description.BusNumber = Adapter->NdisMiniportBlock.BusNumber;
+ Description.InterfaceType = Adapter->NdisMiniportBlock.BusType;
Description.DmaChannel = DmaChannel;
Description.MaximumLength = MaximumBufferSize;
- if(Adapter->AdapterType == Isa)
+ if(Adapter->NdisMiniportBlock.AdapterType == Isa)
{
/* system dma */
if(DmaChannel < 4)
@@ -325,7 +325,7 @@
Description.DmaSpeed = Compatible;
}
- else if(Adapter->AdapterType == PCIBus)
+ else if(Adapter->NdisMiniportBlock.AdapterType == PCIBus)
{
if(DmaSize == NDIS_DMA_64BITS)
Description.Dma64BitAddresses = TRUE;
@@ -339,7 +339,7 @@
}
AdapterObject = IoGetDmaAdapter(
- Adapter->PhysicalDeviceObject, &Description, &AvailableMapRegisters);
+ Adapter->NdisMiniportBlock.PhysicalDeviceObject, &Description,
&AvailableMapRegisters);
if(!AdapterObject)
{
@@ -347,7 +347,7 @@
return NDIS_STATUS_RESOURCES;
}
- Adapter->SystemAdapterObject = AdapterObject;
+ Adapter->NdisMiniportBlock.SystemAdapterObject = AdapterObject;
if(AvailableMapRegisters < MapRegistersPerBaseRegister)
{
@@ -358,22 +358,22 @@
}
/* allocate & zero space in the miniport block for the registers */
- Adapter->MapRegisters = ExAllocatePool(NonPagedPool, BaseMapRegistersNeeded *
sizeof(MAP_REGISTER_ENTRY));
- if(!Adapter->MapRegisters)
+ Adapter->NdisMiniportBlock.MapRegisters = ExAllocatePool(NonPagedPool,
BaseMapRegistersNeeded * sizeof(MAP_REGISTER_ENTRY));
+ if(!Adapter->NdisMiniportBlock.MapRegisters)
{
NDIS_DbgPrint(MIN_TRACE, ("insufficient resources.\n"));
return NDIS_STATUS_RESOURCES;
}
- memset(Adapter->MapRegisters, 0, BaseMapRegistersNeeded *
sizeof(MAP_REGISTER_ENTRY));
- Adapter->BaseMapRegistersNeeded = (USHORT)BaseMapRegistersNeeded;
+ memset(Adapter->NdisMiniportBlock.MapRegisters, 0, BaseMapRegistersNeeded *
sizeof(MAP_REGISTER_ENTRY));
+ Adapter->NdisMiniportBlock.BaseMapRegistersNeeded = (USHORT)BaseMapRegistersNeeded;
while(BaseMapRegistersNeeded)
{
NDIS_DbgPrint(MAX_TRACE, ("iterating, basemapregistersneeded = %d\n",
BaseMapRegistersNeeded));
BaseMapRegistersNeeded--;
- Adapter->CurrentMapRegister = (USHORT)BaseMapRegistersNeeded;
+ Adapter->NdisMiniportBlock.CurrentMapRegister = (USHORT)BaseMapRegistersNeeded;
KeRaiseIrql(DISPATCH_LEVEL, &OldIrql);
{
NtStatus = AdapterObject->DmaOperations->AllocateAdapterChannel(
@@ -385,7 +385,7 @@
if(!NT_SUCCESS(NtStatus))
{
NDIS_DbgPrint(MIN_TRACE, ("IoAllocateAdapterChannel failed: 0x%x\n",
NtStatus));
- ExFreePool(Adapter->MapRegisters);
+ ExFreePool(Adapter->NdisMiniportBlock.MapRegisters);
return NDIS_STATUS_RESOURCES;
}
@@ -396,7 +396,7 @@
if(!NT_SUCCESS(NtStatus))
{
NDIS_DbgPrint(MIN_TRACE, ("KeWaitForSingleObject failed: 0x%x\n",
NtStatus));
- ExFreePool(Adapter->MapRegisters);
+ ExFreePool(Adapter->NdisMiniportBlock.MapRegisters);
return NDIS_STATUS_RESOURCES;
}
@@ -439,7 +439,7 @@
* - The caller supplies storage for the physical address array.
*/
{
- PNDIS_MINIPORT_BLOCK Adapter;
+ PLOGICAL_ADAPTER Adapter;
PVOID CurrentVa;
ULONG TotalLength;
PHYSICAL_ADDRESS ReturnedAddress;
@@ -448,7 +448,7 @@
ASSERT(KeGetCurrentIrql() <= DISPATCH_LEVEL);
ASSERT(MiniportAdapterHandle && Buffer && PhysicalAddressArray
&& ArraySize);
- Adapter = (PNDIS_MINIPORT_BLOCK)MiniportAdapterHandle;
+ Adapter = (PLOGICAL_ADAPTER)MiniportAdapterHandle;
CurrentVa = MmGetMdlVirtualAddress(Buffer);
TotalLength = MmGetMdlByteCount(Buffer);
@@ -456,12 +456,12 @@
{
ULONG Length = TotalLength;
- ReturnedAddress =
Adapter->SystemAdapterObject->DmaOperations->MapTransfer(
- Adapter->SystemAdapterObject, Buffer,
- Adapter->MapRegisters[PhysicalMapRegister].MapRegister,
+ ReturnedAddress =
Adapter->NdisMiniportBlock.SystemAdapterObject->DmaOperations->MapTransfer(
+ Adapter->NdisMiniportBlock.SystemAdapterObject, Buffer,
+ Adapter->NdisMiniportBlock.MapRegisters[PhysicalMapRegister].MapRegister,
CurrentVa, &Length, WriteToDevice);
- Adapter->MapRegisters[PhysicalMapRegister].WriteToDevice = WriteToDevice;
+ Adapter->NdisMiniportBlock.MapRegisters[PhysicalMapRegister].WriteToDevice =
WriteToDevice;
PhysicalAddressArray[LoopCount].PhysicalAddress = ReturnedAddress;
PhysicalAddressArray[LoopCount].Length = Length;
@@ -495,22 +495,22 @@
* - May be called at IRQL <= DISPATCH_LEVEL
*/
{
- PNDIS_MINIPORT_BLOCK Adapter;
+ PLOGICAL_ADAPTER Adapter;
VOID *CurrentVa;
ULONG Length;
ASSERT(KeGetCurrentIrql() <= DISPATCH_LEVEL);
ASSERT(MiniportAdapterHandle && Buffer);
- Adapter = (PNDIS_MINIPORT_BLOCK)MiniportAdapterHandle;
+ Adapter = (PLOGICAL_ADAPTER)MiniportAdapterHandle;
CurrentVa = MmGetMdlVirtualAddress(Buffer);
Length = MmGetMdlByteCount(Buffer);
- Adapter->SystemAdapterObject->DmaOperations->FlushAdapterBuffers(
- Adapter->SystemAdapterObject, Buffer,
- Adapter->MapRegisters[PhysicalMapRegister].MapRegister,
+
Adapter->NdisMiniportBlock.SystemAdapterObject->DmaOperations->FlushAdapterBuffers(
+ Adapter->NdisMiniportBlock.SystemAdapterObject, Buffer,
+ Adapter->NdisMiniportBlock.MapRegisters[PhysicalMapRegister].MapRegister,
CurrentVa, Length,
- Adapter->MapRegisters[PhysicalMapRegister].WriteToDevice);
+ Adapter->NdisMiniportBlock.MapRegisters[PhysicalMapRegister].WriteToDevice);
}
@@ -582,7 +582,7 @@
*/
{
KIRQL OldIrql;
- PNDIS_MINIPORT_BLOCK Adapter = (PNDIS_MINIPORT_BLOCK)MiniportAdapterHandle;
+ PLOGICAL_ADAPTER Adapter = (PLOGICAL_ADAPTER)MiniportAdapterHandle;
PDMA_ADAPTER AdapterObject;
UINT MapRegistersPerBaseRegister;
UINT i;
@@ -592,31 +592,31 @@
ASSERT(Adapter);
/* only bus masters may call this routine */
- ASSERT(Adapter->Flags & NDIS_ATTRIBUTE_BUS_MASTER);
- if(!(Adapter->Flags & NDIS_ATTRIBUTE_BUS_MASTER) ||
- Adapter->SystemAdapterObject == NULL)
+ ASSERT(Adapter->NdisMiniportBlock.Flags & NDIS_ATTRIBUTE_BUS_MASTER);
+ if(!(Adapter->NdisMiniportBlock.Flags & NDIS_ATTRIBUTE_BUS_MASTER) ||
+ Adapter->NdisMiniportBlock.SystemAdapterObject == NULL)
return;
- MapRegistersPerBaseRegister = ((Adapter->MaximumPhysicalMapping - 2) / PAGE_SIZE) +
2;
-
- AdapterObject = Adapter->SystemAdapterObject;
+ MapRegistersPerBaseRegister = ((Adapter->NdisMiniportBlock.MaximumPhysicalMapping -
2) / PAGE_SIZE) + 2;
+
+ AdapterObject = Adapter->NdisMiniportBlock.SystemAdapterObject;
KeRaiseIrql(DISPATCH_LEVEL, &OldIrql);
{
- for(i = 0; i < Adapter->BaseMapRegistersNeeded; i++)
+ for(i = 0; i < Adapter->NdisMiniportBlock.BaseMapRegistersNeeded; i++)
{
AdapterObject->DmaOperations->FreeMapRegisters(
- Adapter->SystemAdapterObject,
- Adapter->MapRegisters[i].MapRegister,
+ Adapter->NdisMiniportBlock.SystemAdapterObject,
+ Adapter->NdisMiniportBlock.MapRegisters[i].MapRegister,
MapRegistersPerBaseRegister);
}
}
KeLowerIrql(OldIrql);
AdapterObject->DmaOperations->PutDmaAdapter(AdapterObject);
- Adapter->SystemAdapterObject = NULL;
-
- ExFreePool(Adapter->MapRegisters);
+ Adapter->NdisMiniportBlock.SystemAdapterObject = NULL;
+
+ ExFreePool(Adapter->NdisMiniportBlock.MapRegisters);
}
@@ -752,7 +752,7 @@
ULONG MappedIRQ;
KIRQL DIrql;
KAFFINITY Affinity;
- PNDIS_MINIPORT_BLOCK Adapter = (PNDIS_MINIPORT_BLOCK)MiniportAdapterHandle;
+ PLOGICAL_ADAPTER Adapter = (PLOGICAL_ADAPTER)MiniportAdapterHandle;
NDIS_DbgPrint(MAX_TRACE, ("Called. InterruptVector (0x%X) InterruptLevel (0x%X)
"
"SharedInterrupt (%d) InterruptMode (0x%X)\n",
@@ -768,9 +768,9 @@
Interrupt->SharedInterrupt = SharedInterrupt;
- Adapter->Interrupt = Interrupt;
-
- MappedIRQ = HalGetInterruptVector(Adapter->BusType, Adapter->BusNumber,
+ Adapter->NdisMiniportBlock.Interrupt = Interrupt;
+
+ MappedIRQ = HalGetInterruptVector(Adapter->NdisMiniportBlock.BusType,
Adapter->NdisMiniportBlock.BusNumber,
InterruptLevel, InterruptVector, &DIrql,
&Affinity);
@@ -818,7 +818,7 @@
*/
{
PHYSICAL_ADDRESS PortAddress, TranslatedAddress;
- PNDIS_MINIPORT_BLOCK Adapter = (PNDIS_MINIPORT_BLOCK)MiniportAdapterHandle;
+ PLOGICAL_ADAPTER Adapter = (PLOGICAL_ADAPTER)MiniportAdapterHandle;
ULONG AddressSpace = 1; /* FIXME The HAL handles this wrong atm */
*PortOffset = 0;
@@ -840,7 +840,7 @@
NDIS_DbgPrint(MAX_TRACE, ("Translating address 0x%x 0x%x\n",
PortAddress.u.HighPart, PortAddress.u.LowPart));
- if(!HalTranslateBusAddress(Adapter->BusType, Adapter->BusNumber,
+ if(!HalTranslateBusAddress(Adapter->NdisMiniportBlock.BusType,
Adapter->NdisMiniportBlock.BusNumber,
PortAddress, &AddressSpace, &TranslatedAddress))
{
NDIS_DbgPrint(MIN_TRACE, ("Unable to translate address\n"));
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] Wed Sep 24 18:39:17
2008
@@ -189,12 +189,12 @@
* - Cached is ignored; we always allocate non-cached
*/
{
- PNDIS_MINIPORT_BLOCK Adapter = (PNDIS_MINIPORT_BLOCK)MiniportAdapterHandle;
+ PLOGICAL_ADAPTER Adapter = (PLOGICAL_ADAPTER)MiniportAdapterHandle;
NDIS_DbgPrint(MAX_TRACE,("Called.\n"));
- *VirtualAddress =
Adapter->SystemAdapterObject->DmaOperations->AllocateCommonBuffer(
- Adapter->SystemAdapterObject, Length, PhysicalAddress, Cached);
+ *VirtualAddress =
Adapter->NdisMiniportBlock.SystemAdapterObject->DmaOperations->AllocateCommonBuffer(
+ Adapter->NdisMiniportBlock.SystemAdapterObject, Length, PhysicalAddress,
Cached);
}
@@ -267,7 +267,7 @@
*/
{
HANDLE ThreadHandle;
- PNDIS_MINIPORT_BLOCK Adapter = (PNDIS_MINIPORT_BLOCK)MiniportAdapterHandle;
+ PLOGICAL_ADAPTER Adapter = (PLOGICAL_ADAPTER)MiniportAdapterHandle;
PMINIPORT_SHARED_MEMORY Memory;
NDIS_DbgPrint(MAX_TRACE,("Called.\n"));
@@ -283,7 +283,7 @@
return;
}
- Memory->AdapterObject = Adapter->SystemAdapterObject;
+ Memory->AdapterObject = Adapter->NdisMiniportBlock.SystemAdapterObject;
Memory->Length = Length;
Memory->PhysicalAddress = PhysicalAddress;
Memory->VirtualAddress = VirtualAddress;
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] Wed Sep 24 18:39:17
2008
@@ -581,6 +581,76 @@
/* FIXME: Wait in pending case! */
return NdisStatus;
+}
+
+BOOLEAN
+MiniCheckForHang( PLOGICAL_ADAPTER Adapter )
+/*
+ * FUNCTION: Checks to see if the miniport is hung
+ * ARGUMENTS:
+ * Adapter = Pointer to the logical adapter object
+ * RETURNS:
+ * TRUE if the miniport is hung
+ * FALSE if the miniport is not hung
+ */
+{
+ BOOLEAN Ret = FALSE;
+ KIRQL OldIrql;
+
+ KeRaiseIrql(DISPATCH_LEVEL, &OldIrql);
+ if
(Adapter->NdisMiniportBlock.DriverHandle->MiniportCharacteristics.CheckForHangHandler)
+ Ret =
(*Adapter->NdisMiniportBlock.DriverHandle->MiniportCharacteristics.CheckForHangHandler)(
+ Adapter->NdisMiniportBlock.MiniportAdapterContext);
+ KeLowerIrql(OldIrql);
+
+ return Ret;
+}
+
+NDIS_STATUS
+MiniReset(
+ PLOGICAL_ADAPTER Adapter,
+ PBOOLEAN AddressingReset)
+/*
+ * FUNCTION: Resets the miniport
+ * ARGUMENTS:
+ * Adapter = Pointer to the logical adapter object
+ * AddressingReset = Set to TRUE if we need to call MiniportSetInformation later
+ * RETURNS:
+ * Status of the operation
+ */
+{
+ NDIS_STATUS Status = NDIS_STATUS_FAILURE;
+ KIRQL OldIrql;
+
+ /* FIXME: What should we return if there isn't a reset handler? */
+
+ KeRaiseIrql(DISPATCH_LEVEL, &OldIrql);
+ if
(Adapter->NdisMiniportBlock.DriverHandle->MiniportCharacteristics.ResetHandler)
+ Status =
(*Adapter->NdisMiniportBlock.DriverHandle->MiniportCharacteristics.ResetHandler)(
+ Adapter->NdisMiniportBlock.MiniportAdapterContext,
+ AddressingReset);
+ KeLowerIrql(OldIrql);
+
+ return Status;
+}
+
+VOID STDCALL
+MiniportHangDpc(
+ PKDPC Dpc,
+ PVOID DeferredContext,
+ PVOID SystemArgument1,
+ PVOID SystemArgument2)
+{
+ PLOGICAL_ADAPTER Adapter = DeferredContext;
+ BOOLEAN AddressingReset = FALSE;
+
+
+ if (MiniCheckForHang(Adapter)) {
+ NDIS_DbgPrint(MIN_TRACE, ("Miniport detected adapter hang\n"));
+ MiniReset(Adapter, &AddressingReset);
+ }
+
+ /* FIXME: We should call MiniportSetInformation if AddressingReset is TRUE */
}
@@ -1370,7 +1440,8 @@
PNDIS_CONFIGURATION_PARAMETER ConfigParam;
NDIS_HANDLE ConfigHandle;
ULONG Size;
-/* FIXME - KIRQL OldIrql; */
+ LARGE_INTEGER Timeout;
+ /* FIXME - KIRQL OldIrql; */
/*
* Prepare wrapper context used by HW and configuration routines.
@@ -1582,8 +1653,17 @@
return (NTSTATUS)NdisStatus;
}
+ /* Check for a hang every two seconds if it wasn't set in MiniportInitialize */
+ if (Adapter->NdisMiniportBlock.CheckForHangSeconds == 0)
+ Adapter->NdisMiniportBlock.CheckForHangSeconds = 2;
+
Adapter->NdisMiniportBlock.OldPnPDeviceState =
Adapter->NdisMiniportBlock.PnPDeviceState;
Adapter->NdisMiniportBlock.PnPDeviceState = NdisPnPDeviceStarted;
+
+ Timeout.QuadPart = (LONGLONG)Adapter->NdisMiniportBlock.CheckForHangSeconds *
-1000000;
+ KeSetTimerEx(&Adapter->NdisMiniportBlock.WakeUpDpcTimer.Timer, Timeout,
+ Adapter->NdisMiniportBlock.CheckForHangSeconds * 1000,
+ &Adapter->NdisMiniportBlock.WakeUpDpcTimer.Dpc);
/* Put adapter in adapter list for this miniport */
ExInterlockedInsertTailList(&Adapter->NdisMiniportBlock.DriverHandle->DeviceList,
&Adapter->MiniportListEntry,
&Adapter->NdisMiniportBlock.DriverHandle->Lock);
@@ -1639,6 +1719,8 @@
Adapter->NdisMiniportBlock.OldPnPDeviceState =
Adapter->NdisMiniportBlock.PnPDeviceState;
Adapter->NdisMiniportBlock.PnPDeviceState = NdisPnPDeviceStopped;
+
+ KeCancelTimer(&Adapter->NdisMiniportBlock.WakeUpDpcTimer.Timer);
return STATUS_SUCCESS;
}
@@ -1826,7 +1908,9 @@
Adapter->NdisMiniportBlock.OldPnPDeviceState = 0;
Adapter->NdisMiniportBlock.PnPDeviceState = NdisPnPDeviceAdded;
- KeInitializeDpc(&Adapter->NdisMiniportBlock.DeferredDpc, MiniportDpc,
(PVOID)Adapter);
+ KeInitializeTimer(&Adapter->NdisMiniportBlock.WakeUpDpcTimer.Timer);
+ KeInitializeDpc(&Adapter->NdisMiniportBlock.WakeUpDpcTimer.Dpc, MiniportHangDpc,
Adapter);
+ KeInitializeDpc(&Adapter->NdisMiniportBlock.DeferredDpc, MiniportDpc, Adapter);
DeviceObject->Flags &= ~DO_DEVICE_INITIALIZING;
@@ -2078,8 +2162,6 @@
* AdapterType = Specifies the I/O bus interface of the caller's
NIC
*/
{
- /* TODO: Take CheckForHandTimeInSeconds into account! */
-
PLOGICAL_ADAPTER Adapter = GET_LOGICAL_ADAPTER(MiniportAdapterHandle);
NDIS_DbgPrint(MAX_TRACE, ("Called.\n"));
@@ -2087,6 +2169,8 @@
Adapter->NdisMiniportBlock.MiniportAdapterContext = MiniportAdapterContext;
Adapter->NdisMiniportBlock.Flags = AttributeFlags;
Adapter->NdisMiniportBlock.AdapterType = AdapterType;
+ if (CheckForHangTimeInSeconds > 0)
+ Adapter->NdisMiniportBlock.CheckForHangSeconds = CheckForHangTimeInSeconds;
if (AttributeFlags & NDIS_ATTRIBUTE_INTERMEDIATE_DRIVER)
NDIS_DbgPrint(MAX_TRACE, ("Intermediate drivers not supported yet.\n"));
}