Page 1 of 1

PCI: Device Response

Posted: Mon Oct 13, 2008 5:11 pm
by whiteOS
So I am using the IO space to speak to my device but it doesn't respond. I try to send it a command to command register and it never clears or changes. Here is the things I have determined --

i. The PCI COnfig Register Command is set to 0x07 which means IO response is enabled.
ii. The values I write to the Device's registers are being written but not always.

Lets say that 9800 is the first port and 9807 is the last port of bar 0, so I am writing to the ports like this --

outb(0x9801, 0x3f); //write 0x3f to bar 0's bitfield 23:16

I am defining the ports like this, for clarity:

9800 = 31:24
9801 = 23:16
9802 = 15:8
9803 = 7:0

When I write a value to port 9801, nothing is written, it returns 0, but this is where the sectors per track register for my device should be, so i dont know what is happened. Does this look right to any of you guy becuase I tested in other OS and get the same thing --nothing but it should be write isnt it?

so my problem has been outlined, my questions is --

how to initialize pci device for response and when using IO space is it commonly done the way I am doing? pci experienced please respond!!!!!!!!

Re: PCI: Device Response

Posted: Mon Oct 13, 2008 5:21 pm
by Brendan
Hi,

Devices may only decode accesses of specific widths. For example, APICs typically only decode 32-bit accesses and ignore any reads/writes that are 8-bit, 16-bit, etc, and lots of older devices only decode 8-bit accesses and ignore 16-bit, 32-bit accesses, etc.
9800 = 31:24
9801 = 23:16
9802 = 15:8
9803 = 7:0
If the device's documentation describes it as one 32-bit I/O port, then try accessing it as one 32-bit I/O port. For example:

Code: Select all

outd(0x9800, (ind(0x9800) & (~0xFF << 8) ) | (0x3F << 8) );
[EDIT] Doh. I just realized you might have some endian issues there too. On 80x86 the least significant bit is in the lowest address, so it might need to be:
  • 9800 = 7:0
    9801 = 15:8
    9802 = 23:16
    9803 = 31:24
[/EDIT]


Cheers,

Brendan

Re: PCI: Device Response

Posted: Mon Oct 13, 2008 9:37 pm
by whiteOS
i thought i might have been looking at it that way --in reverse. I even tried it without good luck. I am certain my device likes only 8bit calls becuase it responds with F's unless i used 8bit calls, then it returns good. i will try 32bit as you suggested and will also try the reverse again. tyfyh

Re: PCI: Device Response

Posted: Fri Oct 17, 2008 5:40 pm
by whiteOS
Do you have to first read the port before you can send a byte? Why can not send byte?

Ex: outb(9800+0x4, 0x3f);