AdapterControl routine
The AdapterControl routine starts a DMA data-transfer operation.
AdapterControl例程启动一个DMA数据传输操作。
语法:
DRIVER_CONTROL AdapterControl;
IO_ALLOCATION_ACTION AdapterControl(
_In_ struct _DEVICE_OBJECT *DeviceObject,
_Inout_ struct _IRP *Irp,
_In_ PVOID MapRegisterBase,
_In_ PVOID Context
)
{ ... }
参数:
DeviceObject [in]
Caller-supplied pointer to a DEVICE_OBJECT structure. This is the device object for the target device, previously created by the driver's AddDevice routine.
这是由调用者提供的一个指向DEVICE_OBJECT结构体的指针,是由驱动的AddDevice例程创建的目标设备的设备对象。
Irp [in, out]
Caller-supplied pointer to an IRP structure. Irp is equal to the value of the CurrentIrp member of DeviceObject when the AdapterControl routine was registered.
这是由调用者提供的一个指向IRP结构体的指针。当AdapterControl例程注册之后,Irp将等于DeviceObject的CurrentIrp成员。
MapRegisterBase [in]
Caller-supplied opaque value that represents the map registers that the system has assigned for this transfer operation. The driver passes this value to FlushAdapterBuffers, FreeMapRegisters, and MapTransfer.
由调用者提供的VOID指针,是系统分配给传输请求的寄存器。驱动会将此值传递到FlushAdapterBuffers,FreeMapRegisters和MapTransfer例程。
Context [in]
Caller-supplied pointer to driver-defined context information, specified in a previous call to AllocateAdapterChannel.
由调用者提供的驱动定义的上下文系统,详细说明在前一个调用AllocateAdapterChannel中。
返回值
The routine must return one of the values defined by the IO_ALLOCATION_ACTION enumeration.
Drivers of bus-master devices return either DeallocateObject or DeallocateObjectKeepRegisters; drivers that use system DMA return KeepObject.
例程必须返回一个由枚举IO_ALLOCATION_ACTION定义的值。总线主控设备的驱动程序返回 DeallocateObject 或者 DeallocateObjectKeepRegisters,使用系统DMA的驱动,返回KeepObject。
总线主控DMA : http://www.cnblogs.com/iwasmu/archive/2009/08/29/1556364.html
续:http://www.cnblogs.com/iwasmu/archive/2009/09/14/1566580.html
说明:
To register an AdapterControl routine for a specific device object, a driver must call IoGetDmaAdapter to obtain an adapter object,
then call AllocateAdapterChannel to request use of the adapter and to supply the AdapterControl routine's address.
为指定设备注册一个AdapterControl例程,驱动必须调用 IoGetDmaAdapter获取一个adapter对象。
When the adapter is free, the system calls the AdapterControl routine.
系统会在释放适配器对象 后调用 AdapterControl例程。
If AdapterControl has been registered by a StartIo routine,
then the Irp parameter is guaranteed to point to the IRP currently being processed by the StartIo routine.
如果AdapterControl是由StartIo例程注册的,则需要保证Irp参数是指向当前正由StartIo例程处理的IRP。
Otherwise, drivers must set the CurrentIrp member of the device object structure before calling AllocateAdapterChannel.
否则,驱动要在调用AllocateAdapterChannel例程之前,设置设备对象的CurrentIrp成员。
详细信息请见,如何编写AdapterControl例程(http://msdn.microsoft.com/en-us/library/windows/hardware/ff566397(v=vs.85).aspx)。
示例:
DRIVER_CONTROL MyAdapterControl;
IO_ALLOCATION_ACTION
MyAdapterControl(
_In_ struct _DEVICE_OBJECT *DeviceObject,
_Inout_ struct _IRP *Irp,
_In_ PVOID MapRegisterBase,
_In_ PVOID Context
)
{
// Function body
}