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