]>
Commit | Line | Data |
---|---|---|
ec2d6189 | 1 | #include <pci.h> |
d6f56afa | 2 | #include <pci-bother.h> |
ec2d6189 JW |
3 | |
4 | struct pci_bother { | |
5 | int bus, dev, fn; | |
6 | unsigned short origstate; | |
7 | }; | |
8 | ||
9 | static struct pci_bother bothers[MAX_BOTHERS]; | |
10 | static int nbothers = 0; | |
11 | ||
12 | int pci_bother_add(pci_dev_t *dev) | |
13 | { | |
14 | if (nbothers == MAX_BOTHERS) | |
15 | return -1; | |
16 | ||
17 | bothers[nbothers].bus = dev->bus; | |
18 | bothers[nbothers].dev = dev->dev; | |
19 | bothers[nbothers].fn = dev->fn; | |
20 | ||
21 | bothers[nbothers].origstate = pci_read16(dev->bus, dev->dev, dev->fn, 0x04); | |
22 | ||
23 | nbothers++; | |
24 | ||
25 | return 0; | |
26 | } | |
27 | ||
28 | void pci_bother_all() | |
29 | { | |
30 | int i; | |
31 | ||
32 | for (i = 0; i < nbothers; i++) | |
d6f56afa | 33 | pci_write16(bothers[i].bus, bothers[i].dev, bothers[i].fn, 0x04, 0x0); |
ec2d6189 JW |
34 | } |
35 | ||
36 | void pci_unbother_all() | |
37 | { | |
38 | int i; | |
39 | ||
40 | for (i = 0; i < nbothers; i++) | |
d6f56afa | 41 | pci_write16(bothers[i].bus, bothers[i].dev, bothers[i].fn, 0x04, bothers[i].origstate); |
ec2d6189 | 42 | } |