PCI in Bochs

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
AUsername
Member
Member
Posts: 54
Joined: Sun Feb 01, 2009 9:07 pm

PCI in Bochs

Post by AUsername »

Alright, in Bochs 2.3.7, I wrote a simple PCI implementation. It gets information about various devices connected to the PCI bus.
After running Linux to get the valid PCI device information I compared it with what my PCIGetDeviceInfo() function is returning.

Everything is valid except for bus 0, card 1, function 1.
It claims that the command register is 1 when it should be 5.

My OS: http://i.imgur.com/UXEA2.png
Linux : http://i.imgur.com/PQxeN.png

It appears to be the only time that my PCIGetDeviceInfo() function refuses to work.

Code (Please, excuse the hackishness of it, in the current state, I know it's painful to look at):
http://pastebin.com/PibQKchW

Any idea what's wrong?
We're at a loss here.
User avatar
Brendan
Member
Member
Posts: 8561
Joined: Sat Jan 15, 2005 12:00 am
Location: At his keyboard!
Contact:

Re: PCI in Bochs

Post by Brendan »

Hi,
AUsername wrote:Alright, in Bochs 2.3.7, I wrote a simple PCI implementation. It gets information about various devices connected to the PCI bus.
After running Linux to get the valid PCI device information I compared it with what my PCIGetDeviceInfo() function is returning.

Everything is valid except for bus 0, card 1, function 1.
It claims that the command register is 1 when it should be 5.
The only difference in the command register is bit 2, which is used to enable/disable the device's ability to act as a bus master. It looks like Linux enables bus mastering (and the BIOS doesn't for backward compatibility). You might have also noticed that the value for "interface" is also different for this device (in Linux its 0x80 while in yours it's 0x00), where bit 7 is used by the device to indicate that it's currently configured for bus mastering.

Basically, your code is right, but your OS doesn't enable bus mastering on this ATA controller.


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.
Post Reply