1
/*
2
* \brief Timers and tick
3
* \author Christian Helmuth
4
* \date 2008-10-22
5
*
6
* DDE kit provides a generic timer implementation that enables users to
7
* execute a callback function after a certain period of time. Therefore, DDE
8
* kit starts a timer thread that executes callbacks and keeps track of the
9
* currently running timers.
10
*/
11
12
/*
13
* Copyright (C) 2008-2013 Genode Labs GmbH
14
*
15
* This file is part of the Genode OS framework, which is distributed
16
* under the terms of the GNU General Public License version 2.
17
*/
18
19
#
ifndef _INCLUDE__DDE_KIT__TIMER_H_
20
#
define _INCLUDE__DDE_KIT__TIMER_H_
21
22
#
include <dde_kit/thread.h>
23
24
25
/**********
26
** Tick **
27
**********/
28
29
/** Timer tick (global symbol) */
30
extern
volatile
unsigned
long dde_kit_timer_ticks;
31
32
/** Timer tick rate */
33
enum
{
DDE_KIT_HZ =
100
}
;
34
35
36
/***********
37
** Timer **
38
***********/
39
40
struct
dde_kit_timer;
41
42
/**
43
* Add timer event handler
44
*
45
* \param fn function to call on timeout
46
* \param priv private handler token
47
* \param timeout absolute timeout (in DDE kit ticks)
48
*
49
* \return timer reference on success; 0 otherwise
50
*
51
* After the absolute timeout has expired, function fn is called with args as
52
* arguments.
53
*/
54
struct
dde_kit_timer *
dde_kit_timer_add(
void (
*
fn)
(
void *
)
,
void *
priv,
55
unsigned
long timeout)
;
56
57
/**
58
* Delete timer
59
*
60
* \param timer timer reference
61
*/
62
void
dde_kit_timer_del(
struct
dde_kit_timer *
timer
)
;
63
64
65
/**
66
* Schedule absolute timeout
67
*
68
* \param timer timer reference
69
* \param timeout absolute timeout (in DDE kit ticks)
70
*/
71
void
dde_kit_timer_schedule_absolute(
struct
dde_kit_timer *
timer
,
unsigned
long
timeout
)
;
72
73
74
/**
75
* Check whether a timer is pending
76
*
77
* \param timer timer reference
78
*/
79
int
dde_kit_timer_pending(
struct
dde_kit_timer *
timer
)
;
80
81
/** Init timers and ticks */
82
void
dde_kit_timer_init(
void(
*
thread_init)
(
void *
)
,
void *
priv
)
;
83
84
#
endif /* _INCLUDE__DDE_KIT__TIMER_H_ */