Доброе Время суток!!!
Столкнулся с проблемой в скорости передачи данных через WDM драйвер, скорость очень низкая по сравнению с драйвером написанном в nuMega. Привожу код функций передачи данных:
#define MDMAI_MEM_READ CTL_CODE(FILE_DEVICE_UNKNOWN, 0x802, METHOD_OUT_DIRECT , FILE_ANY_ACCESS)
#define MDMAI_MEM_WRITE CTL_CODE(FILE_DEVICE_UNKNOWN, 0x803, METHOD_IN_DIRECT , FILE_ANY_ACCESS)
тело функции:
PMDMAI_DEVICE_EXTENSION pdx = (PMDMAI_DEVICE_EXTENSION) fdo->DeviceExtension;
NTSTATUS status = STATUS_SUCCESS;
DbgPrint("enter in DeviceControl!\n");
ULONG info = 0;
PIO_STACK_LOCATION stack = IoGetCurrentIrpStackLocation(Irp);
ULONG cbin = stack->Parameters.DeviceIoControl.InputBufferLength;
ULONG cbout = stack->Parameters.DeviceIoControl.OutputBufferLength;
ULONG code = stack->Parameters.DeviceIoControl.IoControlCode;
//...
case MDMAI_MEM_READ://IOCTL_READ_IMAGE:
{
DbgPrint("enter MDMAI_MEM_READ:\n");
if (cbin < sizeof(XDSP_READ_WRITE_MEMORY_ARGS*))
{
status = STATUS_INVALID_PARAMETER;
break;
}
XDSP_READ_WRITE_MEMORY_ARGS* p = (XDSP_READ_WRITE_MEMORY_ARGS*)Irp->AssociatedIrp.SystemBuffer;
KdPrint((DRIVERNAME " — Size of XDSP_READ_WRITE_MEMORY_ARGS = %I32x \n", sizeof(XDSP_READ_WRITE_MEMORY_ARGS)));
if (p!=NULL)
{
ULONG offset = p->ByteOffset;
KdPrint((DRIVERNAME " — Device on real addrr %I32x, offset = %I32x \n",pdx->MemBar1, offset));
p->DwordCount = READ_REGISTER_ULONG((PULONG)(pdx->MemBar1+offset));
KdPrint((DRIVERNAME " - Device on addrr %I32x has 0x%I32x \n", pdx->MemBar1+offset, p->DwordCount));
info = sizeof(p->DwordCount);
KdPrint((DRIVERNAME " — Size of DATA = %d \n", info));
PVOID pInputBuffer = Irp->AssociatedIrp.SystemBuffer;
PVOID pOutputBuffer = NULL;
if(Irp->MdlAddress)
{
pOutputBuffer = MmGetSystemAddressForMdlSafe(Irp->MdlAddress, NormalPagePriority);
}
if(pInputBuffer && pOutputBuffer)
{
DbgPrint("%i >= %i", cbout, info);
if(cbout >= info)
{
RtlCopyMemory(pOutputBuffer, &p->DwordCount, info);
status = STATUS_SUCCESS;
}else status = STATUS_BUFFER_TOO_SMALL;
}
}else status = STATUS_INVALID_PARAMETER;
break;
}
case MDMAI_MEM_WRITE://IOCTL_WRITE_IMAGE:
{
DbgPrint("enter MDMAI_MEM_WRITE:\n");
if (cbin < sizeof(XDSP_READ_WRITE_MEMORY_ARGS*))
{
status = STATUS_INVALID_PARAMETER;
break;
}
XDSP_READ_WRITE_MEMORY_ARGS* p = (XDSP_READ_WRITE_MEMORY_ARGS*)Irp->AssociatedIrp.SystemBuffer;
KdPrint((DRIVERNAME " — Size of XDSP_READ_WRITE_MEMORY_ARGS = %d \n", sizeof(XDSP_READ_WRITE_MEMORY_ARGS)));
if (p!=NULL)
{
ULONG offset = p->ByteOffset;
KdPrint((DRIVERNAME " — Device on real addrr %I32x, offset = %I32x \n",pdx->MemBar1, offset));
KdPrint((DRIVERNAME " - Device on addrr %I32x has 0x%I32x \n",pdx->MemBar1+offset, p->DwordCount));
WRITE_REGISTER_ULONG((PULONG)(pdx->MemBar1+offset), p->DwordCount);
info = sizeof(p->DwordCount);
KdPrint((DRIVERNAME " — Size of DATA = %d \n", info));
ULONG Data = READ_REGISTER_ULONG((PULONG)(pdx->MemBar1+offset));
KdPrint((DRIVERNAME " — Read DATA = %I32x \n", Data));
status = STATUS_SUCCESS;
}else status = STATUS_INVALID_PARAMETER;
break;
}
Что может быть?
Спасибо!!