Hi All,
I entered a question several days ago that I probably didn’t specify well
enough. I’m attempting to use IOCTLs to perform direct I/O to DDR ram on a
PCI busmaster card. My issue at this time is not how to do the DMA ops, but
how to set up and properly use the IOCTLs.
A user app would call my API to perform the various ops.
IOCTL declarations:
#define V3_IOCTL_READ CTL_CODE (FILE_DEVICE_UNKNOWN, \
0x800, \
METHOD_OUT_DIRECT, \
FILE_ANY_ACCESS);
#define V3_IOCTL_WRITE CTL_CODE (FILE_DEVICE_UNKNOWN, \
0x801, \
METHOD_IN_DIRECT, \
FILE_ANY_ACCESS);
User app code:
hV3Device = CreateFile(“\\.\v3Device”,
GENERIC_READ | GENERIC_WRITE,
FILE_SHARE_READ | FILE_SHARE_WRITE,
NULL,
OPEN_EXISTING,
0,
NULL);
if(hV3Device == INVALID_HANDLE_VALUE)
{
// ERROR, we could not open the device!!!
printf(“ERROR: We could not open the device!\n”);
printf(“Press return to quit”);
getc(stdin);
exit(1);
}
ddr_data = 0;
// Read a quad word from the device
if(DeviceIoControl(hV3Device,
V3_IOCTL_READ,
&memory_address,
sizeof(memory_address),
&ddr_data,
sizeof(ddr_data), // one quad
word
&nBytesTransferred,
NULL) == 0)
{
// ERROR, could not communicate to device!!!
printf(“ERROR: could not communicate to
device!\n”);
printf(“Press return to quit”);
getc(stdin);
exit(1);
}
where:
typedef __int64 longlong;
longlong ddr_data;
unsigned int memory_address = 0;
The IRP thats issued for this read has Irp->MdlAddress == 0x00000000. This
of course quickly results in an access violation.
I know you guys out there have lots of experience working code such as this.
Can anyone suggest what may be wrong with the syntax i’ve used? I know
that one way to get a 0x00000000 in MdlAddress is to have a zero length
output buffer specified, but I dont believe I have that case here. This is
an NT4 style driver written for w2k.
Thanks in advance,
Howard Keller