2008-03-09 14:11:42 +00:00
|
|
|
/*
|
2008-08-18 13:30:17 +00:00
|
|
|
* PROJECT: ReactOS Kernel
|
|
|
|
* COPYRIGHT: GPL - See COPYING in the top level directory
|
|
|
|
* FILE: ntoskrnl/io/pnpmgr/pnpdma.c
|
2005-01-26 13:58:37 +00:00
|
|
|
* PURPOSE: PnP manager DMA routines
|
|
|
|
* PROGRAMMERS: Filip Navara (xnavara@volny.cz)
|
2003-09-25 18:29:45 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
/* INCLUDES ******************************************************************/
|
|
|
|
|
2004-08-15 16:39:12 +00:00
|
|
|
#include <ntoskrnl.h>
|
2004-10-19 19:37:45 +00:00
|
|
|
#define NDEBUG
|
2008-08-30 16:31:06 +00:00
|
|
|
#include <debug.h>
|
2005-12-01 21:37:19 +00:00
|
|
|
#include <wdmguid.h>
|
2003-09-25 18:29:45 +00:00
|
|
|
|
2008-08-18 13:30:17 +00:00
|
|
|
/* PUBLIC FUNCTIONS **********************************************************/
|
2003-09-25 18:29:45 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* @implemented
|
|
|
|
*/
|
2008-08-18 13:30:17 +00:00
|
|
|
PDMA_ADAPTER
|
|
|
|
NTAPI
|
|
|
|
IoGetDmaAdapter(IN PDEVICE_OBJECT PhysicalDeviceObject,
|
|
|
|
IN PDEVICE_DESCRIPTION DeviceDescription,
|
|
|
|
IN OUT PULONG NumberOfMapRegisters)
|
2003-09-25 18:29:45 +00:00
|
|
|
{
|
2008-08-18 13:30:17 +00:00
|
|
|
NTSTATUS Status;
|
|
|
|
ULONG ResultLength;
|
|
|
|
BUS_INTERFACE_STANDARD BusInterface;
|
|
|
|
IO_STATUS_BLOCK IoStatusBlock;
|
|
|
|
IO_STACK_LOCATION Stack;
|
|
|
|
DEVICE_DESCRIPTION PrivateDeviceDescription;
|
|
|
|
PDMA_ADAPTER Adapter = NULL;
|
2005-05-09 01:38:29 +00:00
|
|
|
|
2008-08-18 13:30:17 +00:00
|
|
|
DPRINT("IoGetDmaAdapter called\n");
|
2005-05-09 01:38:29 +00:00
|
|
|
|
2005-08-22 10:51:05 +00:00
|
|
|
|
2008-08-18 13:30:17 +00:00
|
|
|
/* Try to create DMA adapter through bus driver */
|
|
|
|
if (PhysicalDeviceObject)
|
2005-05-09 01:38:29 +00:00
|
|
|
{
|
2008-08-18 13:30:17 +00:00
|
|
|
if (DeviceDescription->InterfaceType == PNPBus ||
|
|
|
|
DeviceDescription->InterfaceType == InterfaceTypeUndefined)
|
|
|
|
{
|
|
|
|
RtlCopyMemory(&PrivateDeviceDescription,
|
|
|
|
DeviceDescription,
|
|
|
|
sizeof(DEVICE_DESCRIPTION));
|
2003-09-25 18:29:45 +00:00
|
|
|
|
2008-08-18 13:30:17 +00:00
|
|
|
Status = IoGetDeviceProperty(PhysicalDeviceObject,
|
|
|
|
DevicePropertyLegacyBusType,
|
|
|
|
sizeof(INTERFACE_TYPE),
|
|
|
|
&PrivateDeviceDescription.InterfaceType,
|
|
|
|
&ResultLength);
|
2003-09-25 18:29:45 +00:00
|
|
|
|
2008-08-18 13:30:17 +00:00
|
|
|
if (!NT_SUCCESS(Status))
|
|
|
|
PrivateDeviceDescription.InterfaceType = Internal;
|
2003-09-25 18:29:45 +00:00
|
|
|
|
2008-08-18 13:30:17 +00:00
|
|
|
DeviceDescription = &PrivateDeviceDescription;
|
|
|
|
}
|
|
|
|
|
|
|
|
Stack.Parameters.QueryInterface.Size = sizeof(BUS_INTERFACE_STANDARD);
|
|
|
|
Stack.Parameters.QueryInterface.Version = 1;
|
|
|
|
Stack.Parameters.QueryInterface.Interface = (PINTERFACE)&BusInterface;
|
|
|
|
Stack.Parameters.QueryInterface.InterfaceType =
|
|
|
|
&GUID_BUS_INTERFACE_STANDARD;
|
2003-09-25 18:29:45 +00:00
|
|
|
|
2008-08-18 13:30:17 +00:00
|
|
|
Status = IopInitiatePnpIrp(PhysicalDeviceObject,
|
|
|
|
&IoStatusBlock,
|
|
|
|
IRP_MN_QUERY_INTERFACE,
|
|
|
|
&Stack);
|
|
|
|
|
|
|
|
if (NT_SUCCESS(Status))
|
|
|
|
{
|
|
|
|
Adapter = BusInterface.GetDmaAdapter(BusInterface.Context,
|
|
|
|
DeviceDescription,
|
|
|
|
NumberOfMapRegisters);
|
|
|
|
|
|
|
|
BusInterface.InterfaceDereference(BusInterface.Context);
|
|
|
|
if (Adapter) return Adapter;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Fall back to HAL */
|
|
|
|
return HalGetDmaAdapter(PhysicalDeviceObject,
|
|
|
|
DeviceDescription,
|
|
|
|
NumberOfMapRegisters);
|
|
|
|
}
|