Page 1 of 1
Questions about PCI configuration space register writing
Posted: Sun Oct 18, 2020 2:07 pm
by abstractmath
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.
Re: Questions about PCI configuration space register writing
Posted: Sun Oct 18, 2020 3:31 pm
by foliagecanine
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: Select all
outl(0xCF8,pci_address);
inl(0xCFC);
For writing, you do:
Code: Select all
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)