]> Joshua Wise's Git repositories - netwatch.git/blob - pci/pci-bother.c
Add the mechanism by which we bother PCI, generically.
[netwatch.git] / pci / pci-bother.c
1 #include <pci.h>
2
3 struct pci_bother {
4         int bus, dev, fn;
5         unsigned short origstate;
6 };
7
8 static struct pci_bother bothers[MAX_BOTHERS];
9 static int nbothers = 0;
10
11 int pci_bother_add(pci_dev_t *dev)
12 {
13         if (nbothers == MAX_BOTHERS)
14                 return -1;
15         
16         bothers[nbothers].bus = dev->bus;
17         bothers[nbothers].dev = dev->dev;
18         bothers[nbothers].fn = dev->fn;
19         
20         bothers[nbothers].origstate = pci_read16(dev->bus, dev->dev, dev->fn, 0x04);
21         
22         nbothers++;
23         
24         return 0;
25 }
26
27 void pci_bother_all()
28 {
29         int i;
30         
31         for (i = 0; i < nbothers; i++)
32                 pci_write16(bothers[i].bus, bothers[i].dev, bothers[i].fn, 0x0);
33 }
34
35 void pci_unbother_all()
36 {
37         int i;
38         
39         for (i = 0; i < nbothers; i++)
40                 pci_write16(bothers[i].bus, bothers[i].dev, bothers[i].fn, bothers[i].origstate);
41 }
This page took 0.026752 seconds and 4 git commands to generate.