ia64/xen-unstable

view xen/include/xen/timer.h @ 19800:78962f85c562

IOMMU: Add two generic functions to vendor neutral interface

Add 2 generic functions into the vendor neutral iommu interface, The
reason is that from changeset 19732, there is only one global flag
"iommu_enabled" that controls iommu enablement for both vtd and amd
systems, so we need different code paths for vtd and amd iommu systems
if this flag has been turned on. Also, the early checking of
"iommu_enabled" in iommu_setup() is removed to prevent iommu
functionalities from been disabled on amd systems.

Signed-off-by: Wei Wang <wei.wang2@amd.com>
author Keir Fraser <keir.fraser@citrix.com>
date Fri Jun 19 08:41:50 2009 +0100 (2009-06-19)
parents d9480422034b
children
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 s_time_t expires_end;
20 /* Position in active-timer data structure. */
21 union {
22 /* Timer-heap offset. */
23 unsigned int heap_offset;
24 /* Linked list. */
25 struct timer *list_next;
26 };
28 /* On expiry, '(*function)(data)' will be executed in softirq context. */
29 void (*function)(void *);
30 void *data;
32 /* CPU on which this timer will be installed and executed. */
33 uint16_t cpu;
35 /* Timer status. */
36 #define TIMER_STATUS_inactive 0 /* Not in use; can be activated. */
37 #define TIMER_STATUS_killed 1 /* Not in use; canot be activated. */
38 #define TIMER_STATUS_in_heap 2 /* In use; on timer heap. */
39 #define TIMER_STATUS_in_list 3 /* In use; on overflow linked list. */
40 uint8_t status;
41 };
43 /*
44 * All functions below can be called for any CPU from any CPU in any context.
45 */
47 /*
48 * Returns TRUE if the given timer is on a timer list.
49 * The timer must *previously* have been initialised by init_timer(), or its
50 * structure initialised to all-zeroes.
51 */
52 static inline int active_timer(struct timer *timer)
53 {
54 return (timer->status >= TIMER_STATUS_in_heap);
55 }
57 /*
58 * Initialise a timer structure with an initial callback CPU, callback
59 * function and callback data pointer. This function may be called at any
60 * time (and multiple times) on an inactive timer. It must *never* execute
61 * concurrently with any other operation on the same timer.
62 */
63 static inline void init_timer(
64 struct timer *timer,
65 void (*function)(void *),
66 void *data,
67 unsigned int cpu)
68 {
69 memset(timer, 0, sizeof(*timer));
70 timer->function = function;
71 timer->data = data;
72 timer->cpu = cpu;
73 }
75 /*
76 * Set the expiry time and activate a timer. The timer must *previously* have
77 * been initialised by init_timer() (so that callback details are known).
78 */
79 extern void set_timer(struct timer *timer, s_time_t expires);
81 /*
82 * Deactivate a timer This function has no effect if the timer is not currently
83 * active.
84 * The timer must *previously* have been initialised by init_timer(), or its
85 * structure initialised to all zeroes.
86 */
87 extern void stop_timer(struct timer *timer);
89 /*
90 * Migrate a timer to a different CPU. The timer may be currently active.
91 * The timer must *previously* have been initialised by init_timer(), or its
92 * structure initialised to all zeroes.
93 */
94 extern void migrate_timer(struct timer *timer, unsigned int new_cpu);
96 /*
97 * Deactivate a timer and prevent it from being re-set (future calls to
98 * set_timer will silently fail). When this function returns it is guaranteed
99 * that the timer callback handler is not running on any CPU.
100 * The timer must *previously* have been initialised by init_timer(), or its
101 * structure initialised to all zeroes.
102 */
103 extern void kill_timer(struct timer *timer);
105 /*
106 * Process pending timers on this CPU. This should be called periodically
107 * when performing work that prevents softirqs from running in a timely manner.
108 */
109 extern void process_pending_timers(void);
111 /*
112 * Bootstrap initialisation. Must be called before any other timer function.
113 */
114 extern void timer_init(void);
116 /*
117 * Next timer deadline for each CPU.
118 * Modified only by the local CPU and never in interrupt context.
119 */
120 DECLARE_PER_CPU(s_time_t, timer_deadline);
122 /* Arch-defined function to reprogram timer hardware for new deadline. */
123 extern int reprogram_timer(s_time_t timeout);
125 /* calculate the aligned first tick time for a given periodic timer */
126 extern s_time_t align_timer(s_time_t firsttick, uint64_t period);
128 #endif /* _TIMER_H_ */
130 /*
131 * Local variables:
132 * mode: C
133 * c-set-style: "BSD"
134 * c-basic-offset: 4
135 * tab-width: 4
136 * indent-tabs-mode: nil
137 * End:
138 */