10 #include <gpxe/list.h>
12 /** Default timeout value */
13 #define DEFAULT_MIN_TIMEOUT ( TICKS_PER_SEC / 4 )
15 /** Limit after which the timeout will be deemed permanent */
16 #define DEFAULT_MAX_TIMEOUT ( 10 * TICKS_PER_SEC )
20 /** List of active timers */
21 struct list_head list;
22 /** Timeout value (in ticks) */
23 unsigned long timeout;
24 /** Minimum timeout value (in ticks)
26 * A value of zero means "use default timeout."
28 unsigned long min_timeout;
29 /** Maximum timeout value before failure (in ticks)
31 * A value of zero means "use default timeout."
33 unsigned long max_timeout;
34 /** Start time (in ticks)
36 * A start time of zero indicates a stopped timer.
41 /** Timer expired callback
43 * @v timer Retry timer
44 * @v fail Failure indicator
46 * The timer will already be stopped when this method is
47 * called. The failure indicator will be True if the retry
48 * timeout has already exceeded @c MAX_TIMEOUT.
50 void ( * expired ) ( struct retry_timer *timer, int over );
53 extern void start_timer ( struct retry_timer *timer );
54 extern void start_timer_fixed ( struct retry_timer *timer,
55 unsigned long timeout );
56 extern void stop_timer ( struct retry_timer *timer );
59 * Start timer with no delay
61 * @v timer Retry timer
63 * This starts the timer running with a zero timeout value.
65 static inline void start_timer_nodelay ( struct retry_timer *timer ) {
66 start_timer_fixed ( timer, 0 );
70 * Test to see if timer is currently running
72 * @v timer Retry timer
73 * @ret running Non-zero if timer is running
75 static inline __attribute__ (( always_inline )) unsigned long
76 timer_running ( struct retry_timer *timer ) {
77 return ( timer->start );
80 #endif /* _GPXE_RETRY_H */