]> git.saurik.com Git - apple/xnu.git/blame - osfmk/kern/timer_queue.h
xnu-2422.1.72.tar.gz
[apple/xnu.git] / osfmk / kern / timer_queue.h
CommitLineData
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)
50#endif
51#define DECR_TIMER_ENTER MACHDBG_CODE(DBG_MACH_EXCP_DECI, 7)
52#define DECR_TIMER_CANCEL MACHDBG_CODE(DBG_MACH_EXCP_DECI, 8)
53#define DECR_TIMER_QUEUE MACHDBG_CODE(DBG_MACH_EXCP_DECI, 9)
54#define DECR_TIMER_EXPIRE MACHDBG_CODE(DBG_MACH_EXCP_DECI,10)
55#define DECR_TIMER_ASYNC_DEQ MACHDBG_CODE(DBG_MACH_EXCP_DECI,11)
56#define DECR_TIMER_UPDATE MACHDBG_CODE(DBG_MACH_EXCP_DECI,12)
57#define DECR_TIMER_ESCALATE MACHDBG_CODE(DBG_MACH_EXCP_DECI,13)
58#define DECR_TIMER_OVERDUE MACHDBG_CODE(DBG_MACH_EXCP_DECI,14)
59#define DECR_TIMER_RESCAN MACHDBG_CODE(DBG_MACH_EXCP_DECI,15)
60
c910b4d9
A
61/*
62 * Invoked by kernel, implemented by platform.
63 */
64
65/* Request an expiration deadline, returns queue association */
39236c6e 66extern mpqueue_head_t * timer_queue_assign(
6d2010ae
A
67 uint64_t deadline);
68
69extern uint64_t timer_call_slop(
39236c6e
A
70 uint64_t deadline,
71 uint64_t armtime,
72 uint32_t urgency,
73 thread_t arming_thread,
74 boolean_t *rlimited);
75extern boolean_t timer_resort_threshold(uint64_t);
c910b4d9
A
76
77/* Cancel an associated expiration deadline and specify new deadline */
6d2010ae
A
78extern void timer_queue_cancel(
79 mpqueue_head_t *queue,
80 uint64_t deadline,
81 uint64_t new_deadline);
c910b4d9 82
39236c6e
A
83/* Return a pointer to the local timer queue for a given cpu */
84extern mpqueue_head_t * timer_queue_cpu(
85 int cpu);
86
87/* Call a function with argument on a cpu */
88extern void timer_call_cpu(
89 int cpu,
90 void (*fn)(void *),
91 void *arg);
92
93/* Queue a function to be called with argument on a cpu */
94extern void timer_call_nosync_cpu(
95 int cpu,
96 void (*fn)(void *),
97 void *arg);
98
c910b4d9
A
99/*
100 * Invoked by platform, implemented by kernel.
101 */
102
103/* Process deadline expiration for queue, returns new deadline */
104extern uint64_t timer_queue_expire(
6d2010ae
A
105 mpqueue_head_t *queue,
106 uint64_t deadline);
c910b4d9 107
39236c6e
A
108extern uint64_t timer_queue_expire_with_options(
109 mpqueue_head_t *,
110 uint64_t,
111 boolean_t);
112
c910b4d9 113/* Shutdown a timer queue and reassign existing activities */
6d2010ae
A
114extern void timer_queue_shutdown(
115 mpqueue_head_t *queue);
116
117/* Move timer requests from one queue to another */
118extern int timer_queue_migrate(
119 mpqueue_head_t *from,
120 mpqueue_head_t *to);
c910b4d9 121
39236c6e
A
122/*
123 * Invoked by platform, implemented by platfrom.
124 */
125
126extern void timer_intr(int inuser, uint64_t iaddr);
127
128#if defined(i386) || defined(x86_64)
129extern uint64_t setPop(uint64_t time);
130#else
131extern int setPop(uint64_t time);
132#endif
133
134extern void timer_resync_deadlines(void);
135
136extern void timer_set_deadline(uint64_t deadline);
137
138/* Migrate the local timer queue of a given cpu to the master cpu */
139extern uint32_t timer_queue_migrate_cpu(int target_cpu);
140
141extern void timer_queue_trace(
142 mpqueue_head_t *queue);
143extern void timer_queue_trace_cpu(int cpu);
144
145extern uint64_t timer_sysctl_get(int oid);
146extern int timer_sysctl_set(int oid, uint64_t value);
147
c910b4d9
A
148#endif /* MACH_KERNEL_PRIVATE */
149
150#endif /* _KERN_TIMER_QUEUE_H_ */