]> Joshua Wise's Git repositories - netwatch.git/commitdiff
merge
authorJoshua Wise <joshua@rebirth.joshuawise.com>
Thu, 2 Oct 2008 23:23:10 +0000 (19:23 -0400)
committerJoshua Wise <joshua@rebirth.joshuawise.com>
Thu, 2 Oct 2008 23:23:10 +0000 (19:23 -0400)
aseg/Makefile
aseg/counter.c
include/pci-bother.h [new file with mode: 0644]
net/net.c
pci/pci-bother.c [new file with mode: 0644]

index dfedc2a203cbb0a1e8d8d9f837170bead92858ba..40726061e4911d7ee6bc9d5ec17e4931db885e94 100644 (file)
@@ -2,8 +2,9 @@ CC=gcc
 CFLAGS=-I../include -I../include/raw -nostdlib -nostdinc -fno-builtin -D__RAW__ -Wall -Werror -pedantic -ansi -std=gnu99
 
 OBJS=counter.o firstrun.o ../pci/pci-raw.o ../lib/minilib.o ../lib/console.o \
-       ../ich2/smram-ich2.o ../ich2/smi.o vga-overlay.o packet.o ../lib/sprintf.o \
-       ../lib/doprnt.o ../pci/pci.o ../net/net.o ../ich2/ich2-timer.o
+       ../ich2/smram-ich2.o ../ich2/smi.o vga-overlay.o packet.o \
+       ../lib/sprintf.o ../lib/doprnt.o ../pci/pci.o ../net/net.o \
+       ../ich2/ich2-timer.o ../pci/pci-bother.o
 
 all: aseg.elf
 
index 868ec459984ce8069f5f0d5e8ba2b53844cfaf07..4876acf354535a4cd00db8c45a8a8684fca0bdea 100644 (file)
@@ -3,6 +3,7 @@
 #include <video_defines.h>
 #include <minilib.h>
 #include <smi.h>
+#include <pci-bother.h>
 #include "../net/net.h"
 #include "vga-overlay.h"
 #include "packet.h"
@@ -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);
@@ -112,6 +114,7 @@ void smi_entry(void)
 
        smi_poll();
        
+       pci_bother_all();
        outl(0xCF8, pcisave);
        outb(0x3D4, vgasave);
 }
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
index 7f1932f3ba848d9e119cda80662053a4804b6956..18eaddf2dc625729b5af87d7d9ee55c339d93cb9 100644 (file)
--- a/net/net.c
+++ b/net/net.c
@@ -1,9 +1,8 @@
 #include <pci.h>
+#include <pci-bother.h>
 #include <output.h>
 #include "net.h"
 
-static int found = 0, _bus, _dev, _fn;
-
 struct nic nic;
 
 static int bother_3c905(pci_dev_t *dev, void *nutrinus)
@@ -12,11 +11,7 @@ static int bother_3c905(pci_dev_t *dev, void *nutrinus)
        {
                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;
@@ -24,12 +19,7 @@ static int bother_3c905(pci_dev_t *dev, void *nutrinus)
 
 void eth_poll()
 {
-       if (!found)
-               return;
-               
-       pci_write16(_bus, _dev, _fn, 0x04, 0xFF);
-       
-       pci_write16(_bus, _dev, _fn, 0x04, 0x00);
+       /* ... */
 }
 
 void eth_init()
diff --git a/pci/pci-bother.c b/pci/pci-bother.c
new file mode 100644 (file)
index 0000000..dd1ff21
--- /dev/null
@@ -0,0 +1,42 @@
+#include <pci.h>
+#include <pci-bother.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, 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, 0x04, bothers[i].origstate);
+}
This page took 0.028856 seconds and 4 git commands to generate.