Generic way to scan the pci

hi all,
i want to know what is the generic way of scanning the bus for
enumerating all the devices on the bus so that it doesnot limit to any bus
no either 1,2,or 3.

Thanks
Nayan


Tried the new MSN Messenger? It’s cool! Download now.
http://messenger.msn.com/Download/Default.aspx?mkt=en-in

Windows does the scanning and owns the ports that control the PCI bus. In
the past HalGetBusData could be used to walk the PCI devices, but that
function is deprecated. Take a look at Mark Roddy’s excellent paper on
replacing HalGetBusData at http://www.hollistech.com/ under Resources.


Don Burn (MVP, Windows DDK)
Windows 2k/XP/2k3 Filesystem and Driver Consulting
http://www.windrvr.com

“nayan kumar” wrote in message news:xxxxx@ntdev…
> hi all,
> i want to know what is the generic way of scanning the bus for
> enumerating all the devices on the bus so that it doesnot limit to any bus
> no either 1,2,or 3.
>
> Thanks
> Nayan
>
> _________________________________________________________________
> Tried the new MSN Messenger? It’s cool! Download now.
> http://messenger.msn.com/Download/Default.aspx?mkt=en-in
>
>

This kind of questions come up once a while in NTDEV and the msft NG.
The OP can use the classic 3 level nested loop and HalGetBusDataByOffset
to enumerate the entire PCI system.

Microsoft made these function “deprecated” for good reasons but I doubt
if they will (can) remove it from the HAL export table.

Calvin Guan (DDK MVP)
Sr. Staff Engineer
NetXtreme NTX Miniport
Broadcom Corporation
Connecting Everything(r)

-----Original Message-----
From: xxxxx@lists.osr.com [mailto:bounce-259588-
xxxxx@lists.osr.com] On Behalf Of Don Burn
Sent: Saturday, August 19, 2006 7:28 AM
To: Windows System Software Devs Interest List
Subject: Re:[ntdev] Generic way to scan the pci

Windows does the scanning and owns the ports that control the PCI bus.
In
the past HalGetBusData could be used to walk the PCI devices, but that
function is deprecated. Take a look at Mark Roddy’s excellent paper
on
replacing HalGetBusData at http://www.hollistech.com/ under Resources.


Don Burn (MVP, Windows DDK)
Windows 2k/XP/2k3 Filesystem and Driver Consulting
http://www.windrvr.com

“nayan kumar” wrote in message
> news:xxxxx@ntdev…
> > hi all,
> > i want to know what is the generic way of scanning the bus
for
> > enumerating all the devices on the bus so that it doesnot limit to
any
> bus
> > no either 1,2,or 3.
> >
> > Thanks
> > Nayan
> >
> > _________________________________________________________________
> > Tried the new MSN Messenger? It’s cool! Download now.
> > http://messenger.msn.com/Download/Default.aspx?mkt=en-in
> >
> >
>
>
>
> —
> 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

Yeah it is stuck in the HAL for now, however it remains not a good idea to
use it. If you really need global information about pci bus configuration a
pci bus filter driver is probably a better way to go, although of course bus
filter drivers remain undocumented.

=====================
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 Calvin
(Hao) Guan
Sent: Saturday, August 19, 2006 11:19 PM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] Generic way to scan the pci

This kind of questions come up once a while in NTDEV and the msft NG.
The OP can use the classic 3 level nested loop and
HalGetBusDataByOffset to enumerate the entire PCI system.

Microsoft made these function “deprecated” for good reasons
but I doubt if they will (can) remove it from the HAL export table.

Calvin Guan (DDK MVP)
Sr. Staff Engineer
NetXtreme NTX Miniport
Broadcom Corporation
Connecting Everything(r)

> -----Original Message-----
> From: xxxxx@lists.osr.com [mailto:bounce-259588-
> xxxxx@lists.osr.com] On Behalf Of Don Burn
> Sent: Saturday, August 19, 2006 7:28 AM
> To: Windows System Software Devs Interest List
> Subject: Re:[ntdev] Generic way to scan the pci
>
> Windows does the scanning and owns the ports that control
the PCI bus.
In
> the past HalGetBusData could be used to walk the PCI
devices, but that
> function is deprecated. Take a look at Mark Roddy’s excellent paper
on
> replacing HalGetBusData at http://www.hollistech.com/ under
Resources.
>
>
> –
> Don Burn (MVP, Windows DDK)
> Windows 2k/XP/2k3 Filesystem and Driver Consulting
> http://www.windrvr.com
>
>
>
> “nayan kumar” wrote in message
> > news:xxxxx@ntdev…
> > > hi all,
> > > i want to know what is the generic way of scanning the bus
> for
> > > enumerating all the devices on the bus so that it doesnot limit to
> any
> > bus
> > > no either 1,2,or 3.
> > >
> > > Thanks
> > > Nayan
> > >
> > > _________________________________________________________________
> > > Tried the new MSN Messenger? It’s cool! Download now.
> > > http://messenger.msn.com/Download/Default.aspx?mkt=en-in
> > >
> > >
> >
> >
> >
> > —
> > 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
>

Hi Sir,
Thanks for your kind support.my question was is there any generic
way to find how many bus my pci .sys is managing.For example suppose i want
to use this function PCIReadConfig()
in which i have to pass busno .

Thanks
Nayan

From: “Don Burn”
>Reply-To: “Windows System Software Devs Interest List”
>
>To: “Windows System Software Devs Interest List”
>Subject: Re:[ntdev] Generic way to scan the pci
>Date: Sat, 19 Aug 2006 10:28:20 -0400
>
>Windows does the scanning and owns the ports that control the PCI bus. In
>the past HalGetBusData could be used to walk the PCI devices, but that
>function is deprecated. Take a look at Mark Roddy’s excellent paper on
>replacing HalGetBusData at http://www.hollistech.com/ under Resources.
>
>
>–
>Don Burn (MVP, Windows DDK)
>Windows 2k/XP/2k3 Filesystem and Driver Consulting
>http://www.windrvr.com
>
>
>
>“nayan kumar” wrote in message
>news:xxxxx@ntdev…
> > hi all,
> > i want to know what is the generic way of scanning the bus for
> > enumerating all the devices on the bus so that it doesnot limit to any
>bus
> > no either 1,2,or 3.
> >
> > Thanks
> > Nayan
> >
> >
> > Tried the new MSN Messenger? It’s cool! Download now.
> > http://messenger.msn.com/Download/Default.aspx?mkt=en-in
> >
> >
>
>
>
>—
>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


Live the life in style with MSN Lifestyle. Check out!
http://content.msn.co.in/Lifestyle/Default

Well as far as I know, PCIReadConfig was something for Windows 98, or the
open software one. So you are not going to be able to use it.


Don Burn (MVP, Windows DDK)
Windows 2k/XP/2k3 Filesystem and Driver Consulting
http://www.windrvr.com
Remove StopSpam from the email to reply

“nayan kumar” wrote in message news:xxxxx@ntdev…
> Hi Sir,
> Thanks for your kind support.my question was is there any generic
> way to find how many bus my pci .sys is managing.For example suppose i
> want to use this function PCIReadConfig()
> in which i have to pass busno .
>
> Thanks
> Nayan
>

Your driver ought not to be managing any pci busses unless it has a
specialized PCI bus that it needs to manage, and even then this is not
really supported. Your driver ought to be managing a PCI function on a PCI
device and should not care at all about the bus topology of the system.

=====================
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 nayan kumar
Sent: Sunday, August 20, 2006 11:56 AM
To: Windows System Software Devs Interest List
Subject: Re:[ntdev] Generic way to scan the pci

Hi Sir,
Thanks for your kind support.my question was is there
any generic way to find how many bus my pci .sys is
managing.For example suppose i want to use this function
PCIReadConfig() in which i have to pass busno .

Thanks
Nayan

>From: “Don Burn”
> >Reply-To: “Windows System Software Devs Interest List”
> >
> >To: “Windows System Software Devs Interest List”
>
> >Subject: Re:[ntdev] Generic way to scan the pci
> >Date: Sat, 19 Aug 2006 10:28:20 -0400
> >
> >Windows does the scanning and owns the ports that control
> the PCI bus.
> >In the past HalGetBusData could be used to walk the PCI devices, but
> >that function is deprecated. Take a look at Mark Roddy’s excellent
> >paper on replacing HalGetBusData at
> http://www.hollistech.com/ under Resources.
> >
> >
> >–
> >Don Burn (MVP, Windows DDK)
> >Windows 2k/XP/2k3 Filesystem and Driver Consulting
> >http://www.windrvr.com
> >
> >
> >
> >“nayan kumar” wrote in message
> >news:xxxxx@ntdev…
> > > hi all,
> > > i want to know what is the generic way of scanning the bus
> > > for enumerating all the devices on the bus so that it
> doesnot limit
> > > to any
> >bus
> > > no either 1,2,or 3.
> > >
> > > Thanks
> > > Nayan
> > >
> > >
> > > Tried the new MSN Messenger? It’s cool! Download now.
> > > http://messenger.msn.com/Download/Default.aspx?mkt=en-in
> > >
> > >
> >
> >
> >
> >—
> >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
>
>

> Live the life in style with MSN Lifestyle. Check out!
> http://content.msn.co.in/Lifestyle/Default
>
>
> —
> 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
>

Yeah, a bus filter certainly will do although automatically attaching to
devices behind a p2p bridge needs some extra work (I personally called
it recursive attaching). The OP should be warned that a bus filter is
not just as easy as intercepting QDR/BusRelations; detaching from the
bus correctly in all possible cases needs some serious work. Also keep
in mind that bus filter is not signable.

There is other much easier way to get the PCI FDO legally w/o a bus
filter if a) bus topologic/relation is not a concern and b) no w2k
support, only xp and up.

I hesitate suggesting any of these methods any more in various NGs
because it defeats the msft’s purposes of deprecating the HAL functions
so why not just go with the good old easy meal. Nothing is easier than
just simply calling HalXxx. I figured there is nothing wrong with the
HalXxx functions themselves assuming programmer knows what they are
doing. If they manage to figure out how to do it in other ways, they
probably know what they are doing:).

There are business and engineering reasons to access arbitrary PCI
devices from within a pci device driver in some cases. It’s the host
bridge’s (or root complex) responsibility to trap port cfc/cf8 access
sequence (other mechanism for pcie extended config), convert them to PCI
cfg cycles and forward to the PCI target. The HAL functions are there to
initiate the request to the host bridge. It should work for all versions
of winnts if Microsoft didn’t screw it up and the platform is not
broken. On the other hand, a device driver under no circumstance should
manipulate the cfc/cf8 ports directly because you don’t have the
spinlock that synchronizes the access with other s/w entities.

Calvin Guan (DDK MVP)
Sr. Staff Engineer
NetXtreme NTX Miniport
Broadcom Corporation
Connecting Everything(r)

-----Original Message-----
From: xxxxx@lists.osr.com [mailto:bounce-259634-
xxxxx@lists.osr.com] On Behalf Of Mark Roddy
Sent: Sunday, August 20, 2006 6:55 AM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] Generic way to scan the pci

Yeah it is stuck in the HAL for now, however it remains not a good
idea to
use it. If you really need global information about pci bus
configuration
a
pci bus filter driver is probably a better way to go, although of
course
bus
filter drivers remain undocumented.

=====================
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 Calvin
> (Hao) Guan
> Sent: Saturday, August 19, 2006 11:19 PM
> To: Windows System Software Devs Interest List
> Subject: RE: [ntdev] Generic way to scan the pci
>
> This kind of questions come up once a while in NTDEV and the msft
NG.
> The OP can use the classic 3 level nested loop and
> HalGetBusDataByOffset to enumerate the entire PCI system.
>
> Microsoft made these function “deprecated” for good reasons
> but I doubt if they will (can) remove it from the HAL export table.
>
> Calvin Guan (DDK MVP)
> Sr. Staff Engineer
> NetXtreme NTX Miniport
> Broadcom Corporation
> Connecting Everything(r)
>
> > -----Original Message-----
> > From: xxxxx@lists.osr.com [mailto:bounce-259588-
> > xxxxx@lists.osr.com] On Behalf Of Don Burn
> > Sent: Saturday, August 19, 2006 7:28 AM
> > To: Windows System Software Devs Interest List
> > Subject: Re:[ntdev] Generic way to scan the pci
> >
> > Windows does the scanning and owns the ports that control
> the PCI bus.
> In
> > the past HalGetBusData could be used to walk the PCI
> devices, but that
> > function is deprecated. Take a look at Mark Roddy’s excellent
paper
> on
> > replacing HalGetBusData at http://www.hollistech.com/ under
> Resources.
> >
> >
> > –
> > Don Burn (MVP, Windows DDK)
> > Windows 2k/XP/2k3 Filesystem and Driver Consulting
> > http://www.windrvr.com
> >
> >
> >
> > “nayan kumar” wrote in message
> > > news:xxxxx@ntdev…
> > > > hi all,
> > > > i want to know what is the generic way of scanning the
bus
> > for
> > > > enumerating all the devices on the bus so that it doesnot limit
to
> > any
> > > bus
> > > > no either 1,2,or 3.
> > > >
> > > > Thanks
> > > > Nayan
> > > >
> > > >
_________________________________________________________________
> > > > Tried the new MSN Messenger? It’s cool! Download now.
> > > > http://messenger.msn.com/Download/Default.aspx?mkt=en-in
> > > >
> > > >
> > >
> > >
> > >
> > > —
> > > 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
> >
>
>
> —
> 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

What do you mean by “how many bus my pci .sys is managing”? Is your
device a pci bridge that enumerates child PCI functions on its secondary
bus?

Calvin Guan (DDK MVP)
Sr. Staff Engineer
NetXtreme NTX Miniport
Broadcom Corporation
Connecting Everything(r)

-----Original Message-----
From: xxxxx@lists.osr.com [mailto:bounce-259638-
xxxxx@lists.osr.com] On Behalf Of nayan kumar
Sent: Sunday, August 20, 2006 8:56 AM
To: Windows System Software Devs Interest List
Subject: Re:[ntdev] Generic way to scan the pci

Hi Sir,
Thanks for your kind support.my question was is there any
generic
way to find how many bus my pci .sys is managing.For example suppose i
want
to use this function PCIReadConfig()
in which i have to pass busno .

Thanks
Nayan

>From: “Don Burn”
> >Reply-To: “Windows System Software Devs Interest List”
> >
> >To: “Windows System Software Devs Interest List”

> >Subject: Re:[ntdev] Generic way to scan the pci
> >Date: Sat, 19 Aug 2006 10:28:20 -0400
> >
> >Windows does the scanning and owns the ports that control the PCI
bus.
> In
> >the past HalGetBusData could be used to walk the PCI devices, but
that
> >function is deprecated. Take a look at Mark Roddy’s excellent paper
on
> >replacing HalGetBusData at http://www.hollistech.com/ under
Resources.
> >
> >
> >–
> >Don Burn (MVP, Windows DDK)
> >Windows 2k/XP/2k3 Filesystem and Driver Consulting
> >http://www.windrvr.com
> >
> >
> >
> >“nayan kumar” wrote in message
> >news:xxxxx@ntdev…
> > > hi all,
> > > i want to know what is the generic way of scanning the bus
for
> > > enumerating all the devices on the bus so that it doesnot limit to
any
> >bus
> > > no either 1,2,or 3.
> > >
> > > Thanks
> > > Nayan
> > >
> > >
> > > Tried the new MSN Messenger? It’s cool! Download now.
> > > http://messenger.msn.com/Download/Default.aspx?mkt=en-in
> > >
> > >
> >
> >
> >
> >—
> >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
>
>

> Live the life in style with MSN Lifestyle. Check out!
> http://content.msn.co.in/Lifestyle/Default
>
>
> —
> 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

This is 32 bit only since the HAL routines don’t exist at all on 64 bit
platforms (IIRC)

d

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Calvin (Hao)
Guan
Sent: Sunday, August 20, 2006 11:45 AM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] Generic way to scan the pci

Yeah, a bus filter certainly will do although automatically attaching to
devices behind a p2p bridge needs some extra work (I personally called
it recursive attaching). The OP should be warned that a bus filter is
not just as easy as intercepting QDR/BusRelations; detaching from the
bus correctly in all possible cases needs some serious work. Also keep
in mind that bus filter is not signable.

There is other much easier way to get the PCI FDO legally w/o a bus
filter if a) bus topologic/relation is not a concern and b) no w2k
support, only xp and up.

I hesitate suggesting any of these methods any more in various NGs
because it defeats the msft’s purposes of deprecating the HAL functions
so why not just go with the good old easy meal. Nothing is easier than
just simply calling HalXxx. I figured there is nothing wrong with the
HalXxx functions themselves assuming programmer knows what they are
doing. If they manage to figure out how to do it in other ways, they
probably know what they are doing:).

There are business and engineering reasons to access arbitrary PCI
devices from within a pci device driver in some cases. It’s the host
bridge’s (or root complex) responsibility to trap port cfc/cf8 access
sequence (other mechanism for pcie extended config), convert them to PCI
cfg cycles and forward to the PCI target. The HAL functions are there to
initiate the request to the host bridge. It should work for all versions
of winnts if Microsoft didn’t screw it up and the platform is not
broken. On the other hand, a device driver under no circumstance should
manipulate the cfc/cf8 ports directly because you don’t have the
spinlock that synchronizes the access with other s/w entities.

Calvin Guan (DDK MVP)
Sr. Staff Engineer
NetXtreme NTX Miniport
Broadcom Corporation
Connecting Everything(r)

-----Original Message-----
From: xxxxx@lists.osr.com [mailto:bounce-259634-
xxxxx@lists.osr.com] On Behalf Of Mark Roddy
Sent: Sunday, August 20, 2006 6:55 AM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] Generic way to scan the pci

Yeah it is stuck in the HAL for now, however it remains not a good
idea to
use it. If you really need global information about pci bus
configuration
a
pci bus filter driver is probably a better way to go, although of
course
bus
filter drivers remain undocumented.

=====================
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 Calvin
> (Hao) Guan
> Sent: Saturday, August 19, 2006 11:19 PM
> To: Windows System Software Devs Interest List
> Subject: RE: [ntdev] Generic way to scan the pci
>
> This kind of questions come up once a while in NTDEV and the msft
NG.
> The OP can use the classic 3 level nested loop and
> HalGetBusDataByOffset to enumerate the entire PCI system.
>
> Microsoft made these function “deprecated” for good reasons
> but I doubt if they will (can) remove it from the HAL export table.
>
> Calvin Guan (DDK MVP)
> Sr. Staff Engineer
> NetXtreme NTX Miniport
> Broadcom Corporation
> Connecting Everything(r)
>
> > -----Original Message-----
> > From: xxxxx@lists.osr.com [mailto:bounce-259588-
> > xxxxx@lists.osr.com] On Behalf Of Don Burn
> > Sent: Saturday, August 19, 2006 7:28 AM
> > To: Windows System Software Devs Interest List
> > Subject: Re:[ntdev] Generic way to scan the pci
> >
> > Windows does the scanning and owns the ports that control
> the PCI bus.
> In
> > the past HalGetBusData could be used to walk the PCI
> devices, but that
> > function is deprecated. Take a look at Mark Roddy’s excellent
paper
> on
> > replacing HalGetBusData at http://www.hollistech.com/ under
> Resources.
> >
> >
> > –
> > Don Burn (MVP, Windows DDK)
> > Windows 2k/XP/2k3 Filesystem and Driver Consulting
> > http://www.windrvr.com
> >
> >
> >
> > “nayan kumar” wrote in message
> > > news:xxxxx@ntdev…
> > > > hi all,
> > > > i want to know what is the generic way of scanning the
bus
> > for
> > > > enumerating all the devices on the bus so that it doesnot limit
to
> > any
> > > bus
> > > > no either 1,2,or 3.
> > > >
> > > > Thanks
> > > > Nayan
> > > >
> > > >
_________________________________________________________________
> > > > Tried the new MSN Messenger? It’s cool! Download now.
> > > > http://messenger.msn.com/Download/Default.aspx?mkt=en-in
> > > >
> > > >
> > >
> > >
> > >
> > > —
> > > 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
> >
>
>
> —
> 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

Doron,

You don’t :slight_smile:

HalGetBusData, HalSetBusData, HalGetBusDataByOffset, HalSetBusDataByOffset
exist and are exported on x64 XP, Windows 2003, and Vista.

I don’t know do they work correctly for PCIe Extended Configuration Space or
they don’t (on Vista/Longhorn).

Dmitriy Budko,
VMware

-----Original Message-----
From: xxxxx@lists.osr.com [mailto:bounce-259652-
xxxxx@lists.osr.com] On Behalf Of Doron Holan
Sent: Sunday, August 20, 2006 5:53 PM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] Generic way to scan the pci

This is 32 bit only since the HAL routines don’t exist at all on 64 bit
platforms (IIRC)

d

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Calvin (Hao)
Guan
Sent: Sunday, August 20, 2006 11:45 AM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] Generic way to scan the pci

Yeah, a bus filter certainly will do although automatically attaching to
devices behind a p2p bridge needs some extra work (I personally called
it recursive attaching). The OP should be warned that a bus filter is
not just as easy as intercepting QDR/BusRelations; detaching from the
bus correctly in all possible cases needs some serious work. Also keep
in mind that bus filter is not signable.

There is other much easier way to get the PCI FDO legally w/o a bus
filter if a) bus topologic/relation is not a concern and b) no w2k
support, only xp and up.

I hesitate suggesting any of these methods any more in various NGs
because it defeats the msft’s purposes of deprecating the HAL functions
so why not just go with the good old easy meal. Nothing is easier than
just simply calling HalXxx. I figured there is nothing wrong with the
HalXxx functions themselves assuming programmer knows what they are
doing. If they manage to figure out how to do it in other ways, they
probably know what they are doing:).

There are business and engineering reasons to access arbitrary PCI
devices from within a pci device driver in some cases. It’s the host
bridge’s (or root complex) responsibility to trap port cfc/cf8 access
sequence (other mechanism for pcie extended config), convert them to PCI
cfg cycles and forward to the PCI target. The HAL functions are there to
initiate the request to the host bridge. It should work for all versions
of winnts if Microsoft didn’t screw it up and the platform is not
broken. On the other hand, a device driver under no circumstance should
manipulate the cfc/cf8 ports directly because you don’t have the
spinlock that synchronizes the access with other s/w entities.

Calvin Guan (DDK MVP)
Sr. Staff Engineer
NetXtreme NTX Miniport
Broadcom Corporation
Connecting Everything(r)

When I tryed the x64 ddk build with the HalGetxxx calls they did not get
linked I then move to the COM interface method with
BUILD_BUS_INTERFACE_STANDARD as descibed by Don Burn above from Mark Roddy’s
white paper and it worked. I needed to restore the PCI BAR values because
when going into Standby on a machine all Voltage to the PCI slots went to
zero. Our FPGA lost these and when coming out of standby did not work.
Hence I had to restore these values.

I also found some other samples on the internet for implementing this
technique. I used the method that allows the callbacks to be at IRQL
DISPATCH_LEVEL too.

-William Michael Jones

“Dmitriy Budko” wrote in message news:xxxxx@ntdev…
Doron,

You don’t :slight_smile:

HalGetBusData, HalSetBusData, HalGetBusDataByOffset, HalSetBusDataByOffset
exist and are exported on x64 XP, Windows 2003, and Vista.

I don’t know do they work correctly for PCIe Extended Configuration Space or
they don’t (on Vista/Longhorn).

Dmitriy Budko,
VMware

> -----Original Message-----
> From: xxxxx@lists.osr.com [mailto:bounce-259652-
> xxxxx@lists.osr.com] On Behalf Of Doron Holan
> Sent: Sunday, August 20, 2006 5:53 PM
> To: Windows System Software Devs Interest List
> Subject: RE: [ntdev] Generic way to scan the pci
>
> This is 32 bit only since the HAL routines don’t exist at all on 64 bit
> platforms (IIRC)
>
> d
>
> -----Original Message-----
> From: xxxxx@lists.osr.com
> [mailto:xxxxx@lists.osr.com] On Behalf Of Calvin (Hao)
> Guan
> Sent: Sunday, August 20, 2006 11:45 AM
> To: Windows System Software Devs Interest List
> Subject: RE: [ntdev] Generic way to scan the pci
>
> Yeah, a bus filter certainly will do although automatically attaching to
> devices behind a p2p bridge needs some extra work (I personally called
> it recursive attaching). The OP should be warned that a bus filter is
> not just as easy as intercepting QDR/BusRelations; detaching from the
> bus correctly in all possible cases needs some serious work. Also keep
> in mind that bus filter is not signable.
>
> There is other much easier way to get the PCI FDO legally w/o a bus
> filter if a) bus topologic/relation is not a concern and b) no w2k
> support, only xp and up.
>
> I hesitate suggesting any of these methods any more in various NGs
> because it defeats the msft’s purposes of deprecating the HAL functions
> so why not just go with the good old easy meal. Nothing is easier than
> just simply calling HalXxx. I figured there is nothing wrong with the
> HalXxx functions themselves assuming programmer knows what they are
> doing. If they manage to figure out how to do it in other ways, they
> probably know what they are doing:).
>
> There are business and engineering reasons to access arbitrary PCI
> devices from within a pci device driver in some cases. It’s the host
> bridge’s (or root complex) responsibility to trap port cfc/cf8 access
> sequence (other mechanism for pcie extended config), convert them to PCI
> cfg cycles and forward to the PCI target. The HAL functions are there to
> initiate the request to the host bridge. It should work for all versions
> of winnts if Microsoft didn’t screw it up and the platform is not
> broken. On the other hand, a device driver under no circumstance should
> manipulate the cfc/cf8 ports directly because you don’t have the
> spinlock that synchronizes the access with other s/w entities.
>
> Calvin Guan (DDK MVP)
> Sr. Staff Engineer
> NetXtreme NTX Miniport
> Broadcom Corporation
> Connecting Everything(r)

Access PCI device of your own (like the one in your case) is never an
issue, in fact the recommended methods (either bus interface or
IRP_MN_Xxx_config) should always be used instead of the deprecated
HalXxx.

The OP wants to access pci config space for devices other than his own
hence his questions.

HalGetBusData and HalSetBusData are removed from ddk headers in x64/ia64
build environment but HalGet/SetBusDataByOffset are not. Neither were
they removed from HAL export table.

Calvin Guan (DDK MVP)
Sr. Staff Engineer
NetXtreme NTX Miniport
Broadcom Corporation
Connecting Everything(r)

-----Original Message-----
From: xxxxx@lists.osr.com [mailto:bounce-259691-
xxxxx@lists.osr.com] On Behalf Of William Michael Jones
Sent: Monday, August 21, 2006 6:58 AM
To: Windows System Software Devs Interest List
Subject: Re:[ntdev] Generic way to scan the pci

When I tryed the x64 ddk build with the HalGetxxx calls they did not
get
linked I then move to the COM interface method with
BUILD_BUS_INTERFACE_STANDARD as descibed by Don Burn above from Mark
Roddy’s
white paper and it worked. I needed to restore the PCI BAR values
because
when going into Standby on a machine all Voltage to the PCI slots went
to
zero. Our FPGA lost these and when coming out of standby did not
work.
Hence I had to restore these values.

I also found some other samples on the internet for implementing this
technique. I used the method that allows the callbacks to be at IRQL
DISPATCH_LEVEL too.

-William Michael Jones

“Dmitriy Budko” wrote in message
news:xxxxx@ntdev…
> Doron,
>
> You don’t :slight_smile:
>
> HalGetBusData, HalSetBusData, HalGetBusDataByOffset,
HalSetBusDataByOffset
> exist and are exported on x64 XP, Windows 2003, and Vista.
>
> I don’t know do they work correctly for PCIe Extended Configuration
Space
> or
> they don’t (on Vista/Longhorn).
>
>
> Dmitriy Budko,
> VMware
>
> > -----Original Message-----
> > From: xxxxx@lists.osr.com [mailto:bounce-259652-
> > xxxxx@lists.osr.com] On Behalf Of Doron Holan
> > Sent: Sunday, August 20, 2006 5:53 PM
> > To: Windows System Software Devs Interest List
> > Subject: RE: [ntdev] Generic way to scan the pci
> >
> > This is 32 bit only since the HAL routines don’t exist at all on 64
bit
> > platforms (IIRC)
> >
> > d
> >
> > -----Original Message-----
> > From: xxxxx@lists.osr.com
> > [mailto:xxxxx@lists.osr.com] On Behalf Of Calvin (Hao)
> > Guan
> > Sent: Sunday, August 20, 2006 11:45 AM
> > To: Windows System Software Devs Interest List
> > Subject: RE: [ntdev] Generic way to scan the pci
> >
> > Yeah, a bus filter certainly will do although automatically
attaching to
> > devices behind a p2p bridge needs some extra work (I personally
called
> > it recursive attaching). The OP should be warned that a bus filter
is
> > not just as easy as intercepting QDR/BusRelations; detaching from
the
> > bus correctly in all possible cases needs some serious work. Also
keep
> > in mind that bus filter is not signable.
> >
> > There is other much easier way to get the PCI FDO legally w/o a bus
> > filter if a) bus topologic/relation is not a concern and b) no w2k
> > support, only xp and up.
> >
> > I hesitate suggesting any of these methods any more in various NGs
> > because it defeats the msft’s purposes of deprecating the HAL
functions
> > so why not just go with the good old easy meal. Nothing is easier
than
> > just simply calling HalXxx. I figured there is nothing wrong with
the
> > HalXxx functions themselves assuming programmer knows what they are
> > doing. If they manage to figure out how to do it in other ways, they
> > probably know what they are doing:).
> >
> > There are business and engineering reasons to access arbitrary PCI
> > devices from within a pci device driver in some cases. It’s the host
> > bridge’s (or root complex) responsibility to trap port cfc/cf8
access
> > sequence (other mechanism for pcie extended config), convert them to
PCI
> > cfg cycles and forward to the PCI target. The HAL functions are
there to
> > initiate the request to the host bridge. It should work for all
versions
> > of winnts if Microsoft didn’t screw it up and the platform is not
> > broken. On the other hand, a device driver under no circumstance
should
> > manipulate the cfc/cf8 ports directly because you don’t have the
> > spinlock that synchronizes the access with other s/w entities.
> >
> > Calvin Guan (DDK MVP)
> > Sr. Staff Engineer
> > NetXtreme NTX Miniport
> > Broadcom Corporation
> > Connecting Everything(r)
>
>
>
> —
> 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

> to use this function PCIReadConfig()

It is called HalGetBusData, and is considered obsolete.

Maxim Shatskih, Windows DDK MVP
StorageCraft Corporation
xxxxx@storagecraft.com
http://www.storagecraft.com

> white paper and it worked. I needed to restore the PCI BAR values because

when going into Standby on a machine all Voltage to the PCI slots went to
zero. Our FPGA lost these and when coming out of standby did not work.

Try using IoInvalidateDeviceState and then responding to MN_QUERY_DEVICE_STATE
to force another START IRP to be sent to your device on resume.

Maxim Shatskih, Windows DDK MVP
StorageCraft Corporation
xxxxx@storagecraft.com
http://www.storagecraft.com

Thank you Maxim. Did not think of that and interesting. I did use Mark
Roddy’s method and the problem is solved.

-William Michael Jones

“Dmitriy Budko” wrote in message news:xxxxx@ntdev…
Doron,

You don’t :slight_smile:

HalGetBusData, HalSetBusData, HalGetBusDataByOffset, HalSetBusDataByOffset
exist and are exported on x64 XP, Windows 2003, and Vista.

I don’t know do they work correctly for PCIe Extended Configuration Space or
they don’t (on Vista/Longhorn).

Dmitriy Budko,
VMware

> -----Original Message-----
> From: xxxxx@lists.osr.com [mailto:bounce-259652-
> xxxxx@lists.osr.com] On Behalf Of Doron Holan
> Sent: Sunday, August 20, 2006 5:53 PM
> To: Windows System Software Devs Interest List
> Subject: RE: [ntdev] Generic way to scan the pci
>
> This is 32 bit only since the HAL routines don’t exist at all on 64 bit
> platforms (IIRC)
>
> d
>
> -----Original Message-----
> From: xxxxx@lists.osr.com
> [mailto:xxxxx@lists.osr.com] On Behalf Of Calvin (Hao)
> Guan
> Sent: Sunday, August 20, 2006 11:45 AM
> To: Windows System Software Devs Interest List
> Subject: RE: [ntdev] Generic way to scan the pci
>
> Yeah, a bus filter certainly will do although automatically attaching to
> devices behind a p2p bridge needs some extra work (I personally called
> it recursive attaching). The OP should be warned that a bus filter is
> not just as easy as intercepting QDR/BusRelations; detaching from the
> bus correctly in all possible cases needs some serious work. Also keep
> in mind that bus filter is not signable.
>
> There is other much easier way to get the PCI FDO legally w/o a bus
> filter if a) bus topologic/relation is not a concern and b) no w2k
> support, only xp and up.
>
> I hesitate suggesting any of these methods any more in various NGs
> because it defeats the msft’s purposes of deprecating the HAL functions
> so why not just go with the good old easy meal. Nothing is easier than
> just simply calling HalXxx. I figured there is nothing wrong with the
> HalXxx functions themselves assuming programmer knows what they are
> doing. If they manage to figure out how to do it in other ways, they
> probably know what they are doing:).
>
> There are business and engineering reasons to access arbitrary PCI
> devices from within a pci device driver in some cases. It’s the host
> bridge’s (or root complex) responsibility to trap port cfc/cf8 access
> sequence (other mechanism for pcie extended config), convert them to PCI
> cfg cycles and forward to the PCI target. The HAL functions are there to
> initiate the request to the host bridge. It should work for all versions
> of winnts if Microsoft didn’t screw it up and the platform is not
> broken. On the other hand, a device driver under no circumstance should
> manipulate the cfc/cf8 ports directly because you don’t have the
> spinlock that synchronizes the access with other s/w entities.
>
> Calvin Guan (DDK MVP)
> Sr. Staff Engineer
> NetXtreme NTX Miniport
> Broadcom Corporation
> Connecting Everything(r)

nayan kumar wrote:

Thanks for your kind support.my question was is there any
generic way to find how many bus my pci .sys is managing.For example
suppose i want to use this function PCIReadConfig()
in which i have to pass busno .

There can be 256 busses, each with 32 devices, each with 8 functions.
You have to try them all. Bus numbers are not contiguous, so you can’t
take shortcuts.


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