]>
Commit | Line | Data |
---|---|---|
1 | #include <io.h> | |
2 | #include <inttypes.h> | |
3 | ||
4 | static void __pci_config(int bus, int slot, int fn, int addr) | |
5 | { | |
6 | outl(0xCF8, 0x80000000ULL | (bus << 16) | (slot << 11) | (fn << 8) | addr); | |
7 | } | |
8 | ||
9 | void pci_write32(int bus, int slot, int fn, int addr, uint32_t data) | |
10 | { | |
11 | __pci_config(bus, slot, fn, addr); | |
12 | outl(0xCFC, data); | |
13 | } | |
14 | ||
15 | void pci_write16(int bus, int slot, int fn, int addr, uint16_t data) | |
16 | { | |
17 | __pci_config(bus, slot, fn, addr); | |
18 | outw(0xCFC, data); | |
19 | } | |
20 | ||
21 | void pci_write8(int bus, int slot, int fn, int addr, uint8_t data) | |
22 | { | |
23 | __pci_config(bus, slot, fn, addr); | |
24 | outb(0xCFC, data); | |
25 | } | |
26 | ||
27 | uint32_t pci_read32(int bus, int slot, int fn, int addr) | |
28 | { | |
29 | __pci_config(bus, slot, fn, addr); | |
30 | return inl(0xCFC); | |
31 | } | |
32 | ||
33 | uint16_t pci_read16(int bus, int slot, int fn, int addr) | |
34 | { | |
35 | __pci_config(bus, slot, fn, addr); | |
36 | return inw(0xCFC); | |
37 | } | |
38 | ||
39 | uint8_t pci_read8(int bus, int slot, int fn, int addr) | |
40 | { | |
41 | __pci_config(bus, slot, fn, addr); | |
42 | return inb(0xCFC); | |
43 | } |