]> git.saurik.com Git - apple/xnu.git/blob - osfmk/ppc/chud/chud_xnu.h
xnu-517.tar.gz
[apple/xnu.git] / osfmk / ppc / chud / chud_xnu.h
1 /*
2 * Copyright (c) 2003 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
6 * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
7 *
8 * This file contains Original Code and/or Modifications of Original Code
9 * as defined in and that are subject to the Apple Public Source License
10 * Version 2.0 (the 'License'). You may not use this file except in
11 * compliance with the License. Please obtain a copy of the License at
12 * http://www.opensource.apple.com/apsl/ and read it before using this
13 * file.
14 *
15 * The Original Code and all software distributed under the License are
16 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
17 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
18 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
20 * Please see the License for the specific language governing rights and
21 * limitations under the License.
22 *
23 * @APPLE_LICENSE_HEADER_END@
24 */
25
26 #ifndef _PPC_CHUD_XNU_H_
27 #define _PPC_CHUD_XNU_H_
28
29
30 #include <stdint.h>
31 #include <mach/boolean.h>
32 #include <mach/mach_types.h>
33
34 #pragma mark **** process ****
35 // ********************************************************************************
36 // process
37 // ********************************************************************************
38 int chudxnu_pid_for_task(task_t task);
39 task_t chudxnu_task_for_pid(int pid);
40 int chudxnu_current_pid(void);
41
42 #pragma mark **** thread ****
43 // ********************************************************************************
44 // thread
45 // ********************************************************************************
46 kern_return_t chudxnu_bind_current_thread(int cpu);
47
48 kern_return_t chudxnu_unbind_current_thread(void);
49
50 kern_return_t chudxnu_thread_get_state(thread_act_t thr_act,
51 thread_flavor_t flavor,
52 thread_state_t tstate,
53 mach_msg_type_number_t *count,
54 boolean_t user_only);
55
56 kern_return_t chudxnu_thread_set_state(thread_act_t thr_act,
57 thread_flavor_t flavor,
58 thread_state_t tstate,
59 mach_msg_type_number_t count,
60 boolean_t user_only);
61
62 kern_return_t chudxnu_current_thread_get_callstack(uint32_t *callStack,
63 mach_msg_type_number_t *count,
64 boolean_t user_only);
65
66 task_t chudxnu_current_task(void);
67
68 thread_act_t chudxnu_current_act(void);
69
70 int chudxnu_task_threads(task_t task,
71 thread_act_array_t *thr_act_list,
72 mach_msg_type_number_t *count);
73
74 kern_return_t chudxnu_thread_info(thread_act_t thr_act,
75 thread_flavor_t flavor,
76 thread_info_t thread_info_out,
77 mach_msg_type_number_t *thread_info_count);
78
79 #pragma mark **** memory ****
80 // ********************************************************************************
81 // memory
82 // ********************************************************************************
83
84 uint64_t chudxnu_avail_memory_size(void);
85 uint64_t chudxnu_phys_memory_size(void);
86
87 vm_offset_t chudxnu_io_map(uint64_t phys_addr, vm_size_t size);
88
89 uint32_t chudxnu_phys_addr_wimg(uint64_t phys_addr);
90
91 #pragma mark **** cpu ****
92 // ********************************************************************************
93 // cpu
94 // ********************************************************************************
95 int chudxnu_avail_cpu_count(void);
96 int chudxnu_phys_cpu_count(void);
97 int chudxnu_cpu_number(void);
98
99 kern_return_t chudxnu_enable_cpu(int cpu, boolean_t enable);
100
101 kern_return_t chudxnu_enable_cpu_nap(int cpu, boolean_t enable);
102 boolean_t chudxnu_cpu_nap_enabled(int cpu);
103
104 boolean_t chudxnu_get_interrupts_enabled(void);
105 boolean_t chudxnu_set_interrupts_enabled(boolean_t enable);
106 boolean_t chudxnu_at_interrupt_context(void);
107 void chudxnu_cause_interrupt(void);
108
109 kern_return_t chudxnu_set_shadowed_spr(int cpu, int spr, uint32_t val);
110 kern_return_t chudxnu_set_shadowed_spr64(int cpu, int spr, uint64_t val);
111
112 uint32_t chudxnu_get_orig_cpu_l2cr(int cpu);
113 uint32_t chudxnu_get_orig_cpu_l3cr(int cpu);
114
115 void chudxnu_flush_caches(void);
116 void chudxnu_enable_caches(boolean_t enable);
117
118 kern_return_t chudxnu_perfmon_acquire_facility(task_t);
119 kern_return_t chudxnu_perfmon_release_facility(task_t);
120
121 uint32_t * chudxnu_get_branch_trace_buffer(uint32_t *entries);
122
123 typedef struct {
124 uint32_t hwResets;
125 uint32_t hwMachineChecks;
126 uint32_t hwDSIs;
127 uint32_t hwISIs;
128 uint32_t hwExternals;
129 uint32_t hwAlignments;
130 uint32_t hwPrograms;
131 uint32_t hwFloatPointUnavailable;
132 uint32_t hwDecrementers;
133 uint32_t hwIOErrors;
134 uint32_t hwSystemCalls;
135 uint32_t hwTraces;
136 uint32_t hwFloatingPointAssists;
137 uint32_t hwPerformanceMonitors;
138 uint32_t hwAltivecs;
139 uint32_t hwInstBreakpoints;
140 uint32_t hwSystemManagements;
141 uint32_t hwAltivecAssists;
142 uint32_t hwThermal;
143 uint32_t hwSoftPatches;
144 uint32_t hwMaintenances;
145 uint32_t hwInstrumentations;
146 } rupt_counters_t;
147
148 kern_return_t chudxnu_get_cpu_rupt_counters(int cpu, rupt_counters_t *rupts);
149 kern_return_t chudxnu_clear_cpu_rupt_counters(int cpu);
150
151 kern_return_t chudxnu_passup_alignment_exceptions(boolean_t enable);
152
153 #pragma mark **** callbacks ****
154 // ********************************************************************************
155 // callbacks
156 // ********************************************************************************
157
158 void chudxnu_cancel_all_callbacks(void);
159
160 // cpu timer - each cpu has its own callback
161 typedef kern_return_t (*chudxnu_cpu_timer_callback_func_t)(thread_flavor_t flavor, thread_state_t tstate, mach_msg_type_number_t count);
162 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
163 kern_return_t chudxnu_cpu_timer_callback_cancel(void); // callback is cleared on current cpu
164 kern_return_t chudxnu_cpu_timer_callback_cancel_all(void); // callback is cleared on all cpus
165
166 // trap callback - one callback for system
167 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);
168 kern_return_t chudxnu_trap_callback_enter(chudxnu_trap_callback_func_t func);
169 kern_return_t chudxnu_trap_callback_cancel(void);
170
171 // interrupt callback - one callback for system
172 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);
173 kern_return_t chudxnu_interrupt_callback_enter(chudxnu_interrupt_callback_func_t func);
174 kern_return_t chudxnu_interrupt_callback_cancel(void);
175
176 // ast callback - one callback for system
177 typedef kern_return_t (*chudxnu_perfmon_ast_callback_func_t)(thread_flavor_t flavor, thread_state_t tstate, mach_msg_type_number_t count);
178 kern_return_t chudxnu_perfmon_ast_callback_enter(chudxnu_perfmon_ast_callback_func_t func);
179 kern_return_t chudxnu_perfmon_ast_callback_cancel(void);
180 kern_return_t chudxnu_perfmon_ast_send(void);
181
182 // cpusig callback - one callback for system
183 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);
184 kern_return_t chudxnu_cpusig_callback_enter(chudxnu_cpusig_callback_func_t func);
185 kern_return_t chudxnu_cpusig_callback_cancel(void);
186 kern_return_t chudxnu_cpusig_send(int otherCPU, uint32_t request);
187
188 // kdebug callback - one callback for system
189 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);
190 kern_return_t chudxnu_kdebug_callback_enter(chudxnu_kdebug_callback_func_t func);
191 kern_return_t chudxnu_kdebug_callback_cancel(void);
192
193 // task exit callback - one callback for system
194 typedef kern_return_t (*chudxnu_exit_callback_func_t)(int pid);
195 kern_return_t chudxnu_exit_callback_enter(chudxnu_exit_callback_func_t func);
196 kern_return_t chudxnu_exit_callback_cancel(void);
197
198 // thread timer callback - one callback for system
199 typedef kern_return_t (*chudxnu_thread_timer_callback_func_t)(uint32_t arg);
200 kern_return_t chudxnu_thread_timer_callback_enter(chudxnu_thread_timer_callback_func_t func, uint32_t arg, uint32_t time, uint32_t units);
201 kern_return_t chudxnu_thread_timer_callback_cancel(void);
202
203
204 #endif /* _PPC_CHUD_XNU_H_ */