2 * Raw PCI implementation
3 * NetWatch system management mode administration console
5 * Copyright (c) 2008 Jacob Potter and Joshua Wise. All rights reserved.
6 * This program is free software; you can redistribute and/or modify it under
7 * the terms found in the file LICENSE in the root of this source tree.
15 static void __pci_config(int bus, int slot, int fn, int addr)
17 outl(0xCF8, 0x80000000ULL | (bus << 16) | (slot << 11) | (fn << 8) | (addr & ~3));
20 void pci_write32(int bus, int slot, int fn, int addr, uint32_t data)
22 __pci_config(bus, slot, fn, addr);
26 void pci_write16(int bus, int slot, int fn, int addr, uint16_t data)
28 __pci_config(bus, slot, fn, addr);
32 void pci_write8(int bus, int slot, int fn, int addr, uint8_t data)
34 __pci_config(bus, slot, fn, addr);
38 uint32_t pci_read32(int bus, int slot, int fn, int addr)
40 __pci_config(bus, slot, fn, addr);
44 uint16_t pci_read16(int bus, int slot, int fn, int addr)
46 __pci_config(bus, slot, fn, addr);
47 return inw(0xCFC + (addr & 2));
50 uint8_t pci_read8(int bus, int slot, int fn, int addr)
52 __pci_config(bus, slot, fn, addr);
53 return inb(0xCFC + (addr & 3));