Accessing PCI Configuration Space on PCI Bridge

Hi Everyone,
I was wondering if any of you might know the answer to this.

I’m trying to access the PCI Configration space on a PCI bridge adapter card. Basically I wrote a function WDM driver for a PMC module. This module sits ontop of a PCI Bridge adapter so I can plug it into the pci slot of my XP system. I want to access the PCI Configration Space of this adapter so that I can write to a register and increase the performance. I wrote a very simple filter driver for the adapter but when I install it, the PMC card isn’t recognized only the PCI Bridge adapter card. Am I missing something? I don’t have the source to the standard Windows pci.sys so I’m not sure how to go about doing it.

If I use the standard pci.sys driver everything works fine but I need to write my own driver to access The PCI Configuration space. Or do I? Can I use my function driver to access the Configuration Space of the PCI Bridge adapter? I think under Windows 2000 and XP you can’t do this.

Thanks

HalGetBusData/HalSetBusData remain available but deprecated. In general you should not be doing this, and I rather doubt you will be getting the performance improvement you think you will get. The other choice is to create a pci bus filter driver, which is undocumented but can be done, which will then give you supported access to the config space of any device on the pci bus. While you will then have a supported non-deprecated access mechanism, messing with bridge device config space is not supported (with exceptions for some non-standard platforms) and is thought to be very much the domain of the OS rather than something to be messed with by device drivers using the OS. Did I mention that I think this is a bad idea?

-----Original Message-----
From: xxxxx@lists.osr.com [mailto:bounce-275526-
xxxxx@lists.osr.com] On Behalf Of xxxxx@yahoo.com
Sent: Saturday, January 13, 2007 11:01 AM
To: Windows System Software Devs Interest List
Subject: [ntdev] Accessing PCI Configuration Space on PCI Bridge

Hi Everyone,
I was wondering if any of you might know the answer to this.

I’m trying to access the PCI Configration space on a PCI bridge adapter
card. Basically I wrote a function WDM driver for a PMC module. This
module sits ontop of a PCI Bridge adapter so I can plug it into the pci
slot of my XP system. I want to access the PCI Configration Space of
this adapter so that I can write to a register and increase the
performance. I wrote a very simple filter driver for the adapter but
when I install it, the PMC card isn’t recognized only the PCI Bridge
adapter card. Am I missing something? I don’t have the source to the
standard Windows pci.sys so I’m not sure how to go about doing it.

If I use the standard pci.sys driver everything works fine but I need
to write my own driver to access The PCI Configuration space. Or do I?
Can I use my function driver to access the Configuration Space of the
PCI Bridge adapter? I think under Windows 2000 and XP you can’t do
this.

Thanks


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

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

You can access the PCI config space using a mechanism of querying
BUS_INTERFACE_STANDARD from the PCI bus driver. Set the IRP minor code to
IRP_MN_QUERY_INTERFACE and the interface type to BUS_INTERFACE_STANDARD. You
can prepare this IRP and pass it to the PCI bus driver from your WDM
function driver. PCI bus driver should return function pointers for
GetBusData, SetBusData etc. You can then use these function pointers to
access the configuration space.
This is documented in DDK. There are two ways documented in DDK. One that I
mentioned above where you get bus driver’s interface pointers for
manipulating config space. Second way is to pass IRP_MN_READ_CONFIG or
IRP_MN_WRITE_CONFIG to the bus driver.

Refer to “Accessing Device Configuration Space” in DDK. They have given a
code sample as well.

Regards,
Mandar

From: xxxxx@yahoo.com
Reply-To: “Windows System Software Devs Interest List”

>To: “Windows System Software Devs Interest List”
>Subject: [ntdev] Accessing PCI Configuration Space on PCI Bridge
>Date: Sat, 13 Jan 2007 11:01:15 -0500 (EST)
>
>Hi Everyone,
> I was wondering if any of you might know the answer to this.
>
>I’m trying to access the PCI Configration space on a PCI bridge adapter
>card. Basically I wrote a function WDM driver for a PMC module. This
>module sits ontop of a PCI Bridge adapter so I can plug it into the pci
>slot of my XP system. I want to access the PCI Configration Space of this
>adapter so that I can write to a register and increase the performance. I
>wrote a very simple filter driver for the adapter but when I install it,
>the PMC card isn’t recognized only the PCI Bridge adapter card. Am I
>missing something? I don’t have the source to the standard Windows pci.sys
>so I’m not sure how to go about doing it.
>
>If I use the standard pci.sys driver everything works fine but I need to
>write my own driver to access The PCI Configuration space. Or do I? Can I
>use my function driver to access the Configuration Space of the PCI Bridge
>adapter? I think under Windows 2000 and XP you can’t do this.
>
>Thanks
>
>—
>Questions? First check the Kernel Driver FAQ at
>http://www.osronline.com/article.cfm?id=256
>
>To unsubscribe, visit the List Server section of OSR Online at
>http://www.osronline.com/page.cfm?name=ListServer

That method only works if you are on the stack of the device you want to
modify. Generically filtering arbitrary PCI devices requires a PCI bus
filter driver, although the OP may be able to filter the specific bridge
device instead of implementing a bus filter driver by using the device
(rather than class) upper filter methods documented in the DDK.

-----Original Message-----
From: xxxxx@lists.osr.com [mailto:bounce-275615-
xxxxx@lists.osr.com] On Behalf Of Mandar Barve
Sent: Monday, January 15, 2007 5:06 AM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] Accessing PCI Configuration Space on PCI Bridge

You can access the PCI config space using a mechanism of querying
BUS_INTERFACE_STANDARD from the PCI bus driver. Set the IRP minor code
to
IRP_MN_QUERY_INTERFACE and the interface type to
BUS_INTERFACE_STANDARD. You
can prepare this IRP and pass it to the PCI bus driver from your WDM
function driver. PCI bus driver should return function pointers for
GetBusData, SetBusData etc. You can then use these function pointers to
access the configuration space.
This is documented in DDK. There are two ways documented in DDK. One
that I
mentioned above where you get bus driver’s interface pointers for
manipulating config space. Second way is to pass IRP_MN_READ_CONFIG or
IRP_MN_WRITE_CONFIG to the bus driver.

Refer to “Accessing Device Configuration Space” in DDK. They have given
a
code sample as well.

Regards,
Mandar

>From: xxxxx@yahoo.com
>Reply-To: “Windows System Software Devs Interest List”
>
> >To: “Windows System Software Devs Interest List”
> >Subject: [ntdev] Accessing PCI Configuration Space on PCI Bridge
> >Date: Sat, 13 Jan 2007 11:01:15 -0500 (EST)
> >
> >Hi Everyone,
> > I was wondering if any of you might know the answer to this.
> >
> >I’m trying to access the PCI Configration space on a PCI bridge
> adapter
> >card. Basically I wrote a function WDM driver for a PMC module. This
> >module sits ontop of a PCI Bridge adapter so I can plug it into the
> pci
> >slot of my XP system. I want to access the PCI Configration Space of
> this
> >adapter so that I can write to a register and increase the
> performance. I
> >wrote a very simple filter driver for the adapter but when I install
> it,
> >the PMC card isn’t recognized only the PCI Bridge adapter card. Am I
> >missing something? I don’t have the source to the standard Windows
> pci.sys
> >so I’m not sure how to go about doing it.
> >
> >If I use the standard pci.sys driver everything works fine but I need
> to
> >write my own driver to access The PCI Configuration space. Or do I?
> Can I
> >use my function driver to access the Configuration Space of the PCI
> Bridge
> >adapter? I think under Windows 2000 and XP you can’t do this.
> >
> >Thanks
> >
> >—
> >Questions? First check the Kernel Driver FAQ at
> >http://www.osronline.com/article.cfm?id=256
> >
> >To unsubscribe, visit the List Server section of OSR Online at
> >http://www.osronline.com/page.cfm?name=ListServer
>
>
>
> —
> Questions? First check the Kernel Driver FAQ at
> http://www.osronline.com/article.cfm?id=256
>
> To unsubscribe, visit the List Server section of OSR Online at
> http://www.osronline.com/page.cfm?name=ListServer

Thanks Mandar,
I will take a look at this. I was under the
assumption that accessing a PCI bridge adapter card
from a function driver wasn’t supported under Windows
XP. I’ll check again.

Thanks,
-Chris

— Mandar Barve wrote:

> You can access the PCI config space using a
> mechanism of querying
> BUS_INTERFACE_STANDARD from the PCI bus driver. Set
> the IRP minor code to
> IRP_MN_QUERY_INTERFACE and the interface type to
> BUS_INTERFACE_STANDARD. You
> can prepare this IRP and pass it to the PCI bus
> driver from your WDM
> function driver. PCI bus driver should return
> function pointers for
> GetBusData, SetBusData etc. You can then use these
> function pointers to
> access the configuration space.
> This is documented in DDK. There are two ways
> documented in DDK. One that I
> mentioned above where you get bus driver’s interface
> pointers for
> manipulating config space. Second way is to pass
> IRP_MN_READ_CONFIG or
> IRP_MN_WRITE_CONFIG to the bus driver.
>
> Refer to “Accessing Device Configuration Space” in
> DDK. They have given a
> code sample as well.
>
> Regards,
> Mandar
>
>
> >From: xxxxx@yahoo.com
> >Reply-To: “Windows System Software Devs Interest
> List”
> >
> >To: “Windows System Software Devs Interest List”
>
> >Subject: [ntdev] Accessing PCI Configuration Space
> on PCI Bridge
> >Date: Sat, 13 Jan 2007 11:01:15 -0500 (EST)
> >
> >Hi Everyone,
> > I was wondering if any of you might know the
> answer to this.
> >
> >I’m trying to access the PCI Configration space on
> a PCI bridge adapter
> >card. Basically I wrote a function WDM driver for
> a PMC module. This
> >module sits ontop of a PCI Bridge adapter so I can
> plug it into the pci
> >slot of my XP system. I want to access the PCI
> Configration Space of this
> >adapter so that I can write to a register and
> increase the performance. I
> >wrote a very simple filter driver for the adapter
> but when I install it,
> >the PMC card isn’t recognized only the PCI Bridge
> adapter card. Am I
> >missing something? I don’t have the source to the
> standard Windows pci.sys
> >so I’m not sure how to go about doing it.
> >
> >If I use the standard pci.sys driver everything
> works fine but I need to
> >write my own driver to access The PCI Configuration
> space. Or do I? Can I
> >use my function driver to access the Configuration
> Space of the PCI Bridge
> >adapter? I think under Windows 2000 and XP you
> can’t do this.
> >
> >Thanks
> >
> >—
> >Questions? First check the Kernel Driver FAQ at
> >http://www.osronline.com/article.cfm?id=256
> >
> >To unsubscribe, visit the List Server section of
> OSR Online at
> >http://www.osronline.com/page.cfm?name=ListServer
>
>
>
> —
> Questions? First check the Kernel Driver FAQ at
> http://www.osronline.com/article.cfm?id=256
>
> To unsubscribe, visit the List Server section of OSR
> Online at
> http://www.osronline.com/page.cfm?name=ListServer
>

____________________________________________________________________________________
Need Mail bonding?
Go to the Yahoo! Mail Q&A for great tips from Yahoo! Answers users.
http://answers.yahoo.com/dir/?link=list&sid=396546091

Hi Mark,
Thanks for the reply. I researched further and found that I will need to somehow retrieve the PDO pointer to the PCI bridge adapter. I don’t believe I can do this with the function driver for the PMC module that I wrote.

If your PMC sits behind a transparent pci bridge (which is what I’m
assuming), then you basically don’t see the bridge itself, since
transparent pci bridges are handled by pci.sys. In this case, the only
‘supported’ way is the one pointed out by Mark Roddy: write a pci bus
filter.

If your PMC is behind a non-transparent bridge, you’ll see only the
bridge, but it will be a ‘normal’ pci device, and you’ll have to
explicitely enable ‘looking’ through it to whatever comes behind. But
then the you can access the the CONFIG space using
BUS_INTERFACE_STANDARD method.

Robin Mitra

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Chris M
Sent: Montag, 15. Januar 2007 16:49
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] Accessing PCI Configuration Space on PCI Bridge

Thanks Mandar,
I will take a look at this. I was under the
assumption that accessing a PCI bridge adapter card
from a function driver wasn’t supported under Windows
XP. I’ll check again.

Thanks,
-Chris

— Mandar Barve wrote:

> You can access the PCI config space using a
> mechanism of querying
> BUS_INTERFACE_STANDARD from the PCI bus driver. Set
> the IRP minor code to
> IRP_MN_QUERY_INTERFACE and the interface type to
> BUS_INTERFACE_STANDARD. You
> can prepare this IRP and pass it to the PCI bus
> driver from your WDM
> function driver. PCI bus driver should return
> function pointers for
> GetBusData, SetBusData etc. You can then use these
> function pointers to
> access the configuration space.
> This is documented in DDK. There are two ways
> documented in DDK. One that I
> mentioned above where you get bus driver’s interface
> pointers for
> manipulating config space. Second way is to pass
> IRP_MN_READ_CONFIG or
> IRP_MN_WRITE_CONFIG to the bus driver.
>
> Refer to “Accessing Device Configuration Space” in
> DDK. They have given a
> code sample as well.
>
> Regards,
> Mandar
>
>
> >From: xxxxx@yahoo.com
> >Reply-To: “Windows System Software Devs Interest
> List”
> >
> >To: “Windows System Software Devs Interest List”
>
> >Subject: [ntdev] Accessing PCI Configuration Space
> on PCI Bridge
> >Date: Sat, 13 Jan 2007 11:01:15 -0500 (EST)
> >
> >Hi Everyone,
> > I was wondering if any of you might know the
> answer to this.
> >
> >I’m trying to access the PCI Configration space on
> a PCI bridge adapter
> >card. Basically I wrote a function WDM driver for
> a PMC module. This
> >module sits ontop of a PCI Bridge adapter so I can
> plug it into the pci
> >slot of my XP system. I want to access the PCI
> Configration Space of this
> >adapter so that I can write to a register and
> increase the performance. I
> >wrote a very simple filter driver for the adapter
> but when I install it,
> >the PMC card isn’t recognized only the PCI Bridge
> adapter card. Am I
> >missing something? I don’t have the source to the
> standard Windows pci.sys
> >so I’m not sure how to go about doing it.
> >
> >If I use the standard pci.sys driver everything
> works fine but I need to
> >write my own driver to access The PCI Configuration
> space. Or do I? Can I
> >use my function driver to access the Configuration
> Space of the PCI Bridge
> >adapter? I think under Windows 2000 and XP you
> can’t do this.
> >
> >Thanks
> >
> >—
> >Questions? First check the Kernel Driver FAQ at
> >http://www.osronline.com/article.cfm?id=256
> >
> >To unsubscribe, visit the List Server section of
> OSR Online at
> >http://www.osronline.com/page.cfm?name=ListServer
>
>
>
> —
> Questions? First check the Kernel Driver FAQ at
> http://www.osronline.com/article.cfm?id=256
>
> To unsubscribe, visit the List Server section of OSR
> Online at
> http://www.osronline.com/page.cfm?name=ListServer
>

____________________________________________________________

Need Mail bonding?
Go to the Yahoo! Mail Q&A for great tips from Yahoo! Answers users.
http://answers.yahoo.com/dir/?link=list&sid=396546091


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

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

I know this might not be the ideal way of doing this but what about using ObReferenceObjectByName?
From what I’ve read, I could use this function to retrieve a Driver Object and then find the associated Device Objects. Once I get the Device Objects I’m just confused as to how to check to see if one of them matches the PCI Bridge adapter I am trying to access. This seems a bit simpler since I could call this function from my Function Driver. Can someone point me in the right direction?