X-Git-Url: https://git.saurik.com/apple/xnu.git/blobdiff_plain/0c530ab8987f0ae6a1a3d9284f40182b88852816..e2fac8b15b12a7979f72090454d850e612fc5b13:/osfmk/chud/chud_xnu.h?ds=sidebyside diff --git a/osfmk/chud/chud_xnu.h b/osfmk/chud/chud_xnu.h index 992aa65f3..9577e8088 100644 --- a/osfmk/chud/chud_xnu.h +++ b/osfmk/chud/chud_xnu.h @@ -1,29 +1,34 @@ /* - * Copyright (c) 2003 Apple Computer, Inc. All rights reserved. + * Copyright (c) 2003-2007 Apple Inc. All rights reserved. * - * @APPLE_LICENSE_HEADER_START@ + * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ * - * The contents of this file constitute Original Code as defined in and - * are subject to the Apple Public Source License Version 1.1 (the - * "License"). You may not use this file except in compliance with the - * License. Please obtain a copy of the License at - * http://www.apple.com/publicsource and read it before using this file. + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. The rights granted to you under the License + * may not be used to create, or enable the creation or redistribution of, + * unlawful or unlicensed copies of an Apple operating system, or to + * circumvent, violate, or enable the circumvention or violation of, any + * terms of an Apple operating system software license agreement. * - * This Original Code and all software distributed under the License are - * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this file. + * + * The Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License. + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * - * @APPLE_LICENSE_HEADER_END@ + * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ */ #ifndef _CHUD_XNU_H_ #define _CHUD_XNU_H_ - #include #include #include @@ -50,14 +55,13 @@ extern boolean_t chudxnu_is_64bit_task(task_t task); // ******************************************************************************** // thread // ******************************************************************************** -extern kern_return_t chudxnu_bind_thread(thread_t thread, int cpu); -extern kern_return_t chudxnu_unbind_thread(thread_t thread); +extern kern_return_t chudxnu_bind_thread(thread_t thread, int cpu, int options); +extern kern_return_t chudxnu_unbind_thread(thread_t thread, int options); extern kern_return_t chudxnu_thread_get_state(thread_t thread, thread_flavor_t flavor, thread_state_t tstate, mach_msg_type_number_t *count, boolean_t user_only); extern kern_return_t chudxnu_thread_set_state(thread_t thread, thread_flavor_t flavor, thread_state_t tstate, mach_msg_type_number_t count, boolean_t user_only); extern kern_return_t chudxnu_thread_user_state_available(thread_t thread); -extern kern_return_t chudxnu_thread_get_callstack(thread_t thread, uint32_t *callStack, mach_msg_type_number_t *count, boolean_t user_only); extern kern_return_t chudxnu_thread_get_callstack64(thread_t thread, uint64_t *callStack, mach_msg_type_number_t *count, boolean_t user_only); extern task_t chudxnu_current_task(void); @@ -76,6 +80,10 @@ extern kern_return_t chudxnu_thread_info( thread_t thread, thread_flavor_t flav extern kern_return_t chudxnu_thread_last_context_switch(thread_t thread, uint64_t *timestamp); +extern boolean_t chudxnu_thread_set_marked(thread_t thread, boolean_t marked); +extern boolean_t chudxnu_thread_get_marked(thread_t thread); +extern boolean_t chudxnu_thread_get_idle(thread_t thread); + #pragma mark **** memory **** // ******************************************************************************** // memory @@ -84,24 +92,18 @@ extern kern_return_t chudxnu_thread_last_context_switch(thread_t thread, uint64_ extern uint64_t chudxnu_avail_memory_size(void); extern uint64_t chudxnu_phys_memory_size(void); extern uint64_t chudxnu_free_memory_size(void); - -extern vm_offset_t chudxnu_io_map(uint64_t phys_addr, vm_size_t size); - -extern uint32_t chudxnu_phys_addr_wimg(uint64_t phys_addr); +extern uint64_t chudxnu_inactive_memory_size(void); #pragma mark **** cpu **** // ******************************************************************************** // cpu // ******************************************************************************** -extern int chudxnu_avail_cpu_count(void); +extern int chudxnu_logical_cpu_count(void); extern int chudxnu_phys_cpu_count(void); extern int chudxnu_cpu_number(void); extern kern_return_t chudxnu_enable_cpu(int cpu, boolean_t enable); -extern kern_return_t chudxnu_enable_cpu_nap(int cpu, boolean_t enable); -extern boolean_t chudxnu_cpu_nap_enabled(int cpu); - extern boolean_t chudxnu_get_interrupts_enabled(void); extern boolean_t chudxnu_set_interrupts_enabled(boolean_t enable); extern boolean_t chudxnu_at_interrupt_context(void); @@ -114,22 +116,9 @@ extern int chudxnu_get_preemption_level(void); extern kern_return_t chudxnu_set_shadowed_spr(int cpu, int spr, uint32_t val); extern kern_return_t chudxnu_set_shadowed_spr64(int cpu, int spr, uint64_t val); -extern uint32_t chudxnu_get_orig_cpu_l2cr(int cpu); -extern uint32_t chudxnu_get_orig_cpu_l3cr(int cpu); - -extern kern_return_t chudxnu_read_spr(int cpu, int spr, uint32_t *val_p); -extern kern_return_t chudxnu_read_spr64(int cpu, int spr, uint64_t *val_p); -extern kern_return_t chudxnu_write_spr(int cpu, int spr, uint32_t val); -extern kern_return_t chudxnu_write_spr64(int cpu, int spr, uint64_t val); - -extern void chudxnu_flush_caches(void); -extern void chudxnu_enable_caches(boolean_t enable); - extern kern_return_t chudxnu_perfmon_acquire_facility(task_t); extern kern_return_t chudxnu_perfmon_release_facility(task_t); -extern uint32_t * chudxnu_get_branch_trace_buffer(uint32_t *entries); - typedef struct { uint32_t hwResets; uint32_t hwMachineChecks; @@ -155,13 +144,8 @@ typedef struct { uint32_t hwInstrumentations; } rupt_counters_t; -extern kern_return_t chudxnu_get_cpu_rupt_counters(int cpu, rupt_counters_t *rupts); -extern kern_return_t chudxnu_clear_cpu_rupt_counters(int cpu); - -extern kern_return_t chudxnu_passup_alignment_exceptions(boolean_t enable); - -extern kern_return_t chudxnu_scom_read(uint32_t reg, uint64_t *data); -extern kern_return_t chudxnu_scom_write(uint32_t reg, uint64_t data); +extern kern_return_t chudxnu_get_cpu_interrupt_counters(int cpu, rupt_counters_t *rupts); +extern kern_return_t chudxnu_clear_cpu_interrupt_counters(int cpu); #pragma mark **** callbacks **** // ******************************************************************************** @@ -210,7 +194,6 @@ extern kern_return_t chudxnu_interrupt_callback_cancel(void); typedef kern_return_t (*chudxnu_perfmon_ast_callback_func_t)(thread_flavor_t flavor, thread_state_t tstate, mach_msg_type_number_t count); extern kern_return_t chudxnu_perfmon_ast_callback_enter(chudxnu_perfmon_ast_callback_func_t func); extern kern_return_t chudxnu_perfmon_ast_callback_cancel(void); -extern kern_return_t chudxnu_perfmon_ast_send(void); extern kern_return_t chudxnu_perfmon_ast_send_urgent(boolean_t urgent); // cpusig callback - one callback for system @@ -233,25 +216,47 @@ extern kern_return_t chudxnu_timer_callback_cancel(chud_timer_t timer); extern kern_return_t chudxnu_timer_free(chud_timer_t timer); // CHUD systemcall callback - one callback for system -//typedef kern_return_t (*chudxnu_syscall_callback_func_t)(thread_flavor_t flavor, thread_state_t tstate, mach_msg_type_number_t count); // v2 typedef kern_return_t (*chudxnu_syscall_callback_func_t)(uint32_t code, uint32_t arg0, uint32_t arg1, uint32_t arg2, uint32_t arg3, uint32_t arg4); extern kern_return_t chudxnu_syscall_callback_enter(chudxnu_syscall_callback_func_t func); extern kern_return_t chudxnu_syscall_callback_cancel(void); +// DTrace Triggering +typedef kern_return_t (*chudxnu_dtrace_callback_t)(uint64_t selector, uint64_t *args, uint32_t count); +extern kern_return_t chudxnu_dtrace_callback(uint64_t selector, uint64_t *args, uint32_t count); +extern void chudxnu_dtrace_callback_enter(chudxnu_dtrace_callback_t fn); +extern void chudxnu_dtrace_callback_cancel(void); + // ******************************************************************************** // DEPRECATED // ******************************************************************************** -extern kern_return_t chudxnu_bind_current_thread(int cpu); +extern kern_return_t chudxnu_perfmon_ast_send(void); +extern kern_return_t chudxnu_thread_get_callstack(thread_t thread, uint32_t *callStack, mach_msg_type_number_t *count, boolean_t user_only); -extern kern_return_t chudxnu_unbind_current_thread(void); +extern vm_offset_t chudxnu_io_map(uint64_t phys_addr, vm_size_t size); +extern uint32_t chudxnu_phys_addr_wimg(uint64_t phys_addr); -extern kern_return_t chudxnu_current_thread_get_callstack(uint32_t *callStack, mach_msg_type_number_t *count, boolean_t user_only); - -extern thread_t chudxnu_current_act(void); +extern int chudxnu_avail_cpu_count(void); -// thread timer callback - one callback for system -typedef kern_return_t (*chudxnu_thread_timer_callback_func_t)(uint32_t param); -extern kern_return_t chudxnu_thread_timer_callback_enter(chudxnu_thread_timer_callback_func_t func, uint32_t param, uint32_t time, uint32_t units); -extern kern_return_t chudxnu_thread_timer_callback_cancel(void); +extern kern_return_t chudxnu_enable_cpu_nap(int cpu, boolean_t enable); +extern boolean_t chudxnu_cpu_nap_enabled(int cpu); + +extern uint32_t chudxnu_get_orig_cpu_l2cr(int cpu); +extern uint32_t chudxnu_get_orig_cpu_l3cr(int cpu); + +extern kern_return_t chudxnu_read_spr(int cpu, int spr, uint32_t *val_p); +extern kern_return_t chudxnu_read_spr64(int cpu, int spr, uint64_t *val_p); +extern kern_return_t chudxnu_write_spr(int cpu, int spr, uint32_t val); +extern kern_return_t chudxnu_write_spr64(int cpu, int spr, uint64_t val); + +extern kern_return_t chudxnu_get_cpu_rupt_counters(int cpu, rupt_counters_t *rupts); +extern kern_return_t chudxnu_clear_cpu_rupt_counters(int cpu); + +extern kern_return_t chudxnu_passup_alignment_exceptions(boolean_t enable); + +extern kern_return_t chudxnu_scom_read(uint32_t reg, uint64_t *data); +extern kern_return_t chudxnu_scom_write(uint32_t reg, uint64_t data); + +extern void chudxnu_flush_caches(void); +extern void chudxnu_enable_caches(boolean_t enable); #endif /* _CHUD_XNU_H_ */