xref: /xnu-11215.41.3/osfmk/kern/machine.h (revision 33de042d024d46de5ff4e89f2471de6608e37fa4)
1 /*
2  * Copyright (c) 2000-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  * @OSF_COPYRIGHT@
30  */
31 
32 #ifndef _KERN_MACHINE_H_
33 #define _KERN_MACHINE_H_
34 
35 #include <mach/kern_return.h>
36 #include <mach/processor_info.h>
37 #include <kern/kern_types.h>
38 #include <kern/sched_urgency.h>
39 #include <kern/startup.h>
40 #include <kern/thread_group.h>
41 #include <kern/work_interval.h>
42 
43 
44 /*
45  * Machine support declarations.
46  */
47 
48 extern void processor_up(
49 	processor_t processor);
50 
51 extern void processor_start_thread(void *machine_param,
52     wait_result_t result);
53 
54 /*
55  * Must be implemented in machine dependent code.
56  */
57 
58 /* Initialize machine dependent ast code */
59 extern void init_ast_check(
60 	processor_t         processor);
61 
62 /* Cause check for ast */
63 extern void cause_ast_check(
64 	processor_t         processor);
65 
66 extern kern_return_t cpu_control(
67 	int                 slot_num,
68 	processor_info_t    info,
69 	unsigned int        count);
70 
71 extern void     cpu_sleep(void);
72 
73 extern void cpu_start(
74 	int                 slot_num);
75 
76 extern void cpu_exit_wait(
77 	int                 slot_num);
78 
79 extern kern_return_t cpu_info(
80 	processor_flavor_t  flavor,
81 	int                 slot_num,
82 	processor_info_t    info,
83 	unsigned int        *count);
84 
85 extern kern_return_t cpu_info_count(
86 	processor_flavor_t  flavor,
87 	unsigned int        *count);
88 
89 extern thread_t         machine_processor_shutdown(
90 	thread_t            thread,
91 	void                (*doshutdown)(processor_t),
92 	processor_t         processor);
93 
94 extern void machine_idle(void);
95 
96 extern void machine_track_platform_idle(boolean_t);
97 
98 /* Signals a processor to bring it out of idle */
99 extern void machine_signal_idle(
100 	processor_t         processor);
101 
102 /* Signals a processor to bring it out of idle unless canceled */
103 extern void machine_signal_idle_deferred(
104 	processor_t         processor);
105 
106 /* Cancels an outstanding machine_signal_idle_deferred, if this is supported */
107 extern void machine_signal_idle_cancel(
108 	processor_t         processor);
109 
110 extern void halt_cpu(void);
111 
112 extern void halt_all_cpus(
113 	boolean_t           reboot);
114 
115 extern char *machine_boot_info(
116 	char                *buf,
117 	vm_size_t           buf_len);
118 
119 extern void consider_machine_collect(void);
120 
121 /*
122  * Machine-dependent routine to inform platform layer and external
123  * CPU power management about context switches
124  */
125 
126 extern void     machine_thread_going_on_core(thread_t   new_thread,
127     thread_urgency_t    urgency,
128     uint64_t        sched_latency,
129     uint64_t        same_pri_latency,
130     uint64_t        dispatch_time);
131 
132 extern void machine_thread_going_off_core(thread_t old_thread, boolean_t thread_terminating,
133     uint64_t last_dispatch, boolean_t thread_runnable);
134 
135 extern void machine_max_runnable_latency(uint64_t bg_max_latency,
136     uint64_t default_max_latency,
137     uint64_t realtime_max_latency);
138 
139 extern void machine_work_interval_notify(thread_t thread, struct kern_work_interval_args* kwi_args);
140 
141 
142 extern void machine_perfcontrol_deadline_passed(uint64_t deadline);
143 
144 extern void machine_switch_perfcontrol_context(perfcontrol_event event,
145     uint64_t timestamp,
146     uint32_t flags,
147     uint64_t new_thread_same_pri_latency,
148     thread_t old,
149     thread_t new);
150 
151 extern void machine_switch_perfcontrol_state_update(perfcontrol_event event,
152     uint64_t timestamp,
153     uint32_t flags,
154     thread_t thread);
155 
156 #if CONFIG_THREAD_GROUPS
157 extern void machine_thread_group_init(struct thread_group *tg);
158 extern void machine_thread_group_deinit(struct thread_group *tg);
159 extern void machine_thread_group_flags_update(struct thread_group *tg, uint32_t flags);
160 extern void machine_thread_group_blocked(struct thread_group *tg_blocked, struct thread_group *tg_blocking, uint32_t flags, thread_t blocked_thread);
161 extern void machine_thread_group_unblocked(struct thread_group *tg_unblocked, struct thread_group *tg_unblocking, uint32_t flags, thread_t unblocked_thread);
162 #endif
163 
164 #endif  /* _KERN_MACHINE_H_ */
165