lwip-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[lwip-devel] [task #7235] Create timeout framework for NO_SYS=1


From: Frédéric Bernon
Subject: [lwip-devel] [task #7235] Create timeout framework for NO_SYS=1
Date: Fri, 02 Nov 2007 16:36:20 +0000
User-agent: Mozilla/5.0 (Windows; U; Windows NT 6.0; fr; rv:1.8.1.8) Gecko/20071008 Firefox/2.0.0.8

Follow-up Comment #4, task #7235 (project lwip):

(extract contrib/ports/msvc6/test.c)

#if NO_SYS
/* port-defined functions used for timer execution */
void sys_init_timing();
u32_t sys_get_ms();
#endif /* NO_SYS*/

#if NO_SYS
/* special functions used for NO_SYS=1 only */
typedef struct _timers_infos {
  int timer;
  int timer_interval;
  void (*timer_func)(void);
}timers_infos;

static timers_infos timers_table[] = {
#if LWIP_TCP
  { 0, TCP_FAST_INTERVAL,       tcp_fasttmr},
  { 0, TCP_SLOW_INTERVAL,       tcp_slowtmr},
#endif /* LWIP_TCP */
#if LWIP_ARP
  { 0, ARP_TMR_INTERVAL,        etharp_tmr},
#endif /* LWIP_ARP */
#if LWIP_DHCP
  { 0, DHCP_FINE_TIMER_MSECS,   dhcp_fine_tmr},
  { 0, DHCP_COARSE_TIMER_MSECS, dhcp_coarse_tmr},
#endif /* LWIP_DHCP */
#if IP_REASSEMBLY
  { 0, IP_TMR_INTERVAL,         ip_reass_tmr},
#endif /* IP_REASSEMBLY*/
#if LWIP_AUTOIP
  { 0, AUTOIP_TMR_INTERVAL,     autoip_tmr},
#endif /* LWIP_AUTOIP */
#if LWIP_IGMP
  { 0, IGMP_TMR_INTERVAL,       igmp_tmr},
#endif /* LWIP_IGMP */
};

/* initialize stack when NO_SYS=1 */
static void
nosys_init()
{
  sys_init_timing();
  lwip_init();
}

/* get the current time and see if any timer has expired */
static void
timers_update()
{
  /* static variables for timer execution, initialized to zero! */
  static int last_time;

  int cur_time, time_diff, idxtimer;

  cur_time = sys_get_ms();
  time_diff = cur_time - last_time;

  /* the '> 0' is an easy wrap-around check: the big gap at
   * the wraparound step is simply ignored... */
  if (time_diff > 0) {
    last_time = cur_time;
    for( idxtimer=0; idxtimer<(sizeof(timers_table)/sizeof(timers_infos));
idxtimer++) {
      timers_table[idxtimer].timer += time_diff;

      if (timers_table[idxtimer].timer >
timers_table[idxtimer].timer_interval) {
        timers_table[idxtimer].timer_func();
        timers_table[idxtimer].timer -=
timers_table[idxtimer].timer_interval;
      }
    }
  }
}
#endif /* NO_SYS */

...

  /* MAIN LOOP for driver update (and timers if NO_SYS) */
  while (!_kbhit()) {
#if NO_SYS
    /* handle timers (already done in tcpip.c when NO_SYS=0) */
    timers_update();
#endif /* NO_SYS */

    /* check for packets */
    update_adapter();
  }

...

    _______________________________________________________

Reply to this item at:

  <http://savannah.nongnu.org/task/?7235>

_______________________________________________
  Message posté via/par Savannah
  http://savannah.nongnu.org/





reply via email to

[Prev in Thread] Current Thread [Next in Thread]