Page 1 of 1

Strange PCI device BAR's...

Posted: Sun Aug 05, 2007 1:00 pm
by 01000101
I just got through writing the BAR decoder for I/O Memory aquiring device ONLY. I wish to get ethernet cards up and running first and finish plain memory mappers later.

So anyways, after reading the config dword from 0x10:0x02 (BAR address offset 0x02 for reserved space) and applying the appropriate mask, the base address returned is = ec01 and the size is 0x7f (almost 128). This seemed somewhat correct, but when i test it on my 'real' computer and not the virtual pc, I get either a base of 0xffff0000 or just plain 0, and the size is equal t either 0x7 or just 0 again.

Ive tried many different algorithms to do this somewhat simple extraction, but it seems that it never gets quite right. Could it be that my ethernet cards (which return a value of 1 at 0x10 btw) dont actually have a mapped IO space or buffer memory?

Do I have to 'install' the device through an IRQ handler first?

Posted: Sun Aug 05, 2007 3:00 pm
by Pavia
Sorry, but i don't understand what you wont do. What is 0x10:0x02 ???
Fisst BAR heve addres 0x10
One register size 32 bits.
if all 32 bits zero then register not used.

if bit 0=1 then I/O else if bit 0=0 memory mappers.

If memory and bit 2=1 and bit 1=0 then used 64bits address(two registers)

if I/O use one registers(32 bit) but hi 16 bits not used and can have rubbish.

Posted: Sun Aug 05, 2007 3:37 pm
by 01000101
After reading a bit more into this, i realized that you do not need to offset the BAR (0x10) by 2, I thought this was true because the first 2 bits in the BAR for an IO device are 0 (reserved) and 1 (IO identifier).

now it seems that I just need to use 0x10 and check out all 32 bits from bit 0.

Im not currently concerned with Memory addressing devices, just IO addressing ones (for NIC development).
if I/O use one registers(32 bit) but hi 16 bits not used and can have rubbish.
im not really sure what you mean with that?

Mainly i need to know if 0xEC01 is in the possible IO address range, or if it is a garbage value. Also, if anyone knows much about NIC's, is 0xff or 0x7f probable value for a NIC's IO mem buffer?

Posted: Sun Aug 05, 2007 4:18 pm
by Pavia
When you read from PCI CFG 0x10
If you sure is I/O then use mask 0xFFFC because
31-16 bits mast be zeros bat can have garbage value.
C=1100 two bit specific.

Code: Select all

BAR=ReadPCI(Device,0x10);
if (BAR & 1 ==1) {
 BaseAddr= BAR & 0xFFFC;
 }
BaseAddr - can use

For gat size. Write 0xFFFFFFFF or 0xFFFFFFFC, read new value and neg his.
Restore value.

Code: Select all

WritePCI(Device,0x10,0xFFFFFFFF);
Size=ReadPCI(Device,0x10);
WritePCI(Device,0x10,BAR);
if (Size & 1 ==1) {
 Size = (~((Size & 0xFFFC)| 0xFFFF0000 ))+1;
 }

Posted: Sun Aug 05, 2007 7:10 pm
by 01000101
Thanks a bunch for that.

It turns out I was solving the wrong issue. The mask is what was off.
now, it is returning good values that actually make sense.
=)
thanks again.