SUPDrvInternal.h revision 6eac83229fa73f9b2a93fdca1ceade0ad71a895c
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync/* $Revision$ */
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync * VirtualBox Support Driver - Internal header.
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync * Copyright (C) 2006-2007 Sun Microsystems, Inc.
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync * available from http://www.virtualbox.org. This file is free software;
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync * you can redistribute it and/or modify it under the terms of the GNU
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync * General Public License (GPL) as published by the Free Software
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync * Foundation, in version 2 as it comes in the "COPYING" file of the
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync * The contents of this file may alternatively be used under the terms
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync * of the Common Development and Distribution License Version 1.0
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync * VirtualBox OSE distribution, in which case the provisions of the
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync * CDDL are applicable instead of those of the GPL.
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync * You may elect to license modified versions of this file under the
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync * terms and conditions of either the GPL or the CDDL or both.
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync * Clara, CA 95054 USA or visit http://www.sun.com if you need
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync * additional information or have any questions.
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync/*******************************************************************************
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync* Header Files *
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync*******************************************************************************/
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync# if (_MSC_VER >= 1400) && !defined(VBOX_WITH_PATCHED_DDK)
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync# define _InterlockedExchange _InterlockedExchange_StupidDDKVsCompilerCrap
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync# define _InterlockedExchangeAdd _InterlockedExchangeAdd_StupidDDKVsCompilerCrap
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync# define _InterlockedCompareExchange _InterlockedCompareExchange_StupidDDKVsCompilerCrap
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync# define _InterlockedAddLargeStatistic _InterlockedAddLargeStatistic_StupidDDKVsCompilerCrap
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync# define _interlockedbittestandset _interlockedbittestandset_StupidDDKVsCompilerCrap
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync# define _interlockedbittestandreset _interlockedbittestandreset_StupidDDKVsCompilerCrap
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync# define _interlockedbittestandset64 _interlockedbittestandset64_StupidDDKVsCompilerCrap
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync# define _interlockedbittestandreset64 _interlockedbittestandreset64_StupidDDKVsCompilerCrap
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync int VBOXCALL mymemcmp(const void *, const void *, size_t);
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync# if defined(CONFIG_MODVERSIONS) && !defined(MODVERSIONS)
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync# define KBUILD_STR(s) #s
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync# else /* older kernels */
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync# endif /* older kernels */
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync# define memset libkern_memset /** @todo these are just hacks to get it compiling, check out later. */
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync/*******************************************************************************
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync* Defined Constants And Macros *
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync*******************************************************************************/
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync * Hardcoded cookies.
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync/* debug printf */
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync/** Maximum number of bytes we try to lock down in one go.
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync * This is supposed to have a limit right below 256MB, but this appears
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync * to actually be much lower. The values here have been determined experimentally.
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync# define MAX_LOCK_MEM_SIZE (32*1024*1024) /* 32mb */
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync# define MAX_LOCK_MEM_SIZE (24*1024*1024) /* 24mb */
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync/* check kernel version */
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync/* debug printf */
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync/* debug printf */
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync/* No log API in OS/2 only COM port. */
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync/* debug printf */
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync/** @todo other os'es */
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync# error "OS interface defines is not done for this OS!"
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync/* dprintf */
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync# define dprintf(a) do {} while (0)
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync/* dprintf2 - extended logging. */
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync#if defined(RT_OS_DARWIN) || defined(RT_OS_OS2) || defined(RT_OS_FREEBSD)
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync# define dprintf2(a) do { } while (0)
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync/** @def RT_WITH_W64_UNWIND_HACK
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync * Changes a function name into the wrapped version if we've
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync * enabled the unwind hack.
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync * The unwind hack is for making the NT unwind procedures skip
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync * our dynamically loaded code when they try to walk the call
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync * stack. Needless to say, they kind of don't expect what
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync * we're doing here and get kind of confused and may BSOD. */
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync/** @def UNWIND_WRAP
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync * If RT_WITH_W64_UNWIND_HACK is defined, the name will be prefixed with
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync * 'supdrvNtWrap'.
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync * @param Name The function to wrapper. */
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync * Error codes.
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync/** @todo retire the SUPDRV_ERR_* stuff, we ship err.h now. */
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync/** Invalid parameter. */
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync/** Invalid parameter. */
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync/** Invalid magic or cookie. */
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync/** Invalid loader handle. */
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync/** Failed to lock the address range. */
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync/** Invalid memory pointer. */
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync/** Failed to patch the IDT. */
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync/** Memory allocation failed. */
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync/** Already loaded. */
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync/** Permission denied. */
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync/** Version mismatch. */
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync/*******************************************************************************
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync* Structures and Typedefs *
MEMREF_TYPE_UNUSED = 0,
typedef struct SUPDRVMEMREF
typedef struct SUPDRVBUNDLE
typedef struct SUPDRVLDRIMAGE
void *pvImage;
typedef struct SUPDRVLDRUSAGE
typedef struct SUPDRVFACTORYREG
typedef struct SUPDRVOBJ
void *pvUser1;
void *pvUser2;
typedef struct SUPDRVUSAGE
typedef struct SUPDRVSESSION
#if defined(RT_OS_DARWIN)
void *pvSupDrvClient;
bool fOpened;
#if defined(RT_OS_OS2)
typedef struct SUPDRVDEVEXT
void * volatile pvVMMR0;
DECLR0CALLBACKMEMBER(int, pfnVMMR0EntryEx, (PVM pVM, VMCPUID idCpu, unsigned uOperation, PSUPVMMR0REQHDR pReq, uint64_t u64Arg, PSUPDRVSESSION pSession));
#ifdef RT_OS_WINDOWS
} SUPDRVDEVEXT;
bool VBOXCALL supdrvOSObjCanAccess(PSUPDRVOBJ pObj, PSUPDRVSESSION pSession, const char *pszObjName, int *prc);
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 supdrvGipInit(PSUPDRVDEVEXT pDevExt, PSUPGLOBALINFOPAGE pGip, RTHCPHYS HCPhys, uint64_t u64NanoTS, unsigned uUpdateHz);