Question about bus driver

Hi All,

I am new to WDM. When studied the Toaster sample code, I couldn’t find any
thing about sending the data to upper driver object. I only can find the
code about sending IRP from upper driver to bus driver to R/W data. What
happen if BUS driver receive data and like to deliver to upper device
object? Is there anyway let bus driver acknowledge upper device object send
IRP to bus driver to read data? Thanks!

Fearow

You can use callbacks to notify the upper driver.

Thanks,
Cyril

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com]On Behalf Of fearow
Sent: Saturday, October 08, 2005 11:31 AM
To: Windows System Software Devs Interest List
Subject: [ntdev] Question about bus driver

Hi All,

I am new to WDM. When studied the Toaster sample code, I couldn’t find any
thing about sending the data to upper driver object. I only can find the
code about sending IRP from upper driver to bus driver to R/W data. What
happen if BUS driver receive data and like to deliver to upper device
object? Is there anyway let bus driver acknowledge upper device object send
IRP to bus driver to read data? Thanks!

Fearow


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: xxxxx@future.futsoft.com
To unsubscribe send a blank email to xxxxx@lists.osr.com

***************************************************************************
This message is proprietary to Future Software Limited (FSL)
and is intended solely for the use of the individual to whom it
is addressed. It may contain privileged or confidential information
and should not be circulated or used for any purpose other than for
what it is intended.

If you have received this message in error, please notify the
originator immediately. If you are not the intended recipient,
you are notified that you are strictly prohibited from using,
copying, altering, or disclosing the contents of this message.
FSL accepts no responsibility for loss or damage arising from
the use of the information transmitted by this email including
damage from virus.
***************************************************************************

The details of how data is transferred between the bus driver managed IO bus
and the function drivers for devices on that bus are specific to the bus and
not defined by the PnP architecture. Consequently the answer to your
question is ‘it depends’.

Consider the PCI bus driver. Each function driver manages its own hardware
resources on the PCI bus its device is attached to and does not interact
with the PCI bus driver at all as far as data transfer operations are
concerned. If the function driver needs to access PCI configuration space,
then it interacts with the PCI bus driver through a device interface, or
through specific PnP IRPs for configuration read/write operations.

At the other end of the spectrum, consider a scsi bus driver (or a usb bus
driver.) All data transfers are managed by the bus driver, and the bus
driver defines a protocol and message format (SRB or URB) for transfering
both data and configuration IO requests between function driver and bus
driver. In both cases the function driver sends IRPs to bus driver PDO
device objects and receives IRP completion request callback events to
continue processing of those requests.

=====================
Mark Roddy DDK MVP
Windows 2003/XP/2000 Consulting
Hollis Technology Solutions 603-321-1032
www.hollistech.com

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of fearow
Sent: Saturday, October 08, 2005 2:01 AM
To: Windows System Software Devs Interest List
Subject: [ntdev] Question about bus driver

Hi All,

I am new to WDM. When studied the Toaster sample code, I
couldn’t find any thing about sending the data to upper
driver object. I only can find the code about sending IRP
from upper driver to bus driver to R/W data. What happen if
BUS driver receive data and like to deliver to upper device
object? Is there anyway let bus driver acknowledge upper
device object send IRP to bus driver to read data? Thanks!

Fearow


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as:
xxxxx@hollistech.com To unsubscribe send a blank email to
xxxxx@lists.osr.com

Thanks for your reply! I know USB device driver sends URB to bus driver to
Tx data and I think bus driver also uses URB to deliver data to upper
driver. The question is how does upper driver know that there is data
waiting in bus driver and then issues URB to read the data? Or does bus
driver send URB to deliver data to upper driver as soon as data received? If
bus driver initiates URB, how does bus driver find upper driver’s
DeviceObject? Can any kernel API do that? Thanks!

Fearow

“Mark Roddy” wrote in message news:xxxxx@ntdev…
> The details of how data is transferred between the bus driver managed IO
> bus
> and the function drivers for devices on that bus are specific to the bus
> and
> not defined by the PnP architecture. Consequently the answer to your
> question is ‘it depends’.
>
> Consider the PCI bus driver. Each function driver manages its own hardware
> resources on the PCI bus its device is attached to and does not interact
> with the PCI bus driver at all as far as data transfer operations are
> concerned. If the function driver needs to access PCI configuration space,
> then it interacts with the PCI bus driver through a device interface, or
> through specific PnP IRPs for configuration read/write operations.
>
> At the other end of the spectrum, consider a scsi bus driver (or a usb bus
> driver.) All data transfers are managed by the bus driver, and the bus
> driver defines a protocol and message format (SRB or URB) for transfering
> both data and configuration IO requests between function driver and bus
> driver. In both cases the function driver sends IRPs to bus driver PDO
> device objects and receives IRP completion request callback events to
> continue processing of those requests.
>
> =====================
> Mark Roddy DDK MVP
> Windows 2003/XP/2000 Consulting
> Hollis Technology Solutions 603-321-1032
> www.hollistech.com
>
>> -----Original Message-----
>> From: xxxxx@lists.osr.com
>> [mailto:xxxxx@lists.osr.com] On Behalf Of fearow
>> Sent: Saturday, October 08, 2005 2:01 AM
>> To: Windows System Software Devs Interest List
>> Subject: [ntdev] Question about bus driver
>>
>> Hi All,
>>
>> I am new to WDM. When studied the Toaster sample code, I
>> couldn’t find any thing about sending the data to upper
>> driver object. I only can find the code about sending IRP
>> from upper driver to bus driver to R/W data. What happen if
>> BUS driver receive data and like to deliver to upper device
>> object? Is there anyway let bus driver acknowledge upper
>> device object send IRP to bus driver to read data? Thanks!
>>
>> Fearow
>>
>>
>>
>> —
>> Questions? First check the Kernel Driver FAQ at
>> http://www.osronline.com/article.cfm?id=256
>>
>> You are currently subscribed to ntdev as:
>> xxxxx@hollistech.com To unsubscribe send a blank email to
>> xxxxx@lists.osr.com
>>
>
>
>

You still have it backwards. A USB disk does not just decide to suddenly
‘send’ data upward. It only does so in response to a request. Read Walter
Oney’s 2nd Edition WDM book. Experiment and use windbg. You can also use
the learning hardware available on osronline. Just don’t use their drivers
until you understand what’s going on. If you can’t get a handle on it
without using their drivers, you will need to spend at least a solid week
with the hardware, drivers, and windbg until you have seen every routine
being invoked.

“fearow” wrote in message news:xxxxx@ntdev…
> Thanks for your reply! I know USB device driver sends URB to bus driver to
> Tx data and I think bus driver also uses URB to deliver data to upper
> driver. The question is how does upper driver know that there is data
> waiting in bus driver and then issues URB to read the data? Or does bus
> driver send URB to deliver data to upper driver as soon as data received?
> If bus driver initiates URB, how does bus driver find upper driver’s
> DeviceObject? Can any kernel API do that? Thanks!
>
> Fearow
>
> “Mark Roddy” wrote in message news:xxxxx@ntdev…
>> The details of how data is transferred between the bus driver managed IO
>> bus
>> and the function drivers for devices on that bus are specific to the bus
>> and
>> not defined by the PnP architecture. Consequently the answer to your
>> question is ‘it depends’.
>>
>> Consider the PCI bus driver. Each function driver manages its own
>> hardware
>> resources on the PCI bus its device is attached to and does not interact
>> with the PCI bus driver at all as far as data transfer operations are
>> concerned. If the function driver needs to access PCI configuration
>> space,
>> then it interacts with the PCI bus driver through a device interface, or
>> through specific PnP IRPs for configuration read/write operations.
>>
>> At the other end of the spectrum, consider a scsi bus driver (or a usb
>> bus
>> driver.) All data transfers are managed by the bus driver, and the bus
>> driver defines a protocol and message format (SRB or URB) for transfering
>> both data and configuration IO requests between function driver and bus
>> driver. In both cases the function driver sends IRPs to bus driver PDO
>> device objects and receives IRP completion request callback events to
>> continue processing of those requests.
>>
>> =====================
>> Mark Roddy DDK MVP
>> Windows 2003/XP/2000 Consulting
>> Hollis Technology Solutions 603-321-1032
>> www.hollistech.com
>>
>>> -----Original Message-----
>>> From: xxxxx@lists.osr.com
>>> [mailto:xxxxx@lists.osr.com] On Behalf Of fearow
>>> Sent: Saturday, October 08, 2005 2:01 AM
>>> To: Windows System Software Devs Interest List
>>> Subject: [ntdev] Question about bus driver
>>>
>>> Hi All,
>>>
>>> I am new to WDM. When studied the Toaster sample code, I
>>> couldn’t find any thing about sending the data to upper
>>> driver object. I only can find the code about sending IRP
>>> from upper driver to bus driver to R/W data. What happen if
>>> BUS driver receive data and like to deliver to upper device
>>> object? Is there anyway let bus driver acknowledge upper
>>> device object send IRP to bus driver to read data? Thanks!
>>>
>>> Fearow
>>>
>>>
>>>
>>> —
>>> Questions? First check the Kernel Driver FAQ at
>>> http://www.osronline.com/article.cfm?id=256
>>>
>>> You are currently subscribed to ntdev as:
>>> xxxxx@hollistech.com To unsubscribe send a blank email to
>>> xxxxx@lists.osr.com
>>>
>>
>>
>>
>
>
>

I agree with that USB disk don’t send the data upward. But how about mouse
and other HID devices? I used USB monitor (from www.hhdsoftware.com) to
capture the URBs between mouse driver and hub driver. When I moved the mouse
I only see the URBs from hub driver to mouse driver. Which means URBs been
sent from lower to upper driver. So the question is: If the driver stack
form lower to upper looks like following:

A <- B <- C (A is the lowest driver)

How does driver B get driver C’s DeviceObject?

Fearow

“David J. Craig” wrote in message
news:xxxxx@ntdev…
> You still have it backwards. A USB disk does not just decide to suddenly
> ‘send’ data upward. It only does so in response to a request. Read
> Walter Oney’s 2nd Edition WDM book. Experiment and use windbg. You can
> also use the learning hardware available on osronline. Just don’t use
> their drivers until you understand what’s going on. If you can’t get a
> handle on it without using their drivers, you will need to spend at least
> a solid week with the hardware, drivers, and windbg until you have seen
> every routine being invoked.
>
> “fearow” wrote in message news:xxxxx@ntdev…
>> Thanks for your reply! I know USB device driver sends URB to bus driver
>> to Tx data and I think bus driver also uses URB to deliver data to upper
>> driver. The question is how does upper driver know that there is data
>> waiting in bus driver and then issues URB to read the data? Or does bus
>> driver send URB to deliver data to upper driver as soon as data received?
>> If bus driver initiates URB, how does bus driver find upper driver’s
>> DeviceObject? Can any kernel API do that? Thanks!
>>
>> Fearow
>>
>> “Mark Roddy” wrote in message news:xxxxx@ntdev…
>>> The details of how data is transferred between the bus driver managed IO
>>> bus
>>> and the function drivers for devices on that bus are specific to the bus
>>> and
>>> not defined by the PnP architecture. Consequently the answer to your
>>> question is ‘it depends’.
>>>
>>> Consider the PCI bus driver. Each function driver manages its own
>>> hardware
>>> resources on the PCI bus its device is attached to and does not interact
>>> with the PCI bus driver at all as far as data transfer operations are
>>> concerned. If the function driver needs to access PCI configuration
>>> space,
>>> then it interacts with the PCI bus driver through a device interface, or
>>> through specific PnP IRPs for configuration read/write operations.
>>>
>>> At the other end of the spectrum, consider a scsi bus driver (or a usb
>>> bus
>>> driver.) All data transfers are managed by the bus driver, and the bus
>>> driver defines a protocol and message format (SRB or URB) for
>>> transfering
>>> both data and configuration IO requests between function driver and bus
>>> driver. In both cases the function driver sends IRPs to bus driver PDO
>>> device objects and receives IRP completion request callback events to
>>> continue processing of those requests.
>>>
>>> =====================
>>> Mark Roddy DDK MVP
>>> Windows 2003/XP/2000 Consulting
>>> Hollis Technology Solutions 603-321-1032
>>> www.hollistech.com
>>>
>>>> -----Original Message-----
>>>> From: xxxxx@lists.osr.com
>>>> [mailto:xxxxx@lists.osr.com] On Behalf Of fearow
>>>> Sent: Saturday, October 08, 2005 2:01 AM
>>>> To: Windows System Software Devs Interest List
>>>> Subject: [ntdev] Question about bus driver
>>>>
>>>> Hi All,
>>>>
>>>> I am new to WDM. When studied the Toaster sample code, I
>>>> couldn’t find any thing about sending the data to upper
>>>> driver object. I only can find the code about sending IRP
>>>> from upper driver to bus driver to R/W data. What happen if
>>>> BUS driver receive data and like to deliver to upper device
>>>> object? Is there anyway let bus driver acknowledge upper
>>>> device object send IRP to bus driver to read data? Thanks!
>>>>
>>>> Fearow
>>>>
>>>>
>>>>
>>>> —
>>>> Questions? First check the Kernel Driver FAQ at
>>>> http://www.osronline.com/article.cfm?id=256
>>>>
>>>> You are currently subscribed to ntdev as:
>>>> xxxxx@hollistech.com To unsubscribe send a blank email to
>>>> xxxxx@lists.osr.com
>>>>
>>>
>>>
>>>
>>
>>
>>
>
>
>

Read the documentation. I have never done anything in the HID stack since
DOS days. I suspect it is callbacks.

“fearow” wrote in message news:xxxxx@ntdev…
>I agree with that USB disk don’t send the data upward. But how about mouse
>and other HID devices? I used USB monitor (from www.hhdsoftware.com) to
>capture the URBs between mouse driver and hub driver. When I moved the
>mouse I only see the URBs from hub driver to mouse driver. Which means URBs
>been sent from lower to upper driver. So the question is: If the driver
>stack form lower to upper looks like following:
>
> A <- B <- C (A is the lowest driver)
>
> How does driver B get driver C’s DeviceObject?
>
> Fearow
>
>
> “David J. Craig” wrote in message
> news:xxxxx@ntdev…
>> You still have it backwards. A USB disk does not just decide to suddenly
>> ‘send’ data upward. It only does so in response to a request. Read
>> Walter Oney’s 2nd Edition WDM book. Experiment and use windbg. You can
>> also use the learning hardware available on osronline. Just don’t use
>> their drivers until you understand what’s going on. If you can’t get a
>> handle on it without using their drivers, you will need to spend at least
>> a solid week with the hardware, drivers, and windbg until you have seen
>> every routine being invoked.
>>
>> “fearow” wrote in message news:xxxxx@ntdev…
>>> Thanks for your reply! I know USB device driver sends URB to bus driver
>>> to Tx data and I think bus driver also uses URB to deliver data to upper
>>> driver. The question is how does upper driver know that there is data
>>> waiting in bus driver and then issues URB to read the data? Or does bus
>>> driver send URB to deliver data to upper driver as soon as data
>>> received? If bus driver initiates URB, how does bus driver find upper
>>> driver’s DeviceObject? Can any kernel API do that? Thanks!
>>>
>>> Fearow
>>>
>>> “Mark Roddy” wrote in message news:xxxxx@ntdev…
>>>> The details of how data is transferred between the bus driver managed
>>>> IO bus
>>>> and the function drivers for devices on that bus are specific to the
>>>> bus and
>>>> not defined by the PnP architecture. Consequently the answer to your
>>>> question is ‘it depends’.
>>>>
>>>> Consider the PCI bus driver. Each function driver manages its own
>>>> hardware
>>>> resources on the PCI bus its device is attached to and does not
>>>> interact
>>>> with the PCI bus driver at all as far as data transfer operations are
>>>> concerned. If the function driver needs to access PCI configuration
>>>> space,
>>>> then it interacts with the PCI bus driver through a device interface,
>>>> or
>>>> through specific PnP IRPs for configuration read/write operations.
>>>>
>>>> At the other end of the spectrum, consider a scsi bus driver (or a usb
>>>> bus
>>>> driver.) All data transfers are managed by the bus driver, and the bus
>>>> driver defines a protocol and message format (SRB or URB) for
>>>> transfering
>>>> both data and configuration IO requests between function driver and bus
>>>> driver. In both cases the function driver sends IRPs to bus driver PDO
>>>> device objects and receives IRP completion request callback events to
>>>> continue processing of those requests.
>>>>
>>>> =====================
>>>> Mark Roddy DDK MVP
>>>> Windows 2003/XP/2000 Consulting
>>>> Hollis Technology Solutions 603-321-1032
>>>> www.hollistech.com
>>>>
>>>>> -----Original Message-----
>>>>> From: xxxxx@lists.osr.com
>>>>> [mailto:xxxxx@lists.osr.com] On Behalf Of fearow
>>>>> Sent: Saturday, October 08, 2005 2:01 AM
>>>>> To: Windows System Software Devs Interest List
>>>>> Subject: [ntdev] Question about bus driver
>>>>>
>>>>> Hi All,
>>>>>
>>>>> I am new to WDM. When studied the Toaster sample code, I
>>>>> couldn’t find any thing about sending the data to upper
>>>>> driver object. I only can find the code about sending IRP
>>>>> from upper driver to bus driver to R/W data. What happen if
>>>>> BUS driver receive data and like to deliver to upper device
>>>>> object? Is there anyway let bus driver acknowledge upper
>>>>> device object send IRP to bus driver to read data? Thanks!
>>>>>
>>>>> Fearow
>>>>>
>>>>>
>>>>>
>>>>> —
>>>>> Questions? First check the Kernel Driver FAQ at
>>>>> http://www.osronline.com/article.cfm?id=256
>>>>>
>>>>> You are currently subscribed to ntdev as:
>>>>> xxxxx@hollistech.com To unsubscribe send a blank email to
>>>>> xxxxx@lists.osr.com
>>>>>
>>>>
>>>>
>>>>
>>>
>>>
>>>
>>
>>
>>
>
>
>

The USB stack takes the approach of having the function drivers park read
irps to accommodate incoming IO events like a mouse or keyboard HID event.
Same approach is used over on the network side of things. There is generally
no side channel signalling mechanism where bus drivers notify function
drivers that a read would be a good idea.

I tried and obviously failed to make clear that there are two basic models
of bus drivers - the PCI IO bus type bus driver and the SCSI serial type bus
driver and in both cases there is no bus driver to function driver initiated
request mechanism. In the PCI type bus driver function drivers themselves
handle interrupt events from devices (or they might directly poll the
device.) In the SCSI type bus driver function drivers either initiate all IO
transactions or queue IRPs for unsolicited incoming requests.

=====================
Mark Roddy DDK MVP
Windows 2003/XP/2000 Consulting
Hollis Technology Solutions 603-321-1032
www.hollistech.com

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of David J. Craig
Sent: Sunday, October 09, 2005 12:29 AM
To: Windows System Software Devs Interest List
Subject: Re:[ntdev] Question about bus driver

Read the documentation. I have never done anything in the
HID stack since DOS days. I suspect it is callbacks.

“fearow” wrote in message news:xxxxx@ntdev…
> >I agree with that USB disk don’t send the data upward. But how about
> >mouse and other HID devices? I used USB monitor (from
> >www.hhdsoftware.com) to capture the URBs between mouse
> driver and hub
> >driver. When I moved the mouse I only see the URBs from hub
> driver to
> >mouse driver. Which means URBs been sent from lower to upper
> driver. So
> >the question is: If the driver stack form lower to upper
> looks like following:
> >
> > A <- B <- C (A is the lowest driver)
> >
> > How does driver B get driver C’s DeviceObject?
> >
> > Fearow
> >
> >
> > “David J. Craig” wrote in message
> > news:xxxxx@ntdev…
> >> You still have it backwards. A USB disk does not just decide to
> >> suddenly ‘send’ data upward. It only does so in response to a
> >> request. Read Walter Oney’s 2nd Edition WDM book. Experiment and
> >> use windbg. You can also use the learning hardware available on
> >> osronline. Just don’t use their drivers until you
> understand what’s
> >> going on. If you can’t get a handle on it without using their
> >> drivers, you will need to spend at least a solid week with the
> >> hardware, drivers, and windbg until you have seen every
> routine being invoked.
> >>
> >> “fearow” wrote in message news:xxxxx@ntdev…
> >>> Thanks for your reply! I know USB device driver sends URB to bus
> >>> driver to Tx data and I think bus driver also uses URB to deliver
> >>> data to upper driver. The question is how does upper driver know
> >>> that there is data waiting in bus driver and then issues
> URB to read
> >>> the data? Or does bus driver send URB to deliver data to upper
> >>> driver as soon as data received? If bus driver initiates URB, how
> >>> does bus driver find upper driver’s DeviceObject? Can any
> kernel API do that? Thanks!
> >>>
> >>> Fearow
> >>>
> >>> “Mark Roddy” wrote in message
> news:xxxxx@ntdev…
> >>>> The details of how data is transferred between the bus driver
> >>>> managed IO bus and the function drivers for devices on
> that bus are
> >>>> specific to the bus and not defined by the PnP architecture.
> >>>> Consequently the answer to your question is ‘it depends’.
> >>>>
> >>>> Consider the PCI bus driver. Each function driver
> manages its own
> >>>> hardware resources on the PCI bus its device is attached to and
> >>>> does not interact with the PCI bus driver at all as far as data
> >>>> transfer operations are concerned. If the function
> driver needs to
> >>>> access PCI configuration space, then it interacts with
> the PCI bus
> >>>> driver through a device interface, or through specific
> PnP IRPs for
> >>>> configuration read/write operations.
> >>>>
> >>>> At the other end of the spectrum, consider a scsi bus
> driver (or a
> >>>> usb bus
> >>>> driver.) All data transfers are managed by the bus
> driver, and the
> >>>> bus driver defines a protocol and message format (SRB or
> URB) for
> >>>> transfering both data and configuration IO requests between
> >>>> function driver and bus driver. In both cases the
> function driver
> >>>> sends IRPs to bus driver PDO device objects and receives IRP
> >>>> completion request callback events to continue
> processing of those
> >>>> requests.
> >>>>
> >>>> =====================
> >>>> Mark Roddy DDK MVP
> >>>> Windows 2003/XP/2000 Consulting
> >>>> Hollis Technology Solutions 603-321-1032 www.hollistech.com
> >>>>
> >>>>> -----Original Message-----
> >>>>> From: xxxxx@lists.osr.com
> >>>>> [mailto:xxxxx@lists.osr.com] On Behalf Of fearow
> >>>>> Sent: Saturday, October 08, 2005 2:01 AM
> >>>>> To: Windows System Software Devs Interest List
> >>>>> Subject: [ntdev] Question about bus driver
> >>>>>
> >>>>> Hi All,
> >>>>>
> >>>>> I am new to WDM. When studied the Toaster sample code,
> I couldn’t
> >>>>> find any thing about sending the data to upper driver object. I
> >>>>> only can find the code about sending IRP from upper
> driver to bus
> >>>>> driver to R/W data. What happen if BUS driver receive data and
> >>>>> like to deliver to upper device object? Is there
> anyway let bus
> >>>>> driver acknowledge upper device object send IRP to bus
> driver to
> >>>>> read data? Thanks!
> >>>>>
> >>>>> Fearow
> >>>>>
> >>>>>
> >>>>>
> >>>>> —
> >>>>> Questions? First check the Kernel Driver FAQ at
> >>>>> http://www.osronline.com/article.cfm?id=256
> >>>>>
> >>>>> You are currently subscribed to ntdev as:
> >>>>> xxxxx@hollistech.com To unsubscribe send a blank email to
> >>>>> xxxxx@lists.osr.com
> >>>>>
> >>>>
> >>>>
> >>>>
> >>>
> >>>
> >>>
> >>
> >>
> >>
> >
> >
> >
>
>
>
> —
> Questions? First check the Kernel Driver FAQ at
> http://www.osronline.com/article.cfm?id=256
>
> You are currently subscribed to ntdev as:
> xxxxx@hollistech.com To unsubscribe send a blank email to
> xxxxx@lists.osr.com
>

B doesn’t get C’s device object. Whatever tool you are using is not
showing everything that is happening. In the HID stack, the hid mapper
(mouhid or kbdhid) continuously sends IRP_MJ_READs to the HID enumerated
PDO. HID completes these reads when there is data. In turn HIDCLASS
continuously sends reads to its own PDO. In the USB HID cases, these
are URBs. These reads are always pending and the usb bus completes them
when there is data.

On protocol buses, you generally have to send a read request to be
pended to get your data. When you send it is up to the data protocol
that your device has. For some devices you would always have a read
pending, for others you would only send a read after a certain event has
occurred (like a write).

d

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of fearow
Sent: Saturday, October 08, 2005 8:01 PM
To: Windows System Software Devs Interest List
Subject: Re:[ntdev] Question about bus driver

I agree with that USB disk don’t send the data upward. But how about
mouse
and other HID devices? I used USB monitor (from www.hhdsoftware.com) to

capture the URBs between mouse driver and hub driver. When I moved the
mouse
I only see the URBs from hub driver to mouse driver. Which means URBs
been
sent from lower to upper driver. So the question is: If the driver stack

form lower to upper looks like following:

A <- B <- C (A is the lowest driver)

How does driver B get driver C’s DeviceObject?

Fearow

“David J. Craig” wrote in message
news:xxxxx@ntdev…
> You still have it backwards. A USB disk does not just decide to
suddenly
> ‘send’ data upward. It only does so in response to a request. Read
> Walter Oney’s 2nd Edition WDM book. Experiment and use windbg. You
can
> also use the learning hardware available on osronline. Just don’t use

> their drivers until you understand what’s going on. If you can’t get
a
> handle on it without using their drivers, you will need to spend at
least
> a solid week with the hardware, drivers, and windbg until you have
seen
> every routine being invoked.
>
> “fearow” wrote in message news:xxxxx@ntdev…
>> Thanks for your reply! I know USB device driver sends URB to bus
driver
>> to Tx data and I think bus driver also uses URB to deliver data to
upper
>> driver. The question is how does upper driver know that there is data

>> waiting in bus driver and then issues URB to read the data? Or does
bus
>> driver send URB to deliver data to upper driver as soon as data
received?
>> If bus driver initiates URB, how does bus driver find upper driver’s
>> DeviceObject? Can any kernel API do that? Thanks!
>>
>> Fearow
>>
>> “Mark Roddy” wrote in message
news:xxxxx@ntdev…
>>> The details of how data is transferred between the bus driver
managed IO
>>> bus
>>> and the function drivers for devices on that bus are specific to the
bus
>>> and
>>> not defined by the PnP architecture. Consequently the answer to your
>>> question is ‘it depends’.
>>>
>>> Consider the PCI bus driver. Each function driver manages its own
>>> hardware
>>> resources on the PCI bus its device is attached to and does not
interact
>>> with the PCI bus driver at all as far as data transfer operations
are
>>> concerned. If the function driver needs to access PCI configuration
>>> space,
>>> then it interacts with the PCI bus driver through a device
interface, or
>>> through specific PnP IRPs for configuration read/write operations.
>>>
>>> At the other end of the spectrum, consider a scsi bus driver (or a
usb
>>> bus
>>> driver.) All data transfers are managed by the bus driver, and the
bus
>>> driver defines a protocol and message format (SRB or URB) for
>>> transfering
>>> both data and configuration IO requests between function driver and
bus
>>> driver. In both cases the function driver sends IRPs to bus driver
PDO
>>> device objects and receives IRP completion request callback events
to
>>> continue processing of those requests.
>>>
>>> =====================
>>> Mark Roddy DDK MVP
>>> Windows 2003/XP/2000 Consulting
>>> Hollis Technology Solutions 603-321-1032
>>> www.hollistech.com
>>>
>>>> -----Original Message-----
>>>> From: xxxxx@lists.osr.com
>>>> [mailto:xxxxx@lists.osr.com] On Behalf Of fearow
>>>> Sent: Saturday, October 08, 2005 2:01 AM
>>>> To: Windows System Software Devs Interest List
>>>> Subject: [ntdev] Question about bus driver
>>>>
>>>> Hi All,
>>>>
>>>> I am new to WDM. When studied the Toaster sample code, I
>>>> couldn’t find any thing about sending the data to upper
>>>> driver object. I only can find the code about sending IRP
>>>> from upper driver to bus driver to R/W data. What happen if
>>>> BUS driver receive data and like to deliver to upper device
>>>> object? Is there anyway let bus driver acknowledge upper
>>>> device object send IRP to bus driver to read data? Thanks!
>>>>
>>>> Fearow
>>>>
>>>>
>>>>
>>>> —
>>>> Questions? First check the Kernel Driver FAQ at
>>>> http://www.osronline.com/article.cfm?id=256
>>>>
>>>> You are currently subscribed to ntdev as:
>>>> xxxxx@hollistech.com To unsubscribe send a blank email to
>>>> xxxxx@lists.osr.com
>>>>
>>>
>>>
>>>
>>
>>
>>
>
>
>


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: xxxxx@microsoft.com
To unsubscribe send a blank email to xxxxx@lists.osr.com

fearow wrote:

I agree with that USB disk don’t send the data upward. But how about mouse
and other HID devices?

No USB device can send data on its own. It simply is not possible. USB
is an entirely host-driven protocol. If the host controller does not
query the device during a frame, then the device will not have an
opportunity to send or receive any data. And if no driver has queued up
an URB by the start of a frame, the host controller will not query the
device.

I used USB monitor (from www.hhdsoftware.com) to
capture the URBs between mouse driver and hub driver. When I moved the mouse
I only see the URBs from hub driver to mouse driver. Which means URBs been
sent from lower to upper driver.

Nope. The mouse cannot have sent data unless the host controller asked
for it, and the host controller would not have done that unless an
upper-level driver queued up an URB. Now, the URB might have been
queued up for a long time, so it’s possible your USB trace simply missed it.


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

Today I used DeviceStudio’s WDM sniffer to capture IRPs between USB mouse
and USB hub and found two URB_FUNCTION_BULK_OR_INTERRUPT_TRANSFER URB sent
to USB hub right after plug-in the mouse. I also found out that in DDK
sample code isousb and bulkusb, URB always been sent to lower device after
compelete previous URB no mater if App. want to read data or not.

I think I got my answer. Thanks for everybody’s help!

“Doron Holan” wrote in message
news:xxxxx@ntdev…
B doesn’t get C’s device object. Whatever tool you are using is not
showing everything that is happening. In the HID stack, the hid mapper
(mouhid or kbdhid) continuously sends IRP_MJ_READs to the HID enumerated
PDO. HID completes these reads when there is data. In turn HIDCLASS
continuously sends reads to its own PDO. In the USB HID cases, these
are URBs. These reads are always pending and the usb bus completes them
when there is data.

On protocol buses, you generally have to send a read request to be
pended to get your data. When you send it is up to the data protocol
that your device has. For some devices you would always have a read
pending, for others you would only send a read after a certain event has
occurred (like a write).

d

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of fearow
Sent: Saturday, October 08, 2005 8:01 PM
To: Windows System Software Devs Interest List
Subject: Re:[ntdev] Question about bus driver

I agree with that USB disk don’t send the data upward. But how about
mouse
and other HID devices? I used USB monitor (from www.hhdsoftware.com) to

capture the URBs between mouse driver and hub driver. When I moved the
mouse
I only see the URBs from hub driver to mouse driver. Which means URBs
been
sent from lower to upper driver. So the question is: If the driver stack

form lower to upper looks like following:

A <- B <- C (A is the lowest driver)

How does driver B get driver C’s DeviceObject?

Fearow

“David J. Craig” wrote in message
news:xxxxx@ntdev…
> You still have it backwards. A USB disk does not just decide to
suddenly
> ‘send’ data upward. It only does so in response to a request. Read
> Walter Oney’s 2nd Edition WDM book. Experiment and use windbg. You
can
> also use the learning hardware available on osronline. Just don’t use

> their drivers until you understand what’s going on. If you can’t get
a
> handle on it without using their drivers, you will need to spend at
least
> a solid week with the hardware, drivers, and windbg until you have
seen
> every routine being invoked.
>
> “fearow” wrote in message news:xxxxx@ntdev…
>> Thanks for your reply! I know USB device driver sends URB to bus
driver
>> to Tx data and I think bus driver also uses URB to deliver data to
upper
>> driver. The question is how does upper driver know that there is data

>> waiting in bus driver and then issues URB to read the data? Or does
bus
>> driver send URB to deliver data to upper driver as soon as data
received?
>> If bus driver initiates URB, how does bus driver find upper driver’s
>> DeviceObject? Can any kernel API do that? Thanks!
>>
>> Fearow
>>
>> “Mark Roddy” wrote in message
news:xxxxx@ntdev…
>>> The details of how data is transferred between the bus driver
managed IO
>>> bus
>>> and the function drivers for devices on that bus are specific to the
bus
>>> and
>>> not defined by the PnP architecture. Consequently the answer to your
>>> question is ‘it depends’.
>>>
>>> Consider the PCI bus driver. Each function driver manages its own
>>> hardware
>>> resources on the PCI bus its device is attached to and does not
interact
>>> with the PCI bus driver at all as far as data transfer operations
are
>>> concerned. If the function driver needs to access PCI configuration
>>> space,
>>> then it interacts with the PCI bus driver through a device
interface, or
>>> through specific PnP IRPs for configuration read/write operations.
>>>
>>> At the other end of the spectrum, consider a scsi bus driver (or a
usb
>>> bus
>>> driver.) All data transfers are managed by the bus driver, and the
bus
>>> driver defines a protocol and message format (SRB or URB) for
>>> transfering
>>> both data and configuration IO requests between function driver and
bus
>>> driver. In both cases the function driver sends IRPs to bus driver
PDO
>>> device objects and receives IRP completion request callback events
to
>>> continue processing of those requests.
>>>
>>> =====================
>>> Mark Roddy DDK MVP
>>> Windows 2003/XP/2000 Consulting
>>> Hollis Technology Solutions 603-321-1032
>>> www.hollistech.com
>>>
>>>> -----Original Message-----
>>>> From: xxxxx@lists.osr.com
>>>> [mailto:xxxxx@lists.osr.com] On Behalf Of fearow
>>>> Sent: Saturday, October 08, 2005 2:01 AM
>>>> To: Windows System Software Devs Interest List
>>>> Subject: [ntdev] Question about bus driver
>>>>
>>>> Hi All,
>>>>
>>>> I am new to WDM. When studied the Toaster sample code, I
>>>> couldn’t find any thing about sending the data to upper
>>>> driver object. I only can find the code about sending IRP
>>>> from upper driver to bus driver to R/W data. What happen if
>>>> BUS driver receive data and like to deliver to upper device
>>>> object? Is there anyway let bus driver acknowledge upper
>>>> device object send IRP to bus driver to read data? Thanks!
>>>>
>>>> Fearow
>>>>
>>>>
>>>>
>>>> —
>>>> Questions? First check the Kernel Driver FAQ at
>>>> http://www.osronline.com/article.cfm?id=256
>>>>
>>>> You are currently subscribed to ntdev as:
>>>> xxxxx@hollistech.com To unsubscribe send a blank email to
>>>> xxxxx@lists.osr.com
>>>>
>>>
>>>
>>>
>>
>>
>>
>
>
>


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: xxxxx@microsoft.com
To unsubscribe send a blank email to xxxxx@lists.osr.com