IOMInternal.h revision 3242fe628b2306c050fb28c489d50bc63118f0c5
/* $Id$ */
/** @file
* IOM - Internal header file.
*/
/*
* Copyright (C) 2006-2007 Oracle Corporation
*
* 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 ___IOMInternal_h
#define ___IOMInternal_h
#include <VBox/pdmcritsect.h>
/** @defgroup grp_iom_int Internals
* @ingroup grp_iom
* @internal
* @{
*/
/**
* MMIO range descriptor.
*/
typedef struct IOMMMIORANGE
{
/** Avl node core with GCPhys as Key and GCPhys + cbSize - 1 as KeyLast. */
/** Start physical address. */
/** Size of the range. */
/** Pointer to user argument - R3. */
/** Pointer to device instance - R3. */
/** Pointer to write callback function - R3. */
/** Pointer to read callback function - R3. */
/** Pointer to fill (memset) callback function - R3. */
/** Pointer to user argument - R0. */
/** Pointer to device instance - R0. */
/** Pointer to write callback function - R0. */
/** Pointer to read callback function - R0. */
/** Pointer to fill (memset) callback function - R0. */
/** Pointer to user argument - RC. */
/** Pointer to device instance - RC. */
/** Pointer to write callback function - RC. */
/** Pointer to read callback function - RC. */
/** Pointer to fill (memset) callback function - RC. */
/** Alignment padding. */
/** Description / Name. For easing debugging. */
} IOMMMIORANGE;
/** Pointer to a MMIO range descriptor, R3 version. */
typedef struct IOMMMIORANGE *PIOMMMIORANGE;
/**
* MMIO address statistics. (one address)
*
* This is a simple way of making on demand statistics, however it's a
* bit free with the hypervisor heap memory.
*/
typedef struct IOMMMIOSTATS
{
/** Avl node core with the address as Key. */
/** Number of accesses (subtract ReadRZToR3 and WriteRZToR3 to get the right
* number). */
/** Profiling read handler overhead in R3. */
/** Profiling write handler overhead in R3. */
} IOMMMIOSTATS;
/** Pointer to I/O port statistics. */
typedef IOMMMIOSTATS *PIOMMMIOSTATS;
/**
* I/O port range descriptor, R3 version.
*/
typedef struct IOMIOPORTRANGER3
{
/** Avl node core with Port as Key and Port + cPorts - 1 as KeyLast. */
#endif
/** Start I/O port address. */
/** Size of the range. */
/** Pointer to user argument. */
/** Pointer to the associated device instance. */
/** Pointer to OUT callback function. */
/** Pointer to IN callback function. */
/** Pointer to string OUT callback function. */
/** Pointer to string IN callback function. */
/** Description / Name. For easing debugging. */
/** Pointer to I/O port range descriptor, R3 version. */
typedef IOMIOPORTRANGER3 *PIOMIOPORTRANGER3;
/**
* I/O port range descriptor, R0 version.
*/
typedef struct IOMIOPORTRANGER0
{
/** Avl node core with Port as Key and Port + cPorts - 1 as KeyLast. */
#endif
/** Start I/O port address. */
/** Size of the range. */
/** Pointer to user argument. */
/** Pointer to the associated device instance. */
/** Pointer to OUT callback function. */
/** Pointer to IN callback function. */
/** Pointer to string OUT callback function. */
/** Pointer to string IN callback function. */
/** Description / Name. For easing debugging. */
/** Pointer to I/O port range descriptor, R0 version. */
typedef IOMIOPORTRANGER0 *PIOMIOPORTRANGER0;
/**
* I/O port range descriptor, RC version.
*/
typedef struct IOMIOPORTRANGERC
{
/** Avl node core with Port as Key and Port + cPorts - 1 as KeyLast. */
/** Start I/O port address. */
/** Size of the range. */
/** Pointer to user argument. */
/** Pointer to the associated device instance. */
/** Pointer to OUT callback function. */
/** Pointer to IN callback function. */
/** Pointer to string OUT callback function. */
/** Pointer to string IN callback function. */
#if HC_ARCH_BITS == 64
#endif
/** Description / Name. For easing debugging. */
/** Pointer to I/O port range descriptor, RC version. */
typedef IOMIOPORTRANGERC *PIOMIOPORTRANGERC;
/**
* I/O port statistics. (one I/O port)
*
* This is a simple way of making on demand statistics, however it's a
* bit free with the hypervisor heap memory.
*/
typedef struct IOMIOPORTSTATS
{
/** Avl node core with the port as Key. */
#endif
/** Number of INs to this port from R3. */
/** Profiling IN handler overhead in R3. */
/** Number of OUTs to this port from R3. */
/** Profiling OUT handler overhead in R3. */
/** Pointer to I/O port statistics. */
typedef IOMIOPORTSTATS *PIOMIOPORTSTATS;
/**
* The IOM trees.
* These are offset based the nodes and root must be in the same
* memory block in HC. The locations of IOM structure and the hypervisor heap
* are quite different in R3, R0 and RC.
*/
typedef struct IOMTREES
{
/** Tree containing I/O port range descriptors registered for HC (IOMIOPORTRANGEHC). */
/** Tree containing I/O port range descriptors registered for R0 (IOMIOPORTRANGER0). */
/** Tree containing I/O port range descriptors registered for RC (IOMIOPORTRANGERC). */
/** Tree containing the MMIO range descriptors (IOMMMIORANGE). */
/** Tree containing I/O port statistics (IOMIOPORTSTATS). */
/** Tree containing MMIO statistics (IOMMMIOSTATS). */
} IOMTREES;
/** Pointer to the IOM trees. */
/**
* Converts an IOM pointer into a VM pointer.
* @returns Pointer to the VM structure the PGM is part of.
* @param pIOM Pointer to IOM instance data.
*/
/**
* IOM Data (part of VM)
*/
typedef struct IOM
{
/** Offset to the VM structure. */
/** Pointer to the trees - RC ptr. */
/** Pointer to the trees - R3 ptr. */
/** Pointer to the trees - R0 ptr. */
/** The ring-0 address of IOMMMIOHandler. */
/** The RC address of IOMMMIOHandler. */
#if HC_ARCH_BITS == 64
#endif
/** Lock serializing EMT access to IOM. */
/** @name Caching of I/O Port and MMIO ranges and statistics.
* @{ */
/** @} */
/** @name I/O Port statistics.
* @{ */
/** @} */
/** @name MMIO statistics.
* @{ */
#ifdef IOM_WITH_MOVS_SUPPORT
#endif
/** @} */
} IOM;
/** Pointer to IOM instance data. */
/**
* IOM per virtual CPU instance data.
*/
typedef struct IOMCPU
{
/** For saving stack space, the disassembler state is allocated here instead of
* on the stack.
union
{
/** The disassembler scratch space. */
/** Padding. */
};
} IOMCPU;
/** Pointer to IOM per virtual CPU instance data. */
#ifdef IN_RING3
#endif /* IN_RING3 */
VMMDECL(int) IOMMMIOHandler(PVM pVM, RTGCUINT uErrorCode, PCPUMCTXCORE pRegFrame, RTGCPTR pvFault, RTGCPHYS GCPhysFault, void *pvUser);
#ifdef IN_RING3
DECLCALLBACK(int) IOMR3MMIOHandler(PVM pVM, RTGCPHYS GCPhys, void *pvPhys, void *pvBuf, size_t cbBuf, PGMACCESSTYPE enmAccessType, void *pvUser);
#endif
/**
* Gets the I/O port range for the specified I/O port in the current context.
*
* @returns Pointer to I/O port range.
* @returns NULL if no port registered.
*
* @param pIOM IOM instance data.
* @param Port Port to lookup.
*/
{
#ifdef IN_RING3
#endif
CTX_SUFF(PIOMIOPORTRANGE) pRange = (CTX_SUFF(PIOMIOPORTRANGE))RTAvlroIOPortRangeGet(&pIOM->CTX_SUFF(pTrees)->CTX_SUFF(IOPortTree), Port);
return pRange;
}
/**
* Gets the I/O port range for the specified I/O port in the HC.
*
* @returns Pointer to I/O port range.
* @returns NULL if no port registered.
*
* @param pIOM IOM instance data.
* @param Port Port to lookup.
*/
{
#ifdef IN_RING3
#endif
PIOMIOPORTRANGER3 pRange = (PIOMIOPORTRANGER3)RTAvlroIOPortRangeGet(&pIOM->CTX_SUFF(pTrees)->IOPortTreeR3, Port);
return pRange;
}
/**
* Gets the MMIO range for the specified physical address in the current context.
*
* @returns Pointer to MMIO range.
* @returns NULL if address not in a MMIO range.
*
* @param pIOM IOM instance data.
* @param GCPhys Physical address to lookup.
*/
{
#ifdef IN_RING3
#endif
if ( !pRange
pIOM->CTX_SUFF(pMMIORangeLast) = pRange = (PIOMMMIORANGE)RTAvlroGCPhysRangeGet(&pIOM->CTX_SUFF(pTrees)->MMIOTree, GCPhys);
return pRange;
}
#ifdef VBOX_STRICT
/**
* Gets the MMIO range for the specified physical address in the current context.
*
* @returns Pointer to MMIO range.
* @returns NULL if address not in a MMIO range.
*
* @param pIOM IOM instance data.
* @param GCPhys Physical address to lookup.
*/
{
if ( !pRange
pIOM->CTX_SUFF(pMMIORangeLast) = pRange = (PIOMMMIORANGE)RTAvlroGCPhysRangeGet(&pIOM->CTX_SUFF(pTrees)->MMIOTree, GCPhys);
return pRange;
}
#endif
#ifdef VBOX_WITH_STATISTICS
/**
* Gets the MMIO statistics record.
*
* return the appropriate status to defer the operation to ring-3.
*
* @returns Pointer to MMIO stats.
*
* @param pIOM IOM instance data.
* @param GCPhys Physical address to lookup.
* @param pRange The MMIO range.
*/
{
/* For large ranges, we'll put everything on the first byte. */
if ( !pStats
{
# ifdef IN_RING3
if (!pStats)
# endif
}
return pStats;
}
#endif
/* IOM locking helpers. */
/* Disassembly helpers used in IOMAll.cpp & IOMAllMMIO.cpp */
bool iomGetRegImmData(PDISCPUSTATE pCpu, PCOP_PARAMETER pParam, PCPUMCTXCORE pRegFrame, uint64_t *pu64Data, unsigned *pcbSize);
bool iomSaveDataToReg(PDISCPUSTATE pCpu, PCOP_PARAMETER pParam, PCPUMCTXCORE pRegFrame, uint64_t u32Data);
#ifdef IN_RING3
#endif
/** @} */
#endif /* ___IOMInternal_h */