[PATCH] bcm43xx: add assert(bcm->initialized) to periodic_tasks_setup().
[linux-2.6/sactl.git] / include / linux / hrtimer.h
blob93830158348e711ad50bc921dec68dd34f649d17
1 /*
2 * include/linux/hrtimer.h
4 * hrtimers - High-resolution kernel timers
6 * Copyright(C) 2005, Thomas Gleixner <tglx@linutronix.de>
7 * Copyright(C) 2005, Red Hat, Inc., Ingo Molnar
9 * data type definitions, declarations, prototypes
11 * Started by: Thomas Gleixner and Ingo Molnar
13 * For licencing details see kernel-base/COPYING
15 #ifndef _LINUX_HRTIMER_H
16 #define _LINUX_HRTIMER_H
18 #include <linux/rbtree.h>
19 #include <linux/ktime.h>
20 #include <linux/init.h>
21 #include <linux/list.h>
22 #include <linux/wait.h>
25 * Mode arguments of xxx_hrtimer functions:
27 enum hrtimer_mode {
28 HRTIMER_ABS, /* Time value is absolute */
29 HRTIMER_REL, /* Time value is relative to now */
32 enum hrtimer_restart {
33 HRTIMER_NORESTART,
34 HRTIMER_RESTART,
37 #define HRTIMER_INACTIVE ((void *)1UL)
39 struct hrtimer_base;
41 /**
42 * struct hrtimer - the basic hrtimer structure
44 * @node: red black tree node for time ordered insertion
45 * @expires: the absolute expiry time in the hrtimers internal
46 * representation. The time is related to the clock on
47 * which the timer is based.
48 * @function: timer expiry callback function
49 * @base: pointer to the timer base (per cpu and per clock)
51 * The hrtimer structure must be initialized by init_hrtimer_#CLOCKTYPE()
53 struct hrtimer {
54 struct rb_node node;
55 ktime_t expires;
56 int (*function)(struct hrtimer *);
57 struct hrtimer_base *base;
60 /**
61 * struct hrtimer_base - the timer base for a specific clock
63 * @index: clock type index for per_cpu support when moving a timer
64 * to a base on another cpu.
65 * @lock: lock protecting the base and associated timers
66 * @active: red black tree root node for the active timers
67 * @first: pointer to the timer node which expires first
68 * @resolution: the resolution of the clock, in nanoseconds
69 * @get_time: function to retrieve the current time of the clock
70 * @get_sofirq_time: function to retrieve the current time from the softirq
71 * @curr_timer: the timer which is executing a callback right now
72 * @softirq_time: the time when running the hrtimer queue in the softirq
74 struct hrtimer_base {
75 clockid_t index;
76 spinlock_t lock;
77 struct rb_root active;
78 struct rb_node *first;
79 ktime_t resolution;
80 ktime_t (*get_time)(void);
81 ktime_t (*get_softirq_time)(void);
82 struct hrtimer *curr_timer;
83 ktime_t softirq_time;
87 * clock_was_set() is a NOP for non- high-resolution systems. The
88 * time-sorted order guarantees that a timer does not expire early and
89 * is expired in the next softirq when the clock was advanced.
91 #define clock_was_set() do { } while (0)
93 /* Exported timer functions: */
95 /* Initialize timers: */
96 extern void hrtimer_init(struct hrtimer *timer, clockid_t which_clock,
97 enum hrtimer_mode mode);
99 /* Basic timer operations: */
100 extern int hrtimer_start(struct hrtimer *timer, ktime_t tim,
101 const enum hrtimer_mode mode);
102 extern int hrtimer_cancel(struct hrtimer *timer);
103 extern int hrtimer_try_to_cancel(struct hrtimer *timer);
105 #define hrtimer_restart(timer) hrtimer_start((timer), (timer)->expires, HRTIMER_ABS)
107 /* Query timers: */
108 extern ktime_t hrtimer_get_remaining(const struct hrtimer *timer);
109 extern int hrtimer_get_res(const clockid_t which_clock, struct timespec *tp);
111 #ifdef CONFIG_NO_IDLE_HZ
112 extern ktime_t hrtimer_get_next_event(void);
113 #endif
115 static inline int hrtimer_active(const struct hrtimer *timer)
117 return timer->node.rb_parent != HRTIMER_INACTIVE;
120 /* Forward a hrtimer so it expires after now: */
121 extern unsigned long
122 hrtimer_forward(struct hrtimer *timer, ktime_t now, ktime_t interval);
124 /* Precise sleep: */
125 extern long hrtimer_nanosleep(struct timespec *rqtp,
126 struct timespec __user *rmtp,
127 const enum hrtimer_mode mode,
128 const clockid_t clockid);
130 /* Soft interrupt function to run the hrtimer queues: */
131 extern void hrtimer_run_queues(void);
133 /* Bootup initialization: */
134 extern void __init hrtimers_init(void);
136 #endif