VirtualBox

source: vbox/trunk/src/VBox/Runtime/r0drv/solaris/the-solaris-kernel.h@ 78381

Last change on this file since 78381 was 76585, checked in by vboxsync, 6 years ago

*: scm --fix-header-guard-endif

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id Revision
File size: 8.9 KB
Line 
1/* $Id: the-solaris-kernel.h 76585 2019-01-01 06:31:29Z vboxsync $ */
2/** @file
3 * IPRT - Include all necessary headers for the Solaris kernel.
4 */
5
6/*
7 * Copyright (C) 2006-2019 Oracle Corporation
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 (GPL) as published by the Free Software
13 * Foundation, in version 2 as it comes in the "COPYING" file of the
14 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16 *
17 * The contents of this file may alternatively be used under the terms
18 * of the Common Development and Distribution License Version 1.0
19 * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
20 * VirtualBox OSE distribution, in which case the provisions of the
21 * CDDL are applicable instead of those of the GPL.
22 *
23 * You may elect to license modified versions of this file under the
24 * terms and conditions of either the GPL or the CDDL or both.
25 */
26
27#ifndef IPRT_INCLUDED_SRC_r0drv_solaris_the_solaris_kernel_h
28#define IPRT_INCLUDED_SRC_r0drv_solaris_the_solaris_kernel_h
29#ifndef RT_WITHOUT_PRAGMA_ONCE
30# pragma once
31#endif
32
33#include <sys/kmem.h>
34#include <sys/types.h>
35#include <sys/mman.h>
36#include <sys/thread.h>
37#include <sys/mutex.h>
38#include <sys/condvar.h>
39#include <sys/sdt.h>
40#include <sys/schedctl.h>
41#include <sys/time.h>
42#include <sys/sysmacros.h>
43#include <sys/cmn_err.h>
44#include <sys/vmsystm.h>
45#include <sys/cyclic.h>
46#include <sys/class.h>
47#include <sys/cpuvar.h>
48#include <sys/archsystm.h>
49#include <sys/x_call.h> /* in platform dir */
50#include <sys/x86_archext.h>
51#include <vm/hat.h>
52#include <vm/seg_vn.h>
53#include <vm/seg_kmem.h>
54#include <vm/page.h>
55#include <sys/ddi.h>
56#include <sys/sunddi.h>
57#include <sys/spl.h>
58#include <sys/archsystm.h>
59#include <sys/callo.h>
60#include <sys/kobj.h>
61#include <sys/ctf_api.h>
62#include <sys/modctl.h>
63#include <sys/proc.h>
64#include <sys/t_lock.h>
65
66#undef u /* /usr/include/sys/user.h:249:1 is where this is defined to (curproc->p_user). very cool. */
67
68#include <iprt/cdefs.h>
69#include <iprt/types.h>
70#include <iprt/dbg.h>
71
72RT_C_DECLS_BEGIN
73
74/* IPRT functions. */
75DECLHIDDEN(void *) rtR0SolMemAlloc(uint64_t cbPhysHi, uint64_t *puPhys, size_t cb, uint64_t cbAlign, bool fContig);
76DECLHIDDEN(void) rtR0SolMemFree(void *pv, size_t cb);
77
78
79/* Solaris functions. */
80typedef callout_id_t (*PFNSOL_timeout_generic)(int type, void (*func)(void *),
81 void *arg, hrtime_t expiration,
82 hrtime_t resultion, int flags);
83typedef hrtime_t (*PFNSOL_untimeout_generic)(callout_id_t id, int nowait);
84typedef int (*PFNSOL_cyclic_reprogram)(cyclic_id_t id, hrtime_t expiration);
85typedef void (*PFNSOL_contig_free)(void *addr, size_t size);
86typedef int (*PFNSOL_page_noreloc_supported)(size_t cbPageSize);
87
88/* IPRT globals. */
89extern bool g_frtSolSplSetsEIF;
90extern RTCPUSET g_rtMpSolCpuSet;
91extern PFNSOL_timeout_generic g_pfnrtR0Sol_timeout_generic;
92extern PFNSOL_untimeout_generic g_pfnrtR0Sol_untimeout_generic;
93extern PFNSOL_cyclic_reprogram g_pfnrtR0Sol_cyclic_reprogram;
94extern PFNSOL_contig_free g_pfnrtR0Sol_contig_free;
95extern PFNSOL_page_noreloc_supported g_pfnrtR0Sol_page_noreloc_supported;
96extern size_t g_offrtSolThreadPreempt;
97extern size_t g_offrtSolThreadIntrThread;
98extern size_t g_offrtSolThreadLock;
99extern size_t g_offrtSolThreadProc;
100extern size_t g_offrtSolThreadId;
101extern size_t g_offrtSolCpuPreempt;
102extern size_t g_offrtSolCpuForceKernelPreempt;
103extern bool g_frtSolInitDone;
104extern RTDBGKRNLINFO g_hKrnlDbgInfo;
105
106/*
107 * Workarounds for running on old versions of solaris with different cross call
108 * interfaces. If we find xc_init_cpu() in the kernel, then just use the
109 * defined interfaces for xc_call() from the include file where the xc_call()
110 * interfaces just takes a pointer to a ulong_t array. The array must be long
111 * enough to hold "ncpus" bits at runtime.
112
113 * The reason for the hacks is that using the type "cpuset_t" is pretty much
114 * impossible from code built outside the Solaris source repository that wants
115 * to run on multiple releases of Solaris.
116 *
117 * For old style xc_call()s, 32 bit solaris and older 64 bit versions use
118 * "ulong_t" as cpuset_t.
119 *
120 * Later versions of 64 bit Solaris used: struct {ulong_t words[x];}
121 * where "x" depends on NCPU.
122 *
123 * We detect the difference in 64 bit support by checking the kernel value of
124 * max_cpuid, which always holds the compiled value of NCPU - 1.
125 *
126 * If Solaris increases NCPU to more than 256, VBox will continue to work on
127 * all versions of Solaris as long as the number of installed CPUs in the
128 * machine is <= IPRT_SOLARIS_NCPUS. If IPRT_SOLARIS_NCPUS is increased, this
129 * code has to be re-written some to provide compatibility with older Solaris
130 * which expects cpuset_t to be based on NCPU==256 -- or we discontinue
131 * support of old Nevada/S10.
132 */
133#define IPRT_SOL_NCPUS 256
134#define IPRT_SOL_SET_WORDS (IPRT_SOL_NCPUS / (sizeof(ulong_t) * 8))
135#define IPRT_SOL_X_CALL_HIPRI (2) /* for Old Solaris interface */
136typedef struct RTSOLCPUSET
137{
138 ulong_t auCpus[IPRT_SOL_SET_WORDS];
139} RTSOLCPUSET;
140typedef RTSOLCPUSET *PRTSOLCPUSET;
141
142/* Avoid warnings even if it means more typing... */
143typedef struct RTR0FNSOLXCCALL
144{
145 union
146 {
147 void *(*pfnSol_xc_call) (xc_arg_t, xc_arg_t, xc_arg_t, ulong_t *, xc_func_t);
148 void *(*pfnSol_xc_call_old) (xc_arg_t, xc_arg_t, xc_arg_t, int, RTSOLCPUSET, xc_func_t);
149 void *(*pfnSol_xc_call_old_ulong)(xc_arg_t, xc_arg_t, xc_arg_t, int, ulong_t, xc_func_t);
150 } u;
151} RTR0FNSOLXCCALL;
152typedef RTR0FNSOLXCCALL *PRTR0FNSOLXCCALL;
153
154extern RTR0FNSOLXCCALL g_rtSolXcCall;
155extern bool g_frtSolOldIPI;
156extern bool g_frtSolOldIPIUlong;
157
158/*
159 * Thread-context hooks.
160 * Workarounds for older Solaris versions that did not have the exitctx() callback.
161 */
162typedef struct RTR0FNSOLTHREADCTX
163{
164 union
165 {
166 void *(*pfnSol_installctx) (kthread_t *pThread, void *pvArg,
167 void (*pfnSave)(void *pvArg),
168 void (*pfnRestore)(void *pvArg),
169 void (*pfnFork)(void *pvThread, void *pvThreadFork),
170 void (*pfnLwpCreate)(void *pvThread, void *pvThreadCreate),
171 void (*pfnExit)(void *pvThread),
172 void (*pfnFree)(void *pvArg, int fIsExec));
173
174 void *(*pfnSol_installctx_old) (kthread_t *pThread, void *pvArg,
175 void (*pfnSave)(void *pvArg),
176 void (*pfnRestore)(void *pvArg),
177 void (*pfnFork)(void *pvThread, void *pvThreadFork),
178 void (*pfnLwpCreate)(void *pvThread, void *pvThreadCreate),
179 void (*pfnFree)(void *pvArg, int fIsExec));
180 } Install;
181
182 union
183 {
184 int (*pfnSol_removectx) (kthread_t *pThread, void *pvArg,
185 void (*pfnSave)(void *pvArg),
186 void (*pfnRestore)(void *pvArg),
187 void (*pfnFork)(void *pvThread, void *pvThreadFork),
188 void (*pfnLwpCreate)(void *pvThread, void *pvThreadCreate),
189 void (*pfnExit)(void *pvThread),
190 void (*pfnFree)(void *pvArg, int fIsExec));
191
192 int (*pfnSol_removectx_old) (kthread_t *pThread, void *pvArg,
193 void (*pfnSave)(void *pvArg),
194 void (*pfnRestore)(void *pvArg),
195 void (*pfnFork)(void *pvThread, void *pvThreadFork),
196 void (*pfnLwpCreate)(void *pvThread, void *pvThreadCreate),
197 void (*pfnFree)(void *pvArg, int fIsExec));
198 } Remove;
199} RTR0FNSOLTHREADCTX;
200typedef RTR0FNSOLTHREADCTX *PRTR0FNSOLTHREADCTX;
201
202extern RTR0FNSOLTHREADCTX g_rtSolThreadCtx;
203extern bool g_frtSolOldThreadCtx;
204
205/* Solaris globals. */
206extern uintptr_t kernelbase;
207
208/* Misc stuff from newer kernels. */
209#ifndef CALLOUT_FLAG_ABSOLUTE
210# define CALLOUT_FLAG_ABSOLUTE 2
211#endif
212
213RT_C_DECLS_END
214
215#endif /* !IPRT_INCLUDED_SRC_r0drv_solaris_the_solaris_kernel_h */
216
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette