PCI: Device Response

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
whiteOS
Member
Member
Posts: 29
Joined: Mon Oct 06, 2008 12:38 am

PCI: Device Response

Post 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!!!!!!!!
User avatar
Brendan
Member
Member
Posts: 8561
Joined: Sat Jan 15, 2005 12:00 am
Location: At his keyboard!
Contact:

Re: PCI: Device Response

Post 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
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.
whiteOS
Member
Member
Posts: 29
Joined: Mon Oct 06, 2008 12:38 am

Re: PCI: Device Response

Post 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
whiteOS
Member
Member
Posts: 29
Joined: Mon Oct 06, 2008 12:38 am

Re: PCI: Device Response

Post 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);
Post Reply