VirtualBox

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

最後變更 在這個檔案從107247是 107247,由 vboxsync 提交於 3 月 前

iprt/the-solaris-kernel.h: Pairfait workaround attempt.

  • 屬性 svn:eol-style 設為 native
  • 屬性 svn:keywords 設為 Id Revision
檔案大小: 10.7 KB
 
1/* $Id: the-solaris-kernel.h 107247 2024-12-06 17:50:03Z vboxsync $ */
2/** @file
3 * IPRT - Include all necessary headers for the Solaris kernel.
4 */
5
6/*
7 * Copyright (C) 2006-2024 Oracle and/or its affiliates.
8 *
9 * This file is part of VirtualBox base platform packages, as
10 * available from https://www.alldomusa.eu.org.
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation, in version 3 of the
15 * License.
16 *
17 * This program is distributed in the hope that it will be useful, but
18 * WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 * General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, see <https://www.gnu.org/licenses>.
24 *
25 * The contents of this file may alternatively be used under the terms
26 * of the Common Development and Distribution License Version 1.0
27 * (CDDL), a copy of it is provided in the "COPYING.CDDL" file included
28 * in the VirtualBox distribution, in which case the provisions of the
29 * CDDL are applicable instead of those of the GPL.
30 *
31 * You may elect to license modified versions of this file under the
32 * terms and conditions of either the GPL or the CDDL or both.
33 *
34 * SPDX-License-Identifier: GPL-3.0-only OR CDDL-1.0
35 */
36
37#ifndef IPRT_INCLUDED_SRC_r0drv_solaris_the_solaris_kernel_h
38#define IPRT_INCLUDED_SRC_r0drv_solaris_the_solaris_kernel_h
39#ifndef RT_WITHOUT_PRAGMA_ONCE
40# pragma once
41#endif
42
43#if defined(VBOX_WITH_PARFAIT) && defined(__INT_FAST16_MAX__)
44/* HACK ALERT: Workaround for duplicate [u]int_fast16_t conflicting due to 'incorrect'
45 __INT_FAST16_TYPE__ and __UINT_FAST16_TYPE__ definitions in pairfait.
46 The types are usually 'int' and 'unsigned int', which the system headers
47 assume, thus we get a conflict when the pairfait compiler redefines to
48 a narrow variant. Workaround, try ignore the system types and use the
49 compiler ones... See also iprt/types.h. */
50# if (__INT_FAST16_MAX__) == 32767
51# define int_fast16_t hacked_int_fast16_t
52# define uint_fast16_t hacked_uint_fast16_t
53# include <sys/int_types.h>
54# endif
55#endif
56#include <sys/kmem.h>
57#include <sys/types.h>
58#include <sys/mman.h>
59#include <sys/thread.h>
60#include <sys/mutex.h>
61#include <sys/condvar.h>
62#include <sys/sdt.h>
63#include <sys/schedctl.h>
64#include <sys/time.h>
65#include <sys/sysmacros.h>
66#include <sys/cmn_err.h>
67#include <sys/vmsystm.h>
68#include <sys/cyclic.h>
69#include <sys/class.h>
70#include <sys/cpuvar.h>
71#include <sys/archsystm.h>
72#include <sys/x_call.h> /* in platform dir */
73#include <sys/x86_archext.h>
74#include <vm/hat.h>
75#include <vm/seg_vn.h>
76#include <vm/seg_kmem.h>
77#include <vm/page.h>
78#include <sys/ddi.h>
79#include <sys/sunddi.h>
80#include <sys/spl.h>
81#include <sys/archsystm.h>
82#include <sys/callo.h>
83#include <sys/kobj.h>
84#include <sys/ctf_api.h>
85#include <sys/modctl.h>
86#include <sys/proc.h>
87#include <sys/t_lock.h>
88
89#undef u /* /usr/include/sys/user.h:249:1 is where this is defined to (curproc->p_user). very cool. */
90#if defined(VBOX_WITH_PARFAIT) && defined(__INT_FAST16_MAX__) && defined(int_fast16_t) && defined(uint_fast16_t) /* see above */
91# undef int_fast16_t
92# undef uint_fast16_t
93#endif
94
95#include <iprt/cdefs.h>
96#include <iprt/types.h>
97#include <iprt/dbg.h>
98
99RT_C_DECLS_BEGIN
100
101/* IPRT functions. */
102DECLHIDDEN(void *) rtR0SolMemAlloc(uint64_t cbPhysHi, uint64_t *puPhys, size_t cb, uint64_t cbAlign, bool fContig);
103DECLHIDDEN(void) rtR0SolMemFree(void *pv, size_t cb);
104
105
106/* Solaris functions. */
107typedef callout_id_t (*PFNSOL_timeout_generic)(int type, void (*func)(void *),
108 void *arg, hrtime_t expiration,
109 hrtime_t resultion, int flags);
110typedef hrtime_t (*PFNSOL_untimeout_generic)(callout_id_t id, int nowait);
111typedef int (*PFNSOL_cyclic_reprogram)(cyclic_id_t id, hrtime_t expiration);
112typedef void (*PFNSOL_contig_free)(void *addr, size_t size);
113typedef int (*PFNSOL_page_noreloc_supported)(size_t cbPageSize);
114
115/* IPRT globals. */
116extern bool g_frtSolSplSetsEIF;
117extern RTCPUSET g_rtMpSolCpuSet;
118extern PFNSOL_timeout_generic g_pfnrtR0Sol_timeout_generic;
119extern PFNSOL_untimeout_generic g_pfnrtR0Sol_untimeout_generic;
120extern PFNSOL_cyclic_reprogram g_pfnrtR0Sol_cyclic_reprogram;
121extern PFNSOL_contig_free g_pfnrtR0Sol_contig_free;
122extern PFNSOL_page_noreloc_supported g_pfnrtR0Sol_page_noreloc_supported;
123extern size_t g_offrtSolThreadPreempt;
124extern size_t g_offrtSolThreadIntrThread;
125extern size_t g_offrtSolThreadLock;
126extern size_t g_offrtSolThreadProc;
127extern size_t g_offrtSolThreadId;
128extern size_t g_offrtSolCpuPreempt;
129extern size_t g_offrtSolCpuForceKernelPreempt;
130extern bool g_frtSolInitDone;
131extern RTDBGKRNLINFO g_hKrnlDbgInfo;
132
133/*
134 * Workarounds for running on old versions of solaris with different cross call
135 * interfaces. If we find xc_init_cpu() in the kernel, then just use the
136 * defined interfaces for xc_call() from the include file where the xc_call()
137 * interfaces just takes a pointer to a ulong_t array. The array must be long
138 * enough to hold "ncpus" bits at runtime.
139
140 * The reason for the hacks is that using the type "cpuset_t" is pretty much
141 * impossible from code built outside the Solaris source repository that wants
142 * to run on multiple releases of Solaris.
143 *
144 * For old style xc_call()s, 32 bit solaris and older 64 bit versions use
145 * "ulong_t" as cpuset_t.
146 *
147 * Later versions of 64 bit Solaris used: struct {ulong_t words[x];}
148 * where "x" depends on NCPU.
149 *
150 * We detect the difference in 64 bit support by checking the kernel value of
151 * max_cpuid, which always holds the compiled value of NCPU - 1.
152 *
153 * If Solaris increases NCPU to more than 256, VBox will continue to work on
154 * all versions of Solaris as long as the number of installed CPUs in the
155 * machine is <= IPRT_SOLARIS_NCPUS. If IPRT_SOLARIS_NCPUS is increased, this
156 * code has to be re-written some to provide compatibility with older Solaris
157 * which expects cpuset_t to be based on NCPU==256 -- or we discontinue
158 * support of old Nevada/S10.
159 */
160#define IPRT_SOL_NCPUS 256
161#define IPRT_SOL_SET_WORDS (IPRT_SOL_NCPUS / (sizeof(ulong_t) * 8))
162#define IPRT_SOL_X_CALL_HIPRI (2) /* for Old Solaris interface */
163typedef struct RTSOLCPUSET
164{
165 ulong_t auCpus[IPRT_SOL_SET_WORDS];
166} RTSOLCPUSET;
167typedef RTSOLCPUSET *PRTSOLCPUSET;
168
169/* Avoid warnings even if it means more typing... */
170typedef struct RTR0FNSOLXCCALL
171{
172 union
173 {
174 void *(*pfnSol_xc_call) (xc_arg_t, xc_arg_t, xc_arg_t, ulong_t *, xc_func_t);
175 void *(*pfnSol_xc_call_old) (xc_arg_t, xc_arg_t, xc_arg_t, int, RTSOLCPUSET, xc_func_t);
176 void *(*pfnSol_xc_call_old_ulong)(xc_arg_t, xc_arg_t, xc_arg_t, int, ulong_t, xc_func_t);
177 } u;
178} RTR0FNSOLXCCALL;
179typedef RTR0FNSOLXCCALL *PRTR0FNSOLXCCALL;
180
181extern RTR0FNSOLXCCALL g_rtSolXcCall;
182extern bool g_frtSolOldIPI;
183extern bool g_frtSolOldIPIUlong;
184
185/*
186 * Thread-context hooks.
187 * Workarounds for older Solaris versions that did not have the exitctx() callback.
188 */
189typedef struct RTR0FNSOLTHREADCTX
190{
191 union
192 {
193 void *(*pfnSol_installctx) (kthread_t *pThread, void *pvArg,
194 void (*pfnSave)(void *pvArg),
195 void (*pfnRestore)(void *pvArg),
196 void (*pfnFork)(void *pvThread, void *pvThreadFork),
197 void (*pfnLwpCreate)(void *pvThread, void *pvThreadCreate),
198 void (*pfnExit)(void *pvThread),
199 void (*pfnFree)(void *pvArg, int fIsExec));
200
201 void *(*pfnSol_installctx_old) (kthread_t *pThread, void *pvArg,
202 void (*pfnSave)(void *pvArg),
203 void (*pfnRestore)(void *pvArg),
204 void (*pfnFork)(void *pvThread, void *pvThreadFork),
205 void (*pfnLwpCreate)(void *pvThread, void *pvThreadCreate),
206 void (*pfnFree)(void *pvArg, int fIsExec));
207 } Install;
208
209 union
210 {
211 int (*pfnSol_removectx) (kthread_t *pThread, void *pvArg,
212 void (*pfnSave)(void *pvArg),
213 void (*pfnRestore)(void *pvArg),
214 void (*pfnFork)(void *pvThread, void *pvThreadFork),
215 void (*pfnLwpCreate)(void *pvThread, void *pvThreadCreate),
216 void (*pfnExit)(void *pvThread),
217 void (*pfnFree)(void *pvArg, int fIsExec));
218
219 int (*pfnSol_removectx_old) (kthread_t *pThread, void *pvArg,
220 void (*pfnSave)(void *pvArg),
221 void (*pfnRestore)(void *pvArg),
222 void (*pfnFork)(void *pvThread, void *pvThreadFork),
223 void (*pfnLwpCreate)(void *pvThread, void *pvThreadCreate),
224 void (*pfnFree)(void *pvArg, int fIsExec));
225 } Remove;
226} RTR0FNSOLTHREADCTX;
227typedef RTR0FNSOLTHREADCTX *PRTR0FNSOLTHREADCTX;
228
229extern RTR0FNSOLTHREADCTX g_rtSolThreadCtx;
230extern bool g_frtSolOldThreadCtx;
231
232/*
233 * Workaround for older Solaris versions which called map_addr()/choose_addr()/
234 * map_addr_proc() with an 'alignment' argument that was removed in Solaris
235 * 11.4.
236 */
237typedef struct RTR0FNSOLMAPADDR
238{
239 union
240 {
241 void *(*pfnSol_map_addr) (caddr_t *, size_t, offset_t, uint_t);
242 void *(*pfnSol_map_addr_old) (caddr_t *, size_t, offset_t, int, uint_t);
243 } u;
244} RTR0FNSOLMAPADDR;
245typedef RTR0FNSOLMAPADDR *PRTR0FNSOLMAPADDR;
246
247extern RTR0FNSOLMAPADDR g_rtSolMapAddr;
248extern bool g_frtSolOldMapAddr;
249
250/* Solaris globals. */
251extern uintptr_t kernelbase;
252
253/* Misc stuff from newer kernels. */
254#ifndef CALLOUT_FLAG_ABSOLUTE
255# define CALLOUT_FLAG_ABSOLUTE 2
256#endif
257
258RT_C_DECLS_END
259
260#endif /* !IPRT_INCLUDED_SRC_r0drv_solaris_the_solaris_kernel_h */
261
注意: 瀏覽 TracBrowser 來幫助您使用儲存庫瀏覽器

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