No Base Address Registers!

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
drnono
Posts: 23
Joined: Sun Aug 09, 2015 11:54 am

No Base Address Registers!

Post by drnono »

I'm scanning the bus for IDE mass storage devices. I can find (some) and get the vendor id's and prog_if etc., but the base address registers all show as zero.

Code: Select all

	
BAR0_offset = 0x04 << 2;	
address = (uint32_t) ( (1<<31) | (bus<<16) | (device<<11) | (func<<8) |  BAR0_offset );
outl(PCI_CONFIG_ADDRESS,address);
tmp = inl(PCI_CONFIG_DATA);
ptr=&tmp;
print_dword(ptr,25, 0, 0);     // bar0
The mass storage controller is being detected as class and subclass 0x01.
I'm using VMware and bochs alternately, and I noticed that the prog_if registers read 0x80 and 0x8a - corresponding to ISA compatibility modes and not PCI modes.
I tried writing 0x8f (PCI native mode controller) as a dword to offset 0x08 but it had no effect on the BAR registers.

How can I get to read these base address registers?
xeyes
Member
Member
Posts: 212
Joined: Mon Dec 07, 2020 8:09 am

Re: No Base Address Registers!

Post by xeyes »

What're the vendor and device IDs of this device you are reading from?

If it is the good old PIIX3 (V8086 D7010) common to many VMs the port base is in BAR4 not BAR0.

Otherwise you probably want to consult the documentation for the device you are trying to use.
Gigasoft
Member
Member
Posts: 856
Joined: Sat Nov 21, 2009 5:11 pm

Re: No Base Address Registers!

Post by Gigasoft »

If you reconfigure the controller, you must allocate addresses and set the BARs yourself.

In VMWare, the mode of operation is always compatibility mode and can't be changed, as indicated by the programming interface byte being 0x80.

BAR4 is for the Bus Master DMA engine.
Ankeraout
Member
Member
Posts: 25
Joined: Tue Feb 28, 2017 10:22 am

Re: No Base Address Registers!

Post by Ankeraout »

This Wiki page states that:
Each IDE controller appears as a device on the PCI bus. If the class code is 0x01 (Mass Storage Controller) and the subclass code is 0x1, (IDE) this device is an IDE Device. The IDE device only uses five BARs out of the six

BAR0: Base address of primary channel (I/O space), if it is 0x0 or 0x1, the port is 0x1F0.
BAR1: Base address of primary channel control port (I/O space), if it is 0x0 or 0x1, the port is 0x3F6.
BAR2: Base address of secondary channel (I/O space), if it is 0x0 or 0x1, the port is 0x170.
BAR3: Base address of secondary channel control port, if it is 0x0 or 0x1, the port is 0x376.
BAR4: Bus Master IDE; refers to the base of I/O range consisting of 16 ports. Each 8 ports controls DMA on the primary and secondary channel respectively.
Gigasoft
Member
Member
Posts: 856
Joined: Sat Nov 21, 2009 5:11 pm

Re: No Base Address Registers!

Post by Gigasoft »

The Wiki page is wrong. The only correct way to determine if a channel is in compatibility mode is by inspecting the Programming Interface register. If it is, the corresponding BARs must be ignored.
Octocontrabass
Member
Member
Posts: 5568
Joined: Mon Mar 25, 2013 7:01 pm

Re: No Base Address Registers!

Post by Octocontrabass »

I've updated that section of the wiki with information from the actual PCI IDE specifications. I have to wonder where that nonsense originally came from...
nullplan
Member
Member
Posts: 1790
Joined: Wed Aug 30, 2017 8:24 am

Re: No Base Address Registers!

Post by nullplan »

Octocontrabass wrote:I've updated that section of the wiki with information from the actual PCI IDE specifications. I have to wonder where that nonsense originally came from...
The contended section was added to the page by the page's creator, Mostafazzio, on November 8, 2009. No edit comment there; they didn't seem to be too fond of those. So no clue about their sources.
Carpe diem!
Post Reply