if_pcn.c (113565) | if_pcn.c (113609) |
---|---|
1/* 2 * Copyright (c) 2000 Berkeley Software Design, Inc. 3 * Copyright (c) 1997, 1998, 1999, 2000 4 * Bill Paul <wpaul@osd.bsdi.com>. All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: --- 36 unchanged lines hidden (view full) --- 45 * these enhancements is the ability to perform PCI DMA operations 46 * using 32-bit addressing (which eliminates the need for ISA 47 * bounce-buffering), and special receive buffer alignment (which 48 * allows the receive handler to pass packets to the upper protocol 49 * layers without copying on both the x86 and alpha platforms). 50 */ 51 52#include <sys/cdefs.h> | 1/* 2 * Copyright (c) 2000 Berkeley Software Design, Inc. 3 * Copyright (c) 1997, 1998, 1999, 2000 4 * Bill Paul <wpaul@osd.bsdi.com>. All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: --- 36 unchanged lines hidden (view full) --- 45 * these enhancements is the ability to perform PCI DMA operations 46 * using 32-bit addressing (which eliminates the need for ISA 47 * bounce-buffering), and special receive buffer alignment (which 48 * allows the receive handler to pass packets to the upper protocol 49 * layers without copying on both the x86 and alpha platforms). 50 */ 51 52#include <sys/cdefs.h> |
53__FBSDID("$FreeBSD: head/sys/pci/if_pcn.c 113565 2003-04-16 15:24:17Z jhb $"); | 53__FBSDID("$FreeBSD: head/sys/pci/if_pcn.c 113609 2003-04-17 20:32:06Z njl $"); |
54 55#include <sys/param.h> 56#include <sys/systm.h> 57#include <sys/sockio.h> 58#include <sys/mbuf.h> 59#include <sys/malloc.h> 60#include <sys/kernel.h> 61#include <sys/socket.h> --- 558 unchanged lines hidden (view full) --- 620 goto fail; 621 } 622 623 /* 624 * Call MI attach routine. 625 */ 626 ether_ifattach(ifp, (u_int8_t *) eaddr); 627 | 54 55#include <sys/param.h> 56#include <sys/systm.h> 57#include <sys/sockio.h> 58#include <sys/mbuf.h> 59#include <sys/malloc.h> 60#include <sys/kernel.h> 61#include <sys/socket.h> --- 558 unchanged lines hidden (view full) --- 620 goto fail; 621 } 622 623 /* 624 * Call MI attach routine. 625 */ 626 ether_ifattach(ifp, (u_int8_t *) eaddr); 627 |
628 /* Hook interrupt last to avoid having to lock softc */ |
|
628 error = bus_setup_intr(dev, sc->pcn_irq, INTR_TYPE_NET, 629 pcn_intr, sc, &sc->pcn_intrhand); 630 631 if (error) { 632 printf("pcn%d: couldn't set up irq\n", unit); | 629 error = bus_setup_intr(dev, sc->pcn_irq, INTR_TYPE_NET, 630 pcn_intr, sc, &sc->pcn_intrhand); 631 632 if (error) { 633 printf("pcn%d: couldn't set up irq\n", unit); |
634 ether_ifdetach(ifp); |
|
633 goto fail; 634 } 635 636fail: 637 if (error) 638 pcn_detach(dev); 639 640 return(error); 641} 642 | 635 goto fail; 636 } 637 638fail: 639 if (error) 640 pcn_detach(dev); 641 642 return(error); 643} 644 |
645/* 646 * Shutdown hardware and free up resources. This can be called any 647 * time after the mutex has been initialized. It is called in both 648 * the error case in attach and the normal detach case so it needs 649 * to be careful about only freeing resources that have actually been 650 * allocated. 651 */ |
|
643static int 644pcn_detach(dev) 645 device_t dev; 646{ 647 struct pcn_softc *sc; 648 struct ifnet *ifp; 649 650 sc = device_get_softc(dev); 651 ifp = &sc->arpcom.ac_if; 652 653 KASSERT(mtx_initialized(&sc->pcn_mtx), ("pcn mutex not initialized")); 654 PCN_LOCK(sc); 655 | 652static int 653pcn_detach(dev) 654 device_t dev; 655{ 656 struct pcn_softc *sc; 657 struct ifnet *ifp; 658 659 sc = device_get_softc(dev); 660 ifp = &sc->arpcom.ac_if; 661 662 KASSERT(mtx_initialized(&sc->pcn_mtx), ("pcn mutex not initialized")); 663 PCN_LOCK(sc); 664 |
665 /* These should only be active if attach succeeded */ |
|
656 if (device_is_alive(dev)) { | 666 if (device_is_alive(dev)) { |
657 if (bus_child_present(dev)) { 658 pcn_reset(sc); 659 pcn_stop(sc); 660 } | 667 pcn_reset(sc); 668 pcn_stop(sc); |
661 ether_ifdetach(ifp); | 669 ether_ifdetach(ifp); |
662 device_delete_child(dev, sc->pcn_miibus); 663 bus_generic_detach(dev); | |
664 } | 670 } |
671 if (sc->pcn_miibus) 672 device_delete_child(dev, sc->pcn_miibus); 673 bus_generic_detach(dev); |
|
665 666 if (sc->pcn_intrhand) 667 bus_teardown_intr(dev, sc->pcn_irq, sc->pcn_intrhand); 668 if (sc->pcn_irq) 669 bus_release_resource(dev, SYS_RES_IRQ, 0, sc->pcn_irq); 670 if (sc->pcn_res) 671 bus_release_resource(dev, PCN_RES, PCN_RID, sc->pcn_res); 672 --- 762 unchanged lines hidden --- | 674 675 if (sc->pcn_intrhand) 676 bus_teardown_intr(dev, sc->pcn_irq, sc->pcn_intrhand); 677 if (sc->pcn_irq) 678 bus_release_resource(dev, SYS_RES_IRQ, 0, sc->pcn_irq); 679 if (sc->pcn_res) 680 bus_release_resource(dev, PCN_RES, PCN_RID, sc->pcn_res); 681 --- 762 unchanged lines hidden --- |