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