]> Joshua Wise's Git repositories - netwatch.git/commitdiff
Add the mechanism by which we bother PCI, generically.
authorJoshua Wise <joshua@rebirth.joshuawise.com>
Thu, 2 Oct 2008 23:20:20 +0000 (19:20 -0400)
committerJoshua Wise <joshua@rebirth.joshuawise.com>
Thu, 2 Oct 2008 23:20:20 +0000 (19:20 -0400)
include/pci-bother.h [new file with mode: 0644]
pci/pci-bother.c [new file with mode: 0644]

diff --git a/include/pci-bother.h b/include/pci-bother.h
new file mode 100644 (file)
index 0000000..ff71755
--- /dev/null
@@ -0,0 +1,12 @@
+#ifndef _PCI_BOTHER_H
+#define _PCI_BOTHER_H
+
+#include <pci.h>
+
+#define MAX_BOTHERS 5
+
+extern int pci_bother_add(pci_dev_t *dev);
+extern void pci_bother_all();
+extern void pci_unbother_all();
+
+#endif
diff --git a/pci/pci-bother.c b/pci/pci-bother.c
new file mode 100644 (file)
index 0000000..0c3c0ec
--- /dev/null
@@ -0,0 +1,41 @@
+#include <pci.h>
+
+struct pci_bother {
+       int bus, dev, fn;
+       unsigned short origstate;
+};
+
+static struct pci_bother bothers[MAX_BOTHERS];
+static int nbothers = 0;
+
+int pci_bother_add(pci_dev_t *dev)
+{
+       if (nbothers == MAX_BOTHERS)
+               return -1;
+       
+       bothers[nbothers].bus = dev->bus;
+       bothers[nbothers].dev = dev->dev;
+       bothers[nbothers].fn = dev->fn;
+       
+       bothers[nbothers].origstate = pci_read16(dev->bus, dev->dev, dev->fn, 0x04);
+       
+       nbothers++;
+       
+       return 0;
+}
+
+void pci_bother_all()
+{
+       int i;
+       
+       for (i = 0; i < nbothers; i++)
+               pci_write16(bothers[i].bus, bothers[i].dev, bothers[i].fn, 0x0);
+}
+
+void pci_unbother_all()
+{
+       int i;
+       
+       for (i = 0; i < nbothers; i++)
+               pci_write16(bothers[i].bus, bothers[i].dev, bothers[i].fn, bothers[i].origstate);
+}
This page took 0.030031 seconds and 4 git commands to generate.