1 | /* $Id: the-darwin-kernel.h 1 1970-01-01 00:00:00Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * InnoTek Portable Runtime - Include all necessary headers for the Darwing kernel.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2006 InnoTek Systemberatung GmbH
|
---|
8 | *
|
---|
9 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
10 | * available from http://www.virtualbox.org. This file is free software;
|
---|
11 | * you can redistribute it and/or modify it under the terms of the GNU
|
---|
12 | * General Public License as published by the Free Software Foundation,
|
---|
13 | * in version 2 as it comes in the "COPYING" file of the VirtualBox OSE
|
---|
14 | * distribution. VirtualBox OSE is distributed in the hope that it will
|
---|
15 | * be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
16 | *
|
---|
17 | * If you received this file as part of a commercial VirtualBox
|
---|
18 | * distribution, then only the terms of your commercial VirtualBox
|
---|
19 | * license agreement apply instead of the previous paragraph.
|
---|
20 | */
|
---|
21 |
|
---|
22 | #ifndef __the_darwin_kernel_h__
|
---|
23 | #define __the_darwin_kernel_h__
|
---|
24 |
|
---|
25 | /* Problematic header(s) containing conflicts with IPRT first. */
|
---|
26 | #define __STDC_CONSTANT_MACROS
|
---|
27 | #define __STDC_LIMIT_MACROS
|
---|
28 | #include <sys/param.h>
|
---|
29 | #include <mach/vm_param.h>
|
---|
30 | #undef ALIGN
|
---|
31 | #undef MIN
|
---|
32 | #undef MAX
|
---|
33 | #undef PAGE_SIZE
|
---|
34 | #undef PAGE_SHIFT
|
---|
35 |
|
---|
36 | /* Include the IPRT definitions of the conflicting #defines & typedefs. */
|
---|
37 | #include <iprt/cdefs.h>
|
---|
38 | #include <iprt/types.h>
|
---|
39 | #include <iprt/param.h>
|
---|
40 |
|
---|
41 |
|
---|
42 | /* After including cdefs, we can check that this really is Darwin. */
|
---|
43 | #ifndef __DARWIN__
|
---|
44 | # error "__DARWIN__ must be defined!"
|
---|
45 | #endif
|
---|
46 |
|
---|
47 | /* now we're ready for including the rest of the Darwin headers. */
|
---|
48 | #include <kern/thread.h>
|
---|
49 | #include <kern/clock.h>
|
---|
50 | #include <kern/sched_prim.h>
|
---|
51 | #include <kern/locks.h>
|
---|
52 | #include <libkern/libkern.h>
|
---|
53 | #include <mach/thread_act.h>
|
---|
54 | #include <pexpert/pexpert.h>
|
---|
55 | #include <sys/conf.h>
|
---|
56 | #include <sys/errno.h>
|
---|
57 | #include <sys/ioccom.h>
|
---|
58 | #include <sys/malloc.h>
|
---|
59 | #include <sys/proc.h>
|
---|
60 | #include <IOKit/IOTypes.h>
|
---|
61 | #include <IOKit/IOLib.h>
|
---|
62 |
|
---|
63 |
|
---|
64 | __BEGIN_DECLS
|
---|
65 | kern_return_t thread_terminate(thread_t);
|
---|
66 | __END_DECLS
|
---|
67 |
|
---|
68 |
|
---|
69 | /*
|
---|
70 | * Internals of the Darwin Ring-0 IPRT.
|
---|
71 | */
|
---|
72 |
|
---|
73 | __BEGIN_DECLS
|
---|
74 | extern lck_grp_t *g_pDarwinLockGroup;
|
---|
75 | __END_DECLS
|
---|
76 |
|
---|
77 |
|
---|
78 | /**
|
---|
79 | * Converts from nanoseconds to Darwin absolute time units.
|
---|
80 | * @returns Darwin absolute time.
|
---|
81 | * @param u64Nano Time interval in nanoseconds
|
---|
82 | */
|
---|
83 | DECLINLINE(uint64_t) rtDarwinAbsTimeFromNano(const uint64_t u64Nano)
|
---|
84 | {
|
---|
85 | uint64_t u64AbsTime;
|
---|
86 | nanoseconds_to_absolutetime(u64Nano, &u64AbsTime);
|
---|
87 | return u64AbsTime;
|
---|
88 | }
|
---|
89 |
|
---|
90 |
|
---|
91 | #include <iprt/err.h>
|
---|
92 |
|
---|
93 | /**
|
---|
94 | * Convert from mach kernel return code to IPRT status code.
|
---|
95 | * @todo put this where it belongs! (i.e. in a separate file and prototype in iprt/err.h)
|
---|
96 | */
|
---|
97 | DECLINLINE(int) RTErrConvertFromMachKernReturn(kern_return_t rc)
|
---|
98 | {
|
---|
99 | switch (rc)
|
---|
100 | {
|
---|
101 | case KERN_SUCCESS: return VINF_SUCCESS;
|
---|
102 | default: return VERR_GENERAL_FAILURE;
|
---|
103 | }
|
---|
104 | }
|
---|
105 |
|
---|
106 | #endif
|
---|
107 |
|
---|