]> git.saurik.com Git - apple/xnu.git/blob - osfmk/chud/chud_osfmk_callback.c
xnu-1699.22.81.tar.gz
[apple/xnu.git] / osfmk / chud / chud_osfmk_callback.c
1 /*
2 * Copyright (c) 2003-2007 Apple Inc. All rights reserved.
3 *
4 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
5 *
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.
14 *
15 * Please obtain a copy of the License at
16 * http://www.opensource.apple.com/apsl/ and read it before using this file.
17 *
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.
25 *
26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
27 */
28
29 #include <stdint.h>
30 #include <mach/boolean.h>
31 #include <mach/mach_types.h>
32
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>
39
40 #include <libkern/OSAtomic.h>
41
42 #include <machine/machine_routines.h>
43 #include <machine/cpu_data.h>
44
45 #include <chud/chud_xnu.h>
46 #include <chud/chud_xnu_private.h>
47
48 #if 0
49 #pragma mark **** timer ****
50 #endif
51
52 __private_extern__ chud_timer_t
53 chudxnu_timer_alloc(chudxnu_timer_callback_func_t func, thread_call_param_t param0)
54 {
55 return (chud_timer_t)thread_call_allocate((thread_call_func_t)func, param0);
56 }
57
58 __private_extern__ kern_return_t
59 chudxnu_timer_callback_enter(
60 chud_timer_t timer,
61 thread_call_param_t param1,
62 uint32_t time,
63 uint32_t units)
64 {
65 uint64_t t_delay;
66 clock_interval_to_deadline(time, units, &t_delay);
67 thread_call_enter1_delayed((thread_call_t)timer, param1, t_delay);
68 return KERN_SUCCESS;
69 }
70
71 __private_extern__ kern_return_t
72 chudxnu_timer_callback_cancel(chud_timer_t timer)
73 {
74 thread_call_cancel((thread_call_t)timer);
75 return KERN_SUCCESS;
76 }
77
78 __private_extern__ kern_return_t
79 chudxnu_timer_free(chud_timer_t timer)
80 {
81 thread_call_cancel((thread_call_t)timer);
82 thread_call_free((thread_call_t)timer);
83 return KERN_SUCCESS;
84 }
85
86