blob: 9531800defef7cd0de9f58fee848dd9cd7fa1f9b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
|
/******************************************************************************
* timer.h
*
* Copyright (c) 2002-2003 Rolf Neugebauer
* Copyright (c) 2002-2005 K A Fraser
*/
#ifndef _TIMER_H_
#define _TIMER_H_
#include <xen/spinlock.h>
#include <xen/time.h>
#include <xen/string.h>
#include <xen/list.h>
#include <xen/percpu.h>
struct timer {
/* System time expiry value (nanoseconds since boot). */
s_time_t expires;
/* Position in active-timer data structure. */
union {
/* Timer-heap offset (TIMER_STATUS_in_heap). */
unsigned int heap_offset;
/* Linked list (TIMER_STATUS_in_list). */
struct timer *list_next;
/* Linked list of inactive timers (TIMER_STATUS_inactive). */
struct list_head inactive;
};
/* On expiry, '(*function)(data)' will be executed in softirq context. */
void (*function)(void *);
void *data;
/* CPU on which this timer will be installed and executed. */
#define TIMER_CPU_status_killed 0xffffu /* Timer is TIMER_STATUS_killed */
uint16_t cpu;
/* Timer status. */
#define TIMER_STATUS_invalid 0 /* Should never see this. */
#define TIMER_STATUS_inactive 1 /* Not in use; can be activated. */
#define TIMER_STATUS_killed 2 /* Not in use; cannot be activated. */
#define TIMER_STATUS_in_heap 3 /* In use; on timer heap. */
#define TIMER_STATUS_in_list 4 /* In use; on overflow linked list. */
uint8_t status;
};
/*
* All functions below can be called for any CPU from any CPU in any context.
*/
/*
* Initialise a timer structure with an initial callback CPU, callback
* function and callback data pointer. This function must only be called on
* a brand new timer, or a killed timer. It must *never* execute concurrently
* with any other operation on the same timer.
*/
void init_timer(
struct timer *timer,
void (*function)(void *),
void *data,
unsigned int cpu);
/* Set the expiry time and activate a timer. */
void set_timer(struct timer *timer, s_time_t expires);
/*
* Deactivate a timer This function has no effect if the timer is not currently
* active.
*/
void stop_timer(struct timer *timer);
/* Migrate a timer to a different CPU. The timer may be currently active. */
void migrate_timer(struct timer *timer, unsigned int new_cpu);
/*
* Deactivate a timer and prevent it from being re-set (future calls to
* set_timer will silently fail). When this function returns it is guaranteed
* that the timer callback handler is not running on any CPU.
*/
void kill_timer(struct timer *timer);
/* Bootstrap initialisation. Must be called before any other timer function. */
void timer_init(void);
/* Next timer deadline for each CPU. */
DECLARE_PER_CPU(s_time_t, timer_deadline);
/* Arch-defined function to reprogram timer hardware for new deadline. */
int reprogram_timer(s_time_t timeout);
/* Calculate the aligned first tick time for a given periodic timer. */
s_time_t align_timer(s_time_t firsttick, uint64_t period);
#endif /* _TIMER_H_ */
/*
* Local variables:
* mode: C
* c-file-style: "BSD"
* c-basic-offset: 4
* tab-width: 4
* indent-tabs-mode: nil
* End:
*/
|