Rev 522 | Rev 762 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
495 | giacomo | 1 | /* |
2 | * Linux timer support. |
||
3 | */ |
||
4 | |||
5 | #include <linuxcomp.h> |
||
6 | |||
7 | #include <linux/kernel.h> |
||
8 | #include <linux/timer.h> |
||
9 | #include <asm/param.h> |
||
10 | |||
11 | //#define TIMER_DEBUG |
||
12 | |||
13 | static inline void jiffies_to_timespec(unsigned long j, struct timespec *value) |
||
14 | { |
||
15 | value->tv_nsec = (j % HZ) * (1000000000L / HZ); |
||
16 | value->tv_sec = j / HZ; |
||
17 | } |
||
18 | |||
526 | giacomo | 19 | extern void *int_arg_table[MAX_INT_TABLE]; |
20 | extern void *int_func_table[MAX_INT_TABLE]; |
||
514 | giacomo | 21 | extern int intr_count; |
22 | |||
23 | /* |
||
24 | * Generic Linux time handler. |
||
25 | */ |
||
26 | void linux_timer(int no) |
||
27 | { |
||
28 | intr_count++; |
||
29 | |||
30 | if (int_func_table[no] != NULL) |
||
31 | (*(void (*)(void *arg))int_func_table[no])(int_arg_table[no]); |
||
32 | |||
33 | intr_count--; |
||
34 | |||
35 | } |
||
36 | |||
495 | giacomo | 37 | void add_timer(struct timer_list *timer) |
38 | { |
||
39 | struct timespec timeout; |
||
40 | |||
41 | jiffies_to_timespec(timer->expires, &timeout); |
||
514 | giacomo | 42 | if (timer->function) { |
43 | timer->event_timer = shark_timer_set(&timeout, (void *)timer->function, (void *)timer->data); |
||
44 | } |
||
495 | giacomo | 45 | |
514 | giacomo | 46 | #ifdef TIMER_DEBUG |
47 | printk("Set to %ld:%ld\n",timeout.tv_sec,timeout.tv_nsec); |
||
48 | #endif |
||
495 | giacomo | 49 | } |
50 | |||
51 | |||
52 | int del_timer(struct timer_list *timer) |
||
53 | { |
||
514 | giacomo | 54 | |
55 | shark_timer_delete(timer->event_timer); |
||
56 | return 0; |
||
57 | |||
495 | giacomo | 58 | } |
59 | |||
60 | int mod_timer(struct timer_list *timer, unsigned long expires) |
||
61 | { |
||
514 | giacomo | 62 | |
522 | mauro | 63 | if (timer->event_timer != -1) shark_timer_delete(timer->event_timer); |
495 | giacomo | 64 | timer->expires = expires; |
65 | add_timer(timer); |
||
514 | giacomo | 66 | return 0; |
67 | |||
495 | giacomo | 68 | } |
69 | |||
70 | void init_timer(struct timer_list * timer) |
||
71 | { |
||
72 | timer->event_timer = -1; |
||
73 | timer->function = NULL; |
||
74 | } |
||
75 | |||
76 | int timer_pending(struct timer_list * timer){ |
||
77 | return timer->event_timer != -1; |
||
78 | } |
||
79 |