]> Zhao Yanbai Git Server - minix.git/commitdiff
PCI support in a separate driver.
authorPhilip Homburg <philip@cs.vu.nl>
Fri, 2 Dec 2005 14:45:10 +0000 (14:45 +0000)
committerPhilip Homburg <philip@cs.vu.nl>
Fri, 2 Dec 2005 14:45:10 +0000 (14:45 +0000)
21 files changed:
drivers/Makefile
drivers/at_wini/Makefile
drivers/at_wini/at_wini.c
drivers/dp8390/Makefile
drivers/dp8390/rtl8029.c
drivers/fxp/Makefile
drivers/fxp/fxp.c
drivers/lance/Makefile
drivers/lance/lance.c
drivers/libpci/Makefile [deleted file]
drivers/pci/Makefile [new file with mode: 0644]
drivers/pci/main.c [new file with mode: 0644]
drivers/pci/pci.c [moved from drivers/libpci/pci.c with 99% similarity]
drivers/pci/pci.h [moved from drivers/libpci/pci.h with 78% similarity]
drivers/pci/pci_amd.h [moved from drivers/libpci/pci_amd.h with 100% similarity]
drivers/pci/pci_intel.h [moved from drivers/libpci/pci_intel.h with 100% similarity]
drivers/pci/pci_sis.h [moved from drivers/libpci/pci_sis.h with 100% similarity]
drivers/pci/pci_table.c [moved from drivers/libpci/pci_table.c with 100% similarity]
drivers/pci/pci_via.h [moved from drivers/libpci/pci_via.h with 100% similarity]
drivers/rtl8139/Makefile
drivers/rtl8139/rtl8139.c

index 4eb46eadfddaa369798fda11dd773bc3930ee2b5..29431b9347451df4cd6523cfacd37b971a264949 100644 (file)
@@ -16,7 +16,6 @@ usage:
 build: all
 all install depend clean:
        cd ./libdriver && $(MAKE) $@
-       cd ./libpci && $(MAKE) $@
        cd ./tty && $(MAKE) $@
        cd ./memory && $(MAKE) $@
        cd ./at_wini && $(MAKE) $@
@@ -32,13 +31,14 @@ all install depend clean:
        cd ./dp8390 && $(MAKE) $@
        cd ./sb16 && $(MAKE) $@
        cd ./lance && $(MAKE) $@
+       cd ./pci && $(MAKE) $@
 
 image:
        cd ./libdriver && $(MAKE) build
-       cd ./libpci && $(MAKE) build
        cd ./tty && $(MAKE) build
        cd ./memory && $(MAKE) build
        cd ./at_wini && $(MAKE) build
        cd ./floppy && $(MAKE) build
        cd ./bios_wini && $(MAKE) build
        cd ./log && $(MAKE) build
+       cd ./pci && $(MAKE) build
index b21d03e694d68a10ec14ed3a142cbab06306c170..738e75567faffe2f0cbf87d067027084b7ecfbcc 100644 (file)
@@ -19,18 +19,14 @@ LIBS = -lsysutil -lsys -ltimers
 
 OBJ = at_wini.o 
 LIBDRIVER = $d/libdriver/driver.o $d/libdriver/drvlib.o 
-LIBPCI = $p/pci.o $p/pci_table.o
 
 
 # build local binary
 all build:     $(DRIVER)
-$(DRIVER):     $(OBJ) $(LIBDRIVER) $(LIBPCI)
-       $(CC) -o $@ $(LDFLAGS) $(OBJ) $(LIBDRIVER) $(LIBS) $(LIBPCI)
+$(DRIVER):     $(OBJ) $(LIBDRIVER)
+       $(CC) -o $@ $(LDFLAGS) $(OBJ) $(LIBDRIVER) $(LIBS)
        install -S 8k $(DRIVER)
 
-$(LIBPCI):
-       cd $p && $(MAKE)
-
 $(LIBDRIVER): 
        cd $d/libdriver && $(MAKE) 
 
index 59421efb05d2f09a1e52b2afe2215c9d35982aaa..985f0baa7ebc43f65a93f96cce098f19f32b4967 100644 (file)
  */
 
 #include "at_wini.h"
-#include "../libpci/pci.h"
 
 #include <minix/sysutil.h>
 #include <minix/keymap.h>
 #include <sys/ioc_disk.h>
+#include <ibm/pci.h>
 
 #define ATAPI_DEBUG        0   /* To debug ATAPI code. */
 
@@ -416,6 +416,10 @@ PRIVATE void init_params_pci(int skip)
           pci_attr_r8(devind, PCI_SCR) != 0x01) {
           continue;
        }
+
+       printf("init_params_pci: found device %04x/%04x at index %d\n",
+               vid, did, devind);
+
        /* Found a controller.
         * Programming interface register tells us more.
         */
index 555b97c416bd2cdfcc86fce6b47b1f08dd973bcd..a3a133dba70bc08a5bab2b3c3a71a6b4ed079188 100644 (file)
@@ -16,17 +16,13 @@ LDFLAGS = -i
 LIBS = -lsys -lsysutil -ltimers
 
 OBJ = 3c503.o dp8390.o ne2000.o rtl8029.o wdeth.o
-LIBPCI = $d/libpci/pci.o $d/libpci/pci_table.o
 
 # build local binary
 all build:     $(DRIVER)
-$(DRIVER):     $(OBJ) $(LIBPCI)
-       $(CC) -o $@ $(LDFLAGS) $(OBJ) $(LIBPCI) $(LIBS)
+$(DRIVER):     $(OBJ) 
+       $(CC) -o $@ $(LDFLAGS) $(OBJ) $(LIBS)
        install -S 4096 $(DRIVER)
 
-$(LIBPCI): 
-       cd $d/libpci && $(MAKE) 
-
 # install with other drivers
 install:       /usr/sbin/$(DRIVER)
 /usr/sbin/$(DRIVER):   $(DRIVER)
@@ -37,7 +33,7 @@ clean:
        rm -f *.o *.bak $(DRIVER)
 
 depend: 
-       /usr/bin/mkdep "$(CC) -E $(CPPFLAGS)" *.c ../libpci/*.c > .depend
+       /usr/bin/mkdep "$(CC) -E $(CPPFLAGS)" *.c > .depend
 
 # Include generated dependencies.
 include .depend
index 76fa8cf52436563c534fd5961270d61735c3d534..2d31d629127662a9ce185a4c4ffc56fe003bc9ea 100644 (file)
@@ -12,9 +12,9 @@ Created:      April 2000 by Philip Homburg <philip@f-mnx.phicoh.com>
 #include <sys/types.h>
 #include <net/gen/ether.h>
 #include <net/gen/eth_io.h>
+#include <ibm/pci.h>
 
 #include "assert.h"
-#include "../libpci/pci.h"
 
 #include "local.h"
 #include "dp8390.h"
index 01ca57f6f9c781b389e7d2f7c49b0584a939e3f3..dbd5c7d3d6d9d90211b1ee455c8db79b57075d49 100644 (file)
@@ -16,17 +16,13 @@ LDFLAGS = -i
 LIBS = -lsys -lsysutil -ltimers
 
 OBJ = fxp.o mii.o
-LIBPCI = $d/libpci/pci.o $d/libpci/pci_table.o
 
 # build local binary
 all build:     $(DRIVER)
-$(DRIVER):     $(OBJ) $(LIBPCI)
-       $(CC) -o $@ $(LDFLAGS) $(OBJ) $(LIBPCI) $(LIBS)
+$(DRIVER):     $(OBJ) 
+       $(CC) -o $@ $(LDFLAGS) $(OBJ) $(LIBS)
        install -S 4096 $(DRIVER)
 
-$(LIBPCI): 
-       cd $d/libpci && $(MAKE) 
-
 # install with other drivers
 install:       /usr/sbin/$(DRIVER)
 /usr/sbin/$(DRIVER):   $(DRIVER)
@@ -37,7 +33,7 @@ clean:
        rm -f *.o *.bak $(DRIVER)
 
 depend: 
-       /usr/bin/mkdep "$(CC) -E $(CPPFLAGS)" *.c ../libpci/*.c > .depend
+       /usr/bin/mkdep "$(CC) -E $(CPPFLAGS)" *.c > .depend
 
 # Include generated dependencies.
 include .depend
index f3b1cfc9b4271f7ba0cb3d5928cb4d97597688cd..f6d287e9673a2db2b88bd5e89a97fe3761d9c26b 100644 (file)
@@ -46,6 +46,7 @@
 #include <net/hton.h>
 #include <net/gen/ether.h>
 #include <net/gen/eth_io.h>
+#include <ibm/pci.h>
 
 #include <timers.h>
 
@@ -58,7 +59,6 @@
 #define vm_1phys2bus(p)                (p)
 
 #include "assert.h"
-#include "../libpci/pci.h"
 #include "fxp.h"
 #include "mii.h"
 
@@ -585,12 +585,24 @@ fxp_t *fp;
        case FXP_REV_82559C:    str= "82559C";                  /* 0x08 */
                                fp->fxp_type= FT_82559;
                                break;
-       case FXP_REV_82559ERA:  str= "82559ER-A"; break;        /* 0x09 */
-       case FXP_REV_82550_1:   str= "82550(1)"; break;         /* 0x0C */
-       case FXP_REV_82550_2:   str= "82550(2)"; break;         /* 0x0D */
-       case FXP_REV_82550_3:   str= "82550(3)"; break;         /* 0x0E */
-       case FXP_REV_82551_1:   str= "82551(1)"; break;         /* 0x0F */
-       case FXP_REV_82551_2:   str= "82551(2)"; break;         /* 0x10 */
+       case FXP_REV_82559ERA:  str= "82559ER-A";               /* 0x09 */
+                               fp->fxp_type= FT_82559;
+                               break;
+       case FXP_REV_82550_1:   str= "82550(1)";                /* 0x0C */
+                               fp->fxp_type= FT_82559;
+                               break;
+       case FXP_REV_82550_2:   str= "82550(2)";                /* 0x0D */
+                               fp->fxp_type= FT_82559;
+                               break;
+       case FXP_REV_82550_3:   str= "82550(3)";                /* 0x0E */
+                               fp->fxp_type= FT_82559;
+                               break;
+       case FXP_REV_82551_1:   str= "82551(1)";                /* 0x0F */
+                               fp->fxp_type= FT_82559;
+                               break;
+       case FXP_REV_82551_2:   str= "82551(2)";                /* 0x10 */
+                               fp->fxp_type= FT_82559;
+                               break;
        }
 
 #if VERBOSE
index a157c4344d8b027c79f88a694552664a92a4340c..fa0048dc62c53bae616811b21b862ac532c71e31 100644 (file)
@@ -17,17 +17,13 @@ LIBS = -lsys -lsysutil
 #-lutils -ltimers
 
 OBJ = lance.o
-LIBPCI = $d/libpci/pci.o $d/libpci/pci_table.o
 
 # build local binary
 all build:     $(DRIVER)
-$(DRIVER):     $(OBJ) $(LIBPCI)
-       $(CC) -o $@ $(LDFLAGS) $(OBJ) $(LIBPCI) $(LIBS)
+$(DRIVER):     $(OBJ) 
+       $(CC) -o $@ $(LDFLAGS) $(OBJ) $(LIBS)
        install -S 1k $(DRIVER)
 
-$(LIBPCI): 
-       cd $d/libpci && $(MAKE) 
-
 # install with other drivers
 install:       /usr/sbin/$(DRIVER)
 /usr/sbin/$(DRIVER):   $(DRIVER)
@@ -38,7 +34,7 @@ clean:
        rm -f *.o *.bak $(DRIVER)
 
 depend:
-       /usr/bin/mkdep "$(CC) -E $(CPPFLAGS)" *.c ../libpci/*.c > .depend
+       /usr/bin/mkdep "$(CC) -E $(CPPFLAGS)" *.c > .depend
 
 # Include generated dependencies.
 include .depend
index da174fe08cc215dab4208e79618fe95ee71865d4..a09940b6a239bf8e818b792b536ba582a9d15efc 100644 (file)
@@ -52,9 +52,9 @@
 #include <assert.h>
 
 #include <minix/syslib.h>
+#include <ibm/pci.h>
 
 #include "lance.h"
-#include "../libpci/pci.h"
 /*#include "proc.h"*/
 
 #include <sys/ioc_memory.h>
diff --git a/drivers/libpci/Makefile b/drivers/libpci/Makefile
deleted file mode 100644 (file)
index 96acf0b..0000000
+++ /dev/null
@@ -1,30 +0,0 @@
-# Makefile for PCI bus library
-
-# Directories
-u = /usr
-i = $u/include
-s = $i/sys
-b = $i/ibm
-m = $i/minix
-
-# Programs, flags, etc.
-CC =   exec cc
-CFLAGS = -I$i
-LDFLAGS = -i
-LIBS = -lsys -lsysutil
-
-OBJECTS = pci.o pci_table.o 
-
-all build install: $(OBJECTS)  
-
-# $(CC) -c $@ $(LDFLAGS) $(OBJ) $(LIBS)
-
-clean:
-       rm -f *.o *.bak 
-
-depend: 
-       /usr/bin/mkdep "$(CC) -E $(CPPFLAGS)" *.c > .depend
-
-# Include generated dependencies.
-include .depend
-
diff --git a/drivers/pci/Makefile b/drivers/pci/Makefile
new file mode 100644 (file)
index 0000000..0499374
--- /dev/null
@@ -0,0 +1,40 @@
+# Makefile for PCI support
+DRIVER = pci
+
+# directories
+u = /usr
+i = $u/include
+s = $i/sys
+m = $i/minix
+b = $i/ibm
+d = ..
+
+# programs, flags, etc.
+CC =   cc
+CFLAGS = -I$i
+LDFLAGS = -i 
+LIBS = -lsys -lsysutil -ltimers
+
+OBJ = main.o pci.o pci_table.o
+
+# build local binary
+all build:     $(DRIVER)
+$(DRIVER):     $(OBJ) 
+       $(CC) -o $@ $(LDFLAGS) $(OBJ) $(LIBS)
+       install -S 4096 $(DRIVER)
+
+# install with other drivers
+install:       /usr/sbin/$(DRIVER)
+/usr/sbin/$(DRIVER):   $(DRIVER)
+       install -o root -cs $? $@
+
+# clean up local files
+clean:
+       rm -f *.o *.bak $(DRIVER)
+
+depend: 
+       /usr/bin/mkdep "$(CC) -E $(CPPFLAGS)" *.c > .depend
+
+# Include generated dependencies.
+include .depend
+
diff --git a/drivers/pci/main.c b/drivers/pci/main.c
new file mode 100644 (file)
index 0000000..84caad1
--- /dev/null
@@ -0,0 +1,301 @@
+/*
+main.c
+*/
+
+#include "../drivers.h"
+
+#include <ibm/pci.h>
+
+FORWARD _PROTOTYPE( void do_init, (message *mp)                                );
+FORWARD _PROTOTYPE( void do_first_dev, (message *mp)                   );
+FORWARD _PROTOTYPE( void do_next_dev, (message *mp)                    );
+FORWARD _PROTOTYPE( void do_find_dev, (message *mp)                    );
+FORWARD _PROTOTYPE( void do_ids, (message *mp)                         );
+FORWARD _PROTOTYPE( void do_dev_name, (message *mp)                    );
+FORWARD _PROTOTYPE( void do_slot_name, (message *mp)                   );
+FORWARD _PROTOTYPE( void do_reserve, (message *mp)                     );
+FORWARD _PROTOTYPE( void do_attr_r8, (message *mp)                     );
+FORWARD _PROTOTYPE( void do_attr_r32, (message *mp)                    );
+FORWARD _PROTOTYPE( void do_attr_w32, (message *mp)                    );
+
+int main(void)
+{
+       int r;
+       message m;
+
+       printf("PCI says: hello world\n");
+
+       pci_init();
+
+       for(;;)
+       {
+               r= receive(ANY, &m);
+               if (r < 0)
+               {
+                       printf("PCI: receive from ANY failed: %d\n", r);
+                       break;
+               }
+               switch(m.m_type)
+               {
+               case BUSC_PCI_INIT: do_init(&m); break;
+               case BUSC_PCI_FIRST_DEV: do_first_dev(&m); break;
+               case BUSC_PCI_NEXT_DEV: do_next_dev(&m); break;
+               case BUSC_PCI_FIND_DEV: do_find_dev(&m); break;
+               case BUSC_PCI_IDS: do_ids(&m); break;
+               case BUSC_PCI_DEV_NAME: do_dev_name(&m); break;
+               case BUSC_PCI_SLOT_NAME: do_slot_name(&m); break;
+               case BUSC_PCI_RESERVE: do_reserve(&m); break;
+               case BUSC_PCI_ATTR_R8: do_attr_r8(&m); break;
+               case BUSC_PCI_ATTR_R32: do_attr_r32(&m); break;
+               case BUSC_PCI_ATTR_W32: do_attr_w32(&m); break;
+               default:
+                       printf("got message from %d, type %d\n",
+                               m.m_source, m.m_type);
+                       break;
+               }
+       }
+
+       return 0;
+}
+
+PRIVATE void do_init(mp)
+message *mp;
+{
+       int r;
+
+       /* NOP for the moment */
+
+       mp->m_type= 0;
+       r= send(mp->m_source, mp);
+       if (r != 0)
+               printf("do_init: unable to send to %d: %d\n", mp->m_source, r);
+}
+
+PRIVATE void do_first_dev(mp)
+message *mp;
+{
+       int r, devind;
+       u16_t vid, did;
+
+       r= pci_first_dev(&devind, &vid, &did);
+       if (r == 1)
+       {
+               mp->m1_i1= devind;
+               mp->m1_i2= vid;
+               mp->m1_i3= did;
+       }
+       mp->m_type= r;
+       r= send(mp->m_source, mp);
+       if (r != 0)
+       {
+               printf("do_first_dev: unable to send to %d: %d\n",
+                       mp->m_source, r);
+       }
+}
+
+PRIVATE void do_next_dev(mp)
+message *mp;
+{
+       int r, devind;
+       u16_t vid, did;
+
+       devind= mp->m1_i1;
+
+       r= pci_next_dev(&devind, &vid, &did);
+       if (r == 1)
+       {
+               mp->m1_i1= devind;
+               mp->m1_i2= vid;
+               mp->m1_i3= did;
+       }
+       mp->m_type= r;
+       r= send(mp->m_source, mp);
+       if (r != 0)
+       {
+               printf("do_next_dev: unable to send to %d: %d\n",
+                       mp->m_source, r);
+       }
+}
+
+PRIVATE void do_find_dev(mp)
+message *mp;
+{
+       int r, devind;
+       u8_t bus, dev, func;
+
+       bus= mp->m1_i1;
+       dev= mp->m1_i2;
+       func= mp->m1_i3;
+
+       r= pci_find_dev(bus, dev, func, &devind);
+       if (r == 1)
+               mp->m1_i1= devind;
+       mp->m_type= r;
+       r= send(mp->m_source, mp);
+       if (r != 0)
+       {
+               printf("do_find_dev: unable to send to %d: %d\n",
+                       mp->m_source, r);
+       }
+}
+
+PRIVATE void do_ids(mp)
+message *mp;
+{
+       int r, devind;
+       u16_t vid, did;
+
+       devind= mp->m1_i1;
+
+       pci_ids(devind, &vid, &did);
+       mp->m1_i1= vid;
+       mp->m1_i2= did;
+       mp->m_type= OK;
+       r= send(mp->m_source, mp);
+       if (r != 0)
+       {
+               printf("do_ids: unable to send to %d: %d\n",
+                       mp->m_source, r);
+       }
+}
+
+PRIVATE void do_dev_name(mp)
+message *mp;
+{
+       int r, name_len, len;
+       u16_t vid, did;
+       char *name_ptr, *name;
+
+       vid= mp->m1_i1;
+       did= mp->m1_i2;
+       name_len= mp->m1_i3;
+       name_ptr= mp->m1_p1;
+
+       name= pci_dev_name(vid, did);
+       if (name == NULL)
+       {
+               /* No name */
+               r= ENOENT;
+       }
+       else
+       {
+               len= strlen(name)+1;
+               if (len > name_len)
+                       len= name_len;
+               r= sys_vircopy(SELF, D, (vir_bytes)name, mp->m_source, D,
+                       (vir_bytes)name_ptr, len);
+       }
+
+       mp->m_type= r;
+       r= send(mp->m_source, mp);
+       if (r != 0)
+       {
+               printf("do_dev_name: unable to send to %d: %d\n",
+                       mp->m_source, r);
+       }
+}
+
+PRIVATE void do_slot_name(mp)
+message *mp;
+{
+       int r, devind, name_len, len;
+       char *name_ptr, *name;
+
+       devind= mp->m1_i1;
+       name_len= mp->m1_i2;
+       name_ptr= mp->m1_p1;
+
+       name= pci_slot_name(devind);
+
+       len= strlen(name)+1;
+       if (len > name_len)
+               len= name_len;
+       r= sys_vircopy(SELF, D, (vir_bytes)name, mp->m_source, D,
+               (vir_bytes)name_ptr, len);
+
+       mp->m_type= r;
+       r= send(mp->m_source, mp);
+       if (r != 0)
+       {
+               printf("do_slot_name: unable to send to %d: %d\n",
+                       mp->m_source, r);
+       }
+}
+
+PRIVATE void do_reserve(mp)
+message *mp;
+{
+       int r, devind;
+
+       devind= mp->m1_i1;
+
+       pci_reserve(devind);
+       mp->m_type= OK;
+       r= send(mp->m_source, mp);
+       if (r != 0)
+       {
+               printf("do_reserve: unable to send to %d: %d\n",
+                       mp->m_source, r);
+       }
+}
+
+PRIVATE void do_attr_r8(mp)
+message *mp;
+{
+       int r, devind, port;
+       u8_t v;
+
+       devind= mp->m2_i1;
+       port= mp->m2_i2;
+
+       v= pci_attr_r8(devind, port);
+       mp->m2_l1= v;
+       mp->m_type= OK;
+       r= send(mp->m_source, mp);
+       if (r != 0)
+       {
+               printf("do_attr_r8: unable to send to %d: %d\n",
+                       mp->m_source, r);
+       }
+}
+
+PRIVATE void do_attr_r32(mp)
+message *mp;
+{
+       int r, devind, port;
+       u32_t v;
+
+       devind= mp->m2_i1;
+       port= mp->m2_i2;
+
+       v= pci_attr_r32(devind, port);
+       mp->m2_l1= v;
+       mp->m_type= OK;
+       r= send(mp->m_source, mp);
+       if (r != 0)
+       {
+               printf("do_attr_r32: unable to send to %d: %d\n",
+                       mp->m_source, r);
+       }
+}
+
+PRIVATE void do_attr_w32(mp)
+message *mp;
+{
+       int r, devind, port;
+       u32_t v;
+
+       devind= mp->m2_i1;
+       port= mp->m2_i2;
+       v= mp->m2_l1;
+
+       pci_attr_w32(devind, port, v);
+       mp->m_type= OK;
+       r= send(mp->m_source, mp);
+       if (r != 0)
+       {
+               printf("do_attr_w32: unable to send to %d: %d\n",
+                       mp->m_source, r);
+       }
+}
+
similarity index 99%
rename from drivers/libpci/pci.c
rename to drivers/pci/pci.c
index b242db21859626d6b96373d9aa12af7778b7b54b..539203f45dcbf3d663aaed2a91d2e2fff66de31c 100644 (file)
@@ -116,7 +116,7 @@ PUBLIC unsigned pci_inb(U16_t port) {
        return value;
 }
 PUBLIC unsigned pci_inw(U16_t port) {
-       U16_t value;
+       u32_t value;
        int s;
        if ((s=sys_inw(port, &value)) !=OK)
                printf("PCI: warning, sys_inw failed: %d\n", s);
similarity index 78%
rename from drivers/libpci/pci.h
rename to drivers/pci/pci.h
index 41385445e6e6d99badd4a27b147198968dde2701..25651ec1d8e5c3b9d3f7840dd0be452ee575852d 100644 (file)
@@ -13,21 +13,6 @@ _PROTOTYPE( void pci_outb, (U16_t port, U8_t value) );
 _PROTOTYPE( void pci_outw, (U16_t port, U16_t value) );
 _PROTOTYPE( void pci_outl, (U16_t port, U32_t value) );
 
-/* pci.c */
-_PROTOTYPE( void pci_init, (void)                                      );
-_PROTOTYPE( int pci_find_dev, (U8_t bus, U8_t dev, U8_t func,
-                                                       int *devindp)   );
-_PROTOTYPE( int pci_first_dev, (int *devindp, u16_t *vidp, u16_t *didp)        );
-_PROTOTYPE( int pci_next_dev, (int *devindp, u16_t *vidp, u16_t *didp) );
-_PROTOTYPE( void pci_reserve, (int devind)                             );
-_PROTOTYPE( void pci_ids, (int devind, u16_t *vidp, u16_t *didp)       );
-_PROTOTYPE( char *pci_slot_name, (int devind)                          );
-_PROTOTYPE( char *pci_dev_name, (U16_t vid, U16_t did)                 );
-_PROTOTYPE( u8_t pci_attr_r8, (int devind, int port)                   );
-_PROTOTYPE( u16_t pci_attr_r16, (int devind, int port)                 );
-_PROTOTYPE( u32_t pci_attr_r32, (int devind, int port)                 );
-_PROTOTYPE( void pci_attr_w16, (int devind, int port, U16_t value)     );
-_PROTOTYPE( void pci_attr_w32, (int devind, int port, u32_t value)     );
 
 #define PCI_VID                0x00    /* Vendor ID, 16-bit */
 #define PCI_DID                0x02    /* Device ID, 16-bit */
index 83be7bd15c12bdf9f524d6e2647c43ca91949e18..bc595d82f03688f064486a3c1903c58274ccd437 100644 (file)
@@ -17,18 +17,13 @@ LDFLAGS = -i
 LIBS = -lsys -lsysutil -ltimers
 
 OBJ = rtl8139.o 
-LIBPCI = $d/libpci/pci.o $d/libpci/pci_table.o
-
 
 # build local binary
 all build:     $(DRIVER)
-$(DRIVER):     $(OBJ) $(PCI)
-       $(CC) -o $@ $(LDFLAGS) $(OBJ) $(LIBPCI) $(LIBS)
+$(DRIVER):     $(OBJ) 
+       $(CC) -o $@ $(LDFLAGS) $(OBJ) $(LIBS)
        install -S 50kw $(DRIVER)
 
-$(PCI): 
-       cd $d/libpci && $(MAKE) 
-
 # install with other drivers
 install:       /usr/sbin/$(DRIVER)
 /usr/sbin/$(DRIVER):   $(DRIVER)
@@ -39,7 +34,7 @@ clean:
        rm -f $(DRIVER) *.o *.bak 
 
 depend: 
-       /usr/bin/mkdep "$(CC) -E $(CPPFLAGS)" *.c ../libpci/*.c > .depend
+       /usr/bin/mkdep "$(CC) -E $(CPPFLAGS)" *.c > .depend
 
 # Include generated dependencies.
 include .depend
index 982dfc8fc9ff9fc951b1b4cc4f31731579b1cbd1..7546ef62c2a4b2926909dca16a77302cd0c8980a 100755 (executable)
@@ -64,6 +64,7 @@
 #include <net/hton.h>
 #include <net/gen/ether.h>
 #include <net/gen/eth_io.h>
+#include <ibm/pci.h>
 
 #include <sys/types.h>
 #include <fcntl.h>
@@ -81,9 +82,8 @@
 #define printW()               ((void)0)
 #define vm_1phys2bus(p)                (p)
 
-#define VERBOSE                0       /* display message during init */
+#define VERBOSE                1       /* display message during init */
 
-#include "../libpci/pci.h"
 #include "rtl8139.h"
 
 #define RX_BUFSIZE     RL_RCR_RBLEN_64K_SIZE
@@ -189,7 +189,7 @@ static unsigned my_inb(U16_t port) {
        return value;
 }
 static unsigned my_inw(U16_t port) {
-       U16_t value;
+       u32_t value;
        int s;
        if ((s=sys_inw(port, &value)) !=OK)
                printf("RTL8139: warning, sys_inw failed: %d\n", s);
@@ -775,7 +775,7 @@ re_t *rep;
                printf("RTL8139: error, couldn't enable interrupts: %d\n", s);
 
 #if VERBOSE    /* stay silent during startup, can always get status later */
-       if (rep->re_mode) {
+       if (rep->re_model) {
                printf("%s: model %s\n", rep->re_name, rep->re_model);
        } else
        {
@@ -825,14 +825,18 @@ re_t *rep;
 #endif
 
        /* Reset the device */
+       printf("rl_reset_hw: (before reset) port = 0x%x, RL_CR = 0x%x\n",
+               port, rl_inb(port, RL_CR));
        rl_outb(port, RL_CR, RL_CR_RST);
        getuptime(&t0);
        do {
                if (!(rl_inb(port, RL_CR) & RL_CR_RST))
                        break;
        } while (getuptime(&t1)==OK && (t1-t0) < HZ);
+       printf("rl_reset_hw: (after reset) port = 0x%x, RL_CR = 0x%x\n",
+               port, rl_inb(port, RL_CR));
        if (rl_inb(port, RL_CR) & RL_CR_RST)
-               panic("rtl8139","reset failed to complete", NO_NUM);
+               printf("rtl8139: reset failed to complete");
 
        t= rl_inl(port, RL_TCR);
        switch(t & (RL_TCR_HWVER_AM | RL_TCR_HWVER_BM))