SUPDRV.h revision d0d2b0c8f3a61896d483a4405ebfed9baa2ca058
4778ff543a041ac356d6e661cc9b66c3fafa2092Adam Moore/* $Revision$ */
2c5ce90c334a2d0f18474e85c93b424b6ec9daaaAdam Moore * VirtualBox Support Driver - Internal header.
c4e6d94ea429e473a6732b6eb5e0fc980e822881Adam Moore * Copyright (C) 2006-2007 Sun Microsystems, Inc.
1b298c6f0ef597aa4ab0b8bcb25430b6c9a87749Adam Moore * This file is part of VirtualBox Open Source Edition (OSE), as
1b298c6f0ef597aa4ab0b8bcb25430b6c9a87749Adam Moore * available from http://www.virtualbox.org. This file is free software;
87d6b0a14cce52c4faa4b78fc9878eb553dab0d5Adam Moore * you can redistribute it and/or modify it under the terms of the GNU
1b298c6f0ef597aa4ab0b8bcb25430b6c9a87749Adam Moore * General Public License (GPL) as published by the Free Software
1b298c6f0ef597aa4ab0b8bcb25430b6c9a87749Adam Moore * Foundation, in version 2 as it comes in the "COPYING" file of the
1b298c6f0ef597aa4ab0b8bcb25430b6c9a87749Adam Moore * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
1b298c6f0ef597aa4ab0b8bcb25430b6c9a87749Adam Moore * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
87d6b0a14cce52c4faa4b78fc9878eb553dab0d5Adam Moore * The contents of this file may alternatively be used under the terms
1b298c6f0ef597aa4ab0b8bcb25430b6c9a87749Adam Moore * of the Common Development and Distribution License Version 1.0
1b298c6f0ef597aa4ab0b8bcb25430b6c9a87749Adam Moore * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
87d6b0a14cce52c4faa4b78fc9878eb553dab0d5Adam Moore * VirtualBox OSE distribution, in which case the provisions of the
1b298c6f0ef597aa4ab0b8bcb25430b6c9a87749Adam Moore * CDDL are applicable instead of those of the GPL.
1b298c6f0ef597aa4ab0b8bcb25430b6c9a87749Adam Moore * You may elect to license modified versions of this file under the
1b298c6f0ef597aa4ab0b8bcb25430b6c9a87749Adam Moore * terms and conditions of either the GPL or the CDDL or both.
1b298c6f0ef597aa4ab0b8bcb25430b6c9a87749Adam Moore * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
1b298c6f0ef597aa4ab0b8bcb25430b6c9a87749Adam Moore * Clara, CA 95054 USA or visit http://www.sun.com if you need
d4dbc3afb5bb9cfd13490b358dc37bf951104ca7Adam Moore * additional information or have any questions.
91ff24e65531ce8bf171340d9384182f8c168af3Adam Moore/*******************************************************************************
91ff24e65531ce8bf171340d9384182f8c168af3Adam Moore* Header Files *
91ff24e65531ce8bf171340d9384182f8c168af3Adam Moore*******************************************************************************/
91ff24e65531ce8bf171340d9384182f8c168af3Adam Moore#if defined(USE_NEW_OS_INTERFACE) || defined(USE_NEW_OS_INTERFACE_FOR_LOW) || defined(USE_NEW_OS_INTERFACE_FOR_MM) || defined(USE_NEW_OS_INTERFACE_FOR_GIP)
d4dbc3afb5bb9cfd13490b358dc37bf951104ca7Adam Moore# if (_MSC_VER >= 1400) && !defined(VBOX_WITH_PATCHED_DDK)
d4dbc3afb5bb9cfd13490b358dc37bf951104ca7Adam Moore# define _InterlockedExchange _InterlockedExchange_StupidDDKVsCompilerCrap
87d6b0a14cce52c4faa4b78fc9878eb553dab0d5Adam Moore# define _InterlockedExchangeAdd _InterlockedExchangeAdd_StupidDDKVsCompilerCrap
d4dbc3afb5bb9cfd13490b358dc37bf951104ca7Adam Moore# define _InterlockedCompareExchange _InterlockedCompareExchange_StupidDDKVsCompilerCrap
d4dbc3afb5bb9cfd13490b358dc37bf951104ca7Adam Moore# define _InterlockedAddLargeStatistic _InterlockedAddLargeStatistic_StupidDDKVsCompilerCrap
d4dbc3afb5bb9cfd13490b358dc37bf951104ca7Adam Moore int VBOXCALL mymemcmp(const void *, const void *, size_t);
d4dbc3afb5bb9cfd13490b358dc37bf951104ca7Adam Moore# if defined(CONFIG_MODVERSIONS) && !defined(MODVERSIONS)
d4dbc3afb5bb9cfd13490b358dc37bf951104ca7Adam Moore# if LINUX_VERSION_CODE < KERNEL_VERSION(2, 5, 71)
d4dbc3afb5bb9cfd13490b358dc37bf951104ca7Adam Moore# if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 16)
d4dbc3afb5bb9cfd13490b358dc37bf951104ca7Adam Moore# define KBUILD_STR(s) #s
1b298c6f0ef597aa4ab0b8bcb25430b6c9a87749Adam Moore/*******************************************************************************
87d6b0a14cce52c4faa4b78fc9878eb553dab0d5Adam Moore* Defined Constants And Macros *
1b298c6f0ef597aa4ab0b8bcb25430b6c9a87749Adam Moore*******************************************************************************/
1b298c6f0ef597aa4ab0b8bcb25430b6c9a87749Adam Moore * Hardcoded cookies.
87d6b0a14cce52c4faa4b78fc9878eb553dab0d5Adam Moore/* debug printf */
efa57736d44cf446f1661497a8645bd388b493fbAdam Moore/** Maximum number of bytes we try to lock down in one go.
efa57736d44cf446f1661497a8645bd388b493fbAdam Moore * This is supposed to have a limit right below 256MB, but this appears
1b298c6f0ef597aa4ab0b8bcb25430b6c9a87749Adam Moore * to actually be much lower. The values here have been determined experimentally.
1b298c6f0ef597aa4ab0b8bcb25430b6c9a87749Adam Moore# define MAX_LOCK_MEM_SIZE (32*1024*1024) /* 32mb */
1b298c6f0ef597aa4ab0b8bcb25430b6c9a87749Adam Moore# define MAX_LOCK_MEM_SIZE (24*1024*1024) /* 24mb */
3395e5fc071521d4e6b258ef4c7c0ef38601b94eAdam Moore/* check kernel version */
3395e5fc071521d4e6b258ef4c7c0ef38601b94eAdam Moore/* debug printf */
3395e5fc071521d4e6b258ef4c7c0ef38601b94eAdam Moore/* debug printf */
3395e5fc071521d4e6b258ef4c7c0ef38601b94eAdam Moore/* No log API in OS/2 only COM port. */
3395e5fc071521d4e6b258ef4c7c0ef38601b94eAdam Moore/* No log API in OS/2 only COM port. */
3395e5fc071521d4e6b258ef4c7c0ef38601b94eAdam Moore/** @todo other os'es */
3395e5fc071521d4e6b258ef4c7c0ef38601b94eAdam Moore# error "OS interface defines is not done for this OS!"
3395e5fc071521d4e6b258ef4c7c0ef38601b94eAdam Moore/* dprintf */
c4e6d94ea429e473a6732b6eb5e0fc980e822881Adam Moore#if (defined(DEBUG) && !defined(NO_LOGGING)) || defined(RT_OS_FREEBSD)
# ifdef LOG_TO_COM
# define dprintf(a) do {} while (0)
# define dprintf2(a) do { } while (0)
#ifdef RT_OS_LINUX
# ifdef VBOX_HRTIMER
#ifdef VBOX_WITH_IDT_PATCHING
typedef struct SUPDRVIDTE
#ifdef RT_ARCH_AMD64
#ifdef RT_ARCH_AMD64
typedef struct SUPDRVPATCH
void *pvIdt;
typedef struct SUPDRVPATCHUSAGE
MEMREF_TYPE_UNUSED = 0,
typedef struct SUPDRVMEMREF
#ifdef USE_NEW_OS_INTERFACE_FOR_MM
void *pvR0;
unsigned cb;
#if defined(RT_OS_WINDOWS)
unsigned cMdls;
unsigned cPages;
} locked;
#if defined(RT_OS_WINDOWS)
unsigned cPages;
} cont;
#if defined(RT_OS_WINDOWS)
unsigned cPages;
} mem;
#if defined(USE_NEW_OS_INTERFACE_FOR_LOW)
} iprt;
typedef struct SUPDRVBUNDLE
typedef struct SUPDRVLDRIMAGE
void *pvImage;
typedef struct SUPDRVLDRUSAGE
typedef struct SUPDRVOBJ
void *pvUser1;
void *pvUser2;
typedef struct SUPDRVUSAGE
typedef struct SUPDRVSESSION
#ifdef VBOX_WITH_IDT_PATCHING
#ifdef USE_NEW_OS_INTERFACE_FOR_GIP
#if defined(RT_OS_OS2)
typedef struct SUPDRVDEVEXT
#ifdef VBOX_WITH_IDT_PATCHING
void * volatile pvVMMR0;
DECLR0CALLBACKMEMBER(int, pfnVMMR0EntryEx, (PVM pVM, unsigned uOperation, PSUPVMMR0REQHDR pReq, uint64_t u64Arg));
#ifdef USE_NEW_OS_INTERFACE_FOR_GIP
# ifdef RT_OS_WINDOWS
# ifdef RT_OS_LINUX
unsigned long ulLastJiffies;
# ifdef CONFIG_SMP
struct LINUXCPU
unsigned long ulLastJiffies;
unsigned iSmpProcessorId;
} SUPDRVDEVEXT;
bool VBOXCALL supdrvOSObjCanAccess(PSUPDRVOBJ pObj, PSUPDRVSESSION pSession, const char *pszObjName, int *prc);
#ifndef USE_NEW_OS_INTERFACE_FOR_MM
int VBOXCALL supdrvOSContAllocOne(PSUPDRVMEMREF pMem, PRTR0PTR ppvR0, PRTR3PTR ppvR3, PRTHCPHYS pHCPhys);
int VBOXCALL supdrvOSLowAllocOne(PSUPDRVMEMREF pMem, PRTR0PTR ppvR0, PRTR3PTR ppvR3, PSUPPAGE paPages);
#ifndef USE_NEW_OS_INTERFACE_FOR_GIP
int VBOXCALL supdrvIOCtl(uintptr_t uIOCtl, PSUPDRVDEVEXT pDevExt, PSUPDRVSESSION pSession, PSUPREQHDR pReqHdr);
int VBOXCALL supdrvGipInit(PSUPDRVDEVEXT pDevExt, PSUPGLOBALINFOPAGE pGip, RTHCPHYS HCPhys, uint64_t u64NanoTS, unsigned uUpdateHz);