debuggers.hg

view xen/include/xen/timer.h @ 0:7d21f7218375

Exact replica of unstable on 051908 + README-this
author Mukesh Rathor
date Mon May 19 15:34:57 2008 -0700 (2008-05-19)
parents
children 5c0bf00e371d
line source
1 /******************************************************************************
2 * timer.h
3 *
4 * Copyright (c) 2002-2003 Rolf Neugebauer
5 * Copyright (c) 2002-2005 K A Fraser
6 */
8 #ifndef _TIMER_H_
9 #define _TIMER_H_
11 #include <xen/spinlock.h>
12 #include <xen/time.h>
13 #include <xen/string.h>
15 struct timer {
16 /* System time expiry value (nanoseconds since boot). */
17 s_time_t expires;
18 /* CPU on which this timer will be installed and executed. */
19 unsigned int cpu;
20 /* On expiry, '(*function)(data)' will be executed in softirq context. */
21 void (*function)(void *);
22 void *data;
23 /* Timer-heap offset. */
24 unsigned int heap_offset;
25 /* Has this timer been killed (cannot be activated)? */
26 int killed;
27 };
29 /*
30 * All functions below can be called for any CPU from any CPU in any context.
31 */
33 /*
34 * Returns TRUE if the given timer is on a timer list.
35 * The timer must *previously* have been initialised by init_timer(), or its
36 * structure initialised to all-zeroes.
37 */
38 static inline int active_timer(struct timer *timer)
39 {
40 return (timer->heap_offset != 0);
41 }
43 /*
44 * Initialise a timer structure with an initial callback CPU, callback
45 * function and callback data pointer. This function may be called at any
46 * time (and multiple times) on an inactive timer. It must *never* execute
47 * concurrently with any other operation on the same timer.
48 */
49 static inline void init_timer(
50 struct timer *timer,
51 void (*function)(void *),
52 void *data,
53 unsigned int cpu)
54 {
55 memset(timer, 0, sizeof(*timer));
56 timer->function = function;
57 timer->data = data;
58 timer->cpu = cpu;
59 }
61 /*
62 * Set the expiry time and activate a timer. The timer must *previously* have
63 * been initialised by init_timer() (so that callback details are known).
64 */
65 extern void set_timer(struct timer *timer, s_time_t expires);
67 /*
68 * Deactivate a timer This function has no effect if the timer is not currently
69 * active.
70 * The timer must *previously* have been initialised by init_timer(), or its
71 * structure initialised to all zeroes.
72 */
73 extern void stop_timer(struct timer *timer);
75 /*
76 * Migrate a timer to a different CPU. The timer may be currently active.
77 * The timer must *previously* have been initialised by init_timer(), or its
78 * structure initialised to all zeroes.
79 */
80 extern void migrate_timer(struct timer *timer, unsigned int new_cpu);
82 /*
83 * Deactivate a timer and prevent it from being re-set (future calls to
84 * set_timer will silently fail). When this function returns it is guaranteed
85 * that the timer callback handler is not running on any CPU.
86 * The timer must *previously* have been initialised by init_timer(), or its
87 * structure initialised to all zeroes.
88 */
89 extern void kill_timer(struct timer *timer);
91 /*
92 * Process pending timers on this CPU. This should be called periodically
93 * when performing work that prevents softirqs from running in a timely manner.
94 */
95 extern void process_pending_timers(void);
97 /*
98 * Bootstrap initialisation. Must be called before any other timer function.
99 */
100 extern void timer_init(void);
102 #endif /* _TIMER_H_ */
104 /*
105 * Local variables:
106 * mode: C
107 * c-set-style: "BSD"
108 * c-basic-offset: 4
109 * tab-width: 4
110 * indent-tabs-mode: nil
111 * End:
112 */