]>
Commit | Line | Data |
---|---|---|
c910b4d9 A |
1 | /* |
2 | * Copyright (c) 2008 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 | * Timer queue support routines. | |
30 | */ | |
31 | ||
32 | #ifndef _KERN_TIMER_QUEUE_H_ | |
33 | #define _KERN_TIMER_QUEUE_H_ | |
34 | ||
35 | #include <mach/mach_types.h> | |
36 | ||
37 | #ifdef MACH_KERNEL_PRIVATE | |
38 | ||
39 | #include <kern/queue.h> | |
40 | ||
39236c6e A |
41 | /* Kernel trace events associated with timers and timer queues */ |
42 | #define DECR_TRAP_LATENCY MACHDBG_CODE(DBG_MACH_EXCP_DECI, 0) | |
43 | #define DECR_SET_DEADLINE MACHDBG_CODE(DBG_MACH_EXCP_DECI, 1) | |
44 | #define DECR_TIMER_CALLOUT MACHDBG_CODE(DBG_MACH_EXCP_DECI, 2) | |
45 | #define DECR_PM_DEADLINE MACHDBG_CODE(DBG_MACH_EXCP_DECI, 3) | |
46 | #define DECR_TIMER_MIGRATE MACHDBG_CODE(DBG_MACH_EXCP_DECI, 4) | |
47 | #if defined(i386) || defined(x86_64) | |
48 | #define DECR_RDHPET MACHDBG_CODE(DBG_MACH_EXCP_DECI, 5) | |
49 | #define DECR_SET_TSC_DEADLINE MACHDBG_CODE(DBG_MACH_EXCP_DECI, 6) | |
fe8ab488 | 50 | #define DECR_SET_APIC_DEADLINE MACHDBG_CODE(DBG_MACH_EXCP_DECI, 16) |
39236c6e A |
51 | #endif |
52 | #define DECR_TIMER_ENTER MACHDBG_CODE(DBG_MACH_EXCP_DECI, 7) | |
53 | #define DECR_TIMER_CANCEL MACHDBG_CODE(DBG_MACH_EXCP_DECI, 8) | |
54 | #define DECR_TIMER_QUEUE MACHDBG_CODE(DBG_MACH_EXCP_DECI, 9) | |
55 | #define DECR_TIMER_EXPIRE MACHDBG_CODE(DBG_MACH_EXCP_DECI,10) | |
56 | #define DECR_TIMER_ASYNC_DEQ MACHDBG_CODE(DBG_MACH_EXCP_DECI,11) | |
57 | #define DECR_TIMER_UPDATE MACHDBG_CODE(DBG_MACH_EXCP_DECI,12) | |
58 | #define DECR_TIMER_ESCALATE MACHDBG_CODE(DBG_MACH_EXCP_DECI,13) | |
59 | #define DECR_TIMER_OVERDUE MACHDBG_CODE(DBG_MACH_EXCP_DECI,14) | |
60 | #define DECR_TIMER_RESCAN MACHDBG_CODE(DBG_MACH_EXCP_DECI,15) | |
61 | ||
c910b4d9 A |
62 | /* |
63 | * Invoked by kernel, implemented by platform. | |
64 | */ | |
65 | ||
66 | /* Request an expiration deadline, returns queue association */ | |
39236c6e | 67 | extern mpqueue_head_t * timer_queue_assign( |
6d2010ae A |
68 | uint64_t deadline); |
69 | ||
70 | extern uint64_t timer_call_slop( | |
39236c6e A |
71 | uint64_t deadline, |
72 | uint64_t armtime, | |
73 | uint32_t urgency, | |
74 | thread_t arming_thread, | |
75 | boolean_t *rlimited); | |
76 | extern boolean_t timer_resort_threshold(uint64_t); | |
c910b4d9 A |
77 | |
78 | /* Cancel an associated expiration deadline and specify new deadline */ | |
6d2010ae A |
79 | extern void timer_queue_cancel( |
80 | mpqueue_head_t *queue, | |
81 | uint64_t deadline, | |
82 | uint64_t new_deadline); | |
c910b4d9 | 83 | |
39236c6e A |
84 | /* Return a pointer to the local timer queue for a given cpu */ |
85 | extern mpqueue_head_t * timer_queue_cpu( | |
86 | int cpu); | |
87 | ||
88 | /* Call a function with argument on a cpu */ | |
89 | extern void timer_call_cpu( | |
90 | int cpu, | |
91 | void (*fn)(void *), | |
92 | void *arg); | |
93 | ||
94 | /* Queue a function to be called with argument on a cpu */ | |
95 | extern void timer_call_nosync_cpu( | |
96 | int cpu, | |
97 | void (*fn)(void *), | |
98 | void *arg); | |
99 | ||
c910b4d9 A |
100 | /* |
101 | * Invoked by platform, implemented by kernel. | |
102 | */ | |
103 | ||
fe8ab488 A |
104 | /* |
105 | * Invoked by kernel, implemented by platform. | |
106 | */ | |
107 | ||
108 | #define NUM_LATENCY_QOS_TIERS (6) | |
109 | ||
110 | typedef struct { | |
111 | uint32_t idle_entry_timer_processing_hdeadline_threshold_ns; | |
112 | uint32_t interrupt_timer_coalescing_ilat_threshold_ns; | |
113 | uint32_t timer_resort_threshold_ns; | |
114 | ||
115 | int32_t timer_coalesce_rt_shift; | |
116 | int32_t timer_coalesce_bg_shift; | |
117 | int32_t timer_coalesce_kt_shift; | |
118 | int32_t timer_coalesce_fp_shift; | |
119 | int32_t timer_coalesce_ts_shift; | |
120 | ||
121 | uint64_t timer_coalesce_rt_ns_max; | |
122 | uint64_t timer_coalesce_bg_ns_max; | |
123 | uint64_t timer_coalesce_kt_ns_max; | |
124 | uint64_t timer_coalesce_fp_ns_max; | |
125 | uint64_t timer_coalesce_ts_ns_max; | |
126 | ||
127 | uint32_t latency_qos_scale[NUM_LATENCY_QOS_TIERS]; | |
128 | uint64_t latency_qos_ns_max[NUM_LATENCY_QOS_TIERS]; | |
129 | boolean_t latency_tier_rate_limited[NUM_LATENCY_QOS_TIERS]; | |
130 | } timer_coalescing_priority_params_ns_t; | |
131 | ||
132 | extern timer_coalescing_priority_params_ns_t * timer_call_get_priority_params(void); | |
133 | ||
134 | ||
135 | extern uint64_t timer_call_slop( | |
136 | uint64_t deadline, | |
137 | uint64_t armtime, | |
138 | uint32_t urgency, | |
139 | thread_t arming_thread, | |
140 | boolean_t *rlimited); | |
141 | ||
c910b4d9 A |
142 | /* Process deadline expiration for queue, returns new deadline */ |
143 | extern uint64_t timer_queue_expire( | |
6d2010ae A |
144 | mpqueue_head_t *queue, |
145 | uint64_t deadline); | |
c910b4d9 | 146 | |
39236c6e A |
147 | extern uint64_t timer_queue_expire_with_options( |
148 | mpqueue_head_t *, | |
149 | uint64_t, | |
150 | boolean_t); | |
151 | ||
c910b4d9 | 152 | /* Shutdown a timer queue and reassign existing activities */ |
6d2010ae A |
153 | extern void timer_queue_shutdown( |
154 | mpqueue_head_t *queue); | |
155 | ||
156 | /* Move timer requests from one queue to another */ | |
157 | extern int timer_queue_migrate( | |
158 | mpqueue_head_t *from, | |
159 | mpqueue_head_t *to); | |
c910b4d9 | 160 | |
39236c6e A |
161 | /* |
162 | * Invoked by platform, implemented by platfrom. | |
163 | */ | |
164 | ||
165 | extern void timer_intr(int inuser, uint64_t iaddr); | |
166 | ||
167 | #if defined(i386) || defined(x86_64) | |
168 | extern uint64_t setPop(uint64_t time); | |
169 | #else | |
170 | extern int setPop(uint64_t time); | |
171 | #endif | |
172 | ||
173 | extern void timer_resync_deadlines(void); | |
174 | ||
175 | extern void timer_set_deadline(uint64_t deadline); | |
176 | ||
177 | /* Migrate the local timer queue of a given cpu to the master cpu */ | |
178 | extern uint32_t timer_queue_migrate_cpu(int target_cpu); | |
179 | ||
180 | extern void timer_queue_trace( | |
181 | mpqueue_head_t *queue); | |
182 | extern void timer_queue_trace_cpu(int cpu); | |
183 | ||
184 | extern uint64_t timer_sysctl_get(int oid); | |
185 | extern int timer_sysctl_set(int oid, uint64_t value); | |
186 | ||
c910b4d9 A |
187 | #endif /* MACH_KERNEL_PRIVATE */ |
188 | ||
189 | #endif /* _KERN_TIMER_QUEUE_H_ */ |