]> Joshua Wise's Git repositories - netwatch.git/blame - pci/pci-bother.c
More ICH2-specific code diked out.
[netwatch.git] / pci / pci-bother.c
CommitLineData
98e930a2
JP
1/* pci-bother.c
2 * PCI bothering code
3 * NetWatch system management mode administration console
4 *
5 * Copyright (c) 2008 Jacob Potter and Joshua Wise. All rights reserved.
6 * This program is free software; you can redistribute and/or modify it under
7 * the terms found in the file LICENSE in the root of this source tree.
8 *
9 */
10
ec2d6189 11#include <pci.h>
d6f56afa 12#include <pci-bother.h>
ec2d6189
JW
13
14struct pci_bother {
15 int bus, dev, fn;
16 unsigned short origstate;
c2e34447 17 unsigned long origbars[6];
ec2d6189
JW
18};
19
20static struct pci_bother bothers[MAX_BOTHERS];
21static int nbothers = 0;
22
23int pci_bother_add(pci_dev_t *dev)
24{
c2e34447
JW
25 int i;
26
ec2d6189
JW
27 if (nbothers == MAX_BOTHERS)
28 return -1;
29
30 bothers[nbothers].bus = dev->bus;
31 bothers[nbothers].dev = dev->dev;
32 bothers[nbothers].fn = dev->fn;
33
34 bothers[nbothers].origstate = pci_read16(dev->bus, dev->dev, dev->fn, 0x04);
c2e34447
JW
35 for (i = 0; i < 6; i++)
36 bothers[nbothers].origbars[i] = pci_read32(dev->bus, dev->dev, dev->fn, 0x10 + i * 4);
ec2d6189
JW
37
38 nbothers++;
39
40 return 0;
41}
42
43void pci_bother_all()
44{
c2e34447 45 int i, j;
ec2d6189
JW
46
47 for (i = 0; i < nbothers; i++)
c2e34447 48 {
d6f56afa 49 pci_write16(bothers[i].bus, bothers[i].dev, bothers[i].fn, 0x04, 0x0);
c2e34447
JW
50 for (j = 0; j < 6; j++)
51 pci_write32(bothers[i].bus, bothers[i].dev, bothers[i].fn, 0x10 + j * 4, 0);
52 }
ec2d6189
JW
53}
54
55void pci_unbother_all()
56{
c2e34447 57 int i, j;
ec2d6189
JW
58
59 for (i = 0; i < nbothers; i++)
c2e34447 60 {
d6f56afa 61 pci_write16(bothers[i].bus, bothers[i].dev, bothers[i].fn, 0x04, bothers[i].origstate);
c2e34447
JW
62 for (j = 0; j < 6; j++)
63 pci_write32(bothers[i].bus, bothers[i].dev, bothers[i].fn, 0x10 + j * 4, bothers[i].origbars[j]);
64 }
ec2d6189 65}
This page took 0.035649 seconds and 5 git commands to generate.