]>
Commit | Line | Data |
---|---|---|
8ad349bb A |
1 | /* |
2 | * Copyright (c) 2003 Apple Computer, Inc. All rights reserved. | |
3 | * | |
4 | * @APPLE_LICENSE_OSREFERENCE_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 | |
10 | * License may not be used to create, or enable the creation or | |
11 | * redistribution of, unlawful or unlicensed copies of an Apple operating | |
12 | * system, or to circumvent, violate, or enable the circumvention or | |
13 | * violation of, any terms of an Apple operating system software license | |
14 | * agreement. | |
15 | * | |
16 | * Please obtain a copy of the License at | |
17 | * http://www.opensource.apple.com/apsl/ and read it before using this | |
18 | * file. | |
19 | * | |
20 | * The Original Code and all software distributed under the License are | |
21 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER | |
22 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, | |
23 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, | |
24 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. | |
25 | * Please see the License for the specific language governing rights and | |
26 | * limitations under the License. | |
27 | * | |
28 | * @APPLE_LICENSE_OSREFERENCE_HEADER_END@ | |
29 | */ | |
30 | ||
31 | #ifndef _PPC_CHUD_XNU_H_ | |
32 | #define _PPC_CHUD_XNU_H_ | |
33 | ||
34 | ||
35 | #include <stdint.h> | |
36 | #include <mach/boolean.h> | |
37 | #include <mach/mach_types.h> | |
38 | ||
39 | #pragma mark **** version **** | |
40 | uint32_t chudxnu_version(void); | |
41 | ||
42 | #pragma mark **** task **** | |
43 | // ******************************************************************************** | |
44 | // task | |
45 | // ******************************************************************************** | |
46 | int chudxnu_pid_for_task(task_t task); | |
47 | task_t chudxnu_task_for_pid(int pid); | |
48 | int chudxnu_current_pid(void); | |
49 | ||
50 | kern_return_t chudxnu_task_read(task_t task, void *kernaddr, uint64_t usraddr, vm_size_t size); | |
51 | kern_return_t chudxnu_task_write(task_t task, uint64_t useraddr, void *kernaddr, vm_size_t size); | |
52 | kern_return_t chudxnu_kern_read(void *destaddr, vm_offset_t srcaddr, vm_size_t size); | |
53 | kern_return_t chudxnu_kern_write(vm_offset_t destaddr, void *srcaddr, vm_size_t size); | |
54 | ||
55 | boolean_t chudxnu_is_64bit_task(task_t task); | |
56 | ||
57 | #pragma mark **** thread **** | |
58 | // ******************************************************************************** | |
59 | // thread | |
60 | // ******************************************************************************** | |
61 | kern_return_t chudxnu_bind_thread(thread_t thread, int cpu); | |
62 | ||
63 | kern_return_t chudxnu_unbind_thread(thread_t thread); | |
64 | ||
65 | kern_return_t chudxnu_thread_get_state( thread_t thread, | |
66 | thread_flavor_t flavor, | |
67 | thread_state_t tstate, | |
68 | mach_msg_type_number_t *count, | |
69 | boolean_t user_only); | |
70 | ||
71 | kern_return_t chudxnu_thread_set_state( thread_t thread, | |
72 | thread_flavor_t flavor, | |
73 | thread_state_t tstate, | |
74 | mach_msg_type_number_t count, | |
75 | boolean_t user_only); | |
76 | ||
77 | kern_return_t chudxnu_thread_user_state_available(thread_t thread); | |
78 | ||
79 | ||
80 | kern_return_t chudxnu_thread_get_callstack( thread_t thread, | |
81 | uint32_t *callStack, | |
82 | mach_msg_type_number_t *count, | |
83 | boolean_t user_only); | |
84 | ||
85 | kern_return_t chudxnu_thread_get_callstack64(thread_t thread, | |
86 | uint64_t *callStack, | |
87 | mach_msg_type_number_t *count, | |
88 | boolean_t user_only); | |
89 | ||
90 | task_t chudxnu_current_task(void); | |
91 | thread_t chudxnu_current_thread(void); | |
92 | ||
93 | task_t chudxnu_task_for_thread(thread_t thread); | |
94 | ||
95 | kern_return_t chudxnu_all_tasks(task_array_t *task_list, | |
96 | mach_msg_type_number_t *count); | |
97 | kern_return_t chudxnu_free_task_list(task_array_t *task_list, | |
98 | mach_msg_type_number_t *count); | |
99 | ||
100 | kern_return_t chudxnu_all_threads( thread_array_t *thread_list, | |
101 | mach_msg_type_number_t *count); | |
102 | kern_return_t chudxnu_task_threads( task_t task, | |
103 | thread_array_t *thread_list, | |
104 | mach_msg_type_number_t *count); | |
105 | kern_return_t chudxnu_free_thread_list(thread_array_t *thread_list, | |
106 | mach_msg_type_number_t *count); | |
107 | ||
108 | kern_return_t chudxnu_thread_info( thread_t thread, | |
109 | thread_flavor_t flavor, | |
110 | thread_info_t thread_info_out, | |
111 | mach_msg_type_number_t *thread_info_count); | |
112 | ||
113 | kern_return_t chudxnu_thread_last_context_switch(thread_t thread, uint64_t *timestamp); | |
114 | ||
115 | ||
116 | #pragma mark **** memory **** | |
117 | // ******************************************************************************** | |
118 | // memory | |
119 | // ******************************************************************************** | |
120 | ||
121 | uint64_t chudxnu_avail_memory_size(void); | |
122 | uint64_t chudxnu_phys_memory_size(void); | |
123 | ||
124 | vm_offset_t chudxnu_io_map(uint64_t phys_addr, vm_size_t size); | |
125 | ||
126 | uint32_t chudxnu_phys_addr_wimg(uint64_t phys_addr); | |
127 | ||
128 | #pragma mark **** cpu **** | |
129 | // ******************************************************************************** | |
130 | // cpu | |
131 | // ******************************************************************************** | |
132 | int chudxnu_avail_cpu_count(void); | |
133 | int chudxnu_phys_cpu_count(void); | |
134 | int chudxnu_cpu_number(void); | |
135 | ||
136 | kern_return_t chudxnu_enable_cpu(int cpu, boolean_t enable); | |
137 | ||
138 | kern_return_t chudxnu_enable_cpu_nap(int cpu, boolean_t enable); | |
139 | boolean_t chudxnu_cpu_nap_enabled(int cpu); | |
140 | ||
141 | boolean_t chudxnu_get_interrupts_enabled(void); | |
142 | boolean_t chudxnu_set_interrupts_enabled(boolean_t enable); | |
143 | boolean_t chudxnu_at_interrupt_context(void); | |
144 | void chudxnu_cause_interrupt(void); | |
145 | ||
146 | kern_return_t chudxnu_set_shadowed_spr(int cpu, int spr, uint32_t val); | |
147 | kern_return_t chudxnu_set_shadowed_spr64(int cpu, int spr, uint64_t val); | |
148 | ||
149 | uint32_t chudxnu_get_orig_cpu_l2cr(int cpu); | |
150 | uint32_t chudxnu_get_orig_cpu_l3cr(int cpu); | |
151 | ||
152 | kern_return_t chudxnu_read_spr(int cpu, int spr, uint32_t *val_p); | |
153 | kern_return_t chudxnu_read_spr64(int cpu, int spr, uint64_t *val_p); | |
154 | kern_return_t chudxnu_write_spr(int cpu, int spr, uint32_t val); | |
155 | kern_return_t chudxnu_write_spr64(int cpu, int spr, uint64_t val); | |
156 | ||
157 | void chudxnu_flush_caches(void); | |
158 | void chudxnu_enable_caches(boolean_t enable); | |
159 | ||
160 | kern_return_t chudxnu_perfmon_acquire_facility(task_t); | |
161 | kern_return_t chudxnu_perfmon_release_facility(task_t); | |
162 | ||
163 | uint32_t * chudxnu_get_branch_trace_buffer(uint32_t *entries); | |
164 | ||
165 | typedef struct { | |
166 | uint32_t hwResets; | |
167 | uint32_t hwMachineChecks; | |
168 | uint32_t hwDSIs; | |
169 | uint32_t hwISIs; | |
170 | uint32_t hwExternals; | |
171 | uint32_t hwAlignments; | |
172 | uint32_t hwPrograms; | |
173 | uint32_t hwFloatPointUnavailable; | |
174 | uint32_t hwDecrementers; | |
175 | uint32_t hwIOErrors; | |
176 | uint32_t hwSystemCalls; | |
177 | uint32_t hwTraces; | |
178 | uint32_t hwFloatingPointAssists; | |
179 | uint32_t hwPerformanceMonitors; | |
180 | uint32_t hwAltivecs; | |
181 | uint32_t hwInstBreakpoints; | |
182 | uint32_t hwSystemManagements; | |
183 | uint32_t hwAltivecAssists; | |
184 | uint32_t hwThermal; | |
185 | uint32_t hwSoftPatches; | |
186 | uint32_t hwMaintenances; | |
187 | uint32_t hwInstrumentations; | |
188 | } rupt_counters_t; | |
189 | ||
190 | kern_return_t chudxnu_get_cpu_rupt_counters(int cpu, rupt_counters_t *rupts); | |
191 | kern_return_t chudxnu_clear_cpu_rupt_counters(int cpu); | |
192 | ||
193 | kern_return_t chudxnu_passup_alignment_exceptions(boolean_t enable); | |
194 | ||
195 | kern_return_t chudxnu_scom_read(uint32_t reg, uint64_t *data); | |
196 | kern_return_t chudxnu_scom_write(uint32_t reg, uint64_t data); | |
197 | ||
198 | #pragma mark **** callbacks **** | |
199 | // ******************************************************************************** | |
200 | // callbacks | |
201 | // ******************************************************************************** | |
202 | ||
203 | void chudxnu_cancel_all_callbacks(void); | |
204 | ||
205 | // cpu timer - each cpu has its own callback | |
206 | typedef kern_return_t (*chudxnu_cpu_timer_callback_func_t)(thread_flavor_t flavor, thread_state_t tstate, mach_msg_type_number_t count); | |
207 | kern_return_t chudxnu_cpu_timer_callback_enter(chudxnu_cpu_timer_callback_func_t func, uint32_t time, uint32_t units); // callback is entered on current cpu | |
208 | kern_return_t chudxnu_cpu_timer_callback_cancel(void); // callback is cleared on current cpu | |
209 | kern_return_t chudxnu_cpu_timer_callback_cancel_all(void); // callback is cleared on all cpus | |
210 | ||
211 | // trap callback - one callback for system | |
212 | typedef kern_return_t (*chudxnu_trap_callback_func_t)(uint32_t trapentry, thread_flavor_t flavor, thread_state_t tstate, mach_msg_type_number_t count); | |
213 | kern_return_t chudxnu_trap_callback_enter(chudxnu_trap_callback_func_t func); | |
214 | kern_return_t chudxnu_trap_callback_cancel(void); | |
215 | ||
216 | // interrupt callback - one callback for system | |
217 | typedef kern_return_t (*chudxnu_interrupt_callback_func_t)(uint32_t trapentry, thread_flavor_t flavor, thread_state_t tstate, mach_msg_type_number_t count); | |
218 | kern_return_t chudxnu_interrupt_callback_enter(chudxnu_interrupt_callback_func_t func); | |
219 | kern_return_t chudxnu_interrupt_callback_cancel(void); | |
220 | ||
221 | // ast callback - one callback for system | |
222 | typedef kern_return_t (*chudxnu_perfmon_ast_callback_func_t)(thread_flavor_t flavor, thread_state_t tstate, mach_msg_type_number_t count); | |
223 | kern_return_t chudxnu_perfmon_ast_callback_enter(chudxnu_perfmon_ast_callback_func_t func); | |
224 | kern_return_t chudxnu_perfmon_ast_callback_cancel(void); | |
225 | kern_return_t chudxnu_perfmon_ast_send(void); | |
226 | kern_return_t chudxnu_perfmon_ast_send_urgent(boolean_t urgent); | |
227 | ||
228 | // cpusig callback - one callback for system | |
229 | typedef kern_return_t (*chudxnu_cpusig_callback_func_t)(int request, thread_flavor_t flavor, thread_state_t tstate, mach_msg_type_number_t count); | |
230 | kern_return_t chudxnu_cpusig_callback_enter(chudxnu_cpusig_callback_func_t func); | |
231 | kern_return_t chudxnu_cpusig_callback_cancel(void); | |
232 | kern_return_t chudxnu_cpusig_send(int otherCPU, uint32_t request); | |
233 | ||
234 | // kdebug callback - one callback for system | |
235 | typedef kern_return_t (*chudxnu_kdebug_callback_func_t)(uint32_t debugid, uint32_t arg0, uint32_t arg1, uint32_t arg2, uint32_t arg3, uint32_t arg4); | |
236 | kern_return_t chudxnu_kdebug_callback_enter(chudxnu_kdebug_callback_func_t func); | |
237 | kern_return_t chudxnu_kdebug_callback_cancel(void); | |
238 | ||
239 | // timer callback - multiple callbacks | |
240 | typedef kern_return_t (*chudxnu_timer_callback_func_t)(uint32_t param0, uint32_t param1); | |
241 | typedef void * chud_timer_t; | |
242 | chud_timer_t chudxnu_timer_alloc(chudxnu_timer_callback_func_t func, uint32_t param0); | |
243 | kern_return_t chudxnu_timer_callback_enter(chud_timer_t timer, uint32_t param1, uint32_t time, uint32_t units); | |
244 | kern_return_t chudxnu_timer_callback_cancel(chud_timer_t timer); | |
245 | kern_return_t chudxnu_timer_free(chud_timer_t timer); | |
246 | ||
247 | // CHUD systemcall callback - one callback for system | |
248 | typedef kern_return_t (*chudxnu_syscall_callback_func_t)(thread_flavor_t flavor, thread_state_t tstate, mach_msg_type_number_t count); | |
249 | kern_return_t chudxnu_syscall_callback_enter(chudxnu_syscall_callback_func_t func); | |
250 | kern_return_t chudxnu_syscall_callback_cancel(void); | |
251 | ||
252 | // ******************************************************************************** | |
253 | // DEPRECATED | |
254 | // ******************************************************************************** | |
255 | kern_return_t chudxnu_bind_current_thread(int cpu); | |
256 | ||
257 | kern_return_t chudxnu_unbind_current_thread(void); | |
258 | ||
259 | kern_return_t chudxnu_current_thread_get_callstack(uint32_t *callStack, | |
260 | mach_msg_type_number_t *count, | |
261 | boolean_t user_only); | |
262 | ||
263 | thread_t chudxnu_current_act(void); | |
264 | ||
265 | // thread timer callback - one callback for system | |
266 | typedef kern_return_t (*chudxnu_thread_timer_callback_func_t)(uint32_t param); | |
267 | kern_return_t chudxnu_thread_timer_callback_enter(chudxnu_thread_timer_callback_func_t func, uint32_t param, uint32_t time, uint32_t units); | |
268 | kern_return_t chudxnu_thread_timer_callback_cancel(void); | |
269 | ||
270 | #endif /* _PPC_CHUD_XNU_H_ */ |