DECLHIDDEN(int) rtR0InitNative(void) { /* * Create the lock group. */ g_pDarwinLockGroup = lck_grp_alloc_init("IPRT", LCK_GRP_ATTR_NULL); AssertReturn(g_pDarwinLockGroup, VERR_NO_MEMORY); /* * Initialize the preemption hacks. */ int rc = rtThreadPreemptDarwinInit(); if (RT_SUCCESS(rc)) { /* * Try resolve kernel symbols we need but apple don't wish to give us. */ RTDBGKRNLINFO hKrnlInfo; rc = RTR0DbgKrnlInfoOpen(&hKrnlInfo, 0 /*fFlags*/); if (RT_SUCCESS(rc)) { RTR0DbgKrnlInfoQuerySymbol(hKrnlInfo, NULL, "ast_pending", (void **)&g_pfnR0DarwinAstPending); printf("ast_pending=%p\n", g_pfnR0DarwinAstPending); RTR0DbgKrnlInfoQuerySymbol(hKrnlInfo, NULL, "cpu_interrupt", (void **)&g_pfnR0DarwinCpuInterrupt); printf("cpu_interrupt=%p\n", g_pfnR0DarwinCpuInterrupt); RTR0DbgKrnlInfoRelease(hKrnlInfo); } if (RT_FAILURE(rc)) { printf("rtR0InitNative: warning! failed to resolve special kernel symbols\n"); rc = VINF_SUCCESS; } } if (RT_FAILURE(rc)) rtR0TermNative(); return rc; }
DECLHIDDEN(int) rtR0InitNative(void) { /* * Create the lock group. */ g_pDarwinLockGroup = lck_grp_alloc_init("IPRT", LCK_GRP_ATTR_NULL); AssertReturn(g_pDarwinLockGroup, VERR_NO_MEMORY); /* * Initialize the preemption hacks. */ 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(); return rc; }