OSDev.org
https://forum.osdev.org/

Questions about PCI configuration space register writing
https://forum.osdev.org/viewtopic.php?f=1&t=37363
Page 1 of 1

Author:  abstractmath [ Sun Oct 18, 2020 2:07 pm ]
Post subject:  Questions about PCI configuration space register writing

I've been working on adding a pci driver to my OS, and I've been following the guide here https://wiki.osdev.org/PCI, and I don't see anywhere in the guide where it says how to write to one of these registers? My guess is that you'd write to the config address register and then write to the config data register, but I'm not sure, and I don't know where to find the information on how to write to one of these registers.

Author:  foliagecanine [ Sun Oct 18, 2020 3:31 pm ]
Post subject:  Re: Questions about PCI configuration space register writing

abstractmath wrote:
My guess is that you'd write to the config address register and then write to the config data register
If I understand you correctly, you are correct.

Writing a PCI register is very similar to reading it.
For reading it you do:
Code:
outl(0xCF8,pci_address);
inl(0xCFC);

For writing, you do:
Code:
outl(0xCF8,pci_address);
outl(0xCFC,value_to_write);

Note that you do have to do some bit shifting, etc, to read/write single bytes.
(Here's my code for writing a PCI byte)

Page 1 of 1 All times are UTC - 6 hours
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/