KMDF: Read from configuration space

Take a look at http://www.hollistech.com/ they have an excellent article on
“Replacing HalGetBusData in Windows 2000” you can use that approach to read
the data from your device.


Don Burn (MVP, Windows DDK)
Windows 2k/XP/2k3 Filesystem and Driver Consulting
Website: http://www.windrvr.com
Blog: http://msmvps.com/blogs/WinDrvr
Remove StopSpam to reply

“Vered Zvi” wrote in message news:xxxxx@ntdev…
> Hello,
>
> I built a KMDF driver for a customized PCI card.
> Is it possible to read data from the configuration space of the card
> (e.g: vendor id, class, … ) ?
> My card has 2 PCI BARs. I succeeded to read\write to\from those BARs.
>
> Thanks.
>
>
>
>
> The information contained in this communication is proprietary to Israel
> Aerospace Industries Ltd., ELTA Systems Ltd.
> and/or third parties, may contain classified or privileged information,
> and is intended only for
> the use of the intended addressee thereof. If you are not the intended
> addressee, please be aware
> that any use, disclosure, distribution and/or copying of this
> communication is strictly prohibited.
> If you receive this communication in error, please notify the sender
> immediately and delete it from
> your computer. Thank you.
>
>
> This message is processed by the PrivaWall Email Security Server.
>
>
>

Vered,

Please refrain from posing messages without the scary footer like your
message has (proprietary, classified !!!).
If your IT sticks the footer to any outgoing email, then you always have
the option
to post messages to this forum via the web interface.

Cheers,
Alexey

Vered Zvi wrote:

Hello,

I built a KMDF driver for a customized PCI card.
Is it possible to read data from the configuration space of the card
(e.g: vendor id, class, … ) ?
My card has 2 PCI BARs. I succeeded to read\write to\from those BARs.

Thanks.

The information contained in this communication is proprietary to
Israel Aerospace Industries Ltd., ELTA Systems Ltd.
and/or third parties, may contain classified or privileged
information, and is intended only for
the use of the intended addressee thereof. If you are not the intended
addressee, please be aware
that any use, disclosure, distribution and/or copying of this
communication is strictly prohibited.
If you receive this communication in error, please notify the sender
immediately and delete it from
your computer. Thank you.

This message is processed by the PrivaWall Email Security Server.


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

There are other differnt methods to send a request to lower layer. One method is by sending IRP_MN_READ_CONFIG to lower driver. You will recieve PCI_COMMON_CONFIG structure.

sreejesh warrier

Why do you want to read config space? You will get those information from windows registry.

sree

While IoGetDeviceProperty will get some of this stuff, I would not call that
reading from the registry. Where in the registry do you think you will get
this stuff, most places it resides are keys that Microsoft states are
subject to change so a really lousy idea to use in a driver?


Don Burn (MVP, Windows DDK)
Windows 2k/XP/2k3 Filesystem and Driver Consulting
Website: http://www.windrvr.com
Blog: http://msmvps.com/blogs/WinDrvr
Remove StopSpam to reply

wrote in message news:xxxxx@ntdev…
> Why do you want to read config space? You will get those information from
> windows registry.
>
> sree
>

Doesn’t the OP need this ?

http://support.microsoft.com/default.aspx?ID=KB;EN-US;Q253232&

That’s what I use to get the dimensions of the PCIe connection to the card (i.e. how many lanes) to feed back to the user. It’s in extended PCI config space.

I did not mean so. I said he can verify vendor,class,bars are correct or not from the registry.

While IoGetDeviceProperty will get some of this stuff, I would not call that
reading from the registry. Where in the registry do you think you will get
this stuff, most places it resides are keys that Microsoft states are
subject to change so a really lousy idea to use in a driver?


Don Burn (MVP, Windows DDK)
Windows 2k/XP/2k3 Filesystem and Driver Consulting

Back to the original question.

Unfortunately, there is no ready-made KMDF samples for accessing PCI
config space (at least, not in WDK),
but it is pretty easy to figure out how to do that.

With WDM there are two proper methods for accessing PCI config space:

  1. By sending an IRP down to the PCI bus driver
  2. By querying the PCI bus driver for a “bus interface” then using the
    callbacks in that interface for reading/writing the PCI config space.

With KMDF, I would go for the second method as all you need to do is to
query for an interface
with guid GUID_BUS_INTERFACE_STANDARD. There are plenty of samples that
show you how to do that.
Once you get the interface, you call it’s GetBusData() and SetBusData()
methods to access the PCI config space.

You can also go for the first method, though it involves a bit more
programming. You need to setup a WDF IO target, then send a WDF request
to it. Considering the lack of samples, pursuing this method will take
more programming effort.

Good luck !
Alexey

xxxxx@nestgroup.net wrote:

I did not mean so. I said he can verify vendor,class,bars are correct or not from the registry.

> While IoGetDeviceProperty will get some of this stuff, I would not call that
> reading from the registry. Where in the registry do you think you will get
> this stuff, most places it resides are keys that Microsoft states are
> subject to change so a really lousy idea to use in a driver?
>

> –
> Don Burn (MVP, Windows DDK)
> Windows 2k/XP/2k3 Filesystem and Driver Consulting
>


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

  1. read http://blogs.msdn.com/doronh/archive/2006/08/16/703157.aspx
  2. WdfFdoQueryForInterface (http://msdn.microsoft.com/en-us/library/aa490912.aspx)

d

-----Original Message-----
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of Alexey Polonsky
Sent: Tuesday, September 23, 2008 12:01 AM
To: Windows System Software Devs Interest List
Subject: Re: [ntdev] KMDF: Read from configuration space

Back to the original question.

Unfortunately, there is no ready-made KMDF samples for accessing PCI
config space (at least, not in WDK),
but it is pretty easy to figure out how to do that.

With WDM there are two proper methods for accessing PCI config space:

  1. By sending an IRP down to the PCI bus driver
  2. By querying the PCI bus driver for a “bus interface” then using the
    callbacks in that interface for reading/writing the PCI config space.

With KMDF, I would go for the second method as all you need to do is to
query for an interface
with guid GUID_BUS_INTERFACE_STANDARD. There are plenty of samples that
show you how to do that.
Once you get the interface, you call it’s GetBusData() and SetBusData()
methods to access the PCI config space.

You can also go for the first method, though it involves a bit more
programming. You need to setup a WDF IO target, then send a WDF request
to it. Considering the lack of samples, pursuing this method will take
more programming effort.

Good luck !
Alexey

xxxxx@nestgroup.net wrote:

I did not mean so. I said he can verify vendor,class,bars are correct or not from the registry.

> While IoGetDeviceProperty will get some of this stuff, I would not call that
> reading from the registry. Where in the registry do you think you will get
> this stuff, most places it resides are keys that Microsoft states are
> subject to change so a really lousy idea to use in a driver?
>

> –
> Don Burn (MVP, Windows DDK)
> Windows 2k/XP/2k3 Filesystem and Driver Consulting
>


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


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