Windows System Software -- Consulting, Training, Development -- Unique Expertise, Guaranteed Results

Before Posting...
Please check out the Community Guidelines in the Announcements and Administration Category.

How to access PCIe device without help from PnP

Michael_RolleMichael_Rolle Member - All Emails Posts: 135
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.

Comments

  • Don_BurnDon_Burn Member - All Emails Posts: 1,649
    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 <xxxxx@lists.osr.com>
    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://www.osronline.com/showlists.cfm?list=ntdev>;

    MONTHLY seminars on crash dump analysis, WDF, Windows internals and software
    drivers!
    Details at <http://www.osr.com/seminars>;

    To unsubscribe, visit the List Server section of OSR Online at
    <http://www.osronline.com/page.cfm?name=ListServer>;
  • Peter_Viscarola_(OSR)Peter_Viscarola_(OSR) Administrator Posts: 7,138
    <quote>
    there is no method of getting to PCI configuration space, if you are
    not the driver that owns the device
    </quote>

    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:

    <quote>
    This is all owned by the PCI driver
    </quote>

    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

    Peter Viscarola
    OSR
    @OSRDrivers

  • Michael_RolleMichael_Rolle Member - All Emails Posts: 135
    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 <xxxxx@lists.osr.com>
    > 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://www.osronline.com/showlists.cfm?list=ntdev>;
    >
    > MONTHLY seminars on crash dump analysis, WDF, Windows internals and software
    > drivers!
    > Details at <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
    >
    > Visit the list online at: <http://www.osronline.com/showlists.cfm?list=ntdev>;
    >
    > MONTHLY seminars on crash dump analysis, WDF, Windows internals and software drivers!
    > Details at <http://www.osr.com/seminars>;
    >
    > To unsubscribe, visit the List Server section of OSR Online at <http://www.osronline.com/page.cfm?name=ListServer>;
    >
    >

    --
    Michael Rolle
    xxxxx@rolle.name
    408-313-8149
  • Michael_RolleMichael_Rolle Member - All Emails Posts: 135
    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 <xxxxx@lists.osr.com>
    > 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://www.osronline.com/showlists.cfm?list=ntdev>;
    >
    > MONTHLY seminars on crash dump analysis, WDF, Windows internals and software
    > drivers!
    > Details at <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
    >
    > Visit the list online at: <http://www.osronline.com/showlists.cfm?list=ntdev>;
    >
    > MONTHLY seminars on crash dump analysis, WDF, Windows internals and software drivers!
    > Details at <http://www.osr.com/seminars>;
    >
    > To unsubscribe, visit the List Server section of OSR Online at <http://www.osronline.com/page.cfm?name=ListServer>;
    >
    >

    --
    Michael Rolle
    xxxxx@rolle.name
    408-313-8149
  • Don_BurnDon_Burn Member - All Emails Posts: 1,649
    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 <xxxxx@lists.osr.com>
    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 <xxxxx@lists.osr.com>
    > 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://www.osronline.com/showlists.cfm?list=ntdev>;
    >
    > MONTHLY seminars on crash dump analysis, WDF, Windows internals and software
    > drivers!
    > Details at <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
    >
    > Visit the list online at: <http://www.osronline.com/showlists.cfm?list=ntdev>;
    >
    > MONTHLY seminars on crash dump analysis, WDF, Windows internals and software drivers!
    > Details at <http://www.osr.com/seminars>;
    >
    > To unsubscribe, visit the List Server section of OSR Online at <http://www.osronline.com/page.cfm?name=ListServer>;
    >
    >

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


    ---
    NTDEV is sponsored by OSR

    Visit the list online at: <http://www.osronline.com/showlists.cfm?list=ntdev>;

    MONTHLY seminars on crash dump analysis, WDF, Windows internals and software drivers!
    Details at <http://www.osr.com/seminars>;

    To unsubscribe, visit the List Server section of OSR Online at <http://www.osronline.com/page.cfm?name=ListServer>;
  • Don_BurnDon_Burn Member - All Emails Posts: 1,649
    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 <xxxxx@lists.osr.com>
    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 <xxxxx@lists.osr.com>
    > 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://www.osronline.com/showlists.cfm?list=ntdev>;
    >
    > MONTHLY seminars on crash dump analysis, WDF, Windows internals and
    > software drivers!
    > Details at <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
    >
    > Visit the list online at:
    > <http://www.osronline.com/showlists.cfm?list=ntdev>;
    >
    > MONTHLY seminars on crash dump analysis, WDF, Windows internals and software drivers!
    > Details at <http://www.osr.com/seminars>;
    >
    > To unsubscribe, visit the List Server section of OSR Online at
    > <http://www.osronline.com/page.cfm?name=ListServer>;
    >
    >

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


    ---
    NTDEV is sponsored by OSR

    Visit the list online at: <http://www.osronline.com/showlists.cfm?list=ntdev>;

    MONTHLY seminars on crash dump analysis, WDF, Windows internals and software drivers!
    Details at <http://www.osr.com/seminars>;

    To unsubscribe, visit the List Server section of OSR Online at <http://www.osronline.com/page.cfm?name=ListServer>;
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Upcoming OSR Seminars
Writing WDF Drivers 25 Feb 2019 OSR Seminar Space
Developing Minifilters 8 April 2019 OSR Seminar Space