CPUMInternal.h revision 17ba03925269c071aa1567eb8c5a49c37a65f62f
/* $Id$ */
/** @file
* CPUM - Internal header file.
*/
/*
* Copyright (C) 2006-2007 innotek 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 ___CPUMInternal_h
#define ___CPUMInternal_h
# error "Not in CPUM! This is an internal header!"
#endif
/** @defgroup grp_cpum_int Internals
* @ingroup grp_cpum
* @internal
* @{
*/
/** Flags and types for CPUM fault handlers
* @{ */
/** Type: Load DS */
#define CPUM_HANDLER_DS 1
/** Type: Load ES */
#define CPUM_HANDLER_ES 2
/** Type: Load FS */
#define CPUM_HANDLER_FS 3
/** Type: Load GS */
#define CPUM_HANDLER_GS 4
/** Type: IRET */
#define CPUM_HANDLER_IRET 5
/** Type mask. */
#define CPUM_HANDLER_TYPEMASK 0xff
/** If set EBP points to the CPUMCTXCORE that's being used. */
/** @} */
/** Use flags (CPUM::fUseFlags).
* (Don't forget to sync this with CPUMInternal.mac!)
* @{ */
/** Used the FPU, SSE or such stuff. */
#define CPUM_USED_FPU BIT(0)
/** Used the FPU, SSE or such stuff since last we were in REM.
* REM syncing is clearing this, lazy FPU is setting it. */
/** Host OS is using SYSENTER and we must NULL the CS. */
/** Host OS is using SYSENTER and we must NULL the CS. */
/** Debug registers are used by host and must be disabled. */
/** Enabled use of debug registers in guest context. */
/** @} */
/* Sanity check. */
# error "VBOX_WITH_HYBIRD_32BIT_KERNEL is only for 32 bit builds."
#endif
/**
* The save host CPU state.
*
* @remark The special VBOX_WITH_HYBIRD_32BIT_KERNEL checks here are for the 10.4.x series
* of Mac OS X where the OS is essentially 32-bit but the cpu mode can be 64-bit.
*/
typedef struct CPUMHOSTCTX
{
/** FPU state. (16-byte alignment)
* @remark On x86, the format isn't necessarily X86FXSTATE (not important). */
/** General purpose register, selectors, flags and more
* @{ */
/** General purpose register ++
* { */
//uint64_t rax; - scratch
//uint64_t rcx; - scratch
//uint64_t rdx; - scratch
//uint64_t r8; - scratch
//uint64_t r9; - scratch
//uint64_t rip; - scratch
#endif
#if HC_ARCH_BITS == 32
//uint32_t eax; - scratch
//uint32_t ecx; - scratch
//uint32_t edx; - scratch
//uint32_t eip; - scratch
/* lss pair! */
#endif
/** @} */
/** Selector registers
* @{ */
/** @} */
/** Control registers.
* @{ */
//uint32_t cr2; - scratch
/** @} */
/** Debug registers.
* @{ */
/** @} */
/** Global Descriptor Table register. */
/** Interrupt Descriptor Table register. */
/** The task register. */
/** The task register. */
/** The sysenter msr registers.
* This member is not used by the hypervisor context. */
/* padding to get 32byte aligned size */
/** Control registers.
* @{ */
//uint64_t cr2; - scratch
/** @} */
/** Debug registers.
* @{ */
/** @} */
/** Global Descriptor Table register. */
/** Interrupt Descriptor Table register. */
/** The task register. */
/** The task register. */
/** MSRs
* @{ */
/** @} */
/* padding to get 32byte aligned size */
# ifdef VBOX_WITH_HYBIRD_32BIT_KERNEL
# else
# endif
#else
#endif
} CPUMHOSTCTX, *PCPUMHOSTCTX;
/**
* Converts a CPUM pointer into a VM pointer.
* @returns Pointer to the VM structure the CPUM is part of.
* @param pCPUM Pointer to CPUM instance data.
*/
/**
* CPUM Data (part of VM)
*/
#pragma pack(1)
typedef struct CPUM
{
/** Offset to the VM structure. */
/** Pointer to CPU structure in GC. */
/** Pointer to CPU structure in HC. */
/** Force 32byte alignment of the next member. */
/**
* Saved host context. Only valid while inside GC.
* Must be aligned on 16 byte boundrary.
*/
/**
* Hypervisor context.
* Must be aligned on 16 byte boundrary.
*/
/**
* Guest context.
* Must be aligned on 16 byte boundrary.
*/
/** Pointer to the current hypervisor core context - HCPtr. */
/** Pointer to the current hypervisor core context - GCPtr. */
/** Use flags.
* These flags indicates both what is to be used and what have been used.
*/
/** Changed flags.
* These flags indicates to REM (and others) which important guest
* registers which has been changed since last time the flags were cleared.
* See the CPUM_CHANGED_* defines for what we keep track of.
*/
/** Hidden selector registers state.
* Valid (hw accelerated raw mode) or not (normal raw mode)
*/
/** Host CPU Features - ECX */
struct
{
/** edx part */
/** ecx part */
} CPUFeatures;
/** CR4 mask */
struct
{
} CR4;
/** Have we entered rawmode? */
bool fRawEntered;
/** The standard set of CpuId leafs. */
/** The extended set of CpuId leafs. */
/** The default set of CpuId leafs. */
/**
* Guest context on raw mode entry.
* This a debug feature.
*/
#pragma pack()
#ifdef IN_RING3
#endif
/** @} */
#endif