int fptc_getreply(struct ftpc_session_s *session) { char tmp[5]="xxx "; int ret; /* Set up a timeout */ if (session->replytimeo) { ret = wd_start(session->wdog, session->replytimeo, ftpc_timeout, 1, session); } /* Get the next line from the server */ ret = ftpc_gets(session); /* Do we still have a connection? */ if (!ftpc_sockconnected(&session->cmd)) { /* No.. cancel the timer and return an error */ wd_cancel(session->wdog); nvdbg("Lost connection\n"); return ERROR; } /* Did an error occur? */ if (ret < 0) { /* No.. cancel the timer and return an error */ wd_cancel(session->wdog); nvdbg("ftpc_gets failed\n"); return ERROR; } nvdbg("Reply: %s\n", session->reply); if (session->reply[3] == '-') { /* Multi-line response */ strncpy(tmp, session->reply, 3); do { if (ftpc_gets(session) == -1) { break; } nvdbg("Reply: %s\n", session->reply); } while (strncmp(tmp, session->reply, 4) != 0); } wd_cancel(session->wdog); return ret; }
void arp_timer_initialize(void) { /* Create and start the ARP timer */ g_arptimer = wd_create(); (void)wd_start(g_arptimer, ARPTIMER_WDINTERVAL, arptimer_poll, 0); }
static void misoc_net_poll_work(FAR void *arg) { FAR struct misoc_net_driver_s *priv = (FAR struct misoc_net_driver_s *)arg; /* Perform the poll */ net_lock(); /* Check if there is room in the send another TX packet. We cannot perform * the TX poll if he are unable to accept another packet for transmission. */ /* If so, update TCP timing states and poll the network for new XMIT data. * Hmmm.. might be bug here. Does this mean if there is a transmit in * progress, we will missing TCP time state updates? */ (void)devif_timer(&priv->misoc_net_dev, misoc_net_txpoll); /* Setup the watchdog poll timer again */ (void)wd_start(priv->misoc_net_txpoll, MISOC_NET_WDDELAY, misoc_net_poll_expiry, 1, (wdparm_t)priv); net_unlock(); }
static void e1000_polltimer(int argc, uint32_t arg, ...) { struct e1000_dev *e1000 = (struct e1000_dev *)arg; int tail = e1000->tx_ring.tail; /* Check if there is room in the send another TX packet. We cannot perform * the TX poll if he are unable to accept another packet for transmission. */ if (!e1000->tx_ring.desc[tail].desc_status) { return; } /* If so, update TCP timing states and poll uIP for new XMIT data. Hmmm.. * might be bug here. Does this mean if there is a transmit in progress, * we will missing TCP time state updates? */ (void)devif_timer(&e1000->netdev, e1000_txpoll, E1000_POLLHSEC); /* Setup the watchdog poll timer again */ (void)wd_start(e1000->txpoll, E1000_WDDELAY, e1000_polltimer, 1, arg); }
static void skel_poll_expiry(int argc, wdparm_t arg, ...) { FAR struct skel_driver_s *priv = (FAR struct skel_driver_s *)arg; #ifdef CONFIG_NET_NOINTS /* Is our single work structure available? It may not be if there are * pending interrupt actions. */ if (work_available(&priv->sk_work)) { /* Schedule to perform the interrupt processing on the worker thread. */ work_queue(HPWORK, &priv->sk_work, skel_poll_work, priv, 0); } else { /* No.. Just re-start the watchdog poll timer, missing one polling * cycle. */ (void)wd_start(priv->sk_txpoll, skeleton_WDDELAY, skel_poll_expiry, 1, arg); } #else /* Process the interrupt now */ skel_poll_process(priv); #endif }
static void skel_txdone(FAR struct skel_driver_s *priv) { /* Check for errors and update statistics */ NETDEV_TXDONE(priv->sk_dev); /* Check if there are pending transmissions */ /* If no further transmissions are pending, then cancel the TX timeout and * disable further Tx interrupts. */ wd_cancel(priv->sk_txtimeout); /* Then make sure that the TX poll timer is running (if it is already * running, the following would restart it). This is necessary to * avoid certain race conditions where the polling sequence can be * interrupted. */ (void)wd_start(priv->sk_txpoll, skeleton_WDDELAY, skel_poll_expiry, 1, (wdparm_t)priv); /* And disable further TX interrupts. */ /* In any event, poll the network for new TX data */ (void)devif_poll(&priv->sk_dev, skel_txpoll); }
static int e1000_ifup(struct net_driver_s *dev) { struct e1000_dev *e1000 = (struct e1000_dev *)dev->d_private; ndbg("Bringing up: %d.%d.%d.%d\n", dev->d_ipaddr & 0xff, (dev->d_ipaddr >> 8) & 0xff, (dev->d_ipaddr >> 16) & 0xff, dev->d_ipaddr >> 24); /* Initialize PHYs, the Ethernet interface, and setup up Ethernet interrupts */ e1000_init(e1000); /* Set and activate a timer process */ (void)wd_start(e1000->txpoll, E1000_WDDELAY, e1000_polltimer, 1, (uint32_t)e1000); if (e1000_inl(e1000, E1000_STATUS) & 2) { e1000->bifup = true; } else { e1000->bifup = false; } return OK; }
static void vnet_polltimer(int argc, uint32_t arg, ...) { FAR struct vnet_driver_s *vnet = (FAR struct vnet_driver_s *)arg; /* Check if there is room in the send another TX packet. We cannot perform * the TX poll if he are unable to accept another packet for transmission. */ if (vnet_is_txbuff_full(vnet->vnet)) { #ifdef CONFIG_DEBUG cprintf("VNET: TX buffer is full\n"); #endif return; } /* If so, update TCP timing states and poll the network for new XMIT data. * Hmmm.. might be bug here. Does this mean if there is a transmit in * progress, we will missing TCP time state updates? */ (void)devif_timer(&vnet->sk_dev, vnet_txpoll); /* Setup the watchdog poll timer again */ (void)wd_start(vnet->sk_txpoll, VNET_WDDELAY, vnet_polltimer, 1, (wdparm_t)arg); }
static void lo_poll_work(FAR void *arg) { FAR struct lo_driver_s *priv = (FAR struct lo_driver_s *)arg; net_lock_t state; /* Perform the poll */ state = net_lock(); priv->lo_txdone = false; (void)devif_timer(&priv->lo_dev, lo_txpoll); /* Was something received and looped back? */ while (priv->lo_txdone) { /* Yes, poll again for more TX data */ priv->lo_txdone = false; (void)devif_poll(&priv->lo_dev, lo_txpoll); } /* Setup the watchdog poll timer again */ (void)wd_start(priv->lo_polldog, LO_WDDELAY, lo_poll_expiry, 1, priv); net_unlock(state); }
void uip_igmpstartticks(FAR struct igmp_group_s *group, int ticks) { int ret; /* Start the timer */ gtmrlldbg("ticks: %d\n", ticks); ret = wd_start(group->wdog, ticks, uip_igmptimeout, 1, (uint32_t)group); DEBUGASSERT(ret == OK); }
static void arptimer_poll(int argc, uint32_t arg, ...) { /* Call the ARP timer function every 10 seconds. */ arp_timer(); /* Setup the watchdog timer again */ (void)wd_start(g_arptimer, ARPTIMER_WDINTERVAL, arptimer_poll, 0); }
static inline void timer_restart(FAR struct posix_timer_s *timer, uint32_t itimer) { /* If this is a repetitive timer, then restart the watchdog */ if (timer->pt_delay) { timer->pt_last = timer->pt_delay; (void)wd_start(timer->pt_wdog, timer->pt_delay, (wdentry_t)timer_timeout, 1, itimer); } }
/** * Wakeup the watchdog, initiating the timer at the configured period. * If no call to wd_kick() are made within the period, the callback will * fire. * * @return TRUE if we woken up the watchdog, FALSE if it was already awake. */ bool wd_wakeup(watchdog_t *wd) { watchdog_check(wd); if (wd->ev) return FALSE; wd_start(wd); return TRUE; }
int wd8003_open(struct device *dev) { unsigned char cmd; int i; /* we probably don't want to be interrupted here. */ cli(); /* This section of code is mostly copied from the bsd driver which is mostly copied from somewhere else. */ /* The somewhere else is probably the cmwymr(sp?) dos packet driver */ cmd=inb_p(WD_COMM); cmd|=CSTOP; cmd &= ~(CSTART|CPAGE); outb_p(cmd, WD_COMM); outb_p(0, WD_IMR); sti(); outb_p( dconfig,WD_DCR); /*Zero the remote byte count. */ outb_p(0, WD_RBY0); outb_p(0, WD_RBY1); outb_p(WD_MCONFIG,WD_RCC); outb_p(WD_TCONFIG,WD_TRC); outb_p(0,WD_TRPG); /* Set the transmit page start = 0 */ outb_p( max_pages,WD_PSTOP); /* (read) page stop = top of board memory */ outb_p(WD_TXBS,WD_PSTRT); /* (read) page start = cur = bnd = top of tx memory */ outb_p(WD_TXBS,WD_BNDR); /* clear interrupt status. */ outb_p(0xff,WD_ISR); /* we don't want no stinking interrupts. */ outb_p(0 ,WD_IMR); cmd|=1<<CPAGE_SHIFT; outb_p(cmd,WD_COMM); /* set the ether address. */ for (i=0; i < ETHER_ADDR_LEN; i++) { outb_p(dev->dev_addr[i],WD_PAR0+i); } /* National recommends setting the boundry < current page register */ outb_p(WD_TXBS+1,WD_CUR); /* Set the current page = page start + 1 */ /* set the multicast address. */ for (i=0; i < ETHER_ADDR_LEN; i++) { outb_p(dev->broadcast[i],WD_MAR0+i); } cmd&=~(CPAGE|CRDMA); cmd|= 4<<CRDMA_SHIFT; outb_p(cmd, WD_COMM); outb_p(WD_RCONFIG,WD_RCC); wd_start(dev); return (0); }
int poll(FAR struct pollfd *fds, nfds_t nfds, int timeout) { WDOG_ID wdog; sem_t sem; int count = 0; int ret; sem_init(&sem, 0, 0); ret = poll_setup(fds, nfds, &sem); if (ret >= 0) { if (timeout >= 0) { /* Wait for the poll event with a timeout. Note that the * millisecond timeout has to be converted to system clock * ticks for wd_start */ wdog = wd_create(); wd_start(wdog, MSEC2TICK(timeout), poll_timeout, 1, (uint32_t)&sem); poll_semtake(&sem); wd_delete(wdog); } else { /* Wait for the poll event with no timeout */ poll_semtake(&sem); } /* Teardown the poll operation and get the count of events */ ret = poll_teardown(fds, nfds, &count); } sem_destroy(&sem); /* Check for errors */ if (ret < 0) { set_errno(-ret); return ERROR; } return count; }
static int vnet_ifup(struct uip_driver_s *dev) { FAR struct vnet_driver_s *vnet = (FAR struct vnet_driver_s *)dev->d_private; ndbg("Bringing up: %d.%d.%d.%d\n", dev->d_ipaddr & 0xff, (dev->d_ipaddr >> 8) & 0xff, (dev->d_ipaddr >> 16) & 0xff, dev->d_ipaddr >> 24 ); /* Initialize PHYs, the Ethernet interface, and setup up Ethernet interrupts */ /* Set and activate a timer process */ (void)wd_start(vnet->sk_txpoll, VNET_WDDELAY, vnet_polltimer, 1, (uint32_t)vnet); vnet->sk_bifup = true; return OK; }
static int emac_transmit(FAR struct emac_driver_s *priv) { /* Verify that the hardware is ready to send another packet. If we get * here, then we are committed to sending a packet; Higher level logic * must have assured that there is not transmission in progress. */ /* Increment statistics */ /* Send the packet: address=priv->d_dev.d_buf, length=priv->d_dev.d_len */ /* Enable Tx interrupts */ /* Setup the TX timeout watchdog (perhaps restarting the timer) */ (void)wd_start(priv->d_txtimeout, HCS12_TXTIMEOUT, emac_txtimeout, 1, (uint32_t)priv); return OK; }
static inline void skel_poll_process(FAR struct skel_driver_s *priv) { /* Check if there is room in the send another TX packet. We cannot perform * the TX poll if he are unable to accept another packet for transmission. */ /* If so, update TCP timing states and poll the network for new XMIT data. * Hmmm.. might be bug here. Does this mean if there is a transmit in * progress, we will missing TCP time state updates? */ (void)devif_timer(&priv->sk_dev, skel_txpoll); /* Setup the watchdog poll timer again */ (void)wd_start(priv->sk_txpoll, skeleton_WDDELAY, skel_poll_expiry, 1, (wdparm_t)priv); }
static int reset_cport(unsigned int cportid, struct usbdev_s *dev) { struct cport_reset_priv *priv; priv = zalloc(sizeof(*priv)); if (!priv) { return -ENOMEM; } wd_static(&priv->timeout_wd); priv->dev = dev; /* a ref for the watchdog and one for the unipro stack */ atomic_init(&priv->refcount, 2); wd_start(&priv->timeout_wd, RESET_TIMEOUT_DELAY, cport_reset_timeout, 1, priv); return unipro_reset_cport(cportid, cport_reset_cb, priv); }
static void skel_polltimer(int argc, uint32_t arg, ...) { FAR struct skel_driver_s *skel = (FAR struct skel_driver_s *)arg; /* Check if there is room in the send another TX packet. We cannot perform * the TX poll if he are unable to accept another packet for transmission. */ /* If so, update TCP timing states and poll uIP for new XMIT data. Hmmm.. * might be bug here. Does this mean if there is a transmit in progress, * we will missing TCP time state updates? */ (void)uip_timer(&skel->sk_dev, skel_uiptxpoll, skeleton_POLLHSEC); /* Setup the watchdog poll timer again */ (void)wd_start(skel->sk_txpoll, skeleton_WDDELAY, skel_polltimer, 1, arg); }
static void emac_polltimer(int argc, uint32_t arg, ...) { FAR struct emac_driver_s *priv = (FAR struct emac_driver_s *)arg; /* Check if there is room in the send another TX packet. We cannot perform * the TX poll if he are unable to accept another packet for transmission. */ /* If so, update TCP timing states and poll the network for new XMIT data. Hmmm.. * might be bug here. Does this mean if there is a transmit in progress, * we will missing TCP time state updates? */ (void)devif_timer(&priv->d_dev, emac_txpoll); /* Setup the watchdog poll timer again */ (void)wd_start(priv->d_txpoll, HCS12_WDDELAY, emac_polltimer, 1, arg); }
/** * Create a new watchdog. * * @param name the watchdog name, for logging purposes * @param period the period after which it triggers, in seconds * @param trigger the callback to invoke if no kicking during period * @param arg the user-supplied argument given to callback * @param start whether to start immediately, or put in sleep state * * @return the created watchdog object. */ watchdog_t * wd_make(const char *name, int period, wd_trigger_t trigger, void *arg, bool start) { watchdog_t *wd; WALLOC0(wd); wd->magic = WATCHDOG_MAGIC; wd->name = atom_str_get(name); wd->period = period; wd->trigger = trigger; wd->arg = arg; if (start) wd_start(wd); watchdog_check(wd); return wd; }
static int emac_ifup(struct net_driver_s *dev) { FAR struct emac_driver_s *priv = (FAR struct emac_driver_s *)dev->d_private; ndbg("Bringing up: %d.%d.%d.%d\n", dev->d_ipaddr & 0xff, (dev->d_ipaddr >> 8) & 0xff, (dev->d_ipaddr >> 16) & 0xff, dev->d_ipaddr >> 24 ); /* Initialize PHYs, the Ethernet interface, and setup up Ethernet interrupts */ /* Set and activate a timer process */ (void)wd_start(priv->d_txpoll, HCS12_WDDELAY, emac_polltimer, 1, (uint32_t)priv); /* Enable the Ethernet interrupt */ priv->d_bifup = true; up_enable_irq(CONFIG_HCS12_IRQ); return OK; }
static int skel_ifup(struct uip_driver_s *dev) { FAR struct skel_driver_s *skel = (FAR struct skel_driver_s *)dev->d_private; ndbg("Bringing up: %d.%d.%d.%d\n", dev->d_ipaddr & 0xff, (dev->d_ipaddr >> 8) & 0xff, (dev->d_ipaddr >> 16) & 0xff, dev->d_ipaddr >> 24 ); /* Initialize PHYs, the Ethernet interface, and setup up Ethernet interrupts */ /* Set and activate a timer process */ (void)wd_start(skel->sk_txpoll, skeleton_WDDELAY, skel_polltimer, 1, (uint32_t)skel); /* Enable the Ethernet interrupt */ skel->sk_bifup = true; up_enable_irq(CONFIG_skeleton_IRQ); return OK; }
static int e1000_transmit(struct e1000_dev *e1000) { int tail = e1000->tx_ring.tail; unsigned char *cp = (unsigned char *) (e1000->tx_ring.buf + tail * CONFIG_E1000_BUFF_SIZE); int count = e1000->netdev.d_len; /* Verify that the hardware is ready to send another packet. If we get * here, then we are committed to sending a packet; Higher level logic * must have assured that there is not transmission in progress. */ if (!e1000->tx_ring.desc[tail].desc_status) { return -1; } /* Increment statistics */ /* Send the packet: address=skel->sk_dev.d_buf, length=skel->sk_dev.d_len */ memcpy(cp, e1000->netdev.d_buf, e1000->netdev.d_len); /* prepare the transmit-descriptor */ e1000->tx_ring.desc[tail].packet_length = count < 60 ? 60 : count; e1000->tx_ring.desc[tail].desc_status = 0; /* give ownership of this descriptor to the network controller */ tail = (tail + 1) % CONFIG_E1000_N_TX_DESC; e1000->tx_ring.tail = tail; e1000_outl(e1000, E1000_TDT, tail); /* Enable Tx interrupts */ /* Setup the TX timeout watchdog (perhaps restarting the timer) */ wd_start(e1000->txtimeout, E1000_TXTIMEOUT, e1000_txtimeout, 1, (uint32_t)e1000); return OK; }
static int skel_transmit(FAR struct skel_driver_s *priv) { /* Verify that the hardware is ready to send another packet. If we get * here, then we are committed to sending a packet; Higher level logic * must have assured that there is no transmission in progress. */ /* Increment statistics */ NETDEV_TXPACKETS(priv->sk_dev); /* Send the packet: address=priv->sk_dev.d_buf, length=priv->sk_dev.d_len */ /* Enable Tx interrupts */ /* Setup the TX timeout watchdog (perhaps restarting the timer) */ (void)wd_start(priv->sk_txtimeout, skeleton_TXTIMEOUT, skel_txtimeout_expiry, 1, (wdparm_t)priv); return OK; }
static void bcmf_poll_work(FAR void *arg) { // wlinfo("Entry\n"); FAR struct bcmf_dev_s *priv = (FAR struct bcmf_dev_s *)arg; /* Lock the network and serialize driver operations if necessary. * NOTE: Serialization is only required in the case where the driver work * is performed on an LP worker thread and where more than one LP worker * thread has been configured. */ net_lock(); /* Perform the poll */ /* Check if there is room in the send another TX packet. We cannot perform * the TX poll if he are unable to accept another packet for transmission. */ if (bcmf_netdev_alloc_tx_frame(priv)) { goto exit_unlock; } /* If so, update TCP timing states and poll the network for new XMIT data. * Hmmm.. might be bug here. Does this mean if there is a transmit in * progress, we will missing TCP time state updates? */ priv->bc_dev.d_buf = priv->cur_tx_frame->data; priv->bc_dev.d_len = 0; (void)devif_timer(&priv->bc_dev, bcmf_txpoll); /* Setup the watchdog poll timer again */ (void)wd_start(priv->bc_txpoll, BCMF_WDDELAY, bcmf_poll_expiry, 1, (wdparm_t)priv); exit_unlock: net_unlock(); }
static int misoc_net_ifup(FAR struct net_driver_s *dev) { FAR struct misoc_net_driver_s *priv = (FAR struct misoc_net_driver_s *)dev->d_private; #ifdef CONFIG_NET_IPv4 ninfo("Bringing up: %d.%d.%d.%d\n", dev->d_ipaddr & 0xff, (dev->d_ipaddr >> 8) & 0xff, (dev->d_ipaddr >> 16) & 0xff, dev->d_ipaddr >> 24); #endif #ifdef CONFIG_NET_IPv6 ninfo("Bringing up: %04x:%04x:%04x:%04x:%04x:%04x:%04x:%04x\n", dev->d_ipv6addr[0], dev->d_ipv6addr[1], dev->d_ipv6addr[2], dev->d_ipv6addr[3], dev->d_ipv6addr[4], dev->d_ipv6addr[5], dev->d_ipv6addr[6], dev->d_ipv6addr[7]); #endif /* Initialize PHYs, the Ethernet interface, and setup up Ethernet interrupts */ /* Instantiate the MAC address from priv->misoc_net_dev.d_mac.ether.ether_addr_octet */ #ifdef CONFIG_NET_ICMPv6 /* Set up IPv6 multicast address filtering */ misoc_net_ipv6multicast(priv); #endif /* Set and activate a timer process */ (void)wd_start(priv->misoc_net_txpoll, MISOC_NET_WDDELAY, misoc_net_poll_expiry, 1, (wdparm_t)priv); priv->misoc_net_bifup = true; up_enable_irq(ETHMAC_INTERRUPT); /* Enable the RX Event Handler */ ethmac_sram_writer_ev_enable_write(1); return OK; }
static int bcmf_ifup(FAR struct net_driver_s *dev) { wlinfo("Entry\n"); FAR struct bcmf_dev_s *priv = (FAR struct bcmf_dev_s *)dev->d_private; #ifdef CONFIG_NET_IPv4 ninfo("Bringing up: %d.%d.%d.%d\n", dev->d_ipaddr & 0xff, (dev->d_ipaddr >> 8) & 0xff, (dev->d_ipaddr >> 16) & 0xff, dev->d_ipaddr >> 24); #endif #ifdef CONFIG_NET_IPv6 ninfo("Bringing up: %04x:%04x:%04x:%04x:%04x:%04x:%04x:%04x\n", dev->d_ipv6addr[0], dev->d_ipv6addr[1], dev->d_ipv6addr[2], dev->d_ipv6addr[3], dev->d_ipv6addr[4], dev->d_ipv6addr[5], dev->d_ipv6addr[6], dev->d_ipv6addr[7]); #endif /* Initialize PHYs, the Ethernet interface, and setup up Ethernet interrupts */ /* Instantiate the MAC address from priv->bc_dev.d_mac.ether.ether_addr_octet */ #ifdef CONFIG_NET_ICMPv6 /* Set up IPv6 multicast address filtering */ bcmf_ipv6multicast(priv); #endif /* Set and activate a timer process */ (void)wd_start(priv->bc_txpoll, BCMF_WDDELAY, bcmf_poll_expiry, 1, (wdparm_t)priv); /* Enable the hardware interrupt */ priv->bc_bifup = true; return OK; }
static int lo_ifup(FAR struct net_driver_s *dev) { FAR struct lo_driver_s *priv = (FAR struct lo_driver_s *)dev->d_private; #ifdef CONFIG_NET_IPv4 ndbg("Bringing up: %d.%d.%d.%d\n", dev->d_ipaddr & 0xff, (dev->d_ipaddr >> 8) & 0xff, (dev->d_ipaddr >> 16) & 0xff, dev->d_ipaddr >> 24); #endif #ifdef CONFIG_NET_IPv6 ndbg("Bringing up: %04x:%04x:%04x:%04x:%04x:%04x:%04x:%04x\n", dev->d_ipv6addr[0], dev->d_ipv6addr[1], dev->d_ipv6addr[2], dev->d_ipv6addr[3], dev->d_ipv6addr[4], dev->d_ipv6addr[5], dev->d_ipv6addr[6], dev->d_ipv6addr[7]); #endif /* Set and activate a timer process */ (void)wd_start(priv->lo_polldog, LO_WDDELAY, lo_poll_expiry, 1, (wdparm_t)priv); priv->lo_bifup = true; return OK; }