Index: /trunk/src/VBox/Runtime/r0drv/darwin/initterm-r0drv-darwin.cpp
===================================================================
--- /trunk/src/VBox/Runtime/r0drv/darwin/initterm-r0drv-darwin.cpp	(revision 37574)
+++ /trunk/src/VBox/Runtime/r0drv/darwin/initterm-r0drv-darwin.cpp	(revision 37575)
@@ -34,5 +34,7 @@
 #include <iprt/err.h>
 #include <iprt/assert.h>
+#include <iprt/darwin/machkernel.h>
 #include "internal/initterm.h"
+
 
 
@@ -41,5 +43,9 @@
 *******************************************************************************/
 /** Pointer to the lock group used by IPRT. */
-lck_grp_t *g_pDarwinLockGroup = NULL;
+lck_grp_t                  *g_pDarwinLockGroup = NULL;
+/** Pointer to the ast_pending function, if found. */
+PFNR0DARWINASTPENDING       g_pfnR0DarwinAstPending = NULL;
+/** Pointer to the cpu_interrupt function, if found. */
+PFNR0DARWINCPUINTERRUPT     g_pfnR0DarwinCpuInterrupt = NULL;
 
 
@@ -56,4 +62,25 @@
      */
     int rc = rtThreadPreemptDarwinInit();
+    if (RT_SUCCESS(rc))
+    {
+        /*
+         * Try resolve kernel symbols we need but apple don't wish to give us.
+         */
+        RTR0MACHKERNEL hKernel;
+        rc = RTR0MachKernelOpen("/mach_kernel", &hKernel);
+        if (RT_SUCCESS(rc))
+        {
+            RTR0MachKernelGetSymbol(hKernel, "ast_pending",   (void **)&g_pfnR0DarwinAstPending);
+            printf("ast_pending=%p\n", g_pfnR0DarwinAstPending);
+            RTR0MachKernelGetSymbol(hKernel, "cpu_interrupt", (void **)&g_pfnR0DarwinCpuInterrupt);
+            printf("cpu_interrupt=%p\n", g_pfnR0DarwinCpuInterrupt);
+            RTR0MachKernelClose(hKernel);
+        }
+        if (RT_FAILURE(rc))
+        {
+            printf("rtR0InitNative: warning! failed to resolve special kernel symbols\n");
+            rc = VINF_SUCCESS;
+        }
+    }
     if (RT_FAILURE(rc))
         rtR0TermNative();
Index: /trunk/src/VBox/Runtime/r0drv/darwin/mach_kernel-r0drv-darwin.cpp
===================================================================
--- /trunk/src/VBox/Runtime/r0drv/darwin/mach_kernel-r0drv-darwin.cpp	(revision 37574)
+++ /trunk/src/VBox/Runtime/r0drv/darwin/mach_kernel-r0drv-darwin.cpp	(revision 37575)
@@ -36,5 +36,14 @@
 # include <sys/kpi_mbuf.h>
 # include <net/kpi_interfacefilter.h>
+# include <sys/kpi_socket.h>
+# include <sys/kpi_socketfilter.h>
 RT_C_DECLS_END
+# include <sys/buf.h>
+# include <sys/vm.h>
+# include <sys/vnode_if.h>
+/*# include <sys/sysctl.h>*/
+# include <sys/systm.h>
+# include <vfs/vfs_support.h>
+/*# include <miscfs/specfs/specdev.h>*/
 #endif
 
@@ -51,4 +60,5 @@
 # define NIL_RTFILE     ((RTFILENEW)-1)
 #endif
+
 #include <iprt/asm.h>
 #include <iprt/assert.h>
@@ -278,5 +288,5 @@
     RTFILENEWINT *pThis = hFile;
     AssertPtrReturn(pThis, VERR_INVALID_HANDLE);
-    AssertReturn(pThis->u32Magic != RTFILE_MAGIC, VERR_INVALID_HANDLE);
+    AssertReturn(pThis->u32Magic == RTFILE_MAGIC, VERR_INVALID_HANDLE);
     pThis->u32Magic = ~RTFILE_MAGIC;
 
@@ -292,5 +302,5 @@
     RTFILENEWINT *pThis = hFile;
     AssertPtrReturn(pThis, VERR_INVALID_HANDLE);
-    AssertReturn(pThis->u32Magic != RTFILE_MAGIC, VERR_INVALID_HANDLE);
+    AssertReturn(pThis->u32Magic == RTFILE_MAGIC, VERR_INVALID_HANDLE);
 
     off_t offNative = (off_t)off;
@@ -454,7 +464,7 @@
 
         /* BSDKernel: */
-        //KNOWN_ENTRY(buf_size),
+        KNOWN_ENTRY(buf_size),
         KNOWN_ENTRY(copystr),
-        //KNOWN_ENTRY(current_proc),
+        KNOWN_ENTRY(current_proc),
         KNOWN_ENTRY(ifnet_hdrlen),
         KNOWN_ENTRY(ifnet_set_promiscuous),
@@ -465,24 +475,24 @@
         KNOWN_ENTRY(kauth_cred_rele),
 #endif
-        //KNOWN_ENTRY(mbuf_data),
+        KNOWN_ENTRY(mbuf_data),
         KNOWN_ENTRY(msleep),
         KNOWN_ENTRY(nanotime),
-        //KNOWN_ENTRY(nop_close),
+        KNOWN_ENTRY(nop_close),
         KNOWN_ENTRY(proc_pid),
-        //KNOWN_ENTRY(sock_accept),
-        //KNOWN_ENTRY(sockopt_name),
+        KNOWN_ENTRY(sock_accept),
+        KNOWN_ENTRY(sockopt_name),
         //KNOWN_ENTRY(spec_write),
-        //KNOWN_ENTRY(suword),
+        KNOWN_ENTRY(suword),
         //KNOWN_ENTRY(sysctl_int),
         KNOWN_ENTRY(uio_rw),
-        //KNOWN_ENTRY(vfs_flags),
-        //KNOWN_ENTRY(vfs_name),
-        //KNOWN_ENTRY(vfs_statfs),
-        //KNOWN_ENTRY(vn_rdwr),
-        //KNOWN_ENTRY(vnode_get),
-        //KNOWN_ENTRY(vnode_open),
-        //KNOWN_ENTRY(vnode_ref),
-        //KNOWN_ENTRY(vnode_rele),
-        //KNOWN_ENTRY(vnop_close_desc),
+        KNOWN_ENTRY(vfs_flags),
+        KNOWN_ENTRY(vfs_name),
+        KNOWN_ENTRY(vfs_statfs),
+        KNOWN_ENTRY(vn_rdwr),
+        KNOWN_ENTRY(vnode_get),
+        KNOWN_ENTRY(vnode_open),
+        KNOWN_ENTRY(vnode_ref),
+        KNOWN_ENTRY(vnode_rele),
+        KNOWN_ENTRY(vnop_close_desc),
         KNOWN_ENTRY(wakeup),
         KNOWN_ENTRY(wakeup_one),
Index: /trunk/src/VBox/Runtime/r0drv/darwin/mp-r0drv-darwin.cpp
===================================================================
--- /trunk/src/VBox/Runtime/r0drv/darwin/mp-r0drv-darwin.cpp	(revision 37574)
+++ /trunk/src/VBox/Runtime/r0drv/darwin/mp-r0drv-darwin.cpp	(revision 37575)
@@ -265,6 +265,8 @@
     RT_ASSERT_INTS_ON();
 
-    /* no unicast IPI */
-    return VERR_NOT_SUPPORTED;
-}
-
+    if (g_pfnR0DarwinCpuInterrupt == NULL)
+        return VERR_NOT_SUPPORTED;
+    g_pfnR0DarwinCpuInterrupt(idCpu);
+    return VINF_SUCCESS;
+}
+
Index: /trunk/src/VBox/Runtime/r0drv/darwin/the-darwin-kernel.h
===================================================================
--- /trunk/src/VBox/Runtime/r0drv/darwin/the-darwin-kernel.h	(revision 37574)
+++ /trunk/src/VBox/Runtime/r0drv/darwin/the-darwin-kernel.h	(revision 37575)
@@ -5,5 +5,5 @@
 
 /*
- * Copyright (C) 2006-2007 Oracle Corporation
+ * Copyright (C) 2006-2011 Oracle Corporation
  *
  * This file is part of VirtualBox Open Source Edition (OSE), as
@@ -152,9 +152,17 @@
  * Internals of the Darwin Ring-0 IPRT.
  */
+RT_C_DECLS_BEGIN
 
-RT_C_DECLS_BEGIN
-extern lck_grp_t *g_pDarwinLockGroup;
+/* initterm-r0drv-darwin.cpp. */
+typedef uint32_t *  (*PFNR0DARWINASTPENDING)(void);
+typedef void        (*PFNR0DARWINCPUINTERRUPT)(int);
+extern lck_grp_t                  *g_pDarwinLockGroup;
+extern PFNR0DARWINASTPENDING       g_pfnR0DarwinAstPending;
+extern PFNR0DARWINCPUINTERRUPT     g_pfnR0DarwinCpuInterrupt;
+
+/* threadpreempt-r0drv-darwin.cpp */
 int  rtThreadPreemptDarwinInit(void);
 void rtThreadPreemptDarwinTerm(void);
+
 RT_C_DECLS_END
 
Index: /trunk/src/VBox/Runtime/r0drv/darwin/threadpreempt-r0drv-darwin.cpp
===================================================================
--- /trunk/src/VBox/Runtime/r0drv/darwin/threadpreempt-r0drv-darwin.cpp	(revision 37574)
+++ /trunk/src/VBox/Runtime/r0drv/darwin/threadpreempt-r0drv-darwin.cpp	(revision 37575)
@@ -105,17 +105,11 @@
 RTDECL(bool) RTThreadPreemptIsPending(RTTHREAD hThread)
 {
-    Assert(hThread == NIL_RTTHREAD);
+    if (!g_pfnR0DarwinAstPending)
+        return false;
+    uint32_t volatile *pfAstPending = g_pfnR0DarwinAstPending(); AssertPtr(pfAstPending);
+    uint32_t  const    fAstPending = *pfAstPending;
 
-    /* HACK ALERT! This ASSUMES that the cpu_pending_ast member of cpu_data_t doesn't move. */
-    uint32_t ast_pending;
-#if defined(RT_ARCH_X86) || defined(RT_ARCH_AMD64)
-    __asm__ volatile("movl %%gs:%P1,%0\n\t"
-                     : "=r" (ast_pending)
-                     : "i"  (__builtin_offsetof(struct my_cpu_data_x86, cpu_pending_ast)) );
-#else
-# error "Port me"
-#endif
-    AssertMsg(!(ast_pending & UINT32_C(0xfffff000)),("%#x\n", ast_pending));
-    return (ast_pending & (AST_PREEMPT | AST_URGENT)) != 0;
+    AssertMsg(!(fAstPending & UINT32_C(0xfffff000)), ("%#x\n", fAstPending));
+    return (fAstPending & (AST_PREEMPT | AST_URGENT)) != 0;
 }
 
@@ -124,5 +118,5 @@
 {
     /* yes, we think that RTThreadPreemptIsPending is reliable... */
-    return true;
+    return g_pfnR0DarwinAstPending != NULL;
 }
 
