How to access PCIe device without help from PnP

Hi,
I want to access certain registers for things internally part of the processor, which are presented as though they were on the PCIe bus.
As a specific example, the thermal reading on the AMD K15 family is a 32-bit value denoted in their docs as D18F3xA4, meaning device 18h, function 3, address A4h. I think that node 0 is implied here.
I believe I can get a physical address from that by combining these numbers with a base configuration space address located in an MSR. This is all very processor-specific.
I was wondering if there was generic mechanism to get a mapping to configuration space, given the node, device, function, and address.
Since this is not a plug-n-play feature, I don’t have the luxury of getting resources already packaged for me by the PnP manager.

No, there is no method of getting to PCI configuration space, if you are
not the driver that owns the device. This is all owned by the PCI driver
which is PnP!

Don Burn
Windows Driver Consulting
Website: http://www.windrvr.com

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of xxxxx@rolle.name
Sent: Monday, March 19, 2018 2:41 AM
To: Windows System Software Devs Interest List
Subject: [ntdev] How to access PCIe device without help from PnP

Hi,
I want to access certain registers for things internally part of the
processor, which are presented as though they were on the PCIe bus.
As a specific example, the thermal reading on the AMD K15 family is a 32-bit
value denoted in their docs as D18F3xA4, meaning device 18h, function 3,
address A4h. I think that node 0 is implied here.
I believe I can get a physical address from that by combining these numbers
with a base configuration space address located in an MSR. This is all very
processor-specific.
I was wondering if there was generic mechanism to get a mapping to
configuration space, given the node, device, function, and address.
Since this is not a plug-n-play feature, I don’t have the luxury of getting
resources already packaged for me by the PnP manager.


NTDEV is sponsored by OSR

Visit the list online at:
http:

MONTHLY seminars on crash dump analysis, WDF, Windows internals and software
drivers!
Details at http:

To unsubscribe, visit the List Server section of OSR Online at
http:</http:></http:></http:>

OK… that’s a bit of an exageration and Mr. Burn knows it.

But the SPIRIT of Mr. Burn’s post is right on target. As he says:

So right!

While it is certainly possible to arbitrarily query PCI Configuration Space, the registers to do so are owned by PCI. As a result, in Windows, architecturally, you are absolutely forbidden from manipulating these registers yourself. To do so, you risk screwing up the bus driver.

Please. Just don’t do these hackish things.

Peter
OSR
@OSRDrivers

Thanks, Don, good to see you’re still around.

OK, so PnP manages the PCI space.  Then does the PnP driver expose any
functions to map, or get phys addr for, a specific bus/device/function?

On 3/19/2018 3:52 AM, xxxxx@windrvr.com wrote:

No, there is no method of getting to PCI configuration space, if you are
not the driver that owns the device. This is all owned by the PCI driver
which is PnP!

Don Burn
Windows Driver Consulting
Website: http://www.windrvr.com

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of xxxxx@rolle.name
Sent: Monday, March 19, 2018 2:41 AM
To: Windows System Software Devs Interest List
> Subject: [ntdev] How to access PCIe device without help from PnP
>
> Hi,
> I want to access certain registers for things internally part of the
> processor, which are presented as though they were on the PCIe bus.
> As a specific example, the thermal reading on the AMD K15 family is a 32-bit
> value denoted in their docs as D18F3xA4, meaning device 18h, function 3,
> address A4h. I think that node 0 is implied here.
> I believe I can get a physical address from that by combining these numbers
> with a base configuration space address located in an MSR. This is all very
> processor-specific.
> I was wondering if there was generic mechanism to get a mapping to
> configuration space, given the node, device, function, and address.
> Since this is not a plug-n-play feature, I don’t have the luxury of getting
> resources already packaged for me by the PnP manager.
>
>
>
> —
> NTDEV is sponsored by OSR
>
> Visit the list online at:
> http:
>
> MONTHLY seminars on crash dump analysis, WDF, Windows internals and software
> drivers!
> Details at http:
>
> To unsubscribe, visit the List Server section of OSR Online at
> http:
>
>
> —
> NTDEV is sponsored by OSR
>
> Visit the list online at: http:
>
> MONTHLY seminars on crash dump analysis, WDF, Windows internals and software drivers!
> Details at http:
>
> To unsubscribe, visit the List Server section of OSR Online at http:
>
>


Michael Rolle
xxxxx@rolle.name
408-313-8149</http:></http:></http:></http:></http:></http:>

Also, I’m wondering how the PnP driver copes with processor
dependencies.  Or does the PCI have a standardized layout for its IO
space.  Even so, how would the driver get a base phys addr for the IO
space in a processor-independent way, i.e. some HAL call?

On 3/19/2018 3:52 AM, xxxxx@windrvr.com wrote:

No, there is no method of getting to PCI configuration space, if you are
not the driver that owns the device. This is all owned by the PCI driver
which is PnP!

Don Burn
Windows Driver Consulting
Website: http://www.windrvr.com

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of xxxxx@rolle.name
Sent: Monday, March 19, 2018 2:41 AM
To: Windows System Software Devs Interest List
> Subject: [ntdev] How to access PCIe device without help from PnP
>
> Hi,
> I want to access certain registers for things internally part of the
> processor, which are presented as though they were on the PCIe bus.
> As a specific example, the thermal reading on the AMD K15 family is a 32-bit
> value denoted in their docs as D18F3xA4, meaning device 18h, function 3,
> address A4h. I think that node 0 is implied here.
> I believe I can get a physical address from that by combining these numbers
> with a base configuration space address located in an MSR. This is all very
> processor-specific.
> I was wondering if there was generic mechanism to get a mapping to
> configuration space, given the node, device, function, and address.
> Since this is not a plug-n-play feature, I don’t have the luxury of getting
> resources already packaged for me by the PnP manager.
>
>
>
> —
> NTDEV is sponsored by OSR
>
> Visit the list online at:
> http:
>
> MONTHLY seminars on crash dump analysis, WDF, Windows internals and software
> drivers!
> Details at http:
>
> To unsubscribe, visit the List Server section of OSR Online at
> http:
>
>
> —
> NTDEV is sponsored by OSR
>
> Visit the list online at: http:
>
> MONTHLY seminars on crash dump analysis, WDF, Windows internals and software drivers!
> Details at http:
>
> To unsubscribe, visit the List Server section of OSR Online at http:
>
>


Michael Rolle
xxxxx@rolle.name
408-313-8149</http:></http:></http:></http:></http:></http:>

Unfortunately, NO. You need to get onto the stack that owns the device, and then use IRP_MN_READ_CONFIG and IRP_MN_WRITE_CONFIG to access things. I would be careful on the WRITE_CONFIG, you can’t be sure someone else is not doing something.

I did a bus filter driver that for some devices tracked the config’s and provided an interface. Part of me keeps thinking of writing a demo driver that would give read access to all PCI devices config data.

Don Burn
Windows Driver Consulting
Website: http://www.windrvr.com

-----Original Message-----
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of xxxxx@rolle.name
Sent: Monday, March 19, 2018 4:19 PM
To: Windows System Software Devs Interest List
Subject: Re: [ntdev] How to access PCIe device without help from PnP

Thanks, Don, good to see you’re still around.

OK, so PnP manages the PCI space. Then does the PnP driver expose any functions to map, or get phys addr for, a specific bus/device/function?

On 3/19/2018 3:52 AM, xxxxx@windrvr.com wrote:
> No, there is no method of getting to PCI configuration space, if you are
> not the driver that owns the device. This is all owned by the PCI driver
> which is PnP!
>
>
> Don Burn
> Windows Driver Consulting
> Website: http://www.windrvr.com
>
>
>
> -----Original Message-----
> From: xxxxx@lists.osr.com
> [mailto:xxxxx@lists.osr.com] On Behalf Of xxxxx@rolle.name
> Sent: Monday, March 19, 2018 2:41 AM
> To: Windows System Software Devs Interest List
> Subject: [ntdev] How to access PCIe device without help from PnP
>
> Hi,
> I want to access certain registers for things internally part of the
> processor, which are presented as though they were on the PCIe bus.
> As a specific example, the thermal reading on the AMD K15 family is a 32-bit
> value denoted in their docs as D18F3xA4, meaning device 18h, function 3,
> address A4h. I think that node 0 is implied here.
> I believe I can get a physical address from that by combining these numbers
> with a base configuration space address located in an MSR. This is all very
> processor-specific.
> I was wondering if there was generic mechanism to get a mapping to
> configuration space, given the node, device, function, and address.
> Since this is not a plug-n-play feature, I don’t have the luxury of getting
> resources already packaged for me by the PnP manager.
>
>
>
> —
> NTDEV is sponsored by OSR
>
> Visit the list online at:
> http:
>
> MONTHLY seminars on crash dump analysis, WDF, Windows internals and software
> drivers!
> Details at http:
>
> To unsubscribe, visit the List Server section of OSR Online at
> http:
>
>
> —
> NTDEV is sponsored by OSR
>
> Visit the list online at: http:
>
> MONTHLY seminars on crash dump analysis, WDF, Windows internals and software drivers!
> Details at http:
>
> To unsubscribe, visit the List Server section of OSR Online at http:
>
>


Michael Rolle
xxxxx@rolle.name
408-313-8149


NTDEV is sponsored by OSR

Visit the list online at: http:

MONTHLY seminars on crash dump analysis, WDF, Windows internals and software drivers!
Details at http:

To unsubscribe, visit the List Server section of OSR Online at http:</http:></http:></http:></http:></http:></http:></http:></http:></http:>

The PCI config space is well defined (though it can have extensions). So basically you have a known structure with pointers to the BAR’s and some other data. If you are asking if there is a standard for what is in the BAR’s no there is not, that is what keeps driver writers employed.

Don Burn
Windows Driver Consulting
Website: http://www.windrvr.com

-----Original Message-----
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of xxxxx@rolle.name
Sent: Monday, March 19, 2018 4:22 PM
To: Windows System Software Devs Interest List
Subject: Re: [ntdev] How to access PCIe device without help from PnP

Also, I’m wondering how the PnP driver copes with processor dependencies. Or does the PCI have a standardized layout for its IO space. Even so, how would the driver get a base phys addr for the IO space in a processor-independent way, i.e. some HAL call?

On 3/19/2018 3:52 AM, xxxxx@windrvr.com wrote:
> No, there is no method of getting to PCI configuration space, if you are
> not the driver that owns the device. This is all owned by the PCI driver
> which is PnP!
>
>
> Don Burn
> Windows Driver Consulting
> Website: http://www.windrvr.com
>
>
>
> -----Original Message-----
> From: xxxxx@lists.osr.com
> [mailto:xxxxx@lists.osr.com] On Behalf Of xxxxx@rolle.name
> Sent: Monday, March 19, 2018 2:41 AM
> To: Windows System Software Devs Interest List
> Subject: [ntdev] How to access PCIe device without help from PnP
>
> Hi,
> I want to access certain registers for things internally part of the
> processor, which are presented as though they were on the PCIe bus.
> As a specific example, the thermal reading on the AMD K15 family is a
> 32-bit value denoted in their docs as D18F3xA4, meaning device 18h,
> function 3, address A4h. I think that node 0 is implied here.
> I believe I can get a physical address from that by combining these
> numbers with a base configuration space address located in an MSR.
> This is all very processor-specific.
> I was wondering if there was generic mechanism to get a mapping to
> configuration space, given the node, device, function, and address.
> Since this is not a plug-n-play feature, I don’t have the luxury of
> getting resources already packaged for me by the PnP manager.
>
>
>
> —
> NTDEV is sponsored by OSR
>
> Visit the list online at:
> http:
>
> MONTHLY seminars on crash dump analysis, WDF, Windows internals and
> software drivers!
> Details at http:
>
> To unsubscribe, visit the List Server section of OSR Online at
> http:
>
>
> —
> NTDEV is sponsored by OSR
>
> Visit the list online at:
> http:
>
> MONTHLY seminars on crash dump analysis, WDF, Windows internals and software drivers!
> Details at http:
>
> To unsubscribe, visit the List Server section of OSR Online at
> http:
>
>


Michael Rolle
xxxxx@rolle.name
408-313-8149


NTDEV is sponsored by OSR

Visit the list online at: http:

MONTHLY seminars on crash dump analysis, WDF, Windows internals and software drivers!
Details at http:

To unsubscribe, visit the List Server section of OSR Online at http:</http:></http:></http:></http:></http:></http:></http:></http:></http:>