2 * Copyright (c) 2003-2007 Apple Inc. All rights reserved.
4 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. The rights granted to you under the License
10 * may not be used to create, or enable the creation or redistribution of,
11 * unlawful or unlicensed copies of an Apple operating system, or to
12 * circumvent, violate, or enable the circumvention or violation of, any
13 * terms of an Apple operating system software license agreement.
15 * Please obtain a copy of the License at
16 * http://www.opensource.apple.com/apsl/ and read it before using this file.
18 * The Original Code and all software distributed under the License are
19 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
20 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
21 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
22 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
23 * Please see the License for the specific language governing rights and
24 * limitations under the License.
26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
30 #include <mach/boolean.h>
31 #include <mach/mach_types.h>
33 #include <kern/kern_types.h>
34 #include <kern/processor.h>
35 #include <kern/timer_call.h>
36 #include <kern/thread_call.h>
37 #include <kern/kalloc.h>
38 #include <kern/thread.h>
40 #include <libkern/OSAtomic.h>
42 #include <machine/machine_routines.h>
43 #include <machine/cpu_data.h>
45 #include <chud/chud_xnu.h>
46 #include <chud/chud_xnu_private.h>
49 #pragma mark **** timer ****
52 __private_extern__ chud_timer_t
53 chudxnu_timer_alloc(chudxnu_timer_callback_func_t func
, thread_call_param_t param0
)
55 return (chud_timer_t
)thread_call_allocate((thread_call_func_t
)func
, param0
);
58 __private_extern__ kern_return_t
59 chudxnu_timer_callback_enter(
61 thread_call_param_t param1
,
66 clock_interval_to_deadline(time
, units
, &t_delay
);
67 thread_call_enter1_delayed((thread_call_t
)timer
, param1
, t_delay
);
71 __private_extern__ kern_return_t
72 chudxnu_timer_callback_cancel(chud_timer_t timer
)
74 thread_call_cancel((thread_call_t
)timer
);
78 __private_extern__ kern_return_t
79 chudxnu_timer_free(chud_timer_t timer
)
81 thread_call_cancel((thread_call_t
)timer
);
82 thread_call_free((thread_call_t
)timer
);