- Fix various bugs in IoGetDmaAdapter.

- Fill the IoStatus values in the Irp I/O status block in IopInitiatePnpIrp.

svn path=/trunk/; revision=11334
This commit is contained in:
Filip Navara 2004-10-19 19:37:45 +00:00
parent cbc7c9eac2
commit 953b49dd54
2 changed files with 37 additions and 38 deletions

View file

@ -1,4 +1,4 @@
/* $Id: pnpdma.c,v 1.7 2004/10/18 21:07:42 navaraf Exp $
/* $Id: pnpdma.c,v 1.8 2004/10/19 19:37:45 navaraf Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
@ -12,6 +12,7 @@
/* INCLUDES ******************************************************************/
#include <ntoskrnl.h>
#define NDEBUG
#include <internal/debug.h>
#ifdef __USE_W32API
@ -193,6 +194,21 @@ IoGetDmaAdapter(
IN PDEVICE_DESCRIPTION DeviceDescription,
IN OUT PULONG NumberOfMapRegisters)
{
static DMA_OPERATIONS HalDmaOperations = {
sizeof(DMA_OPERATIONS),
IopPutDmaAdapter,
IopAllocateCommonBuffer,
IopFreeCommonBuffer,
IopAllocateAdapterChannel,
IopFlushAdapterBuffers,
IopFreeAdapterChannel,
IopFreeMapRegisters,
IopMapTransfer,
IopGetDmaAlignment,
IopReadDmaCounter,
IopGetScatterGatherList,
IopPutScatterGatherList
};
NTSTATUS Status;
ULONG ResultLength;
BUS_INTERFACE_STANDARD BusInterface;
@ -213,7 +229,7 @@ IoGetDmaAdapter(
if (DeviceDescription->InterfaceType == 0x0F /*PNPBus*/ ||
DeviceDescription->InterfaceType == 0xFFFFFFFF)
{
memcpy(&PrivateDeviceDescription, DeviceDescription,
RtlCopyMemory(&PrivateDeviceDescription, DeviceDescription,
sizeof(DEVICE_DESCRIPTION));
Status = IoGetDeviceProperty(PhysicalDeviceObject,
DevicePropertyLegacyBusType, sizeof(INTERFACE_TYPE),
@ -231,7 +247,7 @@ IoGetDmaAdapter(
Stack.Parameters.QueryInterface.InterfaceType =
&GUID_BUS_INTERFACE_STANDARD;
Status = IopInitiatePnpIrp(PhysicalDeviceObject, &IoStatusBlock,
IRP_MN_QUERY_BUS_INFORMATION, &Stack);
IRP_MN_QUERY_INTERFACE, &Stack);
if (NT_SUCCESS(Status))
{
Result = BusInterface.GetDmaAdapter(BusInterface.Context,
@ -248,33 +264,15 @@ IoGetDmaAdapter(
HalAdapter = HalGetAdapter(DeviceDescription, NumberOfMapRegisters);
if (HalAdapter == NULL)
{
return NULL;
}
ResultInternal = ExAllocatePool(PagedPool, sizeof(DMA_ADAPTER_INTERNAL) +
sizeof(DMA_OPERATIONS));
if (Result == NULL)
{
ResultInternal = ExAllocatePool(PagedPool, sizeof(DMA_ADAPTER_INTERNAL));
if (ResultInternal == NULL)
return NULL;
}
ResultInternal->Version = DEVICE_DESCRIPTION_VERSION;
ResultInternal->Size = sizeof(DMA_ADAPTER);
ResultInternal->DmaOperations = (PDMA_OPERATIONS)(ResultInternal + 1);
ResultInternal->DmaOperations->Size = sizeof(DMA_OPERATIONS);
ResultInternal->DmaOperations->PutDmaAdapter = IopPutDmaAdapter;
ResultInternal->DmaOperations->AllocateCommonBuffer = IopAllocateCommonBuffer;
ResultInternal->DmaOperations->FreeCommonBuffer = IopFreeCommonBuffer;
ResultInternal->DmaOperations->AllocateAdapterChannel = IopAllocateAdapterChannel;
ResultInternal->DmaOperations->FlushAdapterBuffers = IopFlushAdapterBuffers;
ResultInternal->DmaOperations->FreeAdapterChannel = IopFreeAdapterChannel;
ResultInternal->DmaOperations->FreeMapRegisters = IopFreeMapRegisters;
ResultInternal->DmaOperations->MapTransfer = IopMapTransfer;
ResultInternal->DmaOperations->GetDmaAlignment = IopGetDmaAlignment;
ResultInternal->DmaOperations->ReadDmaCounter = IopReadDmaCounter;
ResultInternal->DmaOperations->GetScatterGatherList = IopGetScatterGatherList;
ResultInternal->DmaOperations->PutScatterGatherList = IopPutScatterGatherList;
ResultInternal->DmaOperations = &HalDmaOperations;
ResultInternal->HalAdapter = HalAdapter;
return (PDMA_ADAPTER)ResultInternal;

View file

@ -1,4 +1,4 @@
/* $Id: pnpmgr.c,v 1.37 2004/10/11 19:07:25 ekohl Exp $
/* $Id: pnpmgr.c,v 1.38 2004/10/19 19:37:45 navaraf Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
@ -535,22 +535,22 @@ IopInitiatePnpIrp(
KeInitializeEvent(
&Event,
NotificationEvent,
FALSE);
/* PNP IRPs are always initialized with a status code of
STATUS_NOT_IMPLEMENTED */
IoStatusBlock->Status = STATUS_NOT_IMPLEMENTED;
IoStatusBlock->Information = 0;
NotificationEvent,
FALSE);
Irp = IoBuildSynchronousFsdRequest(
IRP_MJ_PNP,
TopDeviceObject,
NULL,
0,
NULL,
&Event,
IoStatusBlock);
NULL,
0,
NULL,
&Event,
IoStatusBlock);
/* PNP IRPs are always initialized with a status code of
STATUS_NOT_IMPLEMENTED */
Irp->IoStatus.Status = STATUS_NOT_IMPLEMENTED;
Irp->IoStatus.Information = 0;
IrpSp = IoGetNextIrpStackLocation(Irp);
IrpSp->MinorFunction = MinorFunction;
@ -832,7 +832,8 @@ IopSetDeviceInstanceData(HANDLE InstanceKey,
sizeof(ULONG));
/* Set 'UINumber' value */
if (DeviceNode->CapabilityFlags->UINumber != (ULONG)-1)
if (DeviceNode->CapabilityFlags != NULL &&
DeviceNode->CapabilityFlags->UINumber != (ULONG)-1)
{
RtlInitUnicodeString(&KeyName,
L"UINumber");