SUPDrvInternal.h revision c750a78e76a4f82628fdbfb6fb7cf6fd0647dfd3
c785dbab313731d1f4662b4684c0808cc14703dbvboxsync/* $Revision$ */
c785dbab313731d1f4662b4684c0808cc14703dbvboxsync * VirtualBox Support Driver - Internal header.
c785dbab313731d1f4662b4684c0808cc14703dbvboxsync * Copyright (C) 2006-2007 Oracle Corporation
c785dbab313731d1f4662b4684c0808cc14703dbvboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
c785dbab313731d1f4662b4684c0808cc14703dbvboxsync * available from http://www.virtualbox.org. This file is free software;
c785dbab313731d1f4662b4684c0808cc14703dbvboxsync * you can redistribute it and/or modify it under the terms of the GNU
c785dbab313731d1f4662b4684c0808cc14703dbvboxsync * General Public License (GPL) as published by the Free Software
c785dbab313731d1f4662b4684c0808cc14703dbvboxsync * Foundation, in version 2 as it comes in the "COPYING" file of the
c785dbab313731d1f4662b4684c0808cc14703dbvboxsync * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
c785dbab313731d1f4662b4684c0808cc14703dbvboxsync * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
c785dbab313731d1f4662b4684c0808cc14703dbvboxsync * The contents of this file may alternatively be used under the terms
c785dbab313731d1f4662b4684c0808cc14703dbvboxsync * of the Common Development and Distribution License Version 1.0
c785dbab313731d1f4662b4684c0808cc14703dbvboxsync * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
c785dbab313731d1f4662b4684c0808cc14703dbvboxsync * VirtualBox OSE distribution, in which case the provisions of the
c785dbab313731d1f4662b4684c0808cc14703dbvboxsync * CDDL are applicable instead of those of the GPL.
c785dbab313731d1f4662b4684c0808cc14703dbvboxsync * You may elect to license modified versions of this file under the
c785dbab313731d1f4662b4684c0808cc14703dbvboxsync * terms and conditions of either the GPL or the CDDL or both.
c785dbab313731d1f4662b4684c0808cc14703dbvboxsync/*******************************************************************************
c785dbab313731d1f4662b4684c0808cc14703dbvboxsync* Header Files *
c785dbab313731d1f4662b4684c0808cc14703dbvboxsync*******************************************************************************/
c785dbab313731d1f4662b4684c0808cc14703dbvboxsync/* do nothing */
c785dbab313731d1f4662b4684c0808cc14703dbvboxsync# if (_MSC_VER >= 1400) && !defined(VBOX_WITH_PATCHED_DDK)
c785dbab313731d1f4662b4684c0808cc14703dbvboxsync# define _InterlockedExchange _InterlockedExchange_StupidDDKVsCompilerCrap
c785dbab313731d1f4662b4684c0808cc14703dbvboxsync# define _InterlockedExchangeAdd _InterlockedExchangeAdd_StupidDDKVsCompilerCrap
c785dbab313731d1f4662b4684c0808cc14703dbvboxsync# define _InterlockedCompareExchange _InterlockedCompareExchange_StupidDDKVsCompilerCrap
c785dbab313731d1f4662b4684c0808cc14703dbvboxsync# define _InterlockedAddLargeStatistic _InterlockedAddLargeStatistic_StupidDDKVsCompilerCrap
c785dbab313731d1f4662b4684c0808cc14703dbvboxsync# define _interlockedbittestandset _interlockedbittestandset_StupidDDKVsCompilerCrap
c785dbab313731d1f4662b4684c0808cc14703dbvboxsync# define _interlockedbittestandreset _interlockedbittestandreset_StupidDDKVsCompilerCrap
c785dbab313731d1f4662b4684c0808cc14703dbvboxsync# define _interlockedbittestandset64 _interlockedbittestandset64_StupidDDKVsCompilerCrap
c785dbab313731d1f4662b4684c0808cc14703dbvboxsync# define _interlockedbittestandreset64 _interlockedbittestandreset64_StupidDDKVsCompilerCrap
c785dbab313731d1f4662b4684c0808cc14703dbvboxsync int VBOXCALL mymemcmp(const void *, const void *, size_t);
c785dbab313731d1f4662b4684c0808cc14703dbvboxsync# if defined(CONFIG_MODVERSIONS) && !defined(MODVERSIONS)
c785dbab313731d1f4662b4684c0808cc14703dbvboxsync# define KBUILD_STR(s) #s
c785dbab313731d1f4662b4684c0808cc14703dbvboxsync# else /* older kernels */
c785dbab313731d1f4662b4684c0808cc14703dbvboxsync# endif /* older kernels */
c785dbab313731d1f4662b4684c0808cc14703dbvboxsync# define memset libkern_memset /** @todo these are just hacks to get it compiling, check out later. */
c785dbab313731d1f4662b4684c0808cc14703dbvboxsync/*******************************************************************************
c785dbab313731d1f4662b4684c0808cc14703dbvboxsync* Defined Constants And Macros *
c785dbab313731d1f4662b4684c0808cc14703dbvboxsync*******************************************************************************/
c785dbab313731d1f4662b4684c0808cc14703dbvboxsync * Hardcoded cookies.
12767477bc2dbc7815e4784576a15c990f5590d3vboxsync/** Use a normal mutex for the loader so we remain at the same IRQL after
12767477bc2dbc7815e4784576a15c990f5590d3vboxsync * taking it.
12767477bc2dbc7815e4784576a15c990f5590d3vboxsync * @todo fix the mutex implementation on linux and make this the default. */
c785dbab313731d1f4662b4684c0808cc14703dbvboxsync/** Use a normal mutex for the GIP so we remain at the same IRQL after
c785dbab313731d1f4662b4684c0808cc14703dbvboxsync * taking it.
c785dbab313731d1f4662b4684c0808cc14703dbvboxsync * @todo fix the mutex implementation on linux and make this the default. */
12767477bc2dbc7815e4784576a15c990f5590d3vboxsync * OS debug print macro.
12767477bc2dbc7815e4784576a15c990f5590d3vboxsync/** @name Context values for the per-session handle tables.
12767477bc2dbc7815e4784576a15c990f5590d3vboxsync * The context value is used to distinguish between the different kinds of
12767477bc2dbc7815e4784576a15c990f5590d3vboxsync * handles, making the handle table API do all the work.
12767477bc2dbc7815e4784576a15c990f5590d3vboxsync/** Handle context value for single release event handles. */
12767477bc2dbc7815e4784576a15c990f5590d3vboxsync#define SUPDRV_HANDLE_CTX_EVENT ((void *)(uintptr_t)(SUPDRVOBJTYPE_SEM_EVENT))
c785dbab313731d1f4662b4684c0808cc14703dbvboxsync/** Handle context value for multiple release event handles. */
c785dbab313731d1f4662b4684c0808cc14703dbvboxsync#define SUPDRV_HANDLE_CTX_EVENT_MULTI ((void *)(uintptr_t)(SUPDRVOBJTYPE_SEM_EVENT_MULTI))
c785dbab313731d1f4662b4684c0808cc14703dbvboxsync * Validates a session pointer.
12767477bc2dbc7815e4784576a15c990f5590d3vboxsync * @returns true/false accordingly.
12767477bc2dbc7815e4784576a15c990f5590d3vboxsync * @param pSession The session.
c785dbab313731d1f4662b4684c0808cc14703dbvboxsync/*******************************************************************************
c785dbab313731d1f4662b4684c0808cc14703dbvboxsync* Structures and Typedefs *
c785dbab313731d1f4662b4684c0808cc14703dbvboxsync*******************************************************************************/
b46baa80c8be5ebac38e73ce6136d67146cc80d6vboxsync/** Pointer to the device extension. */
c785dbab313731d1f4662b4684c0808cc14703dbvboxsync * Memory reference types.
c785dbab313731d1f4662b4684c0808cc14703dbvboxsynctypedef enum
c785dbab313731d1f4662b4684c0808cc14703dbvboxsync /** Unused entry */
c785dbab313731d1f4662b4684c0808cc14703dbvboxsync /** Locked memory (r3 mapping only). */
c785dbab313731d1f4662b4684c0808cc14703dbvboxsync /** Continuous memory block (r3 and r0 mapping). */
c785dbab313731d1f4662b4684c0808cc14703dbvboxsync /** Low memory block (r3 and r0 mapping). */
c785dbab313731d1f4662b4684c0808cc14703dbvboxsync /** Memory block (r3 and r0 mapping). */
c785dbab313731d1f4662b4684c0808cc14703dbvboxsync /** Locked memory (r3 mapping only) allocated by the support driver. */
c785dbab313731d1f4662b4684c0808cc14703dbvboxsync /** Blow the type up to 32-bit and mark the end. */
c785dbab313731d1f4662b4684c0808cc14703dbvboxsync * Structure used for tracking memory a session
c785dbab313731d1f4662b4684c0808cc14703dbvboxsync * references in one way or another.
c785dbab313731d1f4662b4684c0808cc14703dbvboxsynctypedef struct SUPDRVMEMREF
c785dbab313731d1f4662b4684c0808cc14703dbvboxsync /** The memory object handle. */
c785dbab313731d1f4662b4684c0808cc14703dbvboxsync /** The ring-3 mapping memory object handle. */
c785dbab313731d1f4662b4684c0808cc14703dbvboxsync /** Type of memory. */
c785dbab313731d1f4662b4684c0808cc14703dbvboxsync * Bundle of locked memory ranges.
c785dbab313731d1f4662b4684c0808cc14703dbvboxsynctypedef struct SUPDRVBUNDLE
c785dbab313731d1f4662b4684c0808cc14703dbvboxsync /** Pointer to the next bundle. */
c785dbab313731d1f4662b4684c0808cc14703dbvboxsync /** Referenced memory. */
c785dbab313731d1f4662b4684c0808cc14703dbvboxsync /** Number of entries used. */
c785dbab313731d1f4662b4684c0808cc14703dbvboxsync * Loaded image.
c785dbab313731d1f4662b4684c0808cc14703dbvboxsync /** Next in chain. */
c785dbab313731d1f4662b4684c0808cc14703dbvboxsync /** Pointer to the image. */
c785dbab313731d1f4662b4684c0808cc14703dbvboxsync /** Pointer to the allocated image buffer.
c785dbab313731d1f4662b4684c0808cc14703dbvboxsync * pvImage is 32-byte aligned or it may governed by the native loader (this
c785dbab313731d1f4662b4684c0808cc14703dbvboxsync * member is NULL then). */
c785dbab313731d1f4662b4684c0808cc14703dbvboxsync /** Size of the image including the tables. This is mainly for verification
c785dbab313731d1f4662b4684c0808cc14703dbvboxsync * of the load request. */
c785dbab313731d1f4662b4684c0808cc14703dbvboxsync /** Size of the image. */
c785dbab313731d1f4662b4684c0808cc14703dbvboxsync /** The number of entries in the symbol table. */
c785dbab313731d1f4662b4684c0808cc14703dbvboxsync /** Pointer to the symbol table. */
c785dbab313731d1f4662b4684c0808cc14703dbvboxsync /** The offset of the string table. */
c785dbab313731d1f4662b4684c0808cc14703dbvboxsync /** Size of the string table. */
c785dbab313731d1f4662b4684c0808cc14703dbvboxsync /** Pointer to the optional module initialization callback. */
c785dbab313731d1f4662b4684c0808cc14703dbvboxsync /** Pointer to the optional module termination callback. */
c785dbab313731d1f4662b4684c0808cc14703dbvboxsync /** Service request handler. This is NULL for non-service modules. */
c785dbab313731d1f4662b4684c0808cc14703dbvboxsync /** The ldr image state. (IOCtl code of last operation.) */
c785dbab313731d1f4662b4684c0808cc14703dbvboxsync /** Usage count. */
c785dbab313731d1f4662b4684c0808cc14703dbvboxsync /** Pointer to the device extension. */
c785dbab313731d1f4662b4684c0808cc14703dbvboxsync /** The section object for the loaded image (fNative=true). */
c785dbab313731d1f4662b4684c0808cc14703dbvboxsync /** Lock object. */
c785dbab313731d1f4662b4684c0808cc14703dbvboxsync#if defined(RT_OS_SOLARIS) && defined(VBOX_WITH_NATIVE_SOLARIS_LOADING)
c785dbab313731d1f4662b4684c0808cc14703dbvboxsync /** The Solaris module ID. */
c785dbab313731d1f4662b4684c0808cc14703dbvboxsync /** Pointer to the module control structure. */
c785dbab313731d1f4662b4684c0808cc14703dbvboxsync /** Whether it's loaded by the native loader or not. */
c785dbab313731d1f4662b4684c0808cc14703dbvboxsync /** Image name. */
c785dbab313731d1f4662b4684c0808cc14703dbvboxsync/** Image usage record. */
84c5015eccf5ba071c02e51da99b4d7593f690fevboxsync /** Next in chain. */
c785dbab313731d1f4662b4684c0808cc14703dbvboxsync /** The image. */
c785dbab313731d1f4662b4684c0808cc14703dbvboxsync /** Load count. */
c785dbab313731d1f4662b4684c0808cc14703dbvboxsync * Component factory registration record.
c785dbab313731d1f4662b4684c0808cc14703dbvboxsync /** Pointer to the next registration. */
c785dbab313731d1f4662b4684c0808cc14703dbvboxsync /** Pointer to the registered factory. */
c785dbab313731d1f4662b4684c0808cc14703dbvboxsync /** The session owning the factory.
c785dbab313731d1f4662b4684c0808cc14703dbvboxsync * Used for deregistration and session cleanup. */
c785dbab313731d1f4662b4684c0808cc14703dbvboxsync /** Length of the name. */
c785dbab313731d1f4662b4684c0808cc14703dbvboxsync/** Pointer to a component factory registration record. */
c785dbab313731d1f4662b4684c0808cc14703dbvboxsync/** Pointer to a const component factory registration record. */
typedef struct SUPDRVOBJ
void *pvUser1;
void *pvUser2;
typedef struct SUPDRVUSAGE
typedef struct SUPDRVSESSION
#ifndef SUPDRV_AGNOSTIC
# if defined(RT_OS_DARWIN)
void *pvSupDrvClient;
bool fOpened;
# if defined(RT_OS_OS2)
typedef struct SUPDRVDEVEXT
#ifdef SUPDRV_USE_MUTEX_FOR_LDR
void * volatile pvVMMR0;
DECLR0CALLBACKMEMBER(int, pfnVMMR0EntryEx, (PVM pVM, VMCPUID idCpu, unsigned uOperation, PSUPVMMR0REQHDR pReq, uint64_t u64Arg, PSUPDRVSESSION pSession));
#ifdef SUPDRV_USE_MUTEX_FOR_GIP
bool fTracerUnloading;
#ifndef SUPDRV_AGNOSTIC
# ifdef RT_OS_WINDOWS
} SUPDRVDEVEXT;
bool VBOXCALL supdrvOSObjCanAccess(PSUPDRVOBJ pObj, PSUPDRVSESSION pSession, const char *pszObjName, int *prc);
int VBOXCALL supdrvOSLdrOpen(PSUPDRVDEVEXT pDevExt, PSUPDRVLDRIMAGE pImage, const char *pszFilename);
int VBOXCALL supdrvOSLdrLoad(PSUPDRVDEVEXT pDevExt, PSUPDRVLDRIMAGE pImage, const uint8_t *pbImageBits, PSUPLDRLOAD pReq);
/* SUPDrv.c */
int VBOXCALL supdrvIOCtl(uintptr_t uIOCtl, PSUPDRVDEVEXT pDevExt, PSUPDRVSESSION pSession, PSUPREQHDR pReqHdr);
int VBOXCALL supdrvIOCtlFast(uintptr_t uIOCtl, VMCPUID idCpu, PSUPDRVDEVEXT pDevExt, PSUPDRVSESSION pSession);
int VBOXCALL supdrvIDC(uintptr_t uIOCtl, PSUPDRVDEVEXT pDevExt, PSUPDRVSESSION pSession, PSUPDRVIDCREQHDR pReqHdr);
int VBOXCALL supdrvIOCtl_TracerUmodDeregister(PSUPDRVDEVEXT pDevExt, PSUPDRVSESSION pSession, RTR3PTR R3PtrVtgHdr);
void VBOXCALL supdrvIOCtl_TracerUmodProbeFire(PSUPDRVDEVEXT pDevExt, PSUPDRVSESSION pSession, PSUPDRVTRACERUSRCTX pCtx);
int VBOXCALL supdrvIOCtl_TracerOpen(PSUPDRVDEVEXT pDevExt, PSUPDRVSESSION pSession, uint32_t uCookie, uintptr_t uArg);
int VBOXCALL supdrvIOCtl_TracerIOCtl(PSUPDRVDEVEXT pDevExt, PSUPDRVSESSION pSession, uintptr_t uCmd, uintptr_t uArg, int32_t *piRetVal);
#ifdef VBOX_WITH_NATIVE_DTRACE