About StartIO Routine

Hi

I have a simple question about concept/usage of StartIO routine in driver programs. I can’t figure out the role of Start I/O routine in a driver.

In Windows 2000 Device Driver Book:
“The I/O Manager calls the driver’s Start I/O routine each time a device should begin the start of a data transfer.(…) (Complex devices capable of dealing with simultaneous requests may choose not to utilize this serialized approach.)”
OK. And
“If (as is usual) device operation is required, the Dispatch routine marks the request (IRP) as pending. The I/O Manager is instructed to queue a call to the driver’s Start I/O routine as soon as the device is free. (It is possible the device is handling a previous request.)”

(I think that “The I/O Manager is instructed to queue” means calling IoStartPacket() )

I read them and looked source codes of “Programming the Microsoft Windows Driver Model 2ed book” but there is nothing with Start IO routine and then i looked Toby Opferman’s articles source codes, there is no Start IO routine too.

If Start IO routine makes connection between device and I/O Manger, Can you please explain why there is no code for Start I/O in that drivers? How can it be done?

If a driver hasn’t got a Start I/O routine but also it must data transfer, what will happen next? Is there a default transfer mechanism that i haven’t read yet?

Thanks…

StartIO is simply a convenience mechanism for a driver that only wants to work on one I/O operation at a time. It’s entirely driven by your driver.

Your driver calls IoStartPacket() when it receives a request in its dispatch routine (after you validate parameters, etc…) to queue the request. If the queue is idle then IoStartPacket() will call your StartIo routine directly, and puts the queue into the busy state

When the queue is busy another call to IoStartPacket() will simply enqueue the request.

The queue remains in the busy state until your driver calls IoStartNextPacket(). IoStartNextPacket() will do one of two things:

a) If there aren’t any pending IRPs in the queue it will put the queue into the idle state and return. Now the next call to IoStartPacket() will mark the queue busy & invoke your startio routine.

b) If there is a pending IRP in the queue it will pull that IRP off the queue and call your StartIo routine

It’s simply a flow control mechanism for your driver. You can build the same thing yourself (if you need multiple queues) by using a KDEVICE_QUEUE in WDM. Or write a WDF driver and use the WDFQUEUEs, which provide much richer functionality.

-p

-----Original Message-----
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of xxxxx@gmail.com
Sent: Wednesday, May 07, 2008 5:55 AM
To: Windows System Software Devs Interest List
Subject: [ntdev] About StartIO Routine

Hi

I have a simple question about concept/usage of StartIO routine in driver programs. I can’t figure out the role of Start I/O routine in a driver.

In Windows 2000 Device Driver Book:
“The I/O Manager calls the driver’s Start I/O routine each time a device should begin the start of a data transfer.(…) (Complex devices capable of dealing with simultaneous requests may choose not to utilize this serialized approach.)”
OK. And
“If (as is usual) device operation is required, the Dispatch routine marks the request (IRP) as pending. The I/O Manager is instructed to queue a call to the driver’s Start I/O routine as soon as the device is free. (It is possible the device is handling a previous request.)”

(I think that “The I/O Manager is instructed to queue” means calling IoStartPacket() )

I read them and looked source codes of “Programming the Microsoft Windows Driver Model 2ed book” but there is nothing with Start IO routine and then i looked Toby Opferman’s articles source codes, there is no Start IO routine too.

If Start IO routine makes connection between device and I/O Manger, Can you please explain why there is no code for Start I/O in that drivers? How can it be done?

If a driver hasn’t got a Start I/O routine but also it must data transfer, what will happen next? Is there a default transfer mechanism that i haven’t read yet?

Thanks…


NTDEV is sponsored by OSR

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer

Thank you Peter Wieland
I read your explanations carefully. You said:
“You can build the same thing yourself (if you need multiple queues) by using a KDEVICE_QUEUE in WDM. Or write a WDF driver and use the WDFQUEUEs, which provide much richer functionality.”

If i don’t use/write anyone as Walter Oney’s books source or Toby Opferman’s articles source codes;

What does it mean? Is it mean i will not use my device? Or is there a transfer mechanism that Windows already provide, so i don’t need? I confused because i can’t see any data transfer routine in their source codes… None of them.
Thanks…

xxxxx@gmail.com wrote:

Thank you Peter Wieland
I read your explanations carefully. You said:
“You can build the same thing yourself (if you need multiple queues) by using a KDEVICE_QUEUE in WDM. Or write a WDF driver and use the WDFQUEUEs, which provide much richer functionality.”

If i don’t use/write anyone as Walter Oney’s books source or Toby Opferman’s articles source codes;

What does it mean? Is it mean i will not use my device? Or is there a transfer mechanism that Windows already provide, so i don’t need? I confused because i can’t see any data transfer routine in their source codes… None of them.

I think you are reading too much into what Peter said. All he is
saying, I think, is that the StartIO mechanism is just one way to handle
the stream of requests that come in to a kernel driver. You can do the
same thing in other ways, for example by using a KDEVICE_QUEUE, or by
switching to KMDF and using a WDFQUEUE.

What you DO with those I/O requests, once you have one, is a separate issue.


Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.

> I have a simple question about concept/usage of StartIO routine in driver

programs. I can’t figure out the role of Start I/O routine in a driver.

It is obsolete, and is replaced by cancel-safe queues and KMDF queues.


Maxim Shatskih, Windows DDK MVP
StorageCraft Corporation
xxxxx@storagecraft.com
http://www.storagecraft.com