Home | History | Annotate | Download | only in m_mach
      1 
      2 /*--------------------------------------------------------------------*/
      3 /*--- Basic Mach interface functions                 mach_basics.c ---*/
      4 /*--------------------------------------------------------------------*/
      5 
      6 /*
      7    This file is part of Valgrind, a dynamic binary instrumentation
      8    framework.
      9 
     10    Copyright (C) 2005-2012 Apple Inc.
     11       Greg Parker  gparker (at) 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 #if defined(VGO_darwin)
     32 
     33 #include "pub_core_basics.h"
     34 #include "pub_core_mach.h"
     35 
     36 #include <mach/mach.h>
     37 #include <mach/machine/ndr_def.h>
     38 
     39 /* From mach_traps-<arch>-darwin.S */
     40 //extern mach_port_name_t host_self_trap(void);
     41 extern mach_port_name_t thread_self_trap(void);
     42 extern mach_port_t mach_reply_port(void);
     43 
     44 /* Global variables set in mach_init() */
     45 vm_size_t vm_page_size = 0;
     46 mach_port_name_t mach_task_self_ = 0;
     47 
     48 
     49 mach_port_name_t mach_thread_self(void)
     50 {
     51     return thread_self_trap();
     52 }
     53 
     54 static mach_port_t reply = 0;
     55 
     56 mach_port_t mig_get_reply_port(void)
     57 {
     58     if (!reply) reply = mach_reply_port();
     59     return reply;
     60     // GrP fixme is just one enough for valgrind's own use?
     61     // might work if valgrind never blocks in mig calls on
     62     // its own behalf, and doesn't call mig outside the semaphore
     63 }
     64 
     65 
     66 void mig_dealloc_reply_port(mach_port_t reply_port)
     67 {
     68 }
     69 
     70 
     71 void mig_put_reply_port(mach_port_t reply_port)
     72 {
     73 }
     74 
     75 
     76 /* Initialize Mach global data.
     77    Should be called early in main(). */
     78 void VG_(mach_init)(void)
     79 {
     80     reply = 0;
     81     mach_task_self_ = task_self_trap();
     82 
     83     // GrP fixme host_page_size(host_self_trap(), &vm_page_size);
     84     vm_page_size = 4096;
     85 }
     86 
     87 #endif // defined(VGO_darwin)
     88 
     89 /*--------------------------------------------------------------------*/
     90 /*--- end                                                          ---*/
     91 /*--------------------------------------------------------------------*/
     92