Deleted Added
full compact
32c32
< * $Id: if_ti.c,v 1.8 1999/07/05 20:19:41 wpaul Exp $
---
> * $Id: if_ti.c,v 1.114 1999/07/05 19:20:31 wpaul Exp $
116a117,119
> #include <machine/resource.h>
> #include <sys/bus.h>
> #include <sys/rman.h>
131c134
< "$Id: if_ti.c,v 1.8 1999/07/05 20:19:41 wpaul Exp $";
---
> "$Id: if_ti.c,v 1.114 1999/07/05 19:20:31 wpaul Exp $";
150,153c153,155
< static unsigned long ti_count;
<
< static const char *ti_probe __P((pcici_t, pcidi_t));
< static void ti_attach __P((pcici_t, int));
---
> static int ti_probe __P((device_t));
> static int ti_attach __P((device_t));
> static int ti_detach __P((device_t));
168c170
< static void ti_shutdown __P((int, void *));
---
> static void ti_shutdown __P((device_t));
207a210,228
> static device_method_t ti_methods[] = {
> /* Device interface */
> DEVMETHOD(device_probe, ti_probe),
> DEVMETHOD(device_attach, ti_attach),
> DEVMETHOD(device_detach, ti_detach),
> DEVMETHOD(device_shutdown, ti_shutdown),
> { 0, 0 }
> };
>
> static driver_t ti_driver = {
> "ti",
> ti_methods,
> sizeof(struct ti_softc)
> };
>
> static devclass_t ti_devclass;
>
> DRIVER_MODULE(ti, pci, ti_driver, ti_devclass, 0, 0);
>
1499,1502c1520,1521
< static const char *
< ti_probe(config_id, device_id)
< pcici_t config_id;
< pcidi_t device_id;
---
> static int ti_probe(dev)
> device_t dev;
1509,1511c1528,1532
< if ((device_id & 0xFFFF) == t->ti_vid &&
< ((device_id >> 16) & 0xFFFF) == t->ti_did)
< return(t->ti_name);
---
> if ((pci_get_vendor(dev) == t->ti_vid) &&
> (pci_get_device(dev) == t->ti_did)) {
> device_set_desc(dev, t->ti_name);
> return(0);
> }
1515c1536
< return(NULL);
---
> return(ENXIO);
1518,1522c1539,1540
<
< static void
< ti_attach(config_id, unit)
< pcici_t config_id;
< int unit;
---
> static int ti_attach(dev)
> device_t dev;
1524d1541
< vm_offset_t pbase, vbase;
1528a1546
> int unit, error = 0, rid;
1532,1538c1550,1551
< /* First, allocate memory for the softc struct. */
< sc = malloc(sizeof(struct ti_softc), M_DEVBUF, M_NOWAIT);
< if (sc == NULL) {
< printf("ti%d: no memory for softc struct!\n", unit);
< goto fail;
< }
<
---
> sc = device_get_softc(dev);
> unit = device_get_unit(dev);
1544c1557
< command = pci_conf_read(config_id, PCI_COMMAND_STATUS_REG);
---
> command = pci_read_config(dev, PCI_COMMAND_STATUS_REG, 4);
1546,1547c1559,1560
< pci_conf_write(config_id, PCI_COMMAND_STATUS_REG, command);
< command = pci_conf_read(config_id, PCI_COMMAND_STATUS_REG);
---
> pci_write_config(dev, PCI_COMMAND_STATUS_REG, command, 4);
> command = pci_read_config(dev, PCI_COMMAND_STATUS_REG, 4);
1551c1564
< free(sc, M_DEVBUF);
---
> error = ENXIO;
1555,1556c1568,1572
< #ifdef __i386__
< if (!pci_map_mem(config_id, TI_PCI_LOMEM, &vbase, &pbase)) {
---
> rid = TI_PCI_LOMEM;
> sc->ti_res = bus_alloc_resource(dev, SYS_RES_MEMORY, &rid,
> 0, ~0, 1, RF_ACTIVE);
>
> if (sc->ti_res == NULL) {
1558c1574
< free(sc, M_DEVBUF);
---
> error = ENXIO;
1562,1564c1578,1581
< sc->ti_bhandle = vbase;
< sc->ti_btag = I386_BUS_SPACE_MEM;
< #endif
---
> /* Allocate interrupt */
> rid = 0;
> sc->ti_irq = bus_alloc_resource(dev, SYS_RES_IRQ, &rid, 0, ~0, 1,
> RF_SHAREABLE | RF_ACTIVE);
1566,1570c1583,1585
< #ifdef __alpha__
< if (!(pci_map_bwx(config_id, TI_PCI_LOMEM, &vbase, &pbase) ||
< pci_map_dense(config_id, TI_PCI_LOMEM, &vbase, &pbase))){
< printf ("ti%d: couldn't map memory\n", unit);
< free(sc, M_DEVBUF);
---
> if (sc->ti_irq == NULL) {
> printf("ti%d: couldn't map interrupt\n", unit);
> error = ENXIO;
1574,1581c1589,1596
< sc->ti_bhandle = pbase;
< sc->ti_vhandle = vbase;
< sc->ti_btag = ALPHA_BUS_SPACE_MEM;
< #endif
< /* Allocate interrupt */
< if (!pci_map_int(config_id, ti_intr, sc, &net_imask)) {
< printf("ti%d: couldn't map interrupt\n", unit);
< free(sc, M_DEVBUF);
---
> error = bus_setup_intr(dev, sc->ti_irq, INTR_TYPE_NET,
> ti_intr, sc, &sc->ti_intrhand);
>
> if (error) {
> bus_release_resource(dev, SYS_RES_IRQ, 0, sc->ti_irq);
> bus_release_resource(dev, SYS_RES_MEMORY,
> TI_PCI_LOMEM, sc->ti_res);
> printf("ti%d: couldn't set up irq\n", unit);
1589c1604,1608
< free(sc, M_DEVBUF);
---
> bus_teardown_intr(dev, sc->ti_irq, sc->ti_intrhand);
> bus_release_resource(dev, SYS_RES_IRQ, 0, sc->ti_irq);
> bus_release_resource(dev, SYS_RES_MEMORY,
> TI_PCI_LOMEM, sc->ti_res);
> error = ENXIO;
1599c1618,1622
< free(sc, M_DEVBUF);
---
> bus_teardown_intr(dev, sc->ti_irq, sc->ti_intrhand);
> bus_release_resource(dev, SYS_RES_IRQ, 0, sc->ti_irq);
> bus_release_resource(dev, SYS_RES_MEMORY,
> TI_PCI_LOMEM, sc->ti_res);
> error = ENXIO;
1613c1636,1640
< free(sc, M_DEVBUF);
---
> bus_teardown_intr(dev, sc->ti_irq, sc->ti_intrhand);
> bus_release_resource(dev, SYS_RES_IRQ, 0, sc->ti_irq);
> bus_release_resource(dev, SYS_RES_MEMORY,
> TI_PCI_LOMEM, sc->ti_res);
> error = ENXIO;
1624c1651
< sc->ti_rdata_ptr = contigmalloc(sizeof(struct ti_ring_data), M_DEVBUF,
---
> sc->ti_rdata = contigmalloc(sizeof(struct ti_ring_data), M_DEVBUF,
1627,1628c1654,1659
< if (sc->ti_rdata_ptr == NULL) {
< free(sc, M_DEVBUF);
---
> if (sc->ti_rdata == NULL) {
> bus_teardown_intr(dev, sc->ti_irq, sc->ti_intrhand);
> bus_release_resource(dev, SYS_RES_IRQ, 0, sc->ti_irq);
> bus_release_resource(dev, SYS_RES_MEMORY,
> TI_PCI_LOMEM, sc->ti_res);
> error = ENXIO;
1633d1663
< sc->ti_rdata = (struct ti_ring_data *)sc->ti_rdata_ptr;
1639,1640c1669,1674
< free(sc->ti_rdata_ptr, M_DEVBUF);
< free(sc, M_DEVBUF);
---
> bus_teardown_intr(dev, sc->ti_irq, sc->ti_intrhand);
> bus_release_resource(dev, SYS_RES_IRQ, 0, sc->ti_irq);
> bus_release_resource(dev, SYS_RES_MEMORY,
> TI_PCI_LOMEM, sc->ti_res);
> free(sc->ti_rdata, M_DEVBUF);
> error = ENXIO;
1687,1688d1720
< at_shutdown(ti_shutdown, sc, SHUTDOWN_POST_SYNC);
<
1692c1724
< return;
---
> return(error);
1694a1727,1754
> static int ti_detach(dev)
> device_t dev;
> {
> struct ti_softc *sc;
> struct ifnet *ifp;
> int s;
>
> s = splimp();
>
> sc = device_get_softc(dev);
> ifp = &sc->arpcom.ac_if;
>
> if_detach(ifp);
> ti_stop(sc);
>
> bus_teardown_intr(dev, sc->ti_irq, sc->ti_intrhand);
> bus_release_resource(dev, SYS_RES_IRQ, 0, sc->ti_irq);
> bus_release_resource(dev, SYS_RES_MEMORY, TI_PCI_LOMEM, sc->ti_res);
>
> free(sc->ti_cdata.ti_jumbo_buf, M_DEVBUF);
> free(sc->ti_rdata, M_DEVBUF);
> ifmedia_removeall(&sc->ifmedia);
>
> splx(s);
>
> return(0);
> }
>
2433,2435c2493,2494
< static void ti_shutdown(howto, xsc)
< int howto;
< void *xsc;
---
> static void ti_shutdown(dev)
> device_t dev;
2439c2498
< sc = xsc;
---
> sc = device_get_softc(dev);
2445,2453d2503
<
< static struct pci_device ti_device = {
< "ti",
< ti_probe,
< ti_attach,
< &ti_count,
< NULL
< };
< COMPAT_PCI_DRIVER(ti, ti_device);