PCI enumeration results

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
CR
Posts: 12
Joined: Fri Dec 07, 2012 4:04 pm

PCI enumeration results

Post by CR »

hello! I have another question for you all :)
some time ago I wrote code for PCI enumeration but now I have the doubt it doesn't find all the devices.
On bochs it finds these 4 devices:
device 0: class 0x6 ; sub class 0x0 ; bus=0 ; device=0 function=0
device 1: class 0x6 ; sub class 0x1 ; bus=0 ; device=1 function=0
device 2: class 0x1 ; sub class 0x1 ; bus=0 ; device=1 function=1
device 3: class 0x6 ; sub class 0x80 ; bus=0 ; device=1 function=3

I tried also on vmware and it finds 42 devices (but 33 of those are PCI to PCI bridges)
In both the emulators I don't get any processor.
I get the same result using the brute force method and the recusrive method.

So here's the question: is this the correct result or I should have found something else?
PearOs
Member
Member
Posts: 194
Joined: Mon Apr 08, 2013 3:03 pm
Location: Usually at my keyboard!

Re: PCI enumeration results

Post by PearOs »

CR wrote:hello! I have another question for you all :)
some time ago I wrote code for PCI enumeration but now I have the doubt it doesn't find all the devices.
On bochs it finds these 4 devices:
device 0: class 0x6 ; sub class 0x0 ; bus=0 ; device=0 function=0
device 1: class 0x6 ; sub class 0x1 ; bus=0 ; device=1 function=0
device 2: class 0x1 ; sub class 0x1 ; bus=0 ; device=1 function=1
device 3: class 0x6 ; sub class 0x80 ; bus=0 ; device=1 function=3

I tried also on vmware and it finds 42 devices (but 33 of those are PCI to PCI bridges)
In both the emulators I don't get any processor.
I get the same result using the brute force method and the recusrive method.

So here's the question: is this the correct result or I should have found something else?
Well I know when I run my PCI Bus scanning code in Bochs, I get only two devices. I was only scanning bus 0 at the time. And found lots of devices were not showing up. So I changed my code and scanned bus 0-7 (8 total) and found the remaining devices. You want to make sure the Vender ID isnt 0xFFFF and the Device ID isnt 0xFFFF. That should help, If you don't check the VenderID and the DeviceID you can get all kinds of weird things. I would also check the wiki: http://wiki.osdev.org/PCI

Hope it helps, Matt


Now far as finding a processor, I think sometimes there is one and sometimes there isn't one. Oddly enough. I can't remeber if my current code finds the processor in VMWare but I know on my AMD64 FX processor it finds it.
DennisCGc
Posts: 11
Joined: Fri Apr 22, 2005 11:00 pm

Re: PCI enumeration results

Post by DennisCGc »

CR wrote: I tried also on vmware and it finds 42 devices (but 33 of those are PCI to PCI bridges)
Well, it is consistent with what FreeBSD detects when run in VMWare, so I believe it is fine.
CR
Posts: 12
Joined: Fri Dec 07, 2012 4:04 pm

Re: PCI enumeration results

Post by CR »

ok, so I assume my code is correct! :D
thank you!
User avatar
Shaun
Member
Member
Posts: 43
Joined: Mon Sep 17, 2012 3:14 am
Contact:

Re: PCI enumeration results

Post by Shaun »

CR wrote:ok, so I assume my code is correct! :D
thank you!
oh, no, your code is not correct! sorry...

some pci buses may mirror the device you found, specially for vmware,
say, if you got device id from 1-16, bus may mirror it from 17-32, so you will see totally 32 devices,in fact, it is only 16 device on bus, you should remove the others which was mirrored by bus, these mirrored device was so called ghost device in linux kernel. you can search linux kernel source code and find out the way to fix up your code.
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Re: PCI enumeration results

Post by Combuster »

virusest wrote:
CR wrote:ok, so I assume my code is correct! :D
thank you!
oh, no, your code is not correct! sorry...
It is. VMWare just has a huge load of never-used bridge devices. You on the other hand should probably be fixing your code if it has duplicate devices.
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
User avatar
bluemoon
Member
Member
Posts: 1761
Joined: Wed Dec 01, 2010 3:41 am
Location: Hong Kong

Re: PCI enumeration results

Post by bluemoon »

CR wrote:In both the emulators I don't get any processor.
You won't find any normal processor on the PCI, except if you got some special extension board. Even for "system on board" it is not reported as a processor.
You might got mixed up with ACPI, which indeed report processor(s) and cores.
Post Reply