Index: dev/vx/if_vx_pci.c =================================================================== RCS file: /home/imp/FreeBSD/CVS/src/sys/dev/vx/if_vx_pci.c,v retrieving revision 1.21 diff -u -r1.21 if_vx_pci.c --- dev/vx/if_vx_pci.c 2000/05/28 15:59:52 1.21 +++ dev/vx/if_vx_pci.c 2000/11/05 08:03:54 @@ -36,6 +36,10 @@ #include #include #include +#include +#include +#include +#include #include #include @@ -44,100 +48,153 @@ #include -#ifndef COMPAT_OLDPCI -#error "The vx driver requires the old pci compatability shims." -#endif - -static void vx_pci_shutdown(void *, int); -static const char *vx_pci_probe(pcici_t, pcidi_t); -static void vx_pci_attach(pcici_t, int unit); +static int vx_pci_probe(device_t dev); +static int vx_pci_attach(device_t dev); static void -vx_pci_shutdown( - void *sc, - int howto) +vx_pci_detach(device_t dev) { + struct vx_softc *sc = vx_softc[device_get_unit(dev)]; + vxstop(sc); vxfree(sc); } -static const char* -vx_pci_probe( - pcici_t config_id, - pcidi_t device_id) +static int +vx_pci_probe(device_t dev) { - if(device_id == 0x590010b7ul) - return "3COM 3C590 Etherlink III PCI"; - if(device_id == 0x595010b7ul || device_id == 0x595110b7ul || - device_id == 0x595210b7ul) - return "3COM 3C595 Fast Etherlink III PCI"; - /* - * The (Fast) Etherlink XL adapters are now supported by - * the xl driver, which uses bus master DMA and is much - * faster. (And which also supports the 3c905B. - */ + if(pci_get_vendor(dev) == VX_VENDORID_3COM) { + switch(pci_get_device(dev)) { + case VX_DEVICEID_3C590: + device_set_desc(dev, "3COM 3C590 Etherlink III PCI"); + return 0; + + case VX_DEVICEID_3C595_TX: + case VX_DEVICEID_3C595_T4: + case VX_DEVICEID_3C595_MII: + device_set_desc(dev, "3COM 3C595 Fast Etherlink III PCI"); + return 0; + #ifdef VORTEX_ETHERLINK_XL - if(device_id == 0x900010b7ul || device_id == 0x900110b7ul) - return "3COM 3C900 Etherlink XL PCI"; - if(device_id == 0x905010b7ul || device_id == 0x905110b7ul) - return "3COM 3C905 Fast Etherlink XL PCI"; + /* + * The (Fast) Etherlink XL adapters are now supported by + * the xl driver, which uses bus master DMA and is much + * faster. (And which also supports the 3c905B.) + */ + case VX_DEVICEID_3C900_TPO: + case VX_DEVICEID_3C900_COMBO: + device_set_desc(dev, "3COM 3C900 Etherlink XL PCI"); + return 0; + + case VX_DEVICEID_3C905_TX: + case VX_DEVICEID_3C905_T4: + device_set_desc(dev, "3COM 3C905 Fast Etherlink XL PCI"); + return 0; #endif - return NULL; + + default: + return ENXIO; + } + } + + return ENXIO; } -static void -vx_pci_attach( - pcici_t config_id, - int unit) +static int +vx_pci_attach(device_t dev) { - struct vx_softc *sc; + struct vx_softc *sc = NULL; + int unit = device_get_unit(dev); + struct resource *io = 0; + struct resource *pci_io = 0; + struct resource *irq = 0; + int rid; + void *ih; if (unit >= NVX) { - printf("vx%d: not configured; kernel is built for only %d device%s.\n", - unit, NVX, NVX == 1 ? "" : "s"); - return; + device_printf(dev, "not configured; kernel is built for only %d device%s.\n", + NVX, NVX == 1 ? "" : "s"); + goto bad; + } + + rid = 0; + io = bus_alloc_resource(dev, SYS_RES_IOPORT, &rid, + 0, ~0, 1, RF_ACTIVE); + if (!io) { + device_printf(dev, "No I/O space?!\n"); + goto bad; } + rid = 1; + pci_io = bus_alloc_resource(dev, SYS_RES_IOPORT, &rid, + 0, ~0, 1, RF_ACTIVE); + if (!pci_io) { + device_printf(dev, "No I/O space?!\n"); + goto bad; + } + if ((sc = vxalloc(unit)) == NULL) { - return; + goto bad; + } + + sc->vx_io_addr = rman_get_start(io); + + rid = 0; + irq = bus_alloc_resource(dev, SYS_RES_IRQ, &rid, + 0, ~0, 1, RF_ACTIVE); + if(!irq) { + device_printf(dev, "No irq?!\n"); + goto bad; } - sc->vx_io_addr = pci_conf_read(config_id, 0x10) & 0xffffffe0; + vxattach(sc); - if (vxattach(sc) == 0) { - return; + if (bus_setup_intr(dev, irq, INTR_TYPE_NET, vxintr, sc, &ih)) { + goto bad; } /* defect check for 3C590 */ - if ((pci_conf_read(config_id, 0) >> 16) == 0x5900) { + if (pci_get_device(dev) == VX_DEVICEID_3C590) { GO_WINDOW(0); if (vxbusyeeprom(sc)) - return; + goto bad; outw(BASE + VX_W0_EEPROM_COMMAND, EEPROM_CMD_RD | EEPROM_SOFT_INFO_2); if (vxbusyeeprom(sc)) - return; + goto bad; if (!(inw(BASE + VX_W0_EEPROM_DATA) & NO_RX_OVN_ANOMALY)) { - printf("Warning! Defective early revision adapter!\n"); + device_printf(dev, "Warning! Defective early revision adapter!\n"); } } - /* - * Add shutdown hook so that DMA is disabled prior to reboot. Not - * doing do could allow DMA to corrupt kernel memory during the - * reboot before the driver initializes. - */ - EVENTHANDLER_REGISTER(shutdown_post_sync, vx_pci_shutdown, sc, - SHUTDOWN_PRI_DEFAULT); + return 0; - pci_map_int(config_id, vxintr, (void *) sc, &net_imask); + bad: + if (sc != NULL) + vxfree(sc); + if (io) + bus_release_resource(dev, SYS_RES_IOPORT, 0, io); + if (pci_io) + bus_release_resource(dev, SYS_RES_IOPORT, 0, pci_io); + if (irq) + bus_release_resource(dev, SYS_RES_IRQ, 0, irq); + return -1; } -static struct pci_device vxdevice = { - "vx", - vx_pci_probe, - vx_pci_attach, - &vx_count, - NULL +static device_method_t vx_pci_methods[] = { + /* Device interface */ + DEVMETHOD(device_probe, vx_pci_probe), + DEVMETHOD(device_attach, vx_pci_attach), + DEVMETHOD(device_detach, vx_pci_detach), + + { 0, 0 } +}; + +static driver_t vx_pci_driver = { + "vx", + vx_pci_methods, + sizeof(struct vx_softc), }; + +static devclass_t vx_devclass; -COMPAT_PCI_DRIVER (vx, vxdevice); +DRIVER_MODULE(vx, pci, vx_pci_driver, vx_devclass, 0, 0); Index: dev/vx/if_vxreg.h =================================================================== RCS file: /home/imp/FreeBSD/CVS/src/sys/dev/vx/if_vxreg.h,v retrieving revision 1.6 diff -u -r1.6 if_vxreg.h --- dev/vx/if_vxreg.h 2000/05/01 19:54:26 1.6 +++ dev/vx/if_vxreg.h 2000/11/05 07:58:22 @@ -85,6 +85,19 @@ #define VX_ID_PORT 0x100 /* + * PCI Vendor and Device IDs + */ +#define VX_VENDORID_3COM 0x10b7 +#define VX_DEVICEID_3C590 0x5900 +#define VX_DEVICEID_3C595_TX 0x5950 +#define VX_DEVICEID_3C595_T4 0x5951 +#define VX_DEVICEID_3C595_MII 0x5952 +#define VX_DEVICEID_3C900_TPO 0x9000 +#define VX_DEVICEID_3C900_COMBO 0x9001 +#define VX_DEVICEID_3C905_TX 0x9050 +#define VX_DEVICEID_3C905_T4 0x9051 + +/* * some macros to acces long named fields */ #define BASE (sc->vx_io_addr) Index: i386/conf/GENERIC =================================================================== RCS file: /home/imp/FreeBSD/CVS/src/sys/i386/conf/GENERIC,v retrieving revision 1.284 diff -u -r1.284 GENERIC --- i386/conf/GENERIC 2000/10/28 22:32:17 1.284 +++ i386/conf/GENERIC 2000/11/05 08:13:11 @@ -66,7 +66,7 @@ device eisa device pci options COMPAT_OLDISA # compatability shims for lnc, le -options COMPAT_OLDPCI # compatability shims for lnc, vx +options COMPAT_OLDPCI # compatability shims for lnc # Floppy drives device fdc Index: i386/conf/NOTES =================================================================== RCS file: /home/imp/FreeBSD/CVS/src/sys/i386/conf/NOTES,v retrieving revision 1.850 diff -u -r1.850 NOTES --- i386/conf/NOTES 2000/10/30 20:35:31 1.850 +++ i386/conf/NOTES 2000/11/05 08:13:01 @@ -1752,7 +1752,7 @@ # PCI Ethernet NICs. device de # DEC/Intel DC21x4x (``Tulip'') device fxp # Intel EtherExpress PRO/100B (82557, 82558) -device vx 1 # 3Com 3c590, 3c595 (``Vortex'') +device vx # 3Com 3c590, 3c595 (``Vortex'') # PCI Gigabit & FDDI NICs. device sk