]> Joshua Wise's Git repositories - netwatch.git/blame - pci/pci-bother.c
Enable DHCP.
[netwatch.git] / pci / pci-bother.c
CommitLineData
ec2d6189 1#include <pci.h>
d6f56afa 2#include <pci-bother.h>
ec2d6189
JW
3
4struct pci_bother {
5 int bus, dev, fn;
6 unsigned short origstate;
c2e34447 7 unsigned long origbars[6];
ec2d6189
JW
8};
9
10static struct pci_bother bothers[MAX_BOTHERS];
11static int nbothers = 0;
12
13int pci_bother_add(pci_dev_t *dev)
14{
c2e34447
JW
15 int i;
16
ec2d6189
JW
17 if (nbothers == MAX_BOTHERS)
18 return -1;
19
20 bothers[nbothers].bus = dev->bus;
21 bothers[nbothers].dev = dev->dev;
22 bothers[nbothers].fn = dev->fn;
23
24 bothers[nbothers].origstate = pci_read16(dev->bus, dev->dev, dev->fn, 0x04);
c2e34447
JW
25 for (i = 0; i < 6; i++)
26 bothers[nbothers].origbars[i] = pci_read32(dev->bus, dev->dev, dev->fn, 0x10 + i * 4);
ec2d6189
JW
27
28 nbothers++;
29
30 return 0;
31}
32
33void pci_bother_all()
34{
c2e34447 35 int i, j;
ec2d6189
JW
36
37 for (i = 0; i < nbothers; i++)
c2e34447 38 {
d6f56afa 39 pci_write16(bothers[i].bus, bothers[i].dev, bothers[i].fn, 0x04, 0x0);
c2e34447
JW
40 for (j = 0; j < 6; j++)
41 pci_write32(bothers[i].bus, bothers[i].dev, bothers[i].fn, 0x10 + j * 4, 0);
42 }
ec2d6189
JW
43}
44
45void pci_unbother_all()
46{
c2e34447 47 int i, j;
ec2d6189
JW
48
49 for (i = 0; i < nbothers; i++)
c2e34447 50 {
d6f56afa 51 pci_write16(bothers[i].bus, bothers[i].dev, bothers[i].fn, 0x04, bothers[i].origstate);
c2e34447
JW
52 for (j = 0; j < 6; j++)
53 pci_write32(bothers[i].bus, bothers[i].dev, bothers[i].fn, 0x10 + j * 4, bothers[i].origbars[j]);
54 }
ec2d6189 55}
This page took 0.028809 seconds and 4 git commands to generate.