I am trying to understand the PCI spec to write my PCI driver. I am having a couple of questions:
1) For probing the pci devices mainly 4 things are important, Bus_Number, Device_Number, Function_Number and Register_Number. Do I have to go to every device and look at the Vendor_ID which is not 0xFFFFFFFF. Do I have to do it for every 255 buses.
2) What if we try to set the Vendor_ID to a specific value (I am right now trying it in a virtualized environment). How do we use the ports 0xCF8 & 0xCFC?
I couldn't find a good resource which explains PCI spec and give some demo code. I find out http://members.hyperlink.net.au/~chart/pci.htm but the site seems down.
Scanning PCI devices
Re: Scanning PCI devices
The wayback machine is your friend here.dream21 wrote:I couldn't find a good resource which explains PCI spec and give some demo code.
I find out http://members.hyperlink.net.au/~chart/pci.htm but the site seems down.
https://web.archive.org/web/20030628011 ... rt/pci.htm
- BrightLight
- Member
- Posts: 901
- Joined: Sat Dec 27, 2014 9:11 am
- Location: Maadi, Cairo, Egypt
- Contact:
Re: Scanning PCI devices
This wiki page has everything you need. In a nutshell, you use ports 0xCFC and 0xCF8 to read and write PCI configuration registers.
You know your OS is advanced when you stop using the Intel programming guide as a reference.
Re: Scanning PCI devices
The bus, device and function numbers can be combined to make a single 16-bit number, so you can just check every value between 0 and 65535 to see if the vendor/device ID is 0xFFFFFFFF.
This is what I'm currently doing, and it's plenty fast for my needs, and I would recommend going this route if you are just getting started.
Once you have everything working, you can speed things up quite a bit by starting with bus zero, and only scanning additional bus numbers that are referenced by a device on that bus, recursively.
And, by the way, there is no reason to "set" the vendor ID on a device. You simply read it to help figure out what type of device it is.
This is what I'm currently doing, and it's plenty fast for my needs, and I would recommend going this route if you are just getting started.
Once you have everything working, you can speed things up quite a bit by starting with bus zero, and only scanning additional bus numbers that are referenced by a device on that bus, recursively.
And, by the way, there is no reason to "set" the vendor ID on a device. You simply read it to help figure out what type of device it is.
Project: OZone
Source: GitHub
Current Task: LIB/OBJ file support
"The more they overthink the plumbing, the easier it is to stop up the drain." - Montgomery Scott
Source: GitHub
Current Task: LIB/OBJ file support
"The more they overthink the plumbing, the easier it is to stop up the drain." - Montgomery Scott
Re: Scanning PCI devices
Thank you everyone for your replies. I read a lot about PCI from different forums and references and when I came back to this http://wiki.osdev.org/PCI tutorial, everything became clear.
Re: Scanning PCI devices
That's why this is the best site on the internet, by far.
Let us know if you have any other questions. We'll help where we can.
Let us know if you have any other questions. We'll help where we can.
Project: OZone
Source: GitHub
Current Task: LIB/OBJ file support
"The more they overthink the plumbing, the easier it is to stop up the drain." - Montgomery Scott
Source: GitHub
Current Task: LIB/OBJ file support
"The more they overthink the plumbing, the easier it is to stop up the drain." - Montgomery Scott