-
Notifications
You must be signed in to change notification settings - Fork 0
/
pci.c
60 lines (51 loc) · 1.38 KB
/
pci.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#include "project.h"
#include "pci_regs.h"
/* PCI config read/write */
uint8_t
pci_conf1_read_8 (int bus, int slot, int fn, int off)
{
int addr = 0xcfc + (off & 3);
out_32 (0x0cf8,
0x80000000 | (bus << 16) | (slot << 11) | (fn << 8) | (off & ~3));
return in_8 (addr);
}
uint16_t
pci_conf1_read_16 (int bus, int slot, int fn, int off)
{
int addr = 0xcfc + (off & 3);
out_32 (0x0cf8,
0x80000000 | (bus << 16) | (slot << 11) | (fn << 8) | (off & ~3));
return in_16 (addr);
}
uint32_t
pci_conf1_read_32 (int bus, int slot, int fn, int off)
{
int addr = 0xcfc + (off & 3);
out_32 (0x0cf8,
0x80000000 | (bus << 16) | (slot << 11) | (fn << 8) | (off & ~3));
return in_32 (addr);
}
void
pci_conf1_write_8 (int bus, int slot, int fn, int off, uint8_t val)
{
int addr = 0xcfc + (off & 3);
out_32 (0x0cf8,
0x80000000 | (bus << 16) | (slot << 11) | (fn << 8) | (off & ~3));
out_8 (addr, val);
}
void
pci_conf1_write_16 (int bus, int slot, int fn, int off, uint16_t val)
{
int addr = 0xcfc + (off & 3);
out_32 (0x0cf8,
0x80000000 | (bus << 16) | (slot << 11) | (fn << 8) | (off & ~3));
out_16 (addr, val);
}
void
pci_conf1_write_32 (int bus, int slot, int fn, int off, uint32_t val)
{
int addr = 0xcfc + (off & 3);
out_32 (0x0cf8,
0x80000000 | (bus << 16) | (slot << 11) | (fn << 8) | (off & ~3));
out_32 (addr, val);
}