VirtualBox

source: vbox/trunk/src/VBox/HostDrivers/Support/SUPDrvInternal.h@ 25360

Last change on this file since 25360 was 25336, checked in by vboxsync, 15 years ago

HostDrivers,SrvIntNetR0,iprt/ntwrap.mac: Removed all the RT_WITH_W64_UNWIND_HACK fun.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 24.3 KB
Line 
1/* $Revision: 25336 $ */
2/** @file
3 * VirtualBox Support Driver - Internal header.
4 */
5
6/*
7 * Copyright (C) 2006-2007 Sun Microsystems, Inc.
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 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
27 * Clara, CA 95054 USA or visit http://www.sun.com if you need
28 * additional information or have any questions.
29 */
30
31#ifndef ___SUPDrvInternal_h
32#define ___SUPDrvInternal_h
33
34
35/*******************************************************************************
36* Header Files *
37*******************************************************************************/
38#include <VBox/cdefs.h>
39#include <VBox/types.h>
40#include <iprt/assert.h>
41#include <iprt/asm.h>
42#include <VBox/sup.h>
43#include <iprt/memobj.h>
44#include <iprt/time.h>
45#include <iprt/timer.h>
46#include <iprt/string.h>
47#include <iprt/err.h>
48
49#ifdef SUPDRV_AGNOSTIC
50/* do nothing */
51
52#elif defined(RT_OS_WINDOWS)
53 RT_C_DECLS_BEGIN
54# if (_MSC_VER >= 1400) && !defined(VBOX_WITH_PATCHED_DDK)
55# define _InterlockedExchange _InterlockedExchange_StupidDDKVsCompilerCrap
56# define _InterlockedExchangeAdd _InterlockedExchangeAdd_StupidDDKVsCompilerCrap
57# define _InterlockedCompareExchange _InterlockedCompareExchange_StupidDDKVsCompilerCrap
58# define _InterlockedAddLargeStatistic _InterlockedAddLargeStatistic_StupidDDKVsCompilerCrap
59# define _interlockedbittestandset _interlockedbittestandset_StupidDDKVsCompilerCrap
60# define _interlockedbittestandreset _interlockedbittestandreset_StupidDDKVsCompilerCrap
61# define _interlockedbittestandset64 _interlockedbittestandset64_StupidDDKVsCompilerCrap
62# define _interlockedbittestandreset64 _interlockedbittestandreset64_StupidDDKVsCompilerCrap
63# pragma warning(disable : 4163)
64# include <ntddk.h>
65# pragma warning(default : 4163)
66# undef _InterlockedExchange
67# undef _InterlockedExchangeAdd
68# undef _InterlockedCompareExchange
69# undef _InterlockedAddLargeStatistic
70# undef _interlockedbittestandset
71# undef _interlockedbittestandreset
72# undef _interlockedbittestandset64
73# undef _interlockedbittestandreset64
74# else
75# include <ntddk.h>
76# endif
77# include <memory.h>
78# define memcmp(a,b,c) mymemcmp(a,b,c)
79 int VBOXCALL mymemcmp(const void *, const void *, size_t);
80 RT_C_DECLS_END
81
82#elif defined(RT_OS_LINUX)
83# include <linux/autoconf.h>
84# include <linux/version.h>
85# if defined(CONFIG_MODVERSIONS) && !defined(MODVERSIONS)
86# define MODVERSIONS
87# if LINUX_VERSION_CODE < KERNEL_VERSION(2, 5, 71)
88# include <linux/modversions.h>
89# endif
90# endif
91# if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 0)
92# undef ALIGN
93# endif
94# ifndef KBUILD_STR
95# if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 16)
96# define KBUILD_STR(s) s
97# else
98# define KBUILD_STR(s) #s
99# endif
100# endif
101# include <linux/string.h>
102# include <linux/spinlock.h>
103# include <linux/slab.h>
104# if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27)
105# include <linux/semaphore.h>
106# else /* older kernels */
107# include <asm/semaphore.h>
108# endif /* older kernels */
109# include <linux/timer.h>
110
111# if 0
112# include <linux/hrtimer.h>
113# define VBOX_HRTIMER
114# endif
115
116#elif defined(RT_OS_DARWIN)
117# include <libkern/libkern.h>
118# include <iprt/string.h>
119
120#elif defined(RT_OS_OS2)
121
122#elif defined(RT_OS_FREEBSD)
123# define memset libkern_memset /** @todo these are just hacks to get it compiling, check out later. */
124# define memcmp libkern_memcmp
125# define strchr libkern_strchr
126# define strrchr libkern_strrchr
127# define ffsl libkern_ffsl
128# define fls libkern_fls
129# define flsl libkern_flsl
130# include <sys/libkern.h>
131# undef memset
132# undef memcmp
133# undef strchr
134# undef strrchr
135# undef ffs
136# undef ffsl
137# undef fls
138# undef flsl
139# include <iprt/string.h>
140
141#elif defined(RT_OS_SOLARIS)
142# include <sys/cmn_err.h>
143# include <iprt/string.h>
144
145#else
146# error "unsupported OS."
147#endif
148
149#include "SUPDrvIOC.h"
150#include "SUPDrvIDC.h"
151
152
153
154/*******************************************************************************
155* Defined Constants And Macros *
156*******************************************************************************/
157/*
158 * Hardcoded cookies.
159 */
160#define BIRD 0x64726962 /* 'bird' */
161#define BIRD_INV 0x62697264 /* 'drib' */
162
163
164/*
165 * Win32
166 */
167#if defined(RT_OS_WINDOWS)
168
169/* debug printf */
170# define OSDBGPRINT(a) DbgPrint a
171
172/** Maximum number of bytes we try to lock down in one go.
173 * This is supposed to have a limit right below 256MB, but this appears
174 * to actually be much lower. The values here have been determined experimentally.
175 */
176# ifdef RT_ARCH_X86
177# define MAX_LOCK_MEM_SIZE (32*1024*1024) /* 32mb */
178# endif
179# ifdef RT_ARCH_AMD64
180# define MAX_LOCK_MEM_SIZE (24*1024*1024) /* 24mb */
181# endif
182
183/** Use a normal mutex for the loader so we remain at the same IRQL after
184 * taking it.
185 * @todo fix the mutex implementation on linux and make this the default. */
186# define SUPDRV_USE_MUTEX_FOR_LDR
187
188/*
189 * Linux
190 */
191#elif defined(RT_OS_LINUX)
192
193/* check kernel version */
194# ifndef SUPDRV_AGNOSTIC
195# if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 0)
196# error Unsupported kernel version!
197# endif
198# endif
199
200RT_C_DECLS_BEGIN
201int linux_dprintf(const char *format, ...);
202RT_C_DECLS_END
203
204/* debug printf */
205# define OSDBGPRINT(a) printk a
206
207
208/*
209 * Darwin
210 */
211#elif defined(RT_OS_DARWIN)
212
213/* debug printf */
214# define OSDBGPRINT(a) printf a
215
216
217/*
218 * OS/2
219 */
220#elif defined(RT_OS_OS2)
221
222/* No log API in OS/2 only COM port. */
223# define OSDBGPRINT(a) SUPR0Printf a
224
225
226/*
227 * FreeBSD
228 */
229#elif defined(RT_OS_FREEBSD)
230
231/* debug printf */
232# define OSDBGPRINT(a) printf a
233
234
235/*
236 * Solaris
237 */
238#elif defined(RT_OS_SOLARIS)
239# define OSDBGPRINT(a) SUPR0Printf a
240
241
242#else
243/** @todo other os'es */
244# error "OS interface defines is not done for this OS!"
245#endif
246
247
248/* dprintf */
249#if (defined(DEBUG) && !defined(NO_LOGGING))
250# ifdef LOG_TO_COM
251# include <VBox/log.h>
252# define dprintf(a) RTLogComPrintf a
253# else
254# define dprintf(a) OSDBGPRINT(a)
255# endif
256#else
257# define dprintf(a) do {} while (0)
258#endif
259
260/* dprintf2 - extended logging. */
261#if defined(RT_OS_DARWIN) || defined(RT_OS_OS2) || defined(RT_OS_FREEBSD)
262# define dprintf2 dprintf
263#else
264# define dprintf2(a) do { } while (0)
265#endif
266
267
268/*
269 * Error codes.
270 */
271/** @todo retire the SUPDRV_ERR_* stuff, we ship err.h now. */
272/** Invalid parameter. */
273#define SUPDRV_ERR_GENERAL_FAILURE (-1)
274/** Invalid parameter. */
275#define SUPDRV_ERR_INVALID_PARAM (-2)
276/** Invalid magic or cookie. */
277#define SUPDRV_ERR_INVALID_MAGIC (-3)
278/** Invalid loader handle. */
279#define SUPDRV_ERR_INVALID_HANDLE (-4)
280/** Failed to lock the address range. */
281#define SUPDRV_ERR_LOCK_FAILED (-5)
282/** Invalid memory pointer. */
283#define SUPDRV_ERR_INVALID_POINTER (-6)
284/** Failed to patch the IDT. */
285#define SUPDRV_ERR_IDT_FAILED (-7)
286/** Memory allocation failed. */
287#define SUPDRV_ERR_NO_MEMORY (-8)
288/** Already loaded. */
289#define SUPDRV_ERR_ALREADY_LOADED (-9)
290/** Permission denied. */
291#define SUPDRV_ERR_PERMISSION_DENIED (-10)
292/** Version mismatch. */
293#define SUPDRV_ERR_VERSION_MISMATCH (-11)
294
295
296/** @name Context values for the per-session handle tables.
297 * The context value is used to distiguish between the different kinds of
298 * handles, making the handle table API do all the work.
299 * @{ */
300/** Handle context value for single release event handles. */
301#define SUPDRV_HANDLE_CTX_EVENT ((void *)(uintptr_t)(SUPDRVOBJTYPE_SEM_EVENT))
302/** Handle context value for multiple release event handles. */
303#define SUPDRV_HANDLE_CTX_EVENT_MULTI ((void *)(uintptr_t)(SUPDRVOBJTYPE_SEM_EVENT_MULTI))
304/** @} */
305
306
307/**
308 * Validates a session pointer.
309 *
310 * @returns true/false accordingly.
311 * @param pSession The session.
312 */
313#define SUP_IS_SESSION_VALID(pSession) \
314 ( VALID_PTR(pSession) \
315 && pSession->u32Cookie == BIRD_INV)
316
317
318/*******************************************************************************
319* Structures and Typedefs *
320*******************************************************************************/
321/** Pointer to the device extension. */
322typedef struct SUPDRVDEVEXT *PSUPDRVDEVEXT;
323
324
325/**
326 * Memory reference types.
327 */
328typedef enum
329{
330 /** Unused entry */
331 MEMREF_TYPE_UNUSED = 0,
332 /** Locked memory (r3 mapping only). */
333 MEMREF_TYPE_LOCKED,
334 /** Continous memory block (r3 and r0 mapping). */
335 MEMREF_TYPE_CONT,
336 /** Low memory block (r3 and r0 mapping). */
337 MEMREF_TYPE_LOW,
338 /** Memory block (r3 and r0 mapping). */
339 MEMREF_TYPE_MEM,
340 /** Locked memory (r3 mapping only) allocated by the support driver. */
341 MEMREF_TYPE_PAGE,
342 /** Blow the type up to 32-bit and mark the end. */
343 MEMREG_TYPE_32BIT_HACK = 0x7fffffff
344} SUPDRVMEMREFTYPE, *PSUPDRVMEMREFTYPE;
345
346
347/**
348 * Structure used for tracking memory a session
349 * references in one way or another.
350 */
351typedef struct SUPDRVMEMREF
352{
353 /** The memory object handle. */
354 RTR0MEMOBJ MemObj;
355 /** The ring-3 mapping memory object handle. */
356 RTR0MEMOBJ MapObjR3;
357 /** Type of memory. */
358 SUPDRVMEMREFTYPE eType;
359} SUPDRVMEMREF, *PSUPDRVMEMREF;
360
361
362/**
363 * Bundle of locked memory ranges.
364 */
365typedef struct SUPDRVBUNDLE
366{
367 /** Pointer to the next bundle. */
368 struct SUPDRVBUNDLE * volatile pNext;
369 /** Referenced memory. */
370 SUPDRVMEMREF aMem[64];
371 /** Number of entries used. */
372 uint32_t volatile cUsed;
373} SUPDRVBUNDLE, *PSUPDRVBUNDLE;
374
375
376/**
377 * Loaded image.
378 */
379typedef struct SUPDRVLDRIMAGE
380{
381 /** Next in chain. */
382 struct SUPDRVLDRIMAGE * volatile pNext;
383 /** Pointer to the image. */
384 void *pvImage;
385 /** Pointer to the allocated image buffer.
386 * pvImage is 32-byte aligned or it may governed by the native loader (this
387 * member is NULL then). */
388 void *pvImageAlloc;
389 /** Size of the image including the tables. This is mainly for verification
390 * of the load request. */
391 uint32_t cbImageWithTabs;
392 /** Size of the image. */
393 uint32_t cbImageBits;
394 /** The number of entries in the symbol table. */
395 uint32_t cSymbols;
396 /** Pointer to the symbol table. */
397 PSUPLDRSYM paSymbols;
398 /** The offset of the string table. */
399 char *pachStrTab;
400 /** Size of the string table. */
401 uint32_t cbStrTab;
402 /** Pointer to the optional module initialization callback. */
403 PFNR0MODULEINIT pfnModuleInit;
404 /** Pointer to the optional module termination callback. */
405 PFNR0MODULETERM pfnModuleTerm;
406 /** Service request handler. This is NULL for non-service modules. */
407 PFNSUPR0SERVICEREQHANDLER pfnServiceReqHandler;
408 /** The ldr image state. (IOCtl code of last opration.) */
409 uint32_t uState;
410 /** Usage count. */
411 uint32_t volatile cUsage;
412#ifdef RT_OS_WINDOWS
413 /** The section object for the loaded image (fNative=true). */
414 void *pvNtSectionObj;
415 /** Lock object. */
416 RTR0MEMOBJ hMemLock;
417#endif
418 /** Whether it's loaded by the native loader or not. */
419 bool fNative;
420 /** Image name. */
421 char szName[32];
422} SUPDRVLDRIMAGE, *PSUPDRVLDRIMAGE;
423
424
425/** Image usage record. */
426typedef struct SUPDRVLDRUSAGE
427{
428 /** Next in chain. */
429 struct SUPDRVLDRUSAGE * volatile pNext;
430 /** The image. */
431 PSUPDRVLDRIMAGE pImage;
432 /** Load count. */
433 uint32_t volatile cUsage;
434} SUPDRVLDRUSAGE, *PSUPDRVLDRUSAGE;
435
436
437/**
438 * Component factory registration record.
439 */
440typedef struct SUPDRVFACTORYREG
441{
442 /** Pointer to the next registration. */
443 struct SUPDRVFACTORYREG *pNext;
444 /** Pointer to the registered factory. */
445 PCSUPDRVFACTORY pFactory;
446 /** The session owning the factory.
447 * Used for deregistration and session cleanup. */
448 PSUPDRVSESSION pSession;
449 /** Length of the name. */
450 size_t cchName;
451} SUPDRVFACTORYREG;
452/** Pointer to a component factory registration record. */
453typedef SUPDRVFACTORYREG *PSUPDRVFACTORYREG;
454/** Pointer to a const component factory registration record. */
455typedef SUPDRVFACTORYREG const *PCSUPDRVFACTORYREG;
456
457
458/**
459 * Registered object.
460 * This takes care of reference counting and tracking data for access checks.
461 */
462typedef struct SUPDRVOBJ
463{
464 /** Magic value (SUPDRVOBJ_MAGIC). */
465 uint32_t u32Magic;
466 /** The object type. */
467 SUPDRVOBJTYPE enmType;
468 /** Pointer to the next in the global list. */
469 struct SUPDRVOBJ * volatile pNext;
470 /** Pointer to the object destructor.
471 * This may be set to NULL if the image containing the destructor get unloaded. */
472 PFNSUPDRVDESTRUCTOR pfnDestructor;
473 /** User argument 1. */
474 void *pvUser1;
475 /** User argument 2. */
476 void *pvUser2;
477 /** The total sum of all per-session usage. */
478 uint32_t volatile cUsage;
479 /** The creator user id. */
480 RTUID CreatorUid;
481 /** The creator group id. */
482 RTGID CreatorGid;
483 /** The creator process id. */
484 RTPROCESS CreatorProcess;
485} SUPDRVOBJ, *PSUPDRVOBJ;
486
487/** Magic number for SUPDRVOBJ::u32Magic. (Dame Agatha Mary Clarissa Christie). */
488#define SUPDRVOBJ_MAGIC 0x18900915
489/** Dead number magic for SUPDRVOBJ::u32Magic. */
490#define SUPDRVOBJ_MAGIC_DEAD 0x19760112
491
492/**
493 * The per-session object usage record.
494 */
495typedef struct SUPDRVUSAGE
496{
497 /** Pointer to the next in the list. */
498 struct SUPDRVUSAGE * volatile pNext;
499 /** Pointer to the object we're recording usage for. */
500 PSUPDRVOBJ pObj;
501 /** The usage count. */
502 uint32_t volatile cUsage;
503} SUPDRVUSAGE, *PSUPDRVUSAGE;
504
505
506/**
507 * Per session data.
508 * This is mainly for memory tracking.
509 */
510typedef struct SUPDRVSESSION
511{
512 /** Pointer to the device extension. */
513 PSUPDRVDEVEXT pDevExt;
514 /** Session Cookie. */
515 uint32_t u32Cookie;
516
517 /** The VM associated with the session. */
518 PVM pVM;
519 /** Handle table for IPRT semaphore wrapper APIs.
520 * Programmable from R0 and R3. */
521 RTHANDLETABLE hHandleTable;
522 /** Load usage records. (protected by SUPDRVDEVEXT::mtxLdr) */
523 PSUPDRVLDRUSAGE volatile pLdrUsage;
524
525 /** Spinlock protecting the bundles and the GIP members. */
526 RTSPINLOCK Spinlock;
527 /** The ring-3 mapping of the GIP (readonly). */
528 RTR0MEMOBJ GipMapObjR3;
529 /** Set if the session is using the GIP. */
530 uint32_t fGipReferenced;
531 /** Bundle of locked memory objects. */
532 SUPDRVBUNDLE Bundle;
533 /** List of generic usage records. (protected by SUPDRVDEVEXT::SpinLock) */
534 PSUPDRVUSAGE volatile pUsage;
535
536 /** The user id of the session. (Set by the OS part.) */
537 RTUID Uid;
538 /** The group id of the session. (Set by the OS part.) */
539 RTGID Gid;
540 /** The process (id) of the session. */
541 RTPROCESS Process;
542 /** Which process this session is associated with.
543 * This is NIL_RTR0PROCESS for kernel sessions and valid for user ones. */
544 RTR0PROCESS R0Process;
545#ifndef SUPDRV_AGNOSTIC
546# if defined(RT_OS_DARWIN)
547 /** Pointer to the associated org_virtualbox_SupDrvClient object. */
548 void *pvSupDrvClient;
549 /** Whether this session has been opened or not. */
550 bool fOpened;
551# endif
552# if defined(RT_OS_OS2)
553 /** The system file number of this session. */
554 uint16_t sfn;
555 uint16_t Alignment; /**< Alignment */
556# endif
557# if defined(RT_OS_DARWIN) || defined(RT_OS_OS2) || defined(RT_OS_SOLARIS)
558 /** Pointer to the next session with the same hash. */
559 PSUPDRVSESSION pNextHash;
560# endif
561#endif /* !SUPDRV_AGNOSTIC */
562} SUPDRVSESSION;
563
564
565/**
566 * Device extension.
567 */
568typedef struct SUPDRVDEVEXT
569{
570 /** Spinlock to serialize the initialization, usage counting and objects. */
571 RTSPINLOCK Spinlock;
572
573 /** List of registered objects. Protected by the spinlock. */
574 PSUPDRVOBJ volatile pObjs;
575 /** List of free object usage records. */
576 PSUPDRVUSAGE volatile pUsageFree;
577
578 /** Global cookie. */
579 uint32_t u32Cookie;
580
581 /** The IDT entry number.
582 * Only valid if pIdtPatches is set. */
583 uint8_t volatile u8Idt;
584
585 /** Loader mutex.
586 * This protects pvVMMR0, pvVMMR0Entry, pImages and SUPDRVSESSION::pLdrUsage. */
587#ifdef SUPDRV_USE_MUTEX_FOR_LDR
588 RTSEMMUTEX mtxLdr;
589#else
590 RTSEMFASTMUTEX mtxLdr;
591#endif
592
593 /** VMM Module 'handle'.
594 * 0 if the code VMM isn't loaded and Idt are nops. */
595 void * volatile pvVMMR0;
596 /** VMMR0EntryInt() pointer. */
597 DECLR0CALLBACKMEMBER(int, pfnVMMR0EntryInt, (PVM pVM, unsigned uOperation, void *pvArg));
598 /** VMMR0EntryFast() pointer. */
599 DECLR0CALLBACKMEMBER(void, pfnVMMR0EntryFast, (PVM pVM, VMCPUID idCpu, unsigned uOperation));
600 /** VMMR0EntryEx() pointer. */
601 DECLR0CALLBACKMEMBER(int, pfnVMMR0EntryEx, (PVM pVM, VMCPUID idCpu, unsigned uOperation, PSUPVMMR0REQHDR pReq, uint64_t u64Arg, PSUPDRVSESSION pSession));
602
603 /** Linked list of loaded code. */
604 PSUPDRVLDRIMAGE volatile pLdrImages;
605
606 /** GIP mutex.
607 * Any changes to any of the GIP members requires ownership of this mutex,
608 * except on driver init and termination. */
609 RTSEMFASTMUTEX mtxGip;
610 /** Pointer to the Global Info Page (GIP). */
611 PSUPGLOBALINFOPAGE pGip;
612 /** The physical address of the GIP. */
613 RTHCPHYS HCPhysGip;
614 /** Number of processes using the GIP.
615 * (The updates are suspend while cGipUsers is 0.)*/
616 uint32_t volatile cGipUsers;
617 /** The ring-0 memory object handle for the GIP page. */
618 RTR0MEMOBJ GipMemObj;
619 /** The GIP timer handle. */
620 PRTTIMER pGipTimer;
621 /** If non-zero we've successfully called RTTimerRequestSystemGranularity(). */
622 uint32_t u32SystemTimerGranularityGrant;
623 /** The CPU id of the GIP master.
624 * This CPU is responsible for the updating the common GIP data. */
625 RTCPUID volatile idGipMaster;
626
627 /** Component factory mutex.
628 * This protects pComponentFactoryHead and component factory querying. */
629 RTSEMFASTMUTEX mtxComponentFactory;
630 /** The head of the list of registered component factories. */
631 PSUPDRVFACTORYREG pComponentFactoryHead;
632
633#ifndef SUPDRV_AGNOSTIC
634# ifdef RT_OS_WINDOWS
635 /* Callback object returned by ExCreateCallback. */
636 PCALLBACK_OBJECT pObjPowerCallback;
637 /* Callback handle returned by ExRegisterCallback. */
638 PVOID hPowerCallback;
639# endif
640#endif
641} SUPDRVDEVEXT;
642
643
644RT_C_DECLS_BEGIN
645
646/*******************************************************************************
647* OS Specific Functions *
648*******************************************************************************/
649void VBOXCALL supdrvOSObjInitCreator(PSUPDRVOBJ pObj, PSUPDRVSESSION pSession);
650bool VBOXCALL supdrvOSObjCanAccess(PSUPDRVOBJ pObj, PSUPDRVSESSION pSession, const char *pszObjName, int *prc);
651bool VBOXCALL supdrvOSGetForcedAsyncTscMode(PSUPDRVDEVEXT pDevExt);
652int VBOXCALL supdrvOSEnableVTx(bool fEnabled);
653
654/**
655 * Try open the image using the native loader.
656 *
657 * @returns IPRT status code.
658 * @retval VERR_NOT_SUPPORTED if native loading isn't supported.
659 *
660 * @param pDevExt The device globals.
661 * @param pImage The image handle. pvImage should be set on
662 * success, pvImageAlloc can also be set if
663 * appropriate.
664 * @param pszFilename The file name - UTF-8, may containg UNIX
665 * slashes on non-UNIX systems.
666 */
667int VBOXCALL supdrvOSLdrOpen(PSUPDRVDEVEXT pDevExt, PSUPDRVLDRIMAGE pImage, const char *pszFilename);
668
669/**
670 * Validates an entry point address.
671 *
672 * Called before supdrvOSLdrLoad.
673 *
674 * @returns IPRT status code.
675 * @param pDevExt The device globals.
676 * @param pImage The image data (still in the open state).
677 * @param pv The address within the image.
678 * @param pbImageBits The image bits as loaded by ring-3.
679 */
680int VBOXCALL supdrvOSLdrValidatePointer(PSUPDRVDEVEXT pDevExt, PSUPDRVLDRIMAGE pImage,
681 void *pv, const uint8_t *pbImageBits);
682
683/**
684 * Load the image.
685 *
686 * @returns IPRT status code.
687 * @param pDevExt The device globals.
688 * @param pImage The image data (up to date except for some
689 * entry point pointers).
690 * @param pbImageBits The image bits as loaded by ring-3.
691 */
692int VBOXCALL supdrvOSLdrLoad(PSUPDRVDEVEXT pDevExt, PSUPDRVLDRIMAGE pImage, const uint8_t *pbImageBits);
693
694
695/**
696 * Unload the image.
697 *
698 * @param pDevExt The device globals.
699 * @param pImage The image data (mostly still valid).
700 */
701void VBOXCALL supdrvOSLdrUnload(PSUPDRVDEVEXT pDevExt, PSUPDRVLDRIMAGE pImage);
702
703
704/*******************************************************************************
705* Shared Functions *
706*******************************************************************************/
707/* SUPDrv.c */
708int VBOXCALL supdrvIOCtl(uintptr_t uIOCtl, PSUPDRVDEVEXT pDevExt, PSUPDRVSESSION pSession, PSUPREQHDR pReqHdr);
709int VBOXCALL supdrvIOCtlFast(uintptr_t uIOCtl, VMCPUID idCpu, PSUPDRVDEVEXT pDevExt, PSUPDRVSESSION pSession);
710int VBOXCALL supdrvIDC(uintptr_t uIOCtl, PSUPDRVDEVEXT pDevExt, PSUPDRVSESSION pSession, PSUPDRVIDCREQHDR pReqHdr);
711int VBOXCALL supdrvInitDevExt(PSUPDRVDEVEXT pDevExt);
712void VBOXCALL supdrvDeleteDevExt(PSUPDRVDEVEXT pDevExt);
713int VBOXCALL supdrvCreateSession(PSUPDRVDEVEXT pDevExt, bool fUser, PSUPDRVSESSION *ppSession);
714void VBOXCALL supdrvCloseSession(PSUPDRVDEVEXT pDevExt, PSUPDRVSESSION pSession);
715void VBOXCALL supdrvCleanupSession(PSUPDRVDEVEXT pDevExt, PSUPDRVSESSION pSession);
716int VBOXCALL supdrvGipInit(PSUPDRVDEVEXT pDevExt, PSUPGLOBALINFOPAGE pGip, RTHCPHYS HCPhys, uint64_t u64NanoTS, unsigned uUpdateHz);
717void VBOXCALL supdrvGipTerm(PSUPGLOBALINFOPAGE pGip);
718void VBOXCALL supdrvGipUpdate(PSUPGLOBALINFOPAGE pGip, uint64_t u64NanoTS, uint64_t u64TSC);
719void VBOXCALL supdrvGipUpdatePerCpu(PSUPGLOBALINFOPAGE pGip, uint64_t u64NanoTS, uint64_t u64TSC, unsigned iCpu);
720bool VBOXCALL supdrvDetermineAsyncTsc(uint64_t *pu64DiffCores);
721
722/* SUPDrvAgnostic.c */
723SUPGIPMODE VBOXCALL supdrvGipDeterminTscMode(PSUPDRVDEVEXT pDevExt);
724
725RT_C_DECLS_END
726
727#endif
728
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