int pictimerCleanup(unsigned timer_no) { if ( timer_no >= NumberOf(timerConnected) || !timerConnected[timer_no] ) return 0; openpic_inittimer( timer_no, 0, 0 ); openpic_maptimer( timer_no, 0 ); if ( bspExtRemoveSharedISR(TIMER_IVEC + timer_no, timerConnected[timer_no], (void*)timer_no) ) { fprintf(stderr,"Unable to remove shared ISR for OpenPIC Timer #%i\n",timer_no); return -1; } timerConnected[timer_no] = 0; return 0; }
int NET_EMBEMB(rtems_,NETDRIVER_PREFIX,_attach) (struct rtems_bsdnet_ifconfig *config, int attaching) { int error = 0; device_t dev = net_dev_get(config); struct NET_SOFTC *sc; struct ifnet *ifp; #ifndef HAVE_LIBBSPEXT rtems_irq_connect_data irq_data = { 0, the_net_isr, #if ISMINVERSION(4,6,99) 0, #endif noop, noop, noop1 }; #endif if ( !dev ) return 1; if ( !dev->d_softc.NET_SOFTC_BHANDLE_FIELD ) { #if defined(NETDRIVER_PCI) device_printf(dev,NETDRIVER" unit not configured; executing setup..."); /* setup should really be performed prior to attaching. * Wipe the device; setup and re-obtain the device... */ memset(dev,0,sizeof(*dev)); error = NET_EMBEMB(rtems_,NETDRIVER_PREFIX,_pci_setup)(-1); /* re-obtain the device */ dev = net_dev_get(config); if ( !dev ) { printk("Unable to re-assign device structure???\n"); return 1; } if (error <= 0) { device_printf(dev,NETDRIVER" FAILED; unable to attach interface, sorry\n"); return 1; } device_printf(dev,"success\n"); #else device_printf(dev,NETDRIVER" unit not configured; use 'rtems_"NETDRIVER"_setup()'\n"); return 1; #endif } if ( !net_driver_ticks_per_sec ) rtems_clock_get( RTEMS_CLOCK_GET_TICKS_PER_SECOND, &net_driver_ticks_per_sec ); sc = device_get_softc( dev ); ifp = &sc->arpcom.ac_if; #ifdef DEBUG_MODULAR if (!METHODSPTR) { device_printf(dev,NETDRIVER": method pointer not set\n"); return -1; } #endif if ( attaching ) { if ( ifp->if_init ) { device_printf(dev,NETDRIVER" Driver already attached.\n"); return -1; } if ( config->hardware_address ) { /* use configured MAC address */ memcpy(sc->arpcom.ac_enaddr, config->hardware_address, ETHER_ADDR_LEN); } else { #ifdef NET_READ_MAC_ADDR NET_READ_MAC_ADDR(sc); #endif } if ( METHODSPTR->n_attach(dev) ) { device_printf(dev,NETDRIVER"_attach() failed\n"); return -1; } } else { if ( !ifp->if_init ) { device_printf(dev,NETDRIVER" Driver not attached.\n"); return -1; } if ( METHODSPTR->n_detach ) { if ( METHODSPTR->n_detach(dev) ) { device_printf(dev,NETDRIVER"_detach() failed\n"); return -1; } } else { device_printf(dev,NETDRIVER"_detach() not implemented\n"); return -1; } } if ( !sc->tid ) sc->tid = rtems_bsdnet_newproc(NETDRIVER"d", 4096, net_daemon, sc); if (attaching) { #ifdef DEBUG printf("Installing IRQ # %i\n",sc->irq_no); #endif #ifdef HAVE_LIBBSPEXT if ( bspExtInstallSharedISR(sc->irq_no, the_net_isr, sc, 0) ) #else /* BSP dependent :-( */ irq_data.name = sc->irq_no; #if ISMINVERSION(4,6,99) irq_data.handle = (rtems_irq_hdl_param)sc; #else thesc = sc; #endif if ( ! BSP_install_rtems_irq_handler( &irq_data ) ) #endif { fprintf(stderr,NETDRIVER": unable to install ISR\n"); error = -1; } } else { if ( sc->irq_no ) { #ifdef DEBUG printf("Removing IRQ # %i\n",sc->irq_no); #endif #ifdef HAVE_LIBBSPEXT if (bspExtRemoveSharedISR(sc->irq_no, the_net_isr, sc)) #else /* BSP dependent :-( */ irq_data.name = sc->irq_no; #if ISMINVERSION(4,6,99) irq_data.handle = (rtems_irq_hdl_param)sc; #endif if ( ! BSP_remove_rtems_irq_handler( &irq_data ) ) #endif { fprintf(stderr,NETDRIVER": unable to uninstall ISR\n"); error = -1; } } } return error; }