Author: cgutman
Date: Fri Jun 19 10:47:00 2009
New Revision: 41461
URL:
http://svn.reactos.org/svn/reactos?rev=41461&view=rev
Log:
- Big debugging update
- Also fix some little bugs and reduce code duplication
Modified:
trunk/reactos/drivers/network/ndis/ndis/buffer.c
trunk/reactos/drivers/network/ndis/ndis/config.c
trunk/reactos/drivers/network/ndis/ndis/efilter.c
trunk/reactos/drivers/network/ndis/ndis/hardware.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
trunk/reactos/drivers/network/ndis/ndis/misc.c
trunk/reactos/drivers/network/ndis/ndis/protocol.c
Modified: trunk/reactos/drivers/network/ndis/ndis/buffer.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/network/ndis/ndis/…
==============================================================================
--- trunk/reactos/drivers/network/ndis/ndis/buffer.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/network/ndis/ndis/buffer.c [iso-8859-1] Fri Jun 19 10:47:00
2009
@@ -357,6 +357,7 @@
(*Buffer)->Next = NULL;
*Status = NDIS_STATUS_SUCCESS;
} else {
+ NDIS_DbgPrint(MIN_TRACE, ("IoAllocateMdl failed (%x, %lx)\n",
VirtualAddress, Length));
*Status = NDIS_STATUS_FAILURE;
}
}
@@ -401,43 +402,13 @@
* PoolHandle = Handle returned by NdisAllocatePacketPool
*/
{
- KIRQL OldIrql;
- PNDIS_PACKET Temp;
PNDISI_PACKET_POOL Pool = (PNDISI_PACKET_POOL)PoolHandle;
- NDIS_DbgPrint(MAX_TRACE, ("Status (0x%X) Packet (0x%X) PoolHandle
(0x%X).\n",
- Status, Packet, PoolHandle));
-
- *Packet = NULL;
-
- if (Pool == NULL)
- {
- *Status = NDIS_STATUS_FAILURE;
- return;
- }
-
- KeAcquireSpinLock(&Pool->SpinLock.SpinLock, &OldIrql);
-
- if (Pool->FreeList) {
- Temp = Pool->FreeList;
- Pool->FreeList = (PNDIS_PACKET)Temp->Reserved[0];
-
- KeReleaseSpinLock(&Pool->SpinLock.SpinLock, OldIrql);
-
- RtlZeroMemory(Temp, Pool->PacketLength);
- Temp->Private.Pool = Pool;
- Temp->Private.ValidCounts = TRUE;
- Temp->Private.NdisPacketFlags = fPACKET_ALLOCATED_BY_NDIS;
- Temp->Private.NdisPacketOobOffset = Pool->PacketLength -
- (sizeof(NDIS_PACKET_OOB_DATA) +
- sizeof(NDIS_PACKET_EXTENSION));
-
- *Packet = Temp;
- *Status = NDIS_STATUS_SUCCESS;
- } else {
- *Status = NDIS_STATUS_RESOURCES;
- KeReleaseSpinLock(&Pool->SpinLock.SpinLock, OldIrql);
- }
+ KeAcquireSpinLock(&Pool->SpinLock.SpinLock, &Pool->SpinLock.OldIrql);
+ NdisDprAllocatePacketNonInterlocked(Status,
+ Packet,
+ PoolHandle);
+ KeReleaseSpinLock(&Pool->SpinLock.SpinLock, Pool->SpinLock.OldIrql);
}
@@ -499,6 +470,7 @@
if (NumberOfDescriptors > 0xffff)
{
+ NDIS_DbgPrint(MIN_TRACE, ("Invalid number of descriptors (%lx)\n"))
*Status = NDIS_STATUS_RESOURCES;
}
else
@@ -506,6 +478,7 @@
NumberOfDescriptors += NumberOfOverflowDescriptors;
if (NumberOfDescriptors > 0xffff)
{
+ NDIS_DbgPrint(MIN_TRACE, ("Total number of descriptors > 0xffff
(%lx)\n"));
NumberOfDescriptors = 0xffff;
}
@@ -533,8 +506,10 @@
}
Packet->Reserved[0] = 0;
}
- else
+ else {
+ NDIS_DbgPrint(MIN_TRACE, ("Attempted to allocate a packet pool with
0 descriptors\n"));
Pool->FreeList = NULL;
+ }
*Status = NDIS_STATUS_SUCCESS;
*PoolHandle = (PNDIS_HANDLE)Pool;
@@ -689,6 +664,33 @@
* PoolHandle = Handle returned by NdisAllocatePacketPool
*/
{
+ PNDISI_PACKET_POOL Pool = (PNDISI_PACKET_POOL)PoolHandle;
+
+ KeAcquireSpinLockAtDpcLevel(&Pool->SpinLock.SpinLock);
+ NdisDprAllocatePacketNonInterlocked(Status,
+ Packet,
+ PoolHandle);
+ KeReleaseSpinLockFromDpcLevel(&Pool->SpinLock.SpinLock);
+}
+
+
+/*
+ * @implemented
+ */
+VOID
+EXPORT
+NdisDprAllocatePacketNonInterlocked(
+ OUT PNDIS_STATUS Status,
+ OUT PNDIS_PACKET *Packet,
+ IN NDIS_HANDLE PoolHandle)
+/*
+ * FUNCTION: Allocates a packet at IRQL DISPATCH_LEVEL (w/o synchronization)
+ * ARGUMENTS:
+ * Status = Address of buffer to place status of operation
+ * Packet = Address of buffer to place a pointer to a packet descriptor
+ * PoolHandle = Handle returned by NdisAllocatePacketPool
+ */
+{
PNDIS_PACKET Temp;
PNDISI_PACKET_POOL Pool = (PNDISI_PACKET_POOL)PoolHandle;
@@ -700,16 +702,13 @@
if (Pool == NULL)
{
*Status = NDIS_STATUS_FAILURE;
+ NDIS_DbgPrint(MIN_TRACE, ("Called passed a bad pool handle\n"));
return;
}
-
- KeAcquireSpinLockAtDpcLevel(&Pool->SpinLock.SpinLock);
if (Pool->FreeList) {
Temp = Pool->FreeList;
Pool->FreeList = (PNDIS_PACKET)Temp->Reserved[0];
-
- KeReleaseSpinLockFromDpcLevel(&Pool->SpinLock.SpinLock);
RtlZeroMemory(Temp, Pool->PacketLength);
Temp->Private.Pool = Pool;
@@ -722,58 +721,7 @@
*Packet = Temp;
*Status = NDIS_STATUS_SUCCESS;
} else {
- *Status = NDIS_STATUS_RESOURCES;
- KeReleaseSpinLockFromDpcLevel(&Pool->SpinLock.SpinLock);
- }
-}
-
-
-/*
- * @implemented
- */
-VOID
-EXPORT
-NdisDprAllocatePacketNonInterlocked(
- OUT PNDIS_STATUS Status,
- OUT PNDIS_PACKET *Packet,
- IN NDIS_HANDLE PoolHandle)
-/*
- * FUNCTION: Allocates a packet at IRQL DISPATCH_LEVEL (w/o synchronization)
- * ARGUMENTS:
- * Status = Address of buffer to place status of operation
- * Packet = Address of buffer to place a pointer to a packet descriptor
- * PoolHandle = Handle returned by NdisAllocatePacketPool
- */
-{
- PNDIS_PACKET Temp;
- PNDISI_PACKET_POOL Pool = (PNDISI_PACKET_POOL)PoolHandle;
-
- NDIS_DbgPrint(MAX_TRACE, ("Status (0x%X) Packet (0x%X) PoolHandle
(0x%X).\n",
- Status, Packet, PoolHandle));
-
- *Packet = NULL;
-
- if (Pool == NULL)
- {
- *Status = NDIS_STATUS_FAILURE;
- return;
- }
-
- if (Pool->FreeList) {
- Temp = Pool->FreeList;
- Pool->FreeList = (PNDIS_PACKET)Temp->Reserved[0];
-
- RtlZeroMemory(Temp, Pool->PacketLength);
- Temp->Private.Pool = Pool;
- Temp->Private.ValidCounts = TRUE;
- Temp->Private.NdisPacketFlags = fPACKET_ALLOCATED_BY_NDIS;
- Temp->Private.NdisPacketOobOffset = Pool->PacketLength -
- (sizeof(NDIS_PACKET_OOB_DATA) +
- sizeof(NDIS_PACKET_EXTENSION));
-
- *Packet = Temp;
- *Status = NDIS_STATUS_SUCCESS;
- } else {
+ NDIS_DbgPrint(MIN_TRACE, ("No more free descriptors\n"));
*Status = NDIS_STATUS_RESOURCES;
}
}
@@ -792,12 +740,11 @@
* Packet = Pointer to packet to free
*/
{
- NDIS_DbgPrint(MAX_TRACE, ("Packet (0x%X).\n", Packet));
-
-
KeAcquireSpinLockAtDpcLevel(&((NDISI_PACKET_POOL*)Packet->Private.Pool)->SpinLock.SpinLock);
- Packet->Reserved[0] =
(ULONG_PTR)((NDISI_PACKET_POOL*)Packet->Private.Pool)->FreeList;
- ((NDISI_PACKET_POOL*)Packet->Private.Pool)->FreeList = Packet;
-
KeReleaseSpinLockFromDpcLevel(&((NDISI_PACKET_POOL*)Packet->Private.Pool)->SpinLock.SpinLock);
+ PNDISI_PACKET_POOL Pool = (PNDISI_PACKET_POOL)Packet->Private.Pool;
+
+ KeAcquireSpinLockAtDpcLevel(&Pool->SpinLock.SpinLock);
+ NdisDprFreePacketNonInterlocked(Packet);
+ KeReleaseSpinLockFromDpcLevel(&Pool->SpinLock.SpinLock);
}
@@ -885,14 +832,11 @@
* Packet = Pointer to packet descriptor
*/
{
- KIRQL OldIrql;
-
- NDIS_DbgPrint(MAX_TRACE, ("Packet (0x%X).\n", Packet));
-
-
KeAcquireSpinLock(&((NDISI_PACKET_POOL*)Packet->Private.Pool)->SpinLock.SpinLock,
&OldIrql);
- Packet->Reserved[0] =
(ULONG_PTR)((NDISI_PACKET_POOL*)Packet->Private.Pool)->FreeList;
- ((NDISI_PACKET_POOL*)Packet->Private.Pool)->FreeList = Packet;
-
KeReleaseSpinLock(&((NDISI_PACKET_POOL*)Packet->Private.Pool)->SpinLock.SpinLock,
OldIrql);
+ PNDISI_PACKET_POOL Pool = (PNDISI_PACKET_POOL)Packet->Private.Pool;
+
+ KeAcquireSpinLock(&Pool->SpinLock.SpinLock, &Pool->SpinLock.OldIrql);
+ NdisDprFreePacketNonInterlocked(Packet);
+ KeReleaseSpinLock(&Pool->SpinLock.SpinLock, Pool->SpinLock.OldIrql);
}
@@ -951,6 +895,7 @@
*_FirstBufferVA = MmGetSystemAddressForMdl(Buffer);
Buffer = Buffer->Next;
} else {
+ NDIS_DbgPrint(MIN_TRACE, ("No buffers linked to this packet\n"));
*_FirstBufferLength = 0;
*_FirstBufferVA = NULL;
}
@@ -986,6 +931,7 @@
*_FirstBufferVA = MmGetSystemAddressForMdlSafe(Buffer, Priority);
Buffer = Buffer->Next;
} else {
+ NDIS_DbgPrint(MIN_TRACE, ("No buffers linked to this packet\n"));
*_FirstBufferLength = 0;
*_FirstBufferVA = NULL;
}
@@ -1088,6 +1034,7 @@
&NdisBuffer,
NULL);
if (!NdisBuffer) {
+ NDIS_DbgPrint(MIN_TRACE, ("No buffer to unchain\n"));
*Buffer = NULL;
return;
}
@@ -1136,6 +1083,7 @@
&NdisBuffer,
NULL);
if (!NdisBuffer) {
+ NDIS_DbgPrint(MIN_TRACE, ("No buffer to unchain\n"));
*Buffer = NULL;
return;
}
@@ -1182,6 +1130,7 @@
*Buffer = IoAllocateMdl(CurrentVa, Length, FALSE, FALSE, NULL);
if (!*Buffer)
{
+ NDIS_DbgPrint(MIN_TRACE, ("IoAllocateMdl failed (%x, %lx)\n",
CurrentVa, Length));
*Status = NDIS_STATUS_FAILURE;
return;
}
Modified: trunk/reactos/drivers/network/ndis/ndis/config.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/network/ndis/ndis/…
==============================================================================
--- trunk/reactos/drivers/network/ndis/ndis/config.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/network/ndis/ndis/config.c [iso-8859-1] Fri Jun 19 10:47:00
2009
@@ -68,6 +68,8 @@
PVOID Data;
WCHAR Buff[25];
+ NDIS_DbgPrint(MAX_TRACE, ("Called.\n"));
+
/* reset parameter type to standard reg types */
switch(ParameterType)
{
@@ -114,9 +116,10 @@
*Status =
ZwSetValueKey(((PMINIPORT_CONFIGURATION_CONTEXT)ConfigurationHandle)->Handle,
Keyword, 0, ParameterType, Data, DataSize);
- if(*Status != STATUS_SUCCESS)
- *Status = NDIS_STATUS_FAILURE;
- else
+ if(*Status != STATUS_SUCCESS) {
+ NDIS_DbgPrint(MIN_TRACE, ("ZwSetValueKey failed (%x)\n", *Status));
+ *Status = NDIS_STATUS_FAILURE;
+ } else
*Status = NDIS_STATUS_SUCCESS;
}
@@ -189,7 +192,7 @@
DUPLICATE_SAME_ACCESS);
if(!NT_SUCCESS(*Status))
{
- NDIS_DbgPrint(MID_TRACE, ("Failed to open registry configuration for this
miniport\n"));
+ NDIS_DbgPrint(MIN_TRACE, ("Failed to open registry configuration for this
miniport\n"));
*Status = NDIS_STATUS_FAILURE;
return;
}
@@ -263,6 +266,7 @@
if(*Status != NDIS_STATUS_SUCCESS)
{
+ NDIS_DbgPrint(MIN_TRACE, ("ZwOpenKey failed (%x)\n", *Status));
*ConfigurationHandle = NULL;
*Status = NDIS_STATUS_FAILURE;
return;
@@ -330,7 +334,7 @@
ParameterType != NdisParameterBinary
)
{
- NDIS_DbgPrint(MID_TRACE,("unsupported parameter type\n"));
+ NDIS_DbgPrint(MIN_TRACE,("unsupported parameter type\n"));
*Status = NDIS_STATUS_NOT_SUPPORTED;
return;
}
@@ -339,7 +343,7 @@
if (ConfigurationContext == NULL)
{
- NDIS_DbgPrint(MID_TRACE,("invalid parameter ConfigurationContext
(0x%x)\n",ConfigurationContext));
+ NDIS_DbgPrint(MIN_TRACE,("invalid parameter ConfigurationContext
(0x%x)\n",ConfigurationContext));
return;
}
@@ -460,7 +464,7 @@
*Status = ZwQueryValueKey(ConfigurationContext->Handle, Keyword,
KeyValuePartialInformation, NULL, 0, &KeyDataLength);
if(*Status != STATUS_BUFFER_OVERFLOW && *Status != STATUS_BUFFER_TOO_SMALL
&& *Status != STATUS_SUCCESS)
{
- NDIS_DbgPrint(MID_TRACE,("ZwQueryValueKey #1 failed for %wZ, status
0x%x\n", Keyword, *Status));
+ NDIS_DbgPrint(MIN_TRACE,("ZwQueryValueKey #1 failed for %wZ, status
0x%x\n", Keyword, *Status));
*Status = NDIS_STATUS_FAILURE;
return;
}
@@ -480,7 +484,7 @@
if(*Status != STATUS_SUCCESS)
{
ExFreePool(KeyInformation);
- NDIS_DbgPrint(MID_TRACE,("ZwQueryValueKey #2 failed for %wZ, status
0x%x\n", Keyword, *Status));
+ NDIS_DbgPrint(MIN_TRACE,("ZwQueryValueKey #2 failed for %wZ, status
0x%x\n", Keyword, *Status));
*Status = NDIS_STATUS_FAILURE;
return;
}
@@ -551,7 +555,7 @@
if(KeyInformation->Type != REG_SZ && KeyInformation->Type !=
REG_MULTI_SZ)
{
- NDIS_DbgPrint(MID_TRACE,("requested type does not match actual value
type\n"));
+ NDIS_DbgPrint(MIN_TRACE,("requested type does not match actual value
type\n"));
ExFreePool(KeyInformation);
*ParameterValue = NULL;
*Status = NDIS_STATUS_FAILURE;
@@ -721,6 +725,7 @@
NdisReadConfiguration(Status, &ParameterValue, ConfigurationHandle, &Keyword,
NdisParameterString);
if(*Status != NDIS_STATUS_SUCCESS)
{
+ NDIS_DbgPrint(MIN_TRACE, ("NdisReadConfiguration failed (%x)\n",
*Status));
*Status = NDIS_STATUS_FAILURE;
return;
}
@@ -808,6 +813,7 @@
*Status = ZwEnumerateKey(ConfigurationHandle, Index, KeyBasicInformation, NULL, 0,
&KeyInformationLength);
if(*Status != STATUS_BUFFER_TOO_SMALL && *Status != STATUS_BUFFER_OVERFLOW
&& *Status != STATUS_SUCCESS)
{
+ NDIS_DbgPrint(MIN_TRACE, ("ZwEnumerateKey failed (%x)\n", *Status));
*Status = NDIS_STATUS_FAILURE;
return;
}
@@ -825,6 +831,7 @@
if(*Status != STATUS_SUCCESS)
{
+ NDIS_DbgPrint(MIN_TRACE, ("ZwEnumerateKey failed (%x)\n", *Status));
ExFreePool(KeyInformation);
*Status = NDIS_STATUS_FAILURE;
return;
@@ -842,6 +849,7 @@
if(*Status != STATUS_SUCCESS)
{
+ NDIS_DbgPrint(MIN_TRACE, ("ZwOpenKey failed (%x)\n", *Status));
*Status = NDIS_STATUS_FAILURE;
return;
}
@@ -901,6 +909,7 @@
if(*Status != STATUS_SUCCESS)
{
+ NDIS_DbgPrint(MIN_TRACE, ("ZwOpenKey failed (%x)\n", *Status));
*Status = NDIS_STATUS_FAILURE;
return;
}
Modified: trunk/reactos/drivers/network/ndis/ndis/efilter.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/network/ndis/ndis/…
==============================================================================
--- trunk/reactos/drivers/network/ndis/ndis/efilter.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/network/ndis/ndis/efilter.c [iso-8859-1] Fri Jun 19 10:47:00
2009
@@ -44,8 +44,12 @@
*Filter = (PETH_FILTER)NewFilter;
return TRUE;
}
- *Filter = NULL;
- return FALSE;
+ else
+ {
+ NDIS_DbgPrint(MIN_TRACE, ("Insufficient resources\n"));
+ *Filter = NULL;
+ return FALSE;
+ }
}
@@ -88,7 +92,10 @@
/* Not sure if this is a valid thing to do, but we do arrive here early
* in the boot process with Filter NULL. We need to investigate whether
* this should be handled or not allowed. */
- if( !Filter ) return;
+ if( !Filter ) {
+ NDIS_DbgPrint(MIN_TRACE, ("Filter is NULL\n"));
+ return;
+ }
MiniIndicateData((PLOGICAL_ADAPTER)((PETHI_FILTER)Filter)->Miniport,
MacReceiveContext,
HeaderBuffer,
@@ -118,7 +125,10 @@
NDIS_DbgPrint(DEBUG_MINIPORT, ("Called.\n"));
- if( !Filter ) return;
+ if( !Filter ) {
+ NDIS_DbgPrint(MIN_TRACE, ("Filter is NULL\n"));
+ return;
+ }
Adapter = (PLOGICAL_ADAPTER)((PETHI_FILTER)Filter)->Miniport;
Modified: trunk/reactos/drivers/network/ndis/ndis/hardware.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/network/ndis/ndis/…
==============================================================================
--- trunk/reactos/drivers/network/ndis/ndis/hardware.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/network/ndis/ndis/hardware.c [iso-8859-1] Fri Jun 19 10:47:00
2009
@@ -68,6 +68,7 @@
if (Adapter->NdisMiniportBlock.BusType != NdisInterfacePci ||
Adapter->NdisMiniportBlock.AllocatedResources == NULL)
{
+ NDIS_DbgPrint(MIN_TRACE, ("Bad bus type or no resources\n"));
*AssignedResources = NULL;
return NDIS_STATUS_FAILURE;
}
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] Fri Jun 19 10:47:00 2009
@@ -68,12 +68,14 @@
NDIS_DbgPrint(MAX_TRACE, ("Called. Interrupt (0x%X)\n", NdisInterrupt));
if (NdisInterrupt->IsrRequested) {
+ NDIS_DbgPrint(MAX_TRACE, ("Calling MiniportISR\n"));
(*NdisMiniportBlock->DriverHandle->MiniportCharacteristics.ISRHandler)(
&InterruptRecognized,
&QueueMiniportHandleInterrupt,
NdisMiniportBlock->MiniportAdapterContext);
} else if
(NdisMiniportBlock->DriverHandle->MiniportCharacteristics.DisableInterruptHandler)
{
+ NDIS_DbgPrint(MAX_TRACE, ("Calling MiniportDisableInterrupt\n"));
(*NdisMiniportBlock->DriverHandle->MiniportCharacteristics.DisableInterruptHandler)(
NdisMiniportBlock->MiniportAdapterContext);
QueueMiniportHandleInterrupt = TRUE;
@@ -276,8 +278,10 @@
ASSERT(Adapter);
/* only bus masters may call this routine */
- if(!(Adapter->NdisMiniportBlock.Flags & NDIS_ATTRIBUTE_BUS_MASTER))
+ if(!(Adapter->NdisMiniportBlock.Flags & NDIS_ATTRIBUTE_BUS_MASTER)) {
+ NDIS_DbgPrint(MIN_TRACE, ("Not a bus master\n"));
return NDIS_STATUS_NOT_SUPPORTED;
+ }
DeviceObject = Adapter->NdisMiniportBlock.DeviceObject;
@@ -564,10 +568,11 @@
ASSERT(Adapter);
/* only bus masters may call this routine */
- ASSERT(Adapter->NdisMiniportBlock.Flags & NDIS_ATTRIBUTE_BUS_MASTER);
if(!(Adapter->NdisMiniportBlock.Flags & NDIS_ATTRIBUTE_BUS_MASTER) ||
- Adapter->NdisMiniportBlock.SystemAdapterObject == NULL)
+ Adapter->NdisMiniportBlock.SystemAdapterObject == NULL) {
+ NDIS_DbgPrint(MIN_TRACE, ("Not bus master or bad adapter object\n"));
return;
+ }
MapRegistersPerBaseRegister = ((Adapter->NdisMiniportBlock.MaximumPhysicalMapping -
2) / PAGE_SIZE) + 2;
@@ -717,12 +722,15 @@
DmaBlock = ExAllocatePool(NonPagedPool, sizeof(NDIS_DMA_BLOCK));
- if (!DmaBlock)
+ if (!DmaBlock) {
+ NDIS_DbgPrint(MIN_TRACE, ("Insufficient resources\n"));
return NDIS_STATUS_RESOURCES;
+ }
DmaBlock->SystemAdapterObject =
(PVOID)IoGetDmaAdapter(Adapter->NdisMiniportBlock.PhysicalDeviceObject,
&DeviceDesc, &MapRegisters);
if (!DmaBlock->SystemAdapterObject) {
+ NDIS_DbgPrint(MIN_TRACE, ("Insufficient resources\n"));
ExFreePool(DmaBlock);
return NDIS_STATUS_RESOURCES;
}
@@ -882,8 +890,10 @@
*PortOffset = MmMapIoSpace(TranslatedAddress, NumberOfPorts, MmNonCached);
NDIS_DbgPrint(MAX_TRACE, ("Returning 0x%x for port range\n", *PortOffset));
- if(!*PortOffset)
+ if(!*PortOffset) {
+ NDIS_DbgPrint(MIN_TRACE, ("MmMapIoSpace failed\n"));
return NDIS_STATUS_RESOURCES;
+ }
return NDIS_STATUS_SUCCESS;
}
@@ -941,8 +951,10 @@
NDIS_DbgPrint(MAX_TRACE, ("Called.\n"));
- if (!(Adapter->NdisMiniportBlock.Flags & NDIS_ATTRIBUTE_BUS_MASTER))
+ if (!(Adapter->NdisMiniportBlock.Flags & NDIS_ATTRIBUTE_BUS_MASTER)) {
+ NDIS_DbgPrint(MIN_TRACE, ("Not a bus master\n"));
return NDIS_STATUS_NOT_SUPPORTED;
+ }
RtlZeroMemory(&DeviceDesc, sizeof(DEVICE_DESCRIPTION));
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] Fri Jun 19 10:47:00
2009
@@ -41,8 +41,10 @@
Block = ExAllocatePoolWithTag(NonPagedPool, Length, Tag);
*VirtualAddress = Block;
- if (!Block)
+ if (!Block) {
+ NDIS_DbgPrint(MIN_TRACE, ("Failed to allocate memory (%lx)\n", Length));
return NDIS_STATUS_FAILURE;
+ }
return NDIS_STATUS_SUCCESS;
}
@@ -94,8 +96,10 @@
*VirtualAddress = ExAllocatePool(NonPagedPool, Length);
}
- if (!*VirtualAddress)
+ if (!*VirtualAddress) {
+ NDIS_DbgPrint(MIN_TRACE, ("Allocation failed (%lx, %lx)\n", MemoryFlags,
Length));
return NDIS_STATUS_FAILURE;
+ }
return NDIS_STATUS_SUCCESS;
}
@@ -241,7 +245,7 @@
if(!Memory)
{
- NDIS_DbgPrint(MID_TRACE, ("Insufficient resources\n"));
+ NDIS_DbgPrint(MIN_TRACE, ("Insufficient resources\n"));
return;
}
@@ -319,7 +323,7 @@
if(!Memory)
{
- NDIS_DbgPrint(MID_TRACE, ("Insufficient resources\n"));
+ NDIS_DbgPrint(MIN_TRACE, ("Insufficient resources\n"));
return NDIS_STATUS_FAILURE;
}
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] Fri Jun 19 10:47:00
2009
@@ -210,7 +210,7 @@
if (CurrentEntry == &Adapter->ProtocolListHead)
{
- NDIS_DbgPrint(DEBUG_MINIPORT, ("WARNING: No upper protocol
layer.\n"));
+ NDIS_DbgPrint(MIN_TRACE, ("WARNING: No upper protocol layer.\n"));
}
while (CurrentEntry != &Adapter->ProtocolListHead)
@@ -523,13 +523,13 @@
#if DBG
if(!Adapter)
{
- NDIS_DbgPrint(MID_TRACE, ("Adapter object was null\n"));
+ NDIS_DbgPrint(MIN_TRACE, ("Adapter object was null\n"));
return FALSE;
}
if(!Packet)
{
- NDIS_DbgPrint(MID_TRACE, ("Packet was null\n"));
+ NDIS_DbgPrint(MIN_TRACE, ("Packet was null\n"));
return FALSE;
}
#endif
@@ -538,7 +538,7 @@
if (!NdisBuffer)
{
- NDIS_DbgPrint(MID_TRACE, ("Packet contains no buffers.\n"));
+ NDIS_DbgPrint(MIN_TRACE, ("Packet contains no buffers.\n"));
return FALSE;
}
@@ -560,7 +560,7 @@
if (BufferLength < Length)
{
- NDIS_DbgPrint(MID_TRACE, ("Buffer is too small.\n"));
+ NDIS_DbgPrint(MIN_TRACE, ("Buffer is too small.\n"));
return FALSE;
}
@@ -597,7 +597,7 @@
if(IsListEmpty(&AdapterListHead))
{
- NDIS_DbgPrint(DEBUG_MINIPORT, ("No registered miniports for protocol to bind
to\n"));
+ NDIS_DbgPrint(MIN_TRACE, ("No registered miniports for protocol to bind
to\n"));
return NULL;
}
@@ -632,7 +632,7 @@
}
else
{
- NDIS_DbgPrint(DEBUG_MINIPORT, ("Leaving (adapter not found).\n"));
+ NDIS_DbgPrint(MIN_TRACE, ("Leaving (adapter not found for %wZ).\n",
AdapterName));
}
return Adapter;
@@ -654,13 +654,8 @@
* Size = Size of the passed buffer
* Buffer = Buffer for the output
* BytesWritten = Address of buffer to place number of bytes written
- * NOTES:
- * If the specified buffer is too small, a new buffer is allocated,
- * and the query is attempted again
* RETURNS:
* Status of operation
- * TODO:
- * Is there any way to use the buffer provided by the protocol?
*/
{
NDIS_STATUS NdisStatus;
@@ -669,7 +664,10 @@
NDIS_DbgPrint(DEBUG_MINIPORT, ("Called.\n"));
NdisRequest = ExAllocatePool(NonPagedPool, sizeof(NDIS_REQUEST));
- if (!NdisRequest) return NDIS_STATUS_RESOURCES;
+ if (!NdisRequest) {
+ NDIS_DbgPrint(MIN_TRACE, ("Insufficient resources\n"));
+ return NDIS_STATUS_RESOURCES;
+ }
RtlZeroMemory(NdisRequest, sizeof(NDIS_REQUEST));
@@ -903,6 +901,8 @@
}
else
{
+ NDIS_DbgPrint(MIN_TRACE, ("No work item to dequeue\n"));
+
return NDIS_STATUS_FAILURE;
}
}
@@ -956,6 +956,7 @@
break;
default:
+ NDIS_DbgPrint(MIN_TRACE, ("Bad request type\n"));
Status = NDIS_STATUS_FAILURE;
}
}
@@ -1747,6 +1748,7 @@
ExAllocatePool(PagedPool, ResourceListSize);
if (Adapter->NdisMiniportBlock.AllocatedResources == NULL)
{
+ NDIS_DbgPrint(MIN_TRACE, ("Insufficient resources\n"));
ExInterlockedRemoveEntryList( &Adapter->ListEntry, &AdapterListLock );
return STATUS_INSUFFICIENT_RESOURCES;
}
@@ -1755,6 +1757,7 @@
ExAllocatePool(PagedPool, ResourceListSize);
if (!Adapter->NdisMiniportBlock.Resources)
{
+ NDIS_DbgPrint(MIN_TRACE, ("Insufficient resources\n"));
ExFreePool(Adapter->NdisMiniportBlock.AllocatedResources);
ExInterlockedRemoveEntryList(&Adapter->ListEntry,
&AdapterListLock);
return STATUS_INSUFFICIENT_RESOURCES;
@@ -1781,6 +1784,7 @@
ExAllocatePool(PagedPool, ResourceListSize);
if (Adapter->NdisMiniportBlock.AllocatedResourcesTranslated == NULL)
{
+ NDIS_DbgPrint(MIN_TRACE, ("Insufficient resources\n"));
ExInterlockedRemoveEntryList( &Adapter->ListEntry, &AdapterListLock );
return STATUS_INSUFFICIENT_RESOURCES;
}
@@ -1890,7 +1894,7 @@
if (SelectedMediumIndex >= MEDIA_ARRAY_SIZE)
{
- NDIS_DbgPrint(MIN_TRACE, ("MiniportInitialize() failed for an
adapter\n"));
+ NDIS_DbgPrint(MIN_TRACE, ("MiniportInitialize() selected a bad
index\n"));
ExInterlockedRemoveEntryList( &Adapter->ListEntry, &AdapterListLock );
return NDIS_STATUS_UNSUPPORTED_MEDIA;
}
@@ -1912,7 +1916,7 @@
if (NdisStatus != NDIS_STATUS_SUCCESS)
{
ExInterlockedRemoveEntryList( &Adapter->ListEntry,
&AdapterListLock );
- NDIS_DbgPrint(MAX_TRACE, ("MiniQueryInformation failed (%x)\n",
NdisStatus));
+ NDIS_DbgPrint(MIN_TRACE, ("MiniQueryInformation failed (%x)\n",
NdisStatus));
return NdisStatus;
}
@@ -1930,14 +1934,13 @@
/* FIXME: Support other types of media */
NDIS_DbgPrint(MIN_TRACE, ("error: unsupported media\n"));
ASSERT(FALSE);
-/* FIXME - KeReleaseSpinLock(&Adapter->NdisMiniportBlock.Lock, OldIrql); */
ExInterlockedRemoveEntryList( &Adapter->ListEntry, &AdapterListLock );
return STATUS_UNSUCCESSFUL;
}
if (NdisStatus != NDIS_STATUS_SUCCESS)
{
- NDIS_DbgPrint(MAX_TRACE, ("couldn't create filter (%x)\n",
NdisStatus));
+ NDIS_DbgPrint(MIN_TRACE, ("couldn't create filter (%x)\n",
NdisStatus));
return NdisStatus;
}
@@ -2100,6 +2103,8 @@
{
Status = NdisIPnPStartDevice(DeviceObject, Irp);
}
+ else
+ NDIS_DbgPrint(MIN_TRACE, ("Lower driver failed device
start\n"));
Irp->IoStatus.Status = Status;
IoCompleteRequest(Irp, IO_NO_INCREMENT);
break;
@@ -2110,6 +2115,8 @@
{
Status = NdisIPnPStopDevice(DeviceObject, Irp);
}
+ else
+ NDIS_DbgPrint(MIN_TRACE, ("Lower driver failed device stop\n"));
Irp->IoStatus.Status = Status;
IoCompleteRequest(Irp, IO_NO_INCREMENT);
break;
@@ -2176,8 +2183,8 @@
MiniportPtr = IoGetDriverObjectExtension(DriverObject,
(PVOID)TAG('D','I','M','N'));
if (MiniportPtr == NULL)
{
- NDIS_DbgPrint(DEBUG_MINIPORT, ("Can't get driver object
extension.\n"));
- return STATUS_UNSUCCESSFUL;
+ NDIS_DbgPrint(MIN_TRACE, ("Can't get driver object extension.\n"));
+ return NDIS_STATUS_FAILURE;
}
Miniport = *MiniportPtr;
@@ -2193,7 +2200,7 @@
0, NULL, &DriverKeyLength);
if (Status != STATUS_BUFFER_TOO_SMALL && Status != STATUS_BUFFER_OVERFLOW
&& Status != STATUS_SUCCESS)
{
- NDIS_DbgPrint(DEBUG_MINIPORT, ("Can't get miniport driver key
length.\n"));
+ NDIS_DbgPrint(MIN_TRACE, ("Can't get miniport driver key
length.\n"));
return Status;
}
@@ -2201,7 +2208,7 @@
sizeof(ClassKeyName) + sizeof(LinkageKeyName));
if (LinkageKeyBuffer == NULL)
{
- NDIS_DbgPrint(DEBUG_MINIPORT, ("Can't allocate memory for driver key
name.\n"));
+ NDIS_DbgPrint(MIN_TRACE, ("Can't allocate memory for driver key
name.\n"));
return STATUS_INSUFFICIENT_RESOURCES;
}
@@ -2211,7 +2218,7 @@
&DriverKeyLength);
if (!NT_SUCCESS(Status))
{
- NDIS_DbgPrint(DEBUG_MINIPORT, ("Can't get miniport driver key.\n"));
+ NDIS_DbgPrint(MIN_TRACE, ("Can't get miniport driver key.\n"));
ExFreePool(LinkageKeyBuffer);
return Status;
}
@@ -2239,7 +2246,7 @@
ExFreePool(LinkageKeyBuffer);
if (!NT_SUCCESS(Status))
{
- NDIS_DbgPrint(DEBUG_MINIPORT, ("Can't get miniport device name.
(%x)\n", Status));
+ NDIS_DbgPrint(MIN_TRACE, ("Can't get miniport device name. (%x)\n",
Status));
return Status;
}
@@ -2428,7 +2435,7 @@
sizeof(PNDIS_M_DRIVER_BLOCK),
(PVOID*)&MiniportPtr);
if (!NT_SUCCESS(Status))
{
- NDIS_DbgPrint(DEBUG_MINIPORT, ("Can't allocate driver object
extension.\n"));
+ NDIS_DbgPrint(MIN_TRACE, ("Can't allocate driver object
extension.\n"));
return NDIS_STATUS_RESOURCES;
}
@@ -2718,8 +2725,10 @@
AdapterName.Length = 0;
AdapterName.MaximumLength =
Adapter->NdisMiniportBlock.MiniportName.MaximumLength;
AdapterName.Buffer = ExAllocatePool(PagedPool, AdapterName.MaximumLength);
- if (!AdapterName.Buffer)
+ if (!AdapterName.Buffer) {
+ NDIS_DbgPrint(MIN_TRACE, ("Insufficient resources\n"));
return NDIS_STATUS_RESOURCES;
+ }
RtlCopyUnicodeString(&AdapterName,
&Adapter->NdisMiniportBlock.MiniportName);
@@ -2865,6 +2874,7 @@
if (!NT_SUCCESS(Status))
{
+ NDIS_DbgPrint(MIN_TRACE, ("IoCreateDevice failed (%x)\n", Status));
return Status;
}
@@ -2872,6 +2882,7 @@
if (!NT_SUCCESS(Status))
{
+ NDIS_DbgPrint(MIN_TRACE, ("IoCreateSymbolicLink failed (%x)\n",
Status));
IoDeleteDevice(DeviceObject);
return Status;
}
@@ -2880,6 +2891,7 @@
if (!DeviceBlock)
{
+ NDIS_DbgPrint(MIN_TRACE, ("Insufficient resources\n"));
IoDeleteDevice(DeviceObject);
IoDeleteSymbolicLink(SymbolicName);
return NDIS_STATUS_RESOURCES;
Modified: trunk/reactos/drivers/network/ndis/ndis/misc.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/network/ndis/ndis/…
==============================================================================
--- trunk/reactos/drivers/network/ndis/ndis/misc.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/network/ndis/ndis/misc.c [iso-8859-1] Fri Jun 19 10:47:00 2009
@@ -158,6 +158,7 @@
if (HandleObject->Mapped)
{
/* If a file already mapped we will return an error code */
+ NDIS_DbgPrint(MIN_TRACE, ("File already mapped\n"));
*Status = NDIS_STATUS_ALREADY_MAPPED;
return;
}
@@ -247,6 +248,7 @@
if ( !FullFileName.Buffer )
{
+ NDIS_DbgPrint(MIN_TRACE, ("Insufficient resources\n"));
*Status = NDIS_STATUS_RESOURCES;
goto cleanup;
}
@@ -254,6 +256,7 @@
FileHandleObject = ExAllocatePool ( NonPagedPool, sizeof(NDIS_HANDLE_OBJECT) );
if ( !FileHandleObject )
{
+ NDIS_DbgPrint(MIN_TRACE, ("Insufficient resources\n"));
*Status = NDIS_STATUS_RESOURCES;
goto cleanup;
}
@@ -263,6 +266,7 @@
*Status = RtlAppendUnicodeStringToString ( &FullFileName, FileName );
if ( !NT_SUCCESS(*Status) )
{
+ NDIS_DbgPrint(MIN_TRACE, ("RtlAppendUnicodeStringToString failed (%x)\n",
*Status));
*Status = NDIS_STATUS_FAILURE;
goto cleanup;
}
@@ -288,6 +292,7 @@
if ( !NT_SUCCESS(*Status) )
{
+ NDIS_DbgPrint(MIN_TRACE, ("ZwCreateFile failed (%x)\n", *Status));
*Status = NDIS_STATUS_FAILURE;
}
Modified: trunk/reactos/drivers/network/ndis/ndis/protocol.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/network/ndis/ndis/…
==============================================================================
--- trunk/reactos/drivers/network/ndis/ndis/protocol.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/network/ndis/ndis/protocol.c [iso-8859-1] Fri Jun 19 10:47:00
2009
@@ -36,8 +36,10 @@
PNET_PNP_EVENT PnPEvent;
PnPEvent = ExAllocatePool(PagedPool, sizeof(NET_PNP_EVENT));
- if (!PnPEvent)
+ if (!PnPEvent) {
+ NDIS_DbgPrint(MIN_TRACE, ("Insufficient resources\n"));
return NULL;
+ }
RtlZeroMemory(PnPEvent, sizeof(NET_PNP_EVENT));
@@ -48,6 +50,7 @@
PnPEvent->Buffer = ExAllocatePool(PagedPool, EventBufferLength);
if (!PnPEvent->Buffer)
{
+ NDIS_DbgPrint(MIN_TRACE, ("Insufficient resources\n"));
ExFreePool(PnPEvent);
return NULL;
}
@@ -117,8 +120,10 @@
ASSERT(Stack->Parameters.Power.Type == DevicePowerState);
PnPEvent = ProSetupPnPEvent(NetEventSetPower, &Stack->Parameters.Power.State,
sizeof(NDIS_DEVICE_POWER_STATE));
- if (!PnPEvent)
+ if (!PnPEvent) {
+ NDIS_DbgPrint(MIN_TRACE, ("Insufficient resources\n"));
return NDIS_STATUS_RESOURCES;
+ }
return ProSendAndFreePnPEvent(Adapter, PnPEvent, Irp);
}
@@ -136,8 +141,10 @@
ASSERT(Stack->Parameters.Power.Type == DevicePowerState);
PnPEvent = ProSetupPnPEvent(NetEventQueryPower, &Stack->Parameters.Power.State,
sizeof(NDIS_DEVICE_POWER_STATE));
- if (!PnPEvent)
+ if (!PnPEvent) {
+ NDIS_DbgPrint(MIN_TRACE, ("Insufficient resources\n"));
return NDIS_STATUS_RESOURCES;
+ }
return ProSendAndFreePnPEvent(Adapter, PnPEvent, Irp);
}
@@ -153,8 +160,10 @@
PNET_PNP_EVENT PnPEvent;
PnPEvent = ProSetupPnPEvent(NetEventQueryRemoveDevice, NULL, 0);
- if (!PnPEvent)
+ if (!PnPEvent) {
+ NDIS_DbgPrint(MIN_TRACE, ("Insufficient resources\n"));
return NDIS_STATUS_RESOURCES;
+ }
return ProSendAndFreePnPEvent(Adapter, PnPEvent, Irp);
}
@@ -169,8 +178,10 @@
PNET_PNP_EVENT PnPEvent;
PnPEvent = ProSetupPnPEvent(NetEventCancelRemoveDevice, NULL, 0);
- if (!PnPEvent)
+ if (!PnPEvent) {
+ NDIS_DbgPrint(MIN_TRACE, ("Insufficient resources\n"));
return NDIS_STATUS_RESOURCES;
+ }
return ProSendAndFreePnPEvent(Adapter, PnPEvent, Irp);
}
@@ -198,7 +209,10 @@
{
PROTOCOL_BINDING *Protocol = (PROTOCOL_BINDING *)BindAdapterContext;
- if (!NT_SUCCESS(Status)) return;
+ if (!NT_SUCCESS(Status)) {
+ NDIS_DbgPrint(MIN_TRACE, ("Binding failed (%x)\n", Status));
+ return;
+ }
/* Put protocol binding struct on global list */
ExInterlockedInsertTailList(&ProtocolListHead, &Protocol->ListEntry,
&ProtocolListLock);
@@ -219,7 +233,10 @@
PROTOCOL_BINDING *Protocol = (PROTOCOL_BINDING *)UnbindAdapterContext;
- if (!NT_SUCCESS(Status)) return;
+ if (!NT_SUCCESS(Status)) {
+ NDIS_DbgPrint(MIN_TRACE, ("Unbinding failed (%x)\n", Status));
+ return;
+ }
ExInterlockedRemoveEntryList(&Protocol->ListEntry, &ProtocolListLock);
}
@@ -252,8 +269,10 @@
#endif
LookaheadBuffer = ExAllocatePool(NonPagedPool,
Adapter->NdisMiniportBlock.CurrentLookahead + Adapter->MediumHeaderSize);
- if (!LookaheadBuffer)
+ if (!LookaheadBuffer) {
+ NDIS_DbgPrint(MIN_TRACE, ("Insufficient resources\n"));
return NDIS_STATUS_RESOURCES;
+ }
NdisQueryPacket(Packet, NULL, NULL, NULL, &PacketLength);
@@ -497,8 +516,10 @@
&PacketLength);
Context = ExAllocatePool(NonPagedPool, sizeof(DMA_CONTEXT));
- if (!Context)
+ if (!Context) {
+ NDIS_DbgPrint(MIN_TRACE, ("Insufficient resources\n"));
return NDIS_STATUS_RESOURCES;
+ }
Context->Adapter = Adapter;
Context->Packet = Packet;
@@ -520,7 +541,7 @@
KeLowerIrql(OldIrql);
if (!NT_SUCCESS(NdisStatus)) {
- NDIS_DbgPrint(MIN_TRACE, ("GetScatterGatherList failed!\n"));
+ NDIS_DbgPrint(MIN_TRACE, ("GetScatterGatherList failed!
(%x)\n", NdisStatus));
return NdisStatus;
}
@@ -760,7 +781,7 @@
if(!NdisProtocolHandle)
{
- NDIS_DbgPrint(MAX_TRACE, ("NdisProtocolHandle is NULL\n"));
+ NDIS_DbgPrint(MIN_TRACE, ("NdisProtocolHandle is NULL\n"));
*OpenErrorStatus = *Status = NDIS_STATUS_FAILURE;
return;
}
@@ -973,7 +994,7 @@
if(BindHandler)
BindHandler(Status, BindContext, &DeviceName, &RegistryPath, 0);
else
- NDIS_DbgPrint(MID_TRACE, ("No protocol bind handler
specified\n"));
+ NDIS_DbgPrint(MIN_TRACE, ("No protocol bind handler
specified\n"));
}
}
@@ -1081,6 +1102,7 @@
if (*Status == NDIS_STATUS_SUCCESS) {
ExInterlockedInsertTailList(&ProtocolListHead, &Protocol->ListEntry,
&ProtocolListLock);
} else {
+ NDIS_DbgPrint(MIN_TRACE, ("Binding failed (%x)\n", *Status));
ExFreePool(Protocol);
*NdisProtocolHandle = NULL;
}
@@ -1225,6 +1247,7 @@
if (!Binding)
{
+ NDIS_DbgPrint(MIN_TRACE, ("Bad binding handle\n"));
*NdisDriverHandle = NULL;
return;
}