10 FILE_LICENCE ( GPL2_OR_LATER );
12 #include <gpxe/list.h>
14 /** Default timeout value */
15 #define DEFAULT_MIN_TIMEOUT ( TICKS_PER_SEC / 4 )
17 /** Limit after which the timeout will be deemed permanent */
18 #define DEFAULT_MAX_TIMEOUT ( 10 * TICKS_PER_SEC )
22 /** List of active timers */
23 struct list_head list;
24 /** Timer is currently running */
26 /** Timeout value (in ticks) */
27 unsigned long timeout;
28 /** Minimum timeout value (in ticks)
30 * A value of zero means "use default timeout."
32 unsigned long min_timeout;
33 /** Maximum timeout value before failure (in ticks)
35 * A value of zero means "use default timeout."
37 unsigned long max_timeout;
38 /** Start time (in ticks) */
42 /** Timer expired callback
44 * @v timer Retry timer
45 * @v fail Failure indicator
47 * The timer will already be stopped when this method is
48 * called. The failure indicator will be True if the retry
49 * timeout has already exceeded @c MAX_TIMEOUT.
51 void ( * expired ) ( struct retry_timer *timer, int over );
54 extern void start_timer ( struct retry_timer *timer );
55 extern void start_timer_fixed ( struct retry_timer *timer,
56 unsigned long timeout );
57 extern void stop_timer ( struct retry_timer *timer );
60 * Start timer with no delay
62 * @v timer Retry timer
64 * This starts the timer running with a zero timeout value.
66 static inline void start_timer_nodelay ( struct retry_timer *timer ) {
67 start_timer_fixed ( timer, 0 );
71 * Test to see if timer is currently running
73 * @v timer Retry timer
74 * @ret running Non-zero if timer is running
76 static inline __attribute__ (( always_inline )) unsigned long
77 timer_running ( struct retry_timer *timer ) {
78 return ( timer->running );
81 #endif /* _GPXE_RETRY_H */