VirtualBox

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

Last change on this file since 40981 was 40981, checked in by vboxsync, 13 years ago

SUPLib,SUPDrv: Working on the user mode tracer interface.

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