John Stultz | ff3ead9 | 2011-01-11 09:42:13 -0800 | [diff] [blame] | 1 | #ifndef _LINUX_ALARMTIMER_H |
| 2 | #define _LINUX_ALARMTIMER_H |
| 3 | |
| 4 | #include <linux/time.h> |
| 5 | #include <linux/hrtimer.h> |
| 6 | #include <linux/timerqueue.h> |
| 7 | #include <linux/rtc.h> |
| 8 | |
| 9 | enum alarmtimer_type { |
| 10 | ALARM_REALTIME, |
| 11 | ALARM_BOOTTIME, |
| 12 | |
| 13 | ALARM_NUMTYPE, |
| 14 | }; |
| 15 | |
John Stultz | 4b41308 | 2011-08-10 10:37:59 -0700 | [diff] [blame] | 16 | enum alarmtimer_restart { |
| 17 | ALARMTIMER_NORESTART, |
| 18 | ALARMTIMER_RESTART, |
| 19 | }; |
| 20 | |
John Stultz | 180bf81 | 2011-04-28 12:58:11 -0700 | [diff] [blame] | 21 | /** |
| 22 | * struct alarm - Alarm timer structure |
| 23 | * @node: timerqueue node for adding to the event list this value |
| 24 | * also includes the expiration time. |
| 25 | * @period: Period for recuring alarms |
| 26 | * @function: Function pointer to be executed when the timer fires. |
| 27 | * @type: Alarm type (BOOTTIME/REALTIME) |
| 28 | * @enabled: Flag that represents if the alarm is set to fire or not |
| 29 | * @data: Internal data value. |
| 30 | */ |
John Stultz | ff3ead9 | 2011-01-11 09:42:13 -0800 | [diff] [blame] | 31 | struct alarm { |
| 32 | struct timerqueue_node node; |
| 33 | ktime_t period; |
John Stultz | 4b41308 | 2011-08-10 10:37:59 -0700 | [diff] [blame] | 34 | enum alarmtimer_restart (*function)(struct alarm *, ktime_t now); |
John Stultz | ff3ead9 | 2011-01-11 09:42:13 -0800 | [diff] [blame] | 35 | enum alarmtimer_type type; |
John Stultz | 180bf81 | 2011-04-28 12:58:11 -0700 | [diff] [blame] | 36 | bool enabled; |
John Stultz | ff3ead9 | 2011-01-11 09:42:13 -0800 | [diff] [blame] | 37 | void *data; |
| 38 | }; |
| 39 | |
| 40 | void alarm_init(struct alarm *alarm, enum alarmtimer_type type, |
John Stultz | 4b41308 | 2011-08-10 10:37:59 -0700 | [diff] [blame] | 41 | enum alarmtimer_restart (*function)(struct alarm *, ktime_t)); |
John Stultz | ff3ead9 | 2011-01-11 09:42:13 -0800 | [diff] [blame] | 42 | void alarm_start(struct alarm *alarm, ktime_t start, ktime_t period); |
| 43 | void alarm_cancel(struct alarm *alarm); |
| 44 | |
John Stultz | dce75a8 | 2011-08-10 11:31:03 -0700 | [diff] [blame^] | 45 | u64 alarm_forward(struct alarm *alarm, ktime_t now, ktime_t interval); |
| 46 | |
John Stultz | ff3ead9 | 2011-01-11 09:42:13 -0800 | [diff] [blame] | 47 | #endif |