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, int where)
19 value = inb(IOADDR(devfn, where));
24 static uint16_t pci_conf2_read_config16(struct bus *pbus, int bus, int devfn, int where)
28 value = inw(IOADDR(devfn, where));
33 static uint32_t pci_conf2_read_config32(struct bus *pbus, int bus, int devfn, int where)
37 value = inl(IOADDR(devfn, where));
42 static void pci_conf2_write_config8(struct bus *pbus, int bus, int devfn, int where, uint8_t value)
45 outb(value, IOADDR(devfn, where));
49 static void pci_conf2_write_config16(struct bus *pbus, int bus, int devfn, int where, uint16_t value)
52 outw(value, IOADDR(devfn, where));
56 static void pci_conf2_write_config32(struct bus *pbus, int bus, int devfn, int where, uint32_t value)
59 outl(value, IOADDR(devfn, where));
67 const struct pci_bus_operations pci_cf8_conf2 =
69 .read8 = pci_conf2_read_config8,
70 .read16 = pci_conf2_read_config16,
71 .read32 = pci_conf2_read_config32,
72 .write8 = pci_conf2_write_config8,
73 .write16 = pci_conf2_write_config16,
74 .write32 = pci_conf2_write_config32,