/* * Initialize and start the device */ static void wd_init (void *arg) { struct wd_softc *sc = arg; struct ifnet *ifp = &sc->arpcom.ac_if; if (sc->txDaemonTid == 0) { /* * Set up WD hardware */ wd8003Enet_initialize_hardware (sc); /* * Start driver tasks */ sc->txDaemonTid = rtems_bsdnet_newproc ("SCtx", 4096, wd_txDaemon, sc); sc->rxDaemonTid = rtems_bsdnet_newproc ("SCrx", 4096, wd_rxDaemon, sc); } /* * Tell the world that we're running. */ ifp->if_flags |= IFF_RUNNING; }
/* initialize and start the device */ static void ethernetInit(void *arg) { struct bfin_ethernetSoftc *sc; struct ifnet *ifp; void *ethBase; void *rxdmaBase; void *txdmaBase; sc = arg; ifp = &sc->arpcom.ac_if; ethBase = sc->ethBase; rxdmaBase = sc->rxdmaBase; txdmaBase = sc->txdmaBase; if (sc->txDaemonTid == 0) { initializeHardware(sc); /* start driver tasks */ sc->rxDaemonTid = rtems_bsdnet_newproc("BFrx", 4096, rxDaemon, sc); sc->txDaemonTid = rtems_bsdnet_newproc("BFtx", 4096, txDaemon, sc); } if (ifp->if_flags & IFF_PROMISC) BFIN_REG32(ethBase, EMAC_OPMODE_OFFSET) |= EMAC_OPMODE_PR; else BFIN_REG32(ethBase, EMAC_OPMODE_OFFSET) &= ~EMAC_OPMODE_PR; /* * Tell the world that we're running. */ ifp->if_flags |= IFF_RUNNING; }
int rtems_minimac_driver_attach(struct rtems_bsdnet_ifconfig *config, int attaching) { struct ifnet *ifp; rtems_isr_entry dummy; int i; static int registered; uint8_t *tx_buffer = (uint8_t *)MINIMAC_TX_BASE; if(!attaching) { printk("Minimac driver cannot be detached.\n"); return 0; } ifp = &(arpcom.ac_if); if(registered) { printk("Minimac driver already in use.\n"); return 0; } registered = 1; memcpy(arpcom.ac_enaddr, get_mac_address(), 6); ifp->if_mtu = ETHERMTU; ifp->if_unit = 0; ifp->if_name = "minimac"; ifp->if_init = minimac_init; ifp->if_ioctl = minimac_ioctl; ifp->if_start = minimac_start; ifp->if_output = ether_output; ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX; ifp->if_snd.ifq_maxlen = ifqmaxlen; if_attach(ifp); ether_ifattach(ifp); rx_daemon_id = rtems_bsdnet_newproc("mrxd", 4096, rx_daemon, NULL); tx_daemon_id = rtems_bsdnet_newproc("mtxd", 4096, tx_daemon, NULL); rtems_interrupt_catch(rx_interrupt_handler, MM_IRQ_ETHRX, &dummy); rtems_interrupt_catch(tx_interrupt_handler, MM_IRQ_ETHTX, &dummy); MM_WRITE(MM_MINIMAC_STATE0, MINIMAC_STATE_LOADED); MM_WRITE(MM_MINIMAC_STATE1, MINIMAC_STATE_LOADED); for(i=0;i<7; i++) tx_buffer[i] = 0x55; tx_buffer[7] = 0xd5; MM_WRITE(MM_MINIMAC_SETUP, 0); rtems_bsdnet_event_send(tx_daemon_id, CTS_EVENT); bsp_interrupt_vector_enable(MM_IRQ_ETHRX); bsp_interrupt_vector_enable(MM_IRQ_ETHTX); return 1; }
void mc9328mxl_enet_init(void *arg) { mc9328mxl_enet_softc_t *sc = arg; struct ifnet *ifp = &sc->arpcom.ac_if; /* *This is for stuff that only gets done once (mc9328mxl_enet_init() * gets called multiple times */ if (sc->tx_task == 0) { /* Set up ENET hardware */ mc9328mxl_enet_init_hw(sc); /* Start driver tasks */ sc->rx_task = rtems_bsdnet_newproc("ENrx", 4096, mc9328mxl_enet_rx_task, sc); sc->tx_task = rtems_bsdnet_newproc("ENtx", 4096, mc9328mxl_enet_tx_task, sc); } /* if tx_task */ /* Configure for promiscuous if needed */ if (ifp->if_flags & IFF_PROMISC) { lan91c11x_write_reg(LAN91C11X_RCR, (lan91c11x_read_reg(LAN91C11X_RCR) | LAN91C11X_RCR_PRMS)); } /* * Tell the world that we're running. */ ifp->if_flags |= IFF_RUNNING; /* Enable TX/RX */ lan91c11x_write_reg(LAN91C11X_TCR, (lan91c11x_read_reg(LAN91C11X_TCR) | LAN91C11X_TCR_TXENA)); lan91c11x_write_reg(LAN91C11X_RCR, (lan91c11x_read_reg(LAN91C11X_RCR) | LAN91C11X_RCR_RXEN)); } /* mc9328mxl_enet_init() */
void at91rm9200_emac_init(void *arg) { at91rm9200_emac_softc_t *sc = arg; struct ifnet *ifp = &sc->arpcom.ac_if; /* *This is for stuff that only gets done once (at91rm9200_emac_init() * gets called multiple times */ if (sc->txDaemonTid == 0) { /* Set up EMAC hardware */ at91rm9200_emac_init_hw(sc); /* Start driver tasks */ sc->rxDaemonTid = rtems_bsdnet_newproc("ENrx", 4096, at91rm9200_emac_rxDaemon, sc); sc->txDaemonTid = rtems_bsdnet_newproc("ENtx", 4096, at91rm9200_emac_txDaemon, sc); } /* if txDaemonTid */ /* set our priority in the AIC */ AIC_SMR_REG(AIC_SMR_EMAC) = AIC_SMR_PRIOR(EMAC_INT_PRIORITY); /* install the interrupt handler */ BSP_install_rtems_irq_handler(&at91rm9200_emac_isr_data); /* EMAC doesn't support promiscuous, so ignore requests */ if (ifp->if_flags & IFF_PROMISC) { printk ("Warning - AT91RM9200 Ethernet driver" " doesn't support Promiscuous Mode!\n"); } /* * Tell the world that we're running. */ ifp->if_flags |= IFF_RUNNING; /* Enable TX/RX and clear the statistics counters */ EMAC_REG(EMAC_CTL) = (EMAC_CTL_TE | EMAC_CTL_RE | EMAC_CTL_CSR); /* clear any pending interrupts */ EMAC_REG(EMAC_TSR) = 0xffffffff; EMAC_REG(EMAC_RSR) = 0xffffffff; } /* at91rm9200_emac_init() */
int32_t xilTemac_driver_attach(struct rtems_bsdnet_ifconfig* aBsdConfig, int aDummy) { struct ifnet* ifp; int32_t mtu; int32_t unit; char* unitName; struct XilTemac* xilTemac; unit = rtems_bsdnet_parse_driver_name(aBsdConfig, &unitName); if(unit < 0 ) { printk("%s: Interface Unit number < 0\n", DRIVER_PREFIX ); return 0; } if( aBsdConfig->bpar == 0 ) { printk("%s: Did not specify base address for device '%s'", DRIVER_PREFIX, unitName ); return 0; } if( aBsdConfig->hardware_address == NULL ) { printk("%s: No MAC address given for interface '%s'\n", DRIVER_PREFIX, unitName ); return 0; } xilTemac = &gXilTemac[ unit ]; memset(xilTemac, 0, sizeof(struct XilTemac)); xilTemac->iIsPresent = 1; snprintf( xilTemac->iUnitName, MAX_UNIT_BYTES, "%s%" PRId32, unitName, unit ); xilTemac->iIfp = &(xilTemac->iArpcom.ac_if); ifp = &(xilTemac->iArpcom.ac_if); xilTemac->iAddr = aBsdConfig->bpar; xilTemac->iIoEvent = gUnitSignals[ unit ]; xilTemac->iIsrVector = aBsdConfig->irno; memcpy( xilTemac->iArpcom.ac_enaddr, aBsdConfig->hardware_address, ETHER_ADDR_LEN); if( aBsdConfig->mtu ) { mtu = aBsdConfig->mtu; } else { mtu = ETHERMTU; } ifp->if_softc = xilTemac; ifp->if_unit = unit; ifp->if_name = unitName; ifp->if_mtu = mtu; ifp->if_init = xilTemacInit; ifp->if_ioctl = xilTemacIoctl; ifp->if_start = xilTemacSend; ifp->if_output = ether_output; ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST; if(ifp->if_snd.ifq_maxlen == 0) { ifp->if_snd.ifq_maxlen = ifqmaxlen; } if_attach(ifp); ether_ifattach(ifp); /* create shared rx & tx threads */ if( (gXilRxThread == 0) && (gXilTxThread == 0) ) { printk("%s: Creating shared RX/TX threads\n", DRIVER_PREFIX ); gXilRxThread = rtems_bsdnet_newproc("xerx", 4096, xilTemacRxThread, NULL ); gXilTxThread = rtems_bsdnet_newproc("xetx", 4096, xilTemacTxThread, NULL ); } printk("%s: Initializing driver for '%s'\n", DRIVER_PREFIX, xilTemac->iUnitName ); printk("%s: base address 0x%08X, intnum 0x%02X, \n", DRIVER_PREFIX, aBsdConfig->bpar, aBsdConfig->irno ); return 1; }
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; }