xref: /haiku/headers/private/kernel/timer.h (revision 541ff51a6ef4c47f8ab105ba6ff895cdbba83aca)
1 /*
2 ** Copyright 2003-2004, Axel Dörfler, axeld@pinc-software.de. All rights reserved.
3 ** Distributed under the terms of the OpenBeOS License.
4 */
5 #ifndef _KERNEL_TIMER_H
6 #define _KERNEL_TIMER_H
7 
8 
9 #include <KernelExport.h>
10 
11 
12 #ifdef __cplusplus
13 extern "C" {
14 #endif
15 
16 struct kernel_args;
17 
18 #define B_TIMER_REAL_TIME_BASE			0x2000
19 	// For an absolute timer the given time is interpreted as a real-time, not
20 	// as a system time. Note that setting the real-time clock will cause the
21 	// timer to be updated -- it will expire according to the new clock.
22 	// Relative timers are unaffected by this flag.
23 #define B_TIMER_USE_TIMER_STRUCT_TIMES	0x4000
24 	// For add_timer(): Use the timer::schedule_time (absolute time) and
25 	// timer::period values instead of the period parameter.
26 #define B_TIMER_ACQUIRE_SCHEDULER_LOCK	0x8000
27 	// The timer hook is invoked with the scheduler lock held. When invoking
28 	// cancel_timer() with the scheduler lock held, too, this helps to avoid
29 	// race conditions.
30 #define B_TIMER_FLAGS	\
31 	(B_TIMER_USE_TIMER_STRUCT_TIMES | B_TIMER_ACQUIRE_SCHEDULER_LOCK	\
32 	| B_TIMER_REAL_TIME_BASE)
33 
34 /* Timer info structure */
35 struct timer_info {
36 	const char *name;
37 	int (*get_priority)(void);
38 	status_t (*set_hardware_timer)(bigtime_t timeout);
39 	status_t (*clear_hardware_timer)(void);
40 	status_t (*init)(struct kernel_args *args);
41 };
42 
43 typedef struct timer_info timer_info;
44 
45 
46 /* kernel functions */
47 status_t timer_init(struct kernel_args *);
48 void timer_init_post_rtc(void);
49 void timer_real_time_clock_changed();
50 int32 timer_interrupt(void);
51 
52 #ifdef __cplusplus
53 }
54 #endif
55 
56 #endif	/* _KERNEL_TIMER_H */
57