Author: cgutman
Date: Tue Aug 9 06:00:38 2011
New Revision: 53147
URL:
http://svn.reactos.org/svn/reactos?rev=53147&view=rev
Log:
[NDIS]
- Implement NdisMDeregisterIoPortRange
[PCNET]
- Don't call NdisMFreeMapRegisters if no map registers were allocated
- Call MiFreeSharedMemory before freeing map registers to avoid a crash because freeing
map registers deallocates the adapter object
Modified:
trunk/reactos/drivers/network/dd/pcnet/pcnet.c
trunk/reactos/drivers/network/ndis/ndis/50stubs.c
trunk/reactos/drivers/network/ndis/ndis/io.c
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] Tue Aug 9 06:00:38 2011
@@ -844,7 +844,7 @@
UINT i = 0;
PADAPTER Adapter = 0;
NDIS_STATUS Status = NDIS_STATUS_FAILURE;
- BOOLEAN InterruptRegistered = FALSE;
+ BOOLEAN InterruptRegistered = FALSE, MapRegistersAllocated = FALSE;
NDIS_HANDLE ConfigurationHandle;
UINT *RegNetworkAddress = 0;
UINT RegNetworkAddressLength = 0;
@@ -912,6 +912,8 @@
break;
}
+ MapRegistersAllocated = TRUE;
+
/* set up the interrupt */
Status = NdisMRegisterInterrupt(&Adapter->InterruptObject,
Adapter->MiniportAdapterHandle, Adapter->InterruptVector,
Adapter->InterruptVector, TRUE, TRUE, NdisInterruptLevelSensitive);
@@ -928,7 +930,7 @@
if(Status != NDIS_STATUS_SUCCESS)
{
Status = NDIS_STATUS_RESOURCES;
- DPRINT1("MiAllocateSharedMemory failed", Status);
+ DPRINT1("MiAllocateSharedMemory failed\n", Status);
break;
}
@@ -969,15 +971,16 @@
{
DPRINT("Error; freeing stuff\n");
- NdisMFreeMapRegisters(Adapter->MiniportAdapterHandle); /* doesn't hurt to
free if we never alloc'd? */
+ MiFreeSharedMemory(Adapter);
+
+ if(MapRegistersAllocated)
+ NdisMFreeMapRegisters(Adapter->MiniportAdapterHandle);
if(Adapter->PortOffset)
NdisMDeregisterIoPortRange(Adapter->MiniportAdapterHandle,
Adapter->IoBaseAddress, NUMBER_OF_PORTS, (PVOID)Adapter->PortOffset);
if(InterruptRegistered)
NdisMDeregisterInterrupt(&Adapter->InterruptObject);
-
- MiFreeSharedMemory(Adapter);
NdisFreeMemory(Adapter, 0, 0);
}
Modified: trunk/reactos/drivers/network/ndis/ndis/50stubs.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/network/ndis/ndis/…
==============================================================================
--- trunk/reactos/drivers/network/ndis/ndis/50stubs.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/network/ndis/ndis/50stubs.c [iso-8859-1] Tue Aug 9 06:00:38
2011
@@ -523,26 +523,3 @@
return 0;
}
-
-
-/*
- * @unimplemented
- */
-VOID
-EXPORT
-NdisMDeregisterIoPortRange(
- IN NDIS_HANDLE MiniportAdapterHandle,
- IN UINT InitialPort,
- IN UINT NumberOfPorts,
- IN PVOID PortOffset)
-/*
- * FUNCTION: Releases a register mapping to I/O ports
- * ARGUMENTS:
- * MiniportAdapterHandle = Specifies handle input to MiniportInitialize
- * InitialPort = Bus-relative base port address of a range to be mapped
- * NumberOfPorts = Specifies number of ports to be mapped
- * PortOffset = Pointer to mapped base port address
- */
-{
- UNIMPLEMENTED
-}
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] Tue Aug 9 06:00:38 2011
@@ -898,6 +898,51 @@
return NDIS_STATUS_SUCCESS;
}
+/*
+ * @implemented
+ */
+VOID
+EXPORT
+NdisMDeregisterIoPortRange(IN NDIS_HANDLE MiniportAdapterHandle,
+ IN UINT InitialPort,
+ IN UINT NumberOfPorts,
+ IN PVOID PortOffset)
+/*
+ * FUNCTION: Releases a register mapping to I/O ports
+ * ARGUMENTS:
+ * MiniportAdapterHandle = Specifies handle input to MiniportInitialize
+ * InitialPort = Bus-relative base port address of a range to be mapped
+ * NumberOfPorts = Specifies number of ports to be mapped
+ * PortOffset = Pointer to mapped base port address
+ */
+{
+ PLOGICAL_ADAPTER Adapter = (PLOGICAL_ADAPTER)MiniportAdapterHandle;
+ PHYSICAL_ADDRESS PortAddress = RtlConvertUlongToLargeInteger(InitialPort);
+ PHYSICAL_ADDRESS TranslatedAddress;
+ ULONG AddressSpace = 1;
+
+ NDIS_DbgPrint(MAX_TRACE, ("Called - InitialPort 0x%x, NumberOfPorts 0x%x, Port
Offset 0x%x\n", InitialPort, NumberOfPorts, PortOffset));
+
+ /* Translate the initial port again to find the address space of the translated
address */
+ if(!HalTranslateBusAddress(Adapter->NdisMiniportBlock.BusType,
Adapter->NdisMiniportBlock.BusNumber,
+ PortAddress, &AddressSpace, &TranslatedAddress))
+ {
+ NDIS_DbgPrint(MIN_TRACE, ("Unable to translate address\n"));
+ return;
+ }
+
+ /* Make sure we got the same translation as last time */
+ ASSERT(TranslatedAddress.QuadPart == (ULONG_PTR)PortOffset);
+
+ /* Check if we're in memory space */
+ if (!AddressSpace)
+ {
+ NDIS_DbgPrint(MAX_TRACE, ("Calling MmUnmapIoSpace\n"));
+
+ /* Unmap the memory */
+ MmUnmapIoSpace(PortOffset, NumberOfPorts);
+ }
+}
/*
* @implemented