Questions about PCI configuration space register writing

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
abstractmath
Member
Member
Posts: 46
Joined: Mon Sep 07, 2020 5:50 pm

Questions about PCI configuration space register writing

Post 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.
foliagecanine
Member
Member
Posts: 148
Joined: Sun Aug 23, 2020 4:35 pm

Re: Questions about PCI configuration space register writing

Post 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)
My OS: TritiumOS
https://github.com/foliagecanine/tritium-os
void warranty(laptop_t laptop) { if (laptop.broken) return laptop; }
I don't get it: Why's the warranty void?
Post Reply