2 * Copyright (c) 2003 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
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
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.
23 * @APPLE_LICENSE_HEADER_END@
26 #ifndef _PPC_CHUD_XNU_H_
27 #define _PPC_CHUD_XNU_H_
31 #include <mach/boolean.h>
32 #include <mach/mach_types.h>
34 #pragma mark **** process ****
35 // ********************************************************************************
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);
42 #pragma mark **** thread ****
43 // ********************************************************************************
45 // ********************************************************************************
46 kern_return_t
chudxnu_bind_current_thread(int cpu
);
48 kern_return_t
chudxnu_unbind_current_thread(void);
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
,
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
,
62 kern_return_t
chudxnu_current_thread_get_callstack(uint32_t *callStack
,
63 mach_msg_type_number_t
*count
,
66 task_t
chudxnu_current_task(void);
68 thread_act_t
chudxnu_current_act(void);
70 int chudxnu_task_threads(task_t task
,
71 thread_act_array_t
*thr_act_list
,
72 mach_msg_type_number_t
*count
);
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
);
79 #pragma mark **** memory ****
80 // ********************************************************************************
82 // ********************************************************************************
84 uint64_t chudxnu_avail_memory_size(void);
85 uint64_t chudxnu_phys_memory_size(void);
87 vm_offset_t
chudxnu_io_map(uint64_t phys_addr
, vm_size_t size
);
89 uint32_t chudxnu_phys_addr_wimg(uint64_t phys_addr
);
91 #pragma mark **** cpu ****
92 // ********************************************************************************
94 // ********************************************************************************
95 int chudxnu_avail_cpu_count(void);
96 int chudxnu_phys_cpu_count(void);
97 int chudxnu_cpu_number(void);
99 kern_return_t
chudxnu_enable_cpu(int cpu
, boolean_t enable
);
101 kern_return_t
chudxnu_enable_cpu_nap(int cpu
, boolean_t enable
);
102 boolean_t
chudxnu_cpu_nap_enabled(int cpu
);
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);
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
);
112 uint32_t chudxnu_get_orig_cpu_l2cr(int cpu
);
113 uint32_t chudxnu_get_orig_cpu_l3cr(int cpu
);
115 void chudxnu_flush_caches(void);
116 void chudxnu_enable_caches(boolean_t enable
);
118 kern_return_t
chudxnu_perfmon_acquire_facility(task_t
);
119 kern_return_t
chudxnu_perfmon_release_facility(task_t
);
121 uint32_t * chudxnu_get_branch_trace_buffer(uint32_t *entries
);
125 uint32_t hwMachineChecks
;
128 uint32_t hwExternals
;
129 uint32_t hwAlignments
;
131 uint32_t hwFloatPointUnavailable
;
132 uint32_t hwDecrementers
;
134 uint32_t hwSystemCalls
;
136 uint32_t hwFloatingPointAssists
;
137 uint32_t hwPerformanceMonitors
;
139 uint32_t hwInstBreakpoints
;
140 uint32_t hwSystemManagements
;
141 uint32_t hwAltivecAssists
;
143 uint32_t hwSoftPatches
;
144 uint32_t hwMaintenances
;
145 uint32_t hwInstrumentations
;
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
);
151 kern_return_t
chudxnu_passup_alignment_exceptions(boolean_t enable
);
153 #pragma mark **** callbacks ****
154 // ********************************************************************************
156 // ********************************************************************************
158 void chudxnu_cancel_all_callbacks(void);
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
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);
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);
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);
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
);
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);
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);
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);
204 #endif /* _PPC_CHUD_XNU_H_ */