priv_syswrap-darwin.h revision 8f1da7383f1adac719303aa0c6524b526cc589e8
1 2/*--------------------------------------------------------------------*/ 3/*--- Private syscalls header for Darwin. priv_syswrap-darwin.h ---*/ 4/*--------------------------------------------------------------------*/ 5 6/* 7 This file is part of Valgrind, a dynamic binary instrumentation 8 framework. 9 10 Copyright (C) 2005-2009 Apple Inc. 11 Greg Parker gparker@apple.com 12 13 This program is free software; you can redistribute it and/or 14 modify it under the terms of the GNU General Public License as 15 published by the Free Software Foundation; either version 2 of the 16 License, or (at your option) any later version. 17 18 This program is distributed in the hope that it will be useful, but 19 WITHOUT ANY WARRANTY; without even the implied warranty of 20 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 21 General Public License for more details. 22 23 You should have received a copy of the GNU General Public License 24 along with this program; if not, write to the Free Software 25 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 26 02111-1307, USA. 27 28 The GNU General Public License is contained in the file COPYING. 29*/ 30 31#ifndef __PRIV_SYSWRAP_DARWIN_H 32#define __PRIV_SYSWRAP_DARWIN_H 33 34/* requires #include "priv_types_n_macros.h" */ 35 36// syswrap-darwin.c 37Addr allocstack ( ThreadId tid ); 38void find_stack_segment ( ThreadId tid, Addr sp ); 39void start_thread_NORETURN ( Word arg ); 40void assign_port_name(mach_port_t port, const char *name); 41void record_named_port(ThreadId tid, mach_port_t port, mach_port_right_t right, const char *name); 42 43extern const SyscallTableEntry ML_(mach_trap_table)[]; 44extern const SyscallTableEntry ML_(syscall_table)[]; 45extern const SyscallTableEntry ML_(mdep_trap_table)[]; 46 47extern const UInt ML_(syscall_table_size); 48extern const UInt ML_(mach_trap_table_size); 49extern const UInt ML_(mdep_trap_table_size); 50 51void VG_(show_open_ports)(void); 52 53// Unix syscalls 54DECL_TEMPLATE(darwin, sys_semget); 55DECL_TEMPLATE(darwin, sys_semop); 56DECL_TEMPLATE(darwin, sys_semctl); 57DECL_TEMPLATE(darwin, sys_sem_open); 58DECL_TEMPLATE(darwin, sys_sem_close); 59DECL_TEMPLATE(darwin, sys_sem_unlink); 60DECL_TEMPLATE(darwin, sys_sem_post); 61DECL_TEMPLATE(darwin, sys_sem_init); 62DECL_TEMPLATE(darwin, sys_sem_destroy); 63DECL_TEMPLATE(darwin, sys_sem_wait_nocancel); 64DECL_TEMPLATE(darwin, sys_sem_trywait); 65DECL_TEMPLATE(darwin, sys_bsdthread_create); 66DECL_TEMPLATE(darwin, sys_bsdthread_terminate); 67DECL_TEMPLATE(darwin, sys_kqueue); 68DECL_TEMPLATE(darwin, sys_kevent); 69DECL_TEMPLATE(darwin, sys_bsdthread_register); 70DECL_TEMPLATE(darwin, sys_workq_open); 71DECL_TEMPLATE(darwin, sys_workq_ops); 72DECL_TEMPLATE(darwin, sys___mac_syscall); 73DECL_TEMPLATE(darwin, sys_exit); 74DECL_TEMPLATE(darwin, sys_sigaction); 75DECL_TEMPLATE(darwin, sys___pthread_canceled); 76DECL_TEMPLATE(darwin, sys___pthread_markcancel); 77DECL_TEMPLATE(darwin, sys___pthread_sigmask); 78DECL_TEMPLATE(darwin, sys___disable_threadsignal); 79DECL_TEMPLATE(darwin, sys_kdebug_trace); 80DECL_TEMPLATE(darwin, sys_seteuid); 81DECL_TEMPLATE(darwin, sys_setegid); 82DECL_TEMPLATE(darwin, sys_listxattr); 83DECL_TEMPLATE(darwin, sys_flistxattr); 84DECL_TEMPLATE(darwin, sys_shmctl); 85DECL_TEMPLATE(darwin, sys_shmget); 86DECL_TEMPLATE(darwin, sys_shm_open); 87DECL_TEMPLATE(darwin, sys_statx); 88DECL_TEMPLATE(darwin, sys_fchmod_extended); 89DECL_TEMPLATE(darwin, sys_chmod_extended); 90DECL_TEMPLATE(darwin, sys_accessx); 91DECL_TEMPLATE(darwin, sys_chflags); 92DECL_TEMPLATE(darwin, sys_fchflags); 93DECL_TEMPLATE(darwin, sys_stat64); 94DECL_TEMPLATE(darwin, sys_lstat64); 95DECL_TEMPLATE(darwin, sys_fstat64); 96DECL_TEMPLATE(darwin, sys_getfsstat); 97DECL_TEMPLATE(darwin, sys_getattrlist); 98DECL_TEMPLATE(darwin, sys_setattrlist); 99DECL_TEMPLATE(darwin, sys_getdirentriesattr); 100DECL_TEMPLATE(darwin, sys_fsctl); 101DECL_TEMPLATE(darwin, sys_socket); 102DECL_TEMPLATE(darwin, sys_setsockopt); 103DECL_TEMPLATE(darwin, sys_getsockopt); 104DECL_TEMPLATE(darwin, sys_connect); 105DECL_TEMPLATE(darwin, sys_accept); 106DECL_TEMPLATE(darwin, sys_sendto); 107DECL_TEMPLATE(darwin, sys_recvfrom); 108DECL_TEMPLATE(darwin, sys_sendmsg); 109DECL_TEMPLATE(darwin, sys_recvmsg); 110DECL_TEMPLATE(darwin, sys_shutdown); 111DECL_TEMPLATE(darwin, sys_bind); 112DECL_TEMPLATE(darwin, sys_listen); 113DECL_TEMPLATE(darwin, sys_getsockname); 114DECL_TEMPLATE(darwin, sys_getpeername); 115DECL_TEMPLATE(darwin, sys_socketpair); 116DECL_TEMPLATE(darwin, sys_gethostuuid); 117DECL_TEMPLATE(darwin, sys_pipe); 118DECL_TEMPLATE(darwin, sys_getlogin); 119DECL_TEMPLATE(darwin, sys_ptrace); 120DECL_TEMPLATE(darwin, sys_issetugid); 121DECL_TEMPLATE(darwin, sys_getdtablesize); 122DECL_TEMPLATE(darwin, sys_lseek); 123DECL_TEMPLATE(darwin, sys_getdirentries); 124DECL_TEMPLATE(darwin, sys_getdirentries64); 125DECL_TEMPLATE(darwin, sys_statfs64); 126DECL_TEMPLATE(darwin, sys_fstatfs64); 127DECL_TEMPLATE(darwin, sys_csops); 128DECL_TEMPLATE(darwin, sys_auditon); 129DECL_TEMPLATE(darwin, sys_pathconf); 130DECL_TEMPLATE(darwin, sys_fpathconf); 131DECL_TEMPLATE(darwin, sys_shared_region_map_file_np); 132DECL_TEMPLATE(darwin, sys_mmap); 133DECL_TEMPLATE(darwin, sys_sysctl); 134DECL_TEMPLATE(darwin, sys_sigpending); 135DECL_TEMPLATE(darwin, sys_sigprocmask); 136DECL_TEMPLATE(darwin, sys_sigsuspend); 137DECL_TEMPLATE(darwin, sys_watchevent); 138DECL_TEMPLATE(darwin, sys_waitevent); 139DECL_TEMPLATE(darwin, sys_modwatch); 140DECL_TEMPLATE(darwin, sys_getxattr); 141DECL_TEMPLATE(darwin, sys_fgetxattr); 142DECL_TEMPLATE(darwin, sys_setxattr); 143DECL_TEMPLATE(darwin, sys_fsetxattr); 144DECL_TEMPLATE(darwin, sys_initgroups); 145DECL_TEMPLATE(darwin, sys_posix_spawn); 146DECL_TEMPLATE(darwin, sys_settid); 147DECL_TEMPLATE(darwin, sys_sendfile); 148DECL_TEMPLATE(darwin, sys_fcntl); 149DECL_TEMPLATE(darwin, sys_fcntl64); 150DECL_TEMPLATE(darwin, sys_ioctl); 151DECL_TEMPLATE(darwin, sys_futimes); 152DECL_TEMPLATE(darwin, sys_FAKE_SIGRETURN); 153DECL_TEMPLATE(darwin, sys_sigreturn); 154 155// Mach message helpers 156DECL_TEMPLATE(darwin, host_info); 157DECL_TEMPLATE(darwin, host_page_size); 158DECL_TEMPLATE(darwin, host_get_io_master); 159DECL_TEMPLATE(darwin, host_get_clock_service); 160DECL_TEMPLATE(darwin, host_request_notification); 161DECL_TEMPLATE(darwin, mach_port_type); 162DECL_TEMPLATE(darwin, mach_port_extract_member); 163DECL_TEMPLATE(darwin, mach_port_allocate); 164DECL_TEMPLATE(darwin, mach_port_deallocate); 165DECL_TEMPLATE(darwin, mach_port_get_refs); 166DECL_TEMPLATE(darwin, mach_port_mod_refs); 167DECL_TEMPLATE(darwin, mach_port_get_set_status); 168DECL_TEMPLATE(darwin, mach_port_destroy); 169DECL_TEMPLATE(darwin, mach_port_request_notification); 170DECL_TEMPLATE(darwin, mach_port_insert_right); 171DECL_TEMPLATE(darwin, mach_port_get_attributes); 172DECL_TEMPLATE(darwin, mach_port_set_attributes); 173DECL_TEMPLATE(darwin, mach_port_insert_member); 174DECL_TEMPLATE(darwin, task_get_special_port); 175DECL_TEMPLATE(darwin, semaphore_create); 176DECL_TEMPLATE(darwin, semaphore_destroy); 177DECL_TEMPLATE(darwin, mach_ports_lookup); 178DECL_TEMPLATE(darwin, task_threads); 179DECL_TEMPLATE(darwin, task_suspend); 180DECL_TEMPLATE(darwin, task_resume); 181DECL_TEMPLATE(darwin, vm_allocate); 182DECL_TEMPLATE(darwin, vm_deallocate); 183DECL_TEMPLATE(darwin, vm_protect); 184DECL_TEMPLATE(darwin, vm_inherit); 185DECL_TEMPLATE(darwin, vm_read); 186DECL_TEMPLATE(darwin, mach_vm_read); 187DECL_TEMPLATE(darwin, vm_copy); 188DECL_TEMPLATE(darwin, vm_read_overwrite); 189DECL_TEMPLATE(darwin, vm_map); 190DECL_TEMPLATE(darwin, vm_remap); 191DECL_TEMPLATE(darwin, mach_make_memory_entry_64); 192DECL_TEMPLATE(darwin, vm_purgable_control); 193DECL_TEMPLATE(darwin, mach_vm_purgable_control); 194DECL_TEMPLATE(darwin, mach_vm_allocate); 195DECL_TEMPLATE(darwin, mach_vm_deallocate); 196DECL_TEMPLATE(darwin, mach_vm_protect); 197DECL_TEMPLATE(darwin, mach_vm_copy); 198DECL_TEMPLATE(darwin, mach_vm_inherit); 199DECL_TEMPLATE(darwin, mach_vm_map); 200DECL_TEMPLATE(darwin, mach_vm_region_recurse); 201DECL_TEMPLATE(darwin, thread_terminate); 202DECL_TEMPLATE(darwin, thread_create); 203DECL_TEMPLATE(darwin, thread_create_running); 204DECL_TEMPLATE(darwin, thread_suspend); 205DECL_TEMPLATE(darwin, thread_get_state); 206DECL_TEMPLATE(darwin, thread_policy); 207DECL_TEMPLATE(darwin, thread_info); 208DECL_TEMPLATE(darwin, bootstrap_register); 209DECL_TEMPLATE(darwin, bootstrap_look_up); 210DECL_TEMPLATE(darwin, mach_msg_receive); 211DECL_TEMPLATE(darwin, mach_msg_bootstrap); 212DECL_TEMPLATE(darwin, mach_msg_host); 213DECL_TEMPLATE(darwin, mach_msg_task); 214DECL_TEMPLATE(darwin, mach_msg_thread); 215 216// Mach traps 217DECL_TEMPLATE(darwin, mach_msg_unhandled); 218DECL_TEMPLATE(darwin, mach_msg); 219DECL_TEMPLATE(darwin, mach_reply_port); 220DECL_TEMPLATE(darwin, mach_thread_self); 221DECL_TEMPLATE(darwin, mach_host_self); 222DECL_TEMPLATE(darwin, mach_task_self); 223DECL_TEMPLATE(darwin, syscall_thread_switch); 224DECL_TEMPLATE(darwin, semaphore_signal); 225DECL_TEMPLATE(darwin, semaphore_signal_all); 226DECL_TEMPLATE(darwin, semaphore_signal_thread); 227DECL_TEMPLATE(darwin, semaphore_wait); 228DECL_TEMPLATE(darwin, semaphore_wait_signal); 229DECL_TEMPLATE(darwin, semaphore_timedwait); 230DECL_TEMPLATE(darwin, semaphore_timedwait_signal); 231DECL_TEMPLATE(darwin, sys___semwait_signal); 232DECL_TEMPLATE(darwin, task_for_pid); 233DECL_TEMPLATE(darwin, pid_for_task); 234DECL_TEMPLATE(darwin, mach_timebase_info); 235DECL_TEMPLATE(darwin, mach_wait_until); 236DECL_TEMPLATE(darwin, mk_timer_create); 237DECL_TEMPLATE(darwin, mk_timer_destroy); 238DECL_TEMPLATE(darwin, mk_timer_arm); 239DECL_TEMPLATE(darwin, mk_timer_cancel); 240DECL_TEMPLATE(darwin, iokit_user_client_trap); 241DECL_TEMPLATE(darwin, swtch); 242DECL_TEMPLATE(darwin, swtch_pri); 243 244// Machine-dependent traps 245DECL_TEMPLATE(darwin, thread_fast_set_cthread_self); 246 247// syswrap-<arch>-darwin.c 248#include <mach/mach.h> 249extern 250void thread_state_from_vex(thread_state_t mach_generic, 251 thread_state_flavor_t flavor, 252 mach_msg_type_number_t count, 253 VexGuestArchState *vex_generic); 254extern 255void thread_state_to_vex(const thread_state_t mach_generic, 256 thread_state_flavor_t flavor, 257 mach_msg_type_number_t count, 258 VexGuestArchState *vex_generic); 259extern 260ThreadState *build_thread(const thread_state_t state, 261 thread_state_flavor_t flavor, 262 mach_msg_type_number_t count); 263extern 264void hijack_thread_state(thread_state_t mach_generic, 265 thread_state_flavor_t flavor, 266 mach_msg_type_number_t count, 267 ThreadState *tst); 268extern 269__attribute__((noreturn)) 270void call_on_new_stack_0_1 ( Addr stack, 271 Addr retaddr, 272 void (*f)(Word), 273 Word arg1 ); 274 275extern void pthread_hijack_asm(void); 276extern void pthread_hijack(Addr self, Addr kport, Addr func, Addr func_arg, 277 Addr stacksize, Addr flags, Addr sp); 278extern void wqthread_hijack_asm(void); 279extern void wqthread_hijack(Addr self, Addr kport, Addr stackaddr, Addr workitem, Int reuse, Addr sp); 280 281extern Addr pthread_starter; 282extern Addr wqthread_starter; 283extern SizeT pthread_structsize; 284 285 286#endif 287 288/*--------------------------------------------------------------------*/ 289/*--- end ---*/ 290/*--------------------------------------------------------------------*/ 291