2 * Copyright (c) 2003 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
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.
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
20 * @APPLE_LICENSE_HEADER_END@
23 #ifndef _PPC_CHUD_XNU_H_
24 #define _PPC_CHUD_XNU_H_
28 #include <mach/boolean.h>
29 #include <mach/mach_types.h>
31 #pragma mark **** process ****
32 // ********************************************************************************
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);
39 #pragma mark **** thread ****
40 // ********************************************************************************
42 // ********************************************************************************
43 kern_return_t
chudxnu_bind_current_thread(int cpu
);
45 kern_return_t
chudxnu_unbind_current_thread(void);
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
,
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
,
59 kern_return_t
chudxnu_current_thread_get_callstack(uint32_t *callStack
,
60 mach_msg_type_number_t
*count
,
63 task_t
chudxnu_current_task(void);
65 thread_act_t
chudxnu_current_act(void);
67 int chudxnu_task_threads(task_t task
,
68 thread_act_array_t
*thr_act_list
,
69 mach_msg_type_number_t
*count
);
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
);
76 #pragma mark **** memory ****
77 // ********************************************************************************
79 // ********************************************************************************
81 uint64_t chudxnu_avail_memory_size(void);
82 uint64_t chudxnu_phys_memory_size(void);
84 vm_offset_t
chudxnu_io_map(uint64_t phys_addr
, vm_size_t size
);
86 uint32_t chudxnu_phys_addr_wimg(uint64_t phys_addr
);
88 #pragma mark **** cpu ****
89 // ********************************************************************************
91 // ********************************************************************************
92 int chudxnu_avail_cpu_count(void);
93 int chudxnu_phys_cpu_count(void);
94 int chudxnu_cpu_number(void);
96 kern_return_t
chudxnu_enable_cpu(int cpu
, boolean_t enable
);
98 kern_return_t
chudxnu_enable_cpu_nap(int cpu
, boolean_t enable
);
99 boolean_t
chudxnu_cpu_nap_enabled(int cpu
);
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);
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
);
109 uint32_t chudxnu_get_orig_cpu_l2cr(int cpu
);
110 uint32_t chudxnu_get_orig_cpu_l3cr(int cpu
);
112 void chudxnu_flush_caches(void);
113 void chudxnu_enable_caches(boolean_t enable
);
115 kern_return_t
chudxnu_perfmon_acquire_facility(task_t
);
116 kern_return_t
chudxnu_perfmon_release_facility(task_t
);
118 uint32_t * chudxnu_get_branch_trace_buffer(uint32_t *entries
);
122 uint32_t hwMachineChecks
;
125 uint32_t hwExternals
;
126 uint32_t hwAlignments
;
128 uint32_t hwFloatPointUnavailable
;
129 uint32_t hwDecrementers
;
131 uint32_t hwSystemCalls
;
133 uint32_t hwFloatingPointAssists
;
134 uint32_t hwPerformanceMonitors
;
136 uint32_t hwInstBreakpoints
;
137 uint32_t hwSystemManagements
;
138 uint32_t hwAltivecAssists
;
140 uint32_t hwSoftPatches
;
141 uint32_t hwMaintenances
;
142 uint32_t hwInstrumentations
;
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
);
148 kern_return_t
chudxnu_passup_alignment_exceptions(boolean_t enable
);
150 #pragma mark **** callbacks ****
151 // ********************************************************************************
153 // ********************************************************************************
155 void chudxnu_cancel_all_callbacks(void);
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
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);
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);
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);
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
);
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);
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);
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);
201 #endif /* _PPC_CHUD_XNU_H_ */