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
);
57 * @v timer Retry timer
58 * @v expired Timer expired callback
60 static inline __attribute__ (( always_inline
)) void
61 timer_init ( struct retry_timer
*timer
,
62 void ( * expired
) ( struct retry_timer
*timer
, int over
) ) {
63 timer
->expired
= expired
;
66 extern void start_timer ( struct retry_timer
*timer
);
67 extern void start_timer_fixed ( struct retry_timer
*timer
,
68 unsigned long timeout
);
69 extern void stop_timer ( struct retry_timer
*timer
);
72 * Start timer with no delay
74 * @v timer Retry timer
76 * This starts the timer running with a zero timeout value.
78 static inline void start_timer_nodelay ( struct retry_timer
*timer
) {
79 start_timer_fixed ( timer
, 0 );
83 * Test to see if timer is currently running
85 * @v timer Retry timer
86 * @ret running Non-zero if timer is running
88 static inline __attribute__ (( always_inline
)) unsigned long
89 timer_running ( struct retry_timer
*timer
) {
90 return ( timer
->running
);
93 #endif /* _GPXE_RETRY_H */