From: Joshua Wise Date: Thu, 2 Oct 2008 23:23:10 +0000 (-0400) Subject: merge X-Git-Url: http://git.joshuawise.com/netwatch.git/commitdiff_plain/d6f56afa7470cf4c29f4f9fa4bf2dd1bd0ba9193?hp=-c merge --- d6f56afa7470cf4c29f4f9fa4bf2dd1bd0ba9193 diff --combined aseg/counter.c index bf60ffd,868ec45..4876acf --- a/aseg/counter.c +++ b/aseg/counter.c @@@ -3,8 -3,7 +3,8 @@@ #include #include #include +#include - #include "3c905.h" + #include "../net/net.h" #include "vga-overlay.h" #include "packet.h" @@@ -97,7 -96,6 +97,7 @@@ void smi_entry(void pcisave = inl(0xCF8); vgasave = inb(0x3D4); + pci_unbother_all(); counter++; sprintf(statstr, "15-412! %08x %08x", smi_status(), counter); @@@ -114,7 -112,6 +114,7 @@@ smi_poll(); + pci_bother_all(); outl(0xCF8, pcisave); outb(0x3D4, vgasave); } diff --combined net/net.c index 488f52b,7f1932f..18eaddf --- a/net/net.c +++ b/net/net.c @@@ -1,15 -1,22 +1,17 @@@ #include +#include #include #include "net.h" -static int found = 0, _bus, _dev, _fn; - + struct nic nic; + static int bother_3c905(pci_dev_t *dev, void *nutrinus) { if (dev->vid == 0x10B7 || dev->did == 0x9200) { outputf("Found a 3c905 to bother"); - _bus = dev->bus; - _dev = dev->dev; - _fn = dev->fn; - found = 1; - + pci_bother_add(dev); return 1; } return 0; @@@ -17,7 -24,12 +19,7 @@@ void eth_poll() { - if (!found) - return; - - pci_write16(_bus, _dev, _fn, 0x04, 0xFF); - - pci_write16(_bus, _dev, _fn, 0x04, 0x00); + /* ... */ } void eth_init() diff --combined pci/pci-bother.c index 0c3c0ec,0000000..dd1ff21 mode 100644,000000..100644 --- a/pci/pci-bother.c +++ b/pci/pci-bother.c @@@ -1,41 -1,0 +1,42 @@@ +#include ++#include + +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); ++ pci_write16(bothers[i].bus, bothers[i].dev, bothers[i].fn, 0x04, 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); ++ pci_write16(bothers[i].bus, bothers[i].dev, bothers[i].fn, 0x04, bothers[i].origstate); +}