1 #include <console/console.h>
3 #include <arch/pciconf.h>
4 #include <device/pci.h>
5 #include <device/pci_ids.h>
6 #include <device/pci_ops.h>
8 * Functions for accessing PCI configuration space with type 2 accesses
11 #define IOADDR(devfn, where) ((0xC000 | ((devfn & 0x78) << 5)) + where)
12 #define FUNC(devfn) (((devfn & 7) << 1) | 0xf0)
13 #define SET(bus,devfn) outb(FUNC(devfn), 0xCF8); outb(bus, 0xCFA);
15 static uint8_t pci_conf2_read_config8(struct bus *pbus, int bus, int devfn,
20 value = inb(IOADDR(devfn, where));
25 static uint16_t pci_conf2_read_config16(struct bus *pbus, int bus, int devfn,
30 value = inw(IOADDR(devfn, where));
35 static uint32_t pci_conf2_read_config32(struct bus *pbus, int bus, int devfn,
40 value = inl(IOADDR(devfn, where));
45 static void pci_conf2_write_config8(struct bus *pbus, int bus, int devfn,
46 int where, uint8_t value)
49 outb(value, IOADDR(devfn, where));
53 static void pci_conf2_write_config16(struct bus *pbus, int bus, int devfn,
54 int where, uint16_t value)
57 outw(value, IOADDR(devfn, where));
61 static void pci_conf2_write_config32(struct bus *pbus, int bus, int devfn,
62 int where, uint32_t value)
65 outl(value, IOADDR(devfn, where));
73 const struct pci_bus_operations pci_cf8_conf2 = {
74 .read8 = pci_conf2_read_config8,
75 .read16 = pci_conf2_read_config16,
76 .read32 = pci_conf2_read_config32,
77 .write8 = pci_conf2_write_config8,
78 .write16 = pci_conf2_write_config16,
79 .write32 = pci_conf2_write_config32,