Reading/writing PCI memory space

David C. Davies (davies@ultranet.com)
Wed, 16 Apr 1997 17:23:07 -0400


Anyone know the correct way to read/write PCI memory space? The following
code gives the oops appended below.

The I/O read gave the correct results.

This was all done in an ioctl call into the de4x5 driver. V2.0.27 kernel.

Regards,

Dave
-------------------

pcibios_write_config_word(0, 15 << 3, PCI_COMMAND, 0x07);
pcibios_read_config_word(0, 15 << 3, PCI_COMMAND, (short *)&i);
printk("Command Reg: %04x\n",(u_short)i);

pcibios_read_config_dword(0, 15 << 3, PCI_BASE_ADDRESS_0, &i);
printk("Base Address 0 Reg: %08x\n",i);
pcibios_read_config_dword(0, 15 << 3, PCI_BASE_ADDRESS_3, &i);
printk("Base Address 3 Reg: %08x\n",i);

pcibios_write_config_dword(0, 15 << 3, PCI_BASE_ADDRESS_0, 0x9000000);
pcibios_write_config_dword(0, 15 << 3, PCI_BASE_ADDRESS_5, 0x0005000);
pcibios_read_config_dword(0, 15 << 3, PCI_BASE_ADDRESS_5, &i);
printk("I/O Address Reg: %08x\n",i);

pcibios_write_config_dword(0, 15 << 3, 0x20, 0xa000000);
printk("CPU PCI memory Low Address Decode: %04x\n",inl(0x5058));
oops: printk("CPU PCI memory Low Address Decode: %04x\n",readw((u_long)(0xa000058)));

gave the following output:

Command Reg: 0007
Base Address 0 Reg: 09000000
Base Address 3 Reg: 1f000008
I/O Address Reg: 00005001
CPU PCI memory Low Address Decode: 0090 <------------ correct answer
Unable to handle kernel paging request at virtual address ca000058 <-- bad address?
current->tss.cr3 = 02852000, %cr3 = 02852000
*pde = 00000000
Oops: 0000
CPU: 0
EIP: 0010:[<0484dd22>] <------------ in the ioctl function