the-darwin-kernel.h revision c58f1213e628a545081c70e26c6b67a841cff880
/* $Id$ */
/** @file
* IPRT - Include all necessary headers for the Darwing kernel.
*/
/*
* Copyright (C) 2006-2012 Oracle Corporation
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
* General Public License (GPL) as published by the Free Software
* Foundation, in version 2 as it comes in the "COPYING" file of the
* VirtualBox OSE distribution. VirtualBox OSE is distributed in the
* hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
*
* The contents of this file may alternatively be used under the terms
* of the Common Development and Distribution License Version 1.0
* (CDDL) only, as it comes in the "COPYING.CDDL" file of the
* VirtualBox OSE distribution, in which case the provisions of the
* CDDL are applicable instead of those of the GPL.
*
* You may elect to license modified versions of this file under the
* terms and conditions of either the GPL or the CDDL or both.
*/
#ifndef ___the_darwin_kernel_h
#define ___the_darwin_kernel_h
/* Problematic header(s) containing conflicts with IPRT first. */
#define __STDC_CONSTANT_MACROS
#define __STDC_LIMIT_MACROS
#include <mach/vm_param.h>
/* Include the IPRT definitions of the conflicting #defines & typedefs. */
/* After including cdefs, we can check that this really is Darwin. */
#ifndef RT_OS_DARWIN
# error "RT_OS_DARWIN must be defined!"
#endif
/* now we're ready for including the rest of the Darwin headers. */
#include <kern/sched_prim.h>
# include <i386/mp_events.h>
#endif
#include <mach/thread_act.h>
#include <mach/vm_region.h>
#include <IOKit/IOMemoryDescriptor.h>
#include <IOKit/IOBufferMemoryDescriptor.h>
#include <IOKit/IOMapper.h>
#ifndef AST_PREEMPT
#endif
/* This flag was added in 10.6, it seems. Should be harmless in earlier
releases... */
#if MAC_OS_X_VERSION_MIN_REQUIRED < 1060
#endif
/* mach/vm_types.h */
extern vm_map_t kernel_map;
extern pmap_t kernel_pmap;
/* mach/i386/thread_act.h */
extern void mp_rendezvous(void (*)(void *), void (*)(void *), void (*)(void *), void *);
extern void mp_rendezvous_no_intrs(void (*)(void *), void *);
/* osfmk/i386/cpu_data.h */
struct my_cpu_data_x86
{
struct my_cpu_data_x86 *cpu_this;
void *cpu_int_state;
int cpu_preemption_level;
int cpu_interrupt_level;
int cpu_number;
int cpu_phys_number;
int cpu_signals;
int cpu_mcount_off;
int cpu_type;
int cpu_subtype;
int cpu_threadtype;
int cpu_running;
};
/* osfmk/i386/cpu_number.h */
extern int cpu_number(void);
/*extern kern_return_t vm_region(vm_map_t, vm_address_t *, vm_size_t *, vm_region_flavor_t, vm_region_info_t,
mach_msg_type_number_t *, mach_port_t *);*/
/* i386/machine_routines.h */
extern int ml_get_max_cpus(void);
/*
* Internals of the Darwin Ring-0 IPRT.
*/
/* initterm-r0drv-darwin.cpp. */
typedef uint32_t * (*PFNR0DARWINASTPENDING)(void);
typedef void (*PFNR0DARWINCPUINTERRUPT)(int);
extern lck_grp_t *g_pDarwinLockGroup;
int rtThreadPreemptDarwinInit(void);
void rtThreadPreemptDarwinTerm(void);
/**
* Converts from nanoseconds to Darwin absolute time units.
* @returns Darwin absolute time.
* @param u64Nano Time interval in nanoseconds
*/
{
return u64AbsTime;
}
/**
* Convert from mach kernel return code to IPRT status code.
*/
{
switch (rc)
{
case KERN_SUCCESS: return VINF_SUCCESS;
default: return VERR_GENERAL_FAILURE;
}
}
#endif