does it mean that i have to send some values to pci bus and ask it to store it? i am just not understanding what is enumerating pci bus? should i assign to pci bus or read pci bus and do something?
what is function number that is once of the value used while addressing pci bus?
what is meant by "enumerating the PCI bus"
what is meant by "enumerating the PCI bus"
Walking my way in making my OS
- NickJohnson
- Member
- Posts: 1249
- Joined: Tue Mar 24, 2009 8:11 pm
- Location: Sunnyvale, California
Re: what is meant by "enumerating the PCI bus"
Enumerating means listing the contents of. Therefore, enumerating the PCI bus means going through all the PCI addresses where there could be devices (either by recursively finding the buses through PCI-PCI bridges, or if you're lazy, brute force) and reading the information about those devices to make a list of all devices on the system.
Re: what is meant by "enumerating the PCI bus"
The numbers associated with PCI are like IP address: it comes in the form bus:slot:function.
By convention, bus refer to bus id - to identify a bus; slot identify which slot of that bus; and functions are to index which functionality of that card, some card provide multiple functions.
One of the method is to loop on all possible addresses:
If there is a device on the address, there will be basic info(vendor id, etc) fetch from get_info (check the wiki for detail)
By convention, bus refer to bus id - to identify a bus; slot identify which slot of that bus; and functions are to index which functionality of that card, some card provide multiple functions.
One of the method is to loop on all possible addresses:
Code: Select all
for ( unsigned int bus_id=0; bus_id<256; bus_id++ ) {
for ( unsigned int slot_id=0; slot_id<32; slot_id++ ) {
for ( unsigned int func_id=0; func_id<8; func_id++ ) {
if ( pci_driver->get_info(&pci, bus_id, slot_id, func_id, &info ) < 0 ) break;
Re: what is meant by "enumerating the PCI bus"
how to do that?NickJohnson wrote:either by recursively finding the buses through PCI-PCI bridges
Walking my way in making my OS
Re: what is meant by "enumerating the PCI bus"
Hi,
Cheers,
Brendan
I was going to explain it here; then decided that if I'm explaining it I should try to do it properly and added Enumerating PCI Buses to the wiki page.hegde1997 wrote:how to do that?NickJohnson wrote:either by recursively finding the buses through PCI-PCI bridges
Cheers,
Brendan
For all things; perfection is, and will always remain, impossible to achieve in practice. However; by striving for perfection we create things that are as perfect as practically possible. Let the pursuit of perfection be our guide.
Re: what is meant by "enumerating the PCI bus"
Nice writeup. One assumption I've found (for x86) is that bus numbers are always assigned in increasing order. If that assumption is valid, a no-recursion implementation can set a "goal post" first to bus #0 and then move the goal post each time a PCI-PCI bridge is found. There's a specific value in the PCI-PCI bridge config space that gives the maximum bus number behind the bridge.Brendan wrote:I was going to explain it here; then decided that if I'm explaining it I should try to do it properly and added Enumerating PCI Buses to the wiki page.
Brendan, do you think my assumption is safe?
Re: what is meant by "enumerating the PCI bus"
Hi,
If there are gaps in the bus numbering then it would still work and would be safe - worst case would end up being similar to the brute force method (where you search lots of devices on buses that don't exist).
Cheers,
Brendan
Nothing (that I know of) says that PCI buses must be numbered sequentially. For example, a bridge may be configured with "secondary bus number = 4; subordinate bus number = 128" where buses 5 to 128 don't actually exist. There may also be valid reasons for leaving holes like this (e.g. avoiding the need to renumber buses for hot-plug PCI where bridges may be plugged in after boot).sounds wrote:One assumption I've found (for x86) is that bus numbers are always assigned in increasing order. If that assumption is valid, a no-recursion implementation can set a "goal post" first to bus #0 and then move the goal post each time a PCI-PCI bridge is found. There's a specific value in the PCI-PCI bridge config space that gives the maximum bus number behind the bridge.
Brendan, do you think my assumption is safe?
If there are gaps in the bus numbering then it would still work and would be safe - worst case would end up being similar to the brute force method (where you search lots of devices on buses that don't exist).
Cheers,
Brendan
For all things; perfection is, and will always remain, impossible to achieve in practice. However; by striving for perfection we create things that are as perfect as practically possible. Let the pursuit of perfection be our guide.
Re: what is meant by "enumerating the PCI bus"
Thanks BrendanBrendan wrote: I was going to explain it here; then decided that if I'm explaining it I should try to do it properly and added Enumerating PCI Buses to the wiki page.
Walking my way in making my OS