Basic support for PCI BIOS.
[seabios.git] / src / pci.c
1 #include "pci.h" // PCIDevice
2 #include "ioport.h" // outl
3
4 void pci_config_writel(PCIDevice *d, u32 addr, u32 val)
5 {
6     outl(0x80000000 | (d->bus << 16) | (d->devfn << 8) | (addr & 0xfc), 0xcf8);
7     outl(val, 0xcfc);
8 }
9
10 void pci_config_writew(PCIDevice *d, u32 addr, u16 val)
11 {
12     outl(0x80000000 | (d->bus << 16) | (d->devfn << 8) | (addr & 0xfc), 0xcf8);
13     outw(val, 0xcfc + (addr & 2));
14 }
15
16 void pci_config_writeb(PCIDevice *d, u32 addr, u8 val)
17 {
18     outl(0x80000000 | (d->bus << 16) | (d->devfn << 8) | (addr & 0xfc), 0xcf8);
19     outb(val, 0xcfc + (addr & 3));
20 }
21
22 u32 pci_config_readl(PCIDevice *d, u32 addr)
23 {
24     outl(0x80000000 | (d->bus << 16) | (d->devfn << 8) | (addr & 0xfc), 0xcf8);
25     return inl(0xcfc);
26 }
27
28 u16 pci_config_readw(PCIDevice *d, u32 addr)
29 {
30     outl(0x80000000 | (d->bus << 16) | (d->devfn << 8) | (addr & 0xfc), 0xcf8);
31     return inw(0xcfc + (addr & 2));
32 }
33
34 u8 pci_config_readb(PCIDevice *d, u32 addr)
35 {
36     outl(0x80000000 | (d->bus << 16) | (d->devfn << 8) | (addr & 0xfc), 0xcf8);
37     return inb(0xcfc + (addr & 3));
38 }