[32] | 1 | #ifndef _LINUX_TIMER_H
|
---|
| 2 | #define _LINUX_TIMER_H
|
---|
| 3 |
|
---|
| 4 | /*
|
---|
| 5 | * Old-style timers. Please don't use for any new code.
|
---|
| 6 | *
|
---|
| 7 | * Numbering of these timers should be consecutive to minimize
|
---|
| 8 | * processing delays. [MJ]
|
---|
| 9 | */
|
---|
| 10 |
|
---|
| 11 | #define BLANK_TIMER 0 /* Console screen-saver */
|
---|
| 12 | #define BEEP_TIMER 1 /* Console beep */
|
---|
| 13 | #define RS_TIMER 2 /* RS-232 ports */
|
---|
| 14 | #define SWAP_TIMER 3 /* Background pageout */
|
---|
| 15 | #define BACKGR_TIMER 4 /* io_request background I/O */
|
---|
| 16 | #define HD_TIMER 5 /* Old IDE driver */
|
---|
| 17 | #define FLOPPY_TIMER 6 /* Floppy */
|
---|
| 18 | #define QIC02_TAPE_TIMER 7 /* QIC 02 tape */
|
---|
| 19 | #define MCD_TIMER 8 /* Mitsumi CDROM */
|
---|
| 20 | #define GSCD_TIMER 9 /* Goldstar CDROM */
|
---|
| 21 | #define COMTROL_TIMER 10 /* Comtrol serial */
|
---|
| 22 | #define DIGI_TIMER 11 /* Digi serial */
|
---|
| 23 | #define GDTH_TIMER 12 /* Ugh - gdth scsi driver */
|
---|
| 24 |
|
---|
| 25 | #define COPRO_TIMER 31 /* 387 timeout for buggy hardware (boot only) */
|
---|
| 26 |
|
---|
| 27 | struct timer_struct {
|
---|
| 28 | unsigned long expires;
|
---|
| 29 | void (*fn)(void);
|
---|
| 30 | };
|
---|
| 31 |
|
---|
| 32 | extern unsigned long timer_active;
|
---|
| 33 | extern struct timer_struct timer_table[32];
|
---|
| 34 |
|
---|
| 35 | /*
|
---|
| 36 | * This is completely separate from the above, and is the
|
---|
| 37 | * "new and improved" way of handling timers more dynamically.
|
---|
| 38 | * Hopefully efficient and general enough for most things.
|
---|
| 39 | *
|
---|
| 40 | * The "hardcoded" timers above are still useful for well-
|
---|
| 41 | * defined problems, but the timer-list is probably better
|
---|
| 42 | * when you need multiple outstanding timers or similar.
|
---|
| 43 | *
|
---|
| 44 | * The "data" field is in case you want to use the same
|
---|
| 45 | * timeout function for several timeouts. You can use this
|
---|
| 46 | * to distinguish between the different invocations.
|
---|
| 47 | */
|
---|
| 48 | struct timer_list {
|
---|
| 49 | struct timer_list *next; /* MUST be first element */
|
---|
| 50 | struct timer_list *prev;
|
---|
| 51 | unsigned long expires;
|
---|
| 52 | unsigned long data;
|
---|
| 53 | void (*function)(unsigned long);
|
---|
| 54 | };
|
---|
| 55 |
|
---|
| 56 | extern void add_timer(struct timer_list * timer);
|
---|
| 57 | extern int del_timer(struct timer_list * timer);
|
---|
| 58 |
|
---|
| 59 | /*
|
---|
| 60 | * mod_timer is a more efficient way to update the expire field of an
|
---|
| 61 | * active timer (if the timer is inactive it will be activated)
|
---|
| 62 | * mod_timer(a,b) is equivalent to del_timer(a); a->expires = b; add_timer(a)
|
---|
| 63 | */
|
---|
| 64 | void mod_timer(struct timer_list *timer, unsigned long expires);
|
---|
| 65 |
|
---|
| 66 | extern void it_real_fn(unsigned long);
|
---|
| 67 |
|
---|
| 68 | #define init_timer(timer) \
|
---|
| 69 | (timer)->next = NULL; \
|
---|
| 70 | (timer)->prev = NULL;
|
---|
| 71 |
|
---|
| 72 |
|
---|
| 73 | #define timer_pending(timer) (timer)->prev != NULL;
|
---|
| 74 |
|
---|
| 75 |
|
---|
| 76 | /*
|
---|
| 77 | * These inlines deal with timer wrapping correctly. You are
|
---|
| 78 | * strongly encouraged to use them
|
---|
| 79 | * 1. Because people otherwise forget
|
---|
| 80 | * 2. Because if the timer wrap changes in future you wont have to
|
---|
| 81 | * alter your driver code.
|
---|
| 82 | *
|
---|
| 83 | * Do this with "<0" and ">=0" to only test the sign of the result. A
|
---|
| 84 | * good compiler would generate better code (and a really good compiler
|
---|
| 85 | * wouldn't care). Gcc is currently neither.
|
---|
| 86 | */
|
---|
| 87 | #define time_after(a,b) ((long)(b) - (long)(a) < 0)
|
---|
| 88 | #define time_before(a,b) time_after(b,a)
|
---|
| 89 |
|
---|
| 90 | #define time_after_eq(a,b) ((long)(a) - (long)(b) >= 0)
|
---|
| 91 | #define time_before_eq(a,b) time_after_eq(b,a)
|
---|
[679] | 92 | # define del_timer_sync(t) del_timer(t)
|
---|
[32] | 93 |
|
---|
| 94 | #endif
|
---|