]>
Commit | Line | Data |
---|---|---|
1c79356b | 1 | /* |
c910b4d9 | 2 | * Copyright (c) 1993-1995, 1999-2008 Apple Inc. All rights reserved. |
1c79356b | 3 | * |
2d21ac55 | 4 | * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ |
0a7de745 | 5 | * |
2d21ac55 A |
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. | |
0a7de745 | 14 | * |
2d21ac55 A |
15 | * Please obtain a copy of the License at |
16 | * http://www.opensource.apple.com/apsl/ and read it before using this file. | |
0a7de745 | 17 | * |
2d21ac55 A |
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 | |
8f6c56a5 A |
20 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, |
21 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, | |
2d21ac55 A |
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. | |
0a7de745 | 25 | * |
2d21ac55 | 26 | * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ |
1c79356b A |
27 | */ |
28 | /* | |
29 | * Declarations for timer interrupt callouts. | |
1c79356b A |
30 | */ |
31 | ||
32 | #ifndef _KERN_TIMER_CALL_H_ | |
33 | #define _KERN_TIMER_CALL_H_ | |
34 | ||
1c79356b | 35 | #include <mach/mach_types.h> |
39236c6e | 36 | #include <kern/kern_types.h> |
1c79356b | 37 | |
39236c6e | 38 | #ifdef XNU_KERNEL_PRIVATE |
1c79356b | 39 | |
6d2010ae | 40 | #include <kern/call_entry.h> |
fe8ab488 | 41 | #include <kern/simple_lock.h> |
6d2010ae | 42 | |
39236c6e A |
43 | #ifdef MACH_KERNEL_PRIVATE |
44 | #include <kern/queue.h> | |
0a7de745 | 45 | #include <kern/mpqueue.h> |
39236c6e A |
46 | |
47 | extern boolean_t mach_timer_coalescing_enabled; | |
48 | extern void timer_call_queue_init(mpqueue_head_t *); | |
49 | #endif | |
50 | ||
6d2010ae A |
51 | /* |
52 | * NOTE: for now, bsd/dev/dtrace/dtrace_glue.c has its own definition | |
53 | * of this data structure, and the two had better match. | |
54 | */ | |
55 | typedef struct timer_call { | |
0a7de745 A |
56 | struct call_entry call_entry; |
57 | decl_simple_lock_data(, lock); /* protects call_entry queue */ | |
58 | uint64_t soft_deadline; | |
59 | uint32_t flags; | |
60 | boolean_t async_dequeue; /* this field is protected by | |
61 | * call_entry queue's lock */ | |
62 | uint64_t ttd; /* Time to deadline at creation */ | |
39236c6e A |
63 | } timer_call_data_t, *timer_call_t; |
64 | ||
0a7de745 | 65 | #define EndOfAllTime 0xFFFFFFFFFFFFFFFFULL |
39236c6e | 66 | |
0a7de745 A |
67 | typedef void *timer_call_param_t; |
68 | typedef void (*timer_call_func_t)( | |
69 | timer_call_param_t param0, | |
70 | timer_call_param_t param1); | |
39236c6e A |
71 | |
72 | /* | |
73 | * Flags to alter the default timer/timeout coalescing behavior | |
74 | * on a per-timer_call basis. | |
75 | * | |
76 | * The SYS urgency classes indicate that the timer_call is not | |
77 | * directly related to the current thread at the time the timer_call | |
78 | * is entered, so it is ignored in the calculation entirely (only | |
79 | * the subclass specified is used). | |
80 | * | |
81 | * The USER flags indicate that both the current thread scheduling and QoS | |
82 | * attributes, in addition to the per-timer_call urgency specification, | |
83 | * are used to establish coalescing behavior. | |
84 | */ | |
0a7de745 A |
85 | #define TIMER_CALL_SYS_NORMAL TIMEOUT_URGENCY_SYS_NORMAL |
86 | #define TIMER_CALL_SYS_CRITICAL TIMEOUT_URGENCY_SYS_CRITICAL | |
87 | #define TIMER_CALL_SYS_BACKGROUND TIMEOUT_URGENCY_SYS_BACKGROUND | |
39236c6e | 88 | |
0a7de745 A |
89 | #define TIMER_CALL_USER_MASK TIMEOUT_URGENCY_USER_MASK |
90 | #define TIMER_CALL_USER_NORMAL TIMEOUT_URGENCY_USER_NORMAL | |
91 | #define TIMER_CALL_USER_CRITICAL TIMEOUT_URGENCY_USER_CRITICAL | |
92 | #define TIMER_CALL_USER_BACKGROUND TIMEOUT_URGENCY_USER_BACKGROUND | |
39236c6e | 93 | |
0a7de745 | 94 | #define TIMER_CALL_URGENCY_MASK TIMEOUT_URGENCY_MASK |
39236c6e A |
95 | |
96 | /* | |
97 | * Indicate that a specific leeway value is being provided (otherwise | |
98 | * the leeway parameter is ignored). This supplied value can currently | |
99 | * only be used to extend the leeway calculated internally from the | |
100 | * urgency class provided. | |
101 | */ | |
0a7de745 | 102 | #define TIMER_CALL_LEEWAY TIMEOUT_URGENCY_LEEWAY |
39236c6e A |
103 | |
104 | /* | |
105 | * Non-migratable timer_call | |
106 | */ | |
0a7de745 A |
107 | #define TIMER_CALL_LOCAL TIMEOUT_URGENCY_FIRST_AVAIL |
108 | #define TIMER_CALL_RATELIMITED TIMEOUT_URGENCY_RATELIMITED | |
109 | extern boolean_t timer_call_enter( | |
110 | timer_call_t call, | |
111 | uint64_t deadline, | |
112 | uint32_t flags); | |
113 | ||
114 | extern boolean_t timer_call_enter1( | |
115 | timer_call_t call, | |
116 | timer_call_param_t param1, | |
117 | uint64_t deadline, | |
118 | uint32_t flags); | |
119 | ||
120 | extern boolean_t timer_call_enter_with_leeway( | |
121 | timer_call_t call, | |
122 | timer_call_param_t param1, | |
123 | uint64_t deadline, | |
124 | uint64_t leeway, | |
125 | uint32_t flags, | |
126 | boolean_t ratelimited); | |
127 | ||
128 | extern boolean_t timer_call_quantum_timer_enter( | |
129 | timer_call_t call, | |
130 | timer_call_param_t param1, | |
131 | uint64_t deadline, | |
132 | uint64_t ctime); | |
133 | ||
134 | extern boolean_t timer_call_cancel( | |
135 | timer_call_t call); | |
136 | ||
137 | extern boolean_t timer_call_quantum_timer_cancel( | |
138 | timer_call_t call); | |
139 | ||
140 | extern void timer_call_init(void); | |
141 | ||
142 | extern void timer_call_setup( | |
143 | timer_call_t call, | |
144 | timer_call_func_t func, | |
145 | timer_call_param_t param0); | |
9bccf70c | 146 | |
fe8ab488 A |
147 | extern int timer_get_user_idle_level(void); |
148 | extern kern_return_t timer_set_user_idle_level(int ilevel); | |
149 | ||
150 | #define NUM_LATENCY_QOS_TIERS (6) | |
151 | typedef struct { | |
152 | uint32_t powergate_latency_abstime; | |
153 | ||
154 | uint32_t idle_entry_timer_processing_hdeadline_threshold_abstime; | |
155 | uint32_t interrupt_timer_coalescing_ilat_threshold_abstime; | |
156 | uint32_t timer_resort_threshold_abstime; | |
157 | ||
158 | int32_t timer_coalesce_rt_shift; | |
159 | int32_t timer_coalesce_bg_shift; | |
160 | int32_t timer_coalesce_kt_shift; | |
161 | int32_t timer_coalesce_fp_shift; | |
162 | int32_t timer_coalesce_ts_shift; | |
163 | ||
164 | uint64_t timer_coalesce_rt_abstime_max; | |
165 | uint64_t timer_coalesce_bg_abstime_max; | |
166 | uint64_t timer_coalesce_kt_abstime_max; | |
167 | uint64_t timer_coalesce_fp_abstime_max; | |
168 | uint64_t timer_coalesce_ts_abstime_max; | |
169 | ||
170 | uint32_t latency_qos_scale[NUM_LATENCY_QOS_TIERS]; | |
171 | uint64_t latency_qos_abstime_max[NUM_LATENCY_QOS_TIERS]; | |
172 | boolean_t latency_tier_rate_limited[NUM_LATENCY_QOS_TIERS]; | |
173 | } timer_coalescing_priority_params_t; | |
174 | extern timer_coalescing_priority_params_t tcoal_prio_params; | |
175 | ||
39236c6e | 176 | #endif /* XNU_KERNEL_PRIVATE */ |
1c79356b A |
177 | |
178 | #endif /* _KERN_TIMER_CALL_H_ */ |