REMInternal.h revision 7ff1262edad432431615f5788bdf043af8c22959
/* $Id$ */
/** @file
* REM - 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 (GPL) 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.
*/
#ifndef ___REMInternal_h
#define ___REMInternal_h
#ifdef REM_INCLUDE_CPU_H
# include "target-i386/cpu.h"
#endif
# error "Not in REM! This is an internal header!"
#endif
/** @defgroup grp_rem_int Internals
* @ingroup grp_rem
* @internal
* @{
*/
/** The saved state version number. */
#define REM_SAVED_STATE_VERSION 6
/** @def REM_MONITOR_CODE_PAGES
* Enable to monitor code pages that have been translated by the recompiler. */
#define REM_MONITOR_CODE_PAGES
typedef enum REMHANDLERNOTIFICATIONKIND
{
/** The usual invalid 0 entry. */
/** REMR3NotifyHandlerPhysicalRegister. */
/** REMR3NotifyHandlerPhysicalDeregister. */
/** REMR3NotifyHandlerPhysicalModify. */
/** The usual 32-bit hack. */
REMHANDLERNOTIFICATIONKIND_32BIT_HACK = 0x7fffffff
/**
* A recorded handler notificiation.
*/
typedef struct REMHANDLERNOTIFICATION
{
/** The notification kind. */
/** Type specific data. */
union
{
struct
{
bool fHasHCHandler;
struct
{
bool fHasHCHandler;
bool fRestoreAsRAM;
struct
{
bool fHasHCHandler;
bool fRestoreAsRAM;
} u;
/**
* Dynamically allocated guest RAM chunk information
* HC virt to GC Phys
*
* A RAM chunk can spawn two chunk regions as we don't align them on chunk boundaries.
*/
typedef struct REMCHUNKINFO
{
#define REM_MAX_PHYS_REGISTRATIONS 16
/**
* Registration record for external guest RAM & ROM
*/
typedef struct REMPHYSREGISTRATION
{
/**
* Converts a REM pointer into a VM pointer.
* @returns Pointer to the VM structure the REM is part of.
* @param pREM Pointer to REM instance data.
*/
/**
* REM Data (part of VM)
*/
typedef struct REM
{
/** Offset to the VM structure. */
/** Alignment padding. */
/** Cached guest cpu context pointer. */
/** In REM mode.
* I.e. the correct CPU state and some other bits are with REM. */
bool fInREM;
/** In REMR3State. */
bool fInStateSync;
/** Ignore all that can be ignored. */
bool fIgnoreAll;
/** Ignore CR3 load notifications from the REM. */
bool fIgnoreCR3Load;
/** Ignore invlpg notifications from the REM. */
bool fIgnoreInvlPg;
/** Ignore CR0, CR4 and EFER load. */
bool fIgnoreCpuMode;
/** Ignore set page. */
bool fIgnoreSetPage;
/** Number of times REMR3CanExecuteRaw has been called.
* It is used to prevent rescheduling on the first call. */
/** Pending interrupt (~0 -> nothing). */
#if HC_ARCH_BITS == 64
/** Alignment padding. */
#endif
/** Number of recorded invlpg instructions. */
/** Array of recorded invlpg instruction.
* These instructions are replayed when entering REM. */
/** The number of recorded handler notifications. */
RTUINT volatile cHandlerNotifications;
/** Array of recorded handler noticications.
* These are replayed when entering REM. */
/** Pointer to an array of hc virt to gc phys records. */
/** Pointer to a GC Phys to HC Virt lookup table. */
/** Array of external RAM and ROM registrations (excluding guest RAM). */
/** Number of external RAM and ROM registrations (excluding guest RAM). */
/** MMIO memory type.
* This is used to register MMIO physical access handlers. */
/** Handler memory type.
* This is used to register non-MMIO physical access handlers which are executed in HC. */
/** Pending exception */
/** Pending exception's EIP */
/** Pending exception's CR2 */
/** Nr of pending exceptions */
/** Pending rc. */
/** Time spent in QEMU. */
/** Time spent in rawmode.c. */
/** Time spent switching state. */
/** Time spent switching state back. */
#if HC_ARCH_BITS != 32
/** Padding the CPUX86State structure to 32 byte. */
#endif
/** Recompiler CPU state. */
#ifdef REM_INCLUDE_CPU_H
#else
struct FakeEnv
{
char achPadding[REM_ENV_SIZE];
} Env;
#endif
} REM;
/** Pointer to the REM Data. */
#ifdef REM_INCLUDE_CPU_H
void remR3CpuId(CPUState *env, unsigned uOperator, void *pvEAX, void *pvEBX, void *pvECX, void *pvEDX);
#endif
/** @todo r=bird: clean up the RAWEx stats. */
/* temporary hacks */
#define RAWEx_ProfileStart(a, b) remR3ProfileStart(b)
#define RAWEx_ProfileStop(a, b) remR3ProfileStop(b)
#ifdef VBOX_WITH_STATISTICS
#define STATS_EMULATE_SINGLE_INSTR 1
#define STATS_QEMU_COMPILATION 2
#define STATS_QEMU_RUN_EMULATED_CODE 3
#define STATS_QEMU_TOTAL 4
#define STATS_QEMU_RUN_TIMERS 5
#define STATS_TLB_LOOKUP 6
#define STATS_IRQ_HANDLING 7
#define STATS_RAW_CHECK 8
void remR3ProfileStart(int statcode);
void remR3ProfileStop(int statcode);
#else
#define remR3ProfileStart(c)
#define remR3ProfileStop(c)
#endif
/** @} */
#endif