]> Joshua Wise's Git repositories - netwatch.git/blame - pci/pci-raw.c
add GUIDE
[netwatch.git] / pci / pci-raw.c
CommitLineData
035d7af7 1#include <io.h>
7e16b8e6 2#include <stdint.h>
81148fa1 3#include <pci.h>
035d7af7
JW
4
5static void __pci_config(int bus, int slot, int fn, int addr)
6{
c2e34447 7 outl(0xCF8, 0x80000000ULL | (bus << 16) | (slot << 11) | (fn << 8) | (addr & ~3));
035d7af7
JW
8}
9
10void pci_write32(int bus, int slot, int fn, int addr, uint32_t data)
11{
12 __pci_config(bus, slot, fn, addr);
13 outl(0xCFC, data);
14}
15
16void pci_write16(int bus, int slot, int fn, int addr, uint16_t data)
17{
18 __pci_config(bus, slot, fn, addr);
19 outw(0xCFC, data);
20}
21
22void pci_write8(int bus, int slot, int fn, int addr, uint8_t data)
23{
24 __pci_config(bus, slot, fn, addr);
25 outb(0xCFC, data);
26}
27
28uint32_t pci_read32(int bus, int slot, int fn, int addr)
29{
30 __pci_config(bus, slot, fn, addr);
31 return inl(0xCFC);
32}
33
34uint16_t pci_read16(int bus, int slot, int fn, int addr)
35{
36 __pci_config(bus, slot, fn, addr);
c2e34447 37 return inw(0xCFC + (addr & 2));
035d7af7
JW
38}
39
40uint8_t pci_read8(int bus, int slot, int fn, int addr)
41{
42 __pci_config(bus, slot, fn, addr);
c2e34447 43 return inb(0xCFC + (addr & 3));
035d7af7 44}
This page took 0.03037 seconds and 4 git commands to generate.