Multiple device support questions

Hello,
I would appreciate if anyone could correct me if I am wrong in my
decisions. I’m creating a WDM driver for multiple PCI cards of the same
type. The driver is supposed to provide an interface to user mode
application like,

Read(thisCard, thisOffset)
Write(thisCard, thisOffset, thisData)

As the Win32 ReadFile and WriteFile do not allow parameters to be passed,
I shall be using DeviceIoControl. This should mean that dispatch routines
for IRP_MJ_READ and IRP_MJ_WRITE would not be required. Also, I shall
have to write custom read and write routines for custom IOCTLs. Correct ?

Question no.2. What is the minimum set of routines that I must write to
do a basic IO of the type mentioned above ? I want to make the driver
support PNP later, but first a prototype that performs IO is required.

I would be appreciate any comments, suggestions and guidelines.

Regards,
Sunil Jigyasu,
VigorSoft Pvt. Ltd,
Baroda, India.

xxxxx@vigorsoft.com wrote:

As the Win32 ReadFile and WriteFile do not allow parameters to be passed,
I shall be using DeviceIoControl. This should mean that dispatch routines
for IRP_MJ_READ and IRP_MJ_WRITE would not be required. Also, I shall
have to write custom read and write routines for custom IOCTLs. Correct ?

What do you mean parameters are not passed? You can get the behavior you
desire from read and write by calling SetFilePointer to the desired
offset. Then extract the offset from the stack Parameters.Read structure
in your driver.

Question no.2. What is the minimum set of routines that I must write to
do a basic IO of the type mentioned above ? I want to make the driver
support PNP later, but first a prototype that performs IO is required.

My suggestion is to *start* with PnP and power support, since WDM
drivers just don’t work without it. Use GENERIC.SYS from WDM book to
save yourself a couple thousand lines of boilerplate coding.


Walter Oney, Consulting and Training
Basic and Advanced Driver Programming Seminars
Now teaming with John Hyde for USB Device Engineering Seminars
Check out our schedule at http://www.oneysoft.com

> -----Original Message-----

From: xxxxx@vigorsoft.com [mailto:xxxxx@vigorsoft.com]
Sent: Saturday, March 15, 2003 1:14 AM
To: NT Developers Interest List
Subject: [ntdev] Multiple device support questions

Hello,
I would appreciate if anyone could correct me if I am wrong
in my decisions. I’m creating a WDM driver for multiple PCI
cards of the same type. The driver is supposed to provide an
interface to user mode application like,

Read(thisCard, thisOffset)
Write(thisCard, thisOffset, thisData)

As the Win32 ReadFile and WriteFile do not allow parameters
to be passed, I shall be using DeviceIoControl.
ReadFile and WriteFile do provide device and offset information to the
driver. There is however nothing wrong with the IOCTL approach. See the
documentation (in the latest ddk) for IRP_MJ_READ. In particular look at
Parameters.Read.ByteOffset in the IO_STACK_LOCATION for the IRP. As long as
you are a toplevel driver this information will be valid.

This should
mean that dispatch routines for IRP_MJ_READ and IRP_MJ_WRITE
would not be required. Also, I shall have to write custom
read and write routines for custom IOCTLs. Correct ?

Question no.2. What is the minimum set of routines that I
must write to do a basic IO of the type mentioned above ? I
want to make the driver support PNP later, but first a
prototype that performs IO is required.

You don’t want to ‘make the driver support PnP later’, that is a bad idea.
WDM drivers must support Pnp by definition. Get a good book on writing a WDM
driver. Walter Oney’s Programming the Windows Driver Model ver 2 (Microsoft
Press,) is probably the best one out there specific to WDM drivers.