VMMInternal.h revision 14e9857ef74e7cbd340136cac88a737a15bdb6fc
/* $Id$ */
/** @file
* VMM - Internal header file.
*/
/*
* Copyright (C) 2006 InnoTek Systemberatung GmbH
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
* General Public License as published by the Free Software Foundation,
* in version 2 as it comes in the "COPYING" file of the VirtualBox OSE
* distribution. VirtualBox OSE is distributed in the hope that it will
* be useful, but WITHOUT ANY WARRANTY of any kind.
*
* If you received this file as part of a commercial VirtualBox
* distribution, then only the terms of your commercial VirtualBox
* license agreement apply instead of the previous paragraph.
*/
#ifndef __VMMInternal_h__
#define __VMMInternal_h__
#include <x86context.h>
#include <iprt/critsect.h>
# error "Not in VMM! This is an internal header!"
#endif
/** @defgroup grp_vmm_int Internals
* @ingroup grp_vmm
* @internal
* @{
*/
/** @def VBOX_WITH_GC_AND_R0_RELEASE_LOG
* Enabled GC and R0 release logging (the latter is not implemented yet). */
#define VBOX_WITH_GC_AND_R0_RELEASE_LOG
/**
* Converts a VMM pointer into a VM pointer.
* @returns Pointer to the VM structure the VMM is part of.
* @param pVMM Pointer to VMM instance data.
*/
/**
* Switcher function, HC to GC.
*
* @param pVM The VM handle.
* @returns Return code indicating the action to take.
*/
/** Pointer to switcher function. */
typedef FNVMMSWITCHERHC *PFNVMMSWITCHERHC;
/**
* Switcher function, GC to HC.
*
* @param rc VBox status code.
*/
/** Pointer to switcher function. */
typedef FNVMMSWITCHERGC *PFNVMMSWITCHERGC;
/**
* The ring-0 logger instance.
* We need to be able to find the VM handle from the logger instance.
*/
typedef struct VMMR0LOGGER
{
/** Pointer to the VM handle. */
/** Size of the allocated logger instance (Logger). */
/** Flag indicating whether we've create the logger Ring-0 instance yet. */
bool fCreated;
#if HC_ARCH_BITS == 32
#endif
/** The ring-0 logger instance. This extends beyon the size.*/
} VMMR0LOGGER, *PVMMR0LOGGER;
/**
* quickly 'call' back into Ring-3.
*/
typedef struct VMMR0JMPBUF
{
/** Tranditional jmp_buf stuff
* @{ */
#if HC_ARCH_BITS == 32
#endif
#if HC_ARCH_BITS == 64
# ifdef __WIN__
# endif
#endif
/** @} */
/** Flag that indicates that we've done a ring-3 call. */
bool fInRing3Call;
/** The number of bytes we've saved. */
/** Pointer to the buffer used to save the stack.
* This is assumed to be 8KB. */
/** Esp we we match against esp on resume to make sure the stack wasn't relocated. */
/** The esp we should resume execution with after the restore. */
} VMMR0JMPBUF, *PVMMR0JMPBUF;
/**
* VMM Data (part of VMM)
*/
typedef struct VMM
{
/** Offset to the VM structure.
* See VMM2VM(). */
/** Size of the core code. */
/** Physical address of core code. */
/** @todo pvHCCoreCodeR3 -> pvCoreCodeR3, pvHCCoreCodeR0 -> pvCoreCodeR0 */
/** Pointer to core code ring-3 mapping - contiguous memory.
* At present this only means the context switcher code. */
/** Pointer to core code ring-0 mapping - contiguous memory.
* At present this only means the context switcher code. */
/** Pointer to core code guest context mapping. */
#ifdef VBOX_WITH_NMI
/** The guest context address of the APIC (host) mapping. */
#endif
/** The current switcher.
* This will be set before the VMM is fully initialized. */
/** Array of offsets to the different switchers within the core code. */
/** Flag to disable the switcher permanently (VMX) (boolean) */
bool fSwitcherDisabled;
/** Host to guest switcher entry point. */
/** Guest to host switcher entry point. */
/** Call Trampoline. See vmmGCCallTrampoline(). */
/** Resume Guest Execution. See CPUMGCResumeGuest(). */
/** Resume Guest Execution in V86 mode. See CPUMGCResumeGuestV86(). */
/** The last GC return code. */
#endif
/** VMM stack, pointer to the top of the stack in HC.
* Stack is allocated from the hypervisor heap and is page aligned
* and always writable in GC. */
/** Pointer to the bottom of the stack - needed for doing relocations. */
/** Pointer to the bottom of the stack - needed for doing relocations. */
/** Pointer to the GC logger instance - GC Ptr.
* This is NULL if logging is disabled. */
/** Pointer to the GC logger instance - HC Ptr.
* This is NULL if logging is disabled. */
/** Pointer to the R0 logger instance.
* This is NULL if logging is disabled. */
/** Pointer to the GC release logger instance - GC Ptr. */
/** Size of the allocated release logger instance (pRelLoggerGC/pRelLoggerHC).
* This may differ from cbLoggerGC. */
/** Pointer to the GC release logger instance - HC Ptr. */
#endif /* VBOX_WITH_GC_AND_R0_RELEASE_LOG */
/** Global VM critical section. */
/** The EMT yield timer. */
/** The period to the next timeout when suspended or stopped.
* This is 0 when running. */
/** The EMT yield timer interval (milliseconds). */
#if HC_ARCH_BITS == 32
#endif
/** @name CallHost
* @{ */
/** The pending operation. */
/** The result of the last operation. */
/** The argument to the operation. */
/** The Ring-0 jmp buffer. */
/** @} */
/** Number of VMMR0_DO_RUN_GC calls. */
/** Statistics for each of the GC return codes.
* @{ */
/** @} */
/**
* The VMMGCEntry() codes.
*/
typedef enum VMMGCOPERATION
{
/** Do GC module init. */
VMMGC_DO_VMMGC_INIT = 1,
/** The first Trap testcase. */
VMMGC_DO_TESTCASE_TRAP_FIRST = 0x0dead000,
/** Trap 0 testcases, uArg selects the variation. */
/** Trap 1 testcases, uArg selects the variation. */
/** Trap 2 testcases, uArg selects the variation. */
/** Trap 3 testcases, uArg selects the variation. */
/** Trap 4 testcases, uArg selects the variation. */
/** Trap 5 testcases, uArg selects the variation. */
/** Trap 6 testcases, uArg selects the variation. */
/** Trap 7 testcases, uArg selects the variation. */
/** Trap 8 testcases, uArg selects the variation. */
/** Trap 9 testcases, uArg selects the variation. */
/** Trap 0a testcases, uArg selects the variation. */
/** Trap 0b testcases, uArg selects the variation. */
/** Trap 0c testcases, uArg selects the variation. */
/** Trap 0d testcases, uArg selects the variation. */
/** Trap 0e testcases, uArg selects the variation. */
/** The last trap testcase (exclusive). */
/** Testcase for checking interrupt forwarding. */
/** Switching testing and profiling stub. */
/** Testcase for checking interrupt masking.. */
/** The usual 32-bit hack. */
VMMGC_DO_32_BIT_HACK = 0x7fffffff
#ifdef IN_RING0
/**
* World switcher assembly routine.
* It will call VMMGCEntry().
*
* @returns return code from VMMGCEntry().
* @param pVM The VM in question.
* @param uArg See VMMGCEntry().
* @internal
*/
/**
* Callback function for vmmR0CallHostSetJmp.
*
* @returns VBox status code.
* @param pVM The VM handle.
*/
/** Pointer to FNVMMR0SETJMP(). */
typedef FNVMMR0SETJMP *PFNVMMR0SETJMP;
/**
* The setjmp variant used for calling Ring-3.
*
* This differs from the normal setjmp in that it will resume VMMR0CallHost if we're
* in the middle of a ring-3 call. Another differences is the function pointer and
* argument. This has to do with resuming code and the stack frame of the caller.
*
* @returns VINF_SUCCESS on success or whatever is passed to vmmR0CallHostLongJmp.
* @param pJmpBuf The jmp_buf to set.
* @param pfn The function to be called when not resuming..
* @param pVM The argument of that function.
*/
/**
* Worker for VMMR0CallHost.
* This will save the stack and registers.
*
* @returns rc.
* @param pJmpBuf Pointer to the jump buffer.
* @param rc The return code.
*/
/**
* Internal R0 logger worker: Logger wrapper.
*/
/**
* Internal R0 logger worker: Flush logger.
*
* @param pLogger The logger instance to flush.
* @remark This function must be exported!
*/
#endif /* IN_RING0 */
#ifdef IN_GC
/**
* Internal GC logger worker: Logger wrapper.
*/
/**
* Internal GC release logger worker: Logger wrapper.
*/
/**
* Internal GC logger worker: Flush logger.
*
* @returns VINF_SUCCESS.
* @param pLogger The logger instance to flush.
* @remark This function must be exported!
*/
/** @name Trap testcases
* @{ */
DECLASM(void) vmmGCEnableWP(void);
DECLASM(void) vmmGCDisableWP(void);
DECLASM(int) vmmGCTestTrap3(void);
DECLASM(int) vmmGCTestTrap8(void);
DECLASM(int) vmmGCTestTrap0d(void);
DECLASM(int) vmmGCTestTrap0e(void);
/** @} */
#endif /* IN_GC */
/** @} */
#endif