IOMInternal.h revision df3966b3ff935eba0f3e34d6918309674ad41aed
/* $Id$ */
/** @file
* IOM - Internal header file.
*/
/*
* Copyright (C) 2006-2007 Sun Microsystems, Inc.
*
* 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.
*
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
* Clara, CA 95054 USA or visit http://www.sun.com if you need
* additional information or have any questions.
*/
#ifndef ___IOMInternal_h
#define ___IOMInternal_h
# error "Not in IOM! This is an internal header!"
#endif
/** @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. */
/** Pointer to device instance. */
/** Pointer to write callback function. */
/** Pointer to read callback function. */
/** Pointer to fill (memset) callback function. */
/** Pointer to user argument. */
/** Pointer to device instance. */
/** Pointer to write callback function. */
/** Pointer to read callback function. */
/** Pointer to fill (memset) callback function. */
/** Pointer to user argument. */
/** Pointer to device instance. */
/** Pointer to write callback function. */
/** Pointer to read callback function. */
/** Pointer to fill (memset) callback function. */
/** 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 reads to this address from R3. */
/** Number of writes to this address from R3. */
/** Number of reads to this address from R0. */
/** Number of writes to this address from R0. */
/** Number of reads to this address from GC. */
/** Number of writes to this address from GC. */
/** Profiling read handler overhead in R3. */
/** Profiling write handler overhead in R3. */
/** Profiling read handler overhead in R0. */
/** Profiling write handler overhead in R0. */
/** Profiling read handler overhead in GC. */
/** Profiling write handler overhead in GC. */
/** Number of reads to this address from R0 which was serviced in R3. */
/** Number of writes to this address from R0 which was serviced in R3. */
/** Number of reads to this address from GC which was serviced in R3. */
/** Number of writes to this address from GC which was serviced 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.
*/
typedef struct IOMIOPORTRANGEGC
{
/** 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, GC version. */
typedef IOMIOPORTRANGEGC *PIOMIOPORTRANGEGC;
/**
* 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. */
/** Number of OUTs to this port from R3. */
/** Number of INs to this port from R0. */
/** Number of OUTs to this port from R0. */
/** Number of INs to this port from GC. */
/** Number of OUTs to this port from GC. */
/** Profiling IN handler overhead in R3. */
/** Profiling OUT handler overhead in R3. */
/** Profiling IN handler overhead in R0. */
/** Profiling OUT handler overhead in R0. */
/** Profiling IN handler overhead in GC. */
/** Profiling OUT handler overhead in GC. */
/** Number of INs to this port from R0 which was serviced in R3. */
/** Number of OUTs to this port from R0 which was serviced in R3. */
/** Number of INs to this port from GC which was serviced in R3. */
/** Number of OUTs to this port from GC which was serviced 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 HC and GC.
*/
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 GC (IOMIOPORTRANGEGC). */
/** 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 - GC ptr. */
/** Pointer to the trees - HC ptr. */
/** The ring-0 address of IOMMMIOHandler. */
/** The GC address of IOMMMIOHandler. */
#if GC_ARCH_BITS == 64
#endif
/** @name Caching of I/O Port and MMIO ranges and statistics.
* @{ */
/** @} */
/** @name I/O Port statistics.
* @{ */
/** @} */
/** @name MMIO statistics.
* @{ */
/** @} */
} IOM;
/** Pointer to IOM instance data. */
#ifdef IN_IOM_R3
#endif /* IN_IOM_R3 */
/**
* \#PF Handler callback for MMIO ranges.
*
* @returns VBox status code (appropriate for GC return).
*
* @param pVM VM Handle.
* @param uErrorCode CPU Error code.
* @param pRegFrame Trap register frame.
* @param pvFault The fault address (cr2).
* @param GCPhysFault The GC physical address corresponding to pvFault.
* @param pvUser Pointer to the MMIO range entry.
*/
IOMDECL(int) IOMMMIOHandler(PVM pVM, RTGCUINT uErrorCode, PCPUMCTXCORE pRegFrame, RTGCPTR pvFault, RTGCPHYS GCPhysFault, void *pvUser);
#ifdef IN_RING3
/**
* \#PF Handler callback for MMIO ranges.
*
* @returns VINF_SUCCESS if the handler have carried out the operation.
* @returns VINF_PGM_HANDLER_DO_DEFAULT if the caller should carry out the access operation.
* @param pVM VM Handle.
* @param GCPhys The physical address the guest is writing to.
* @param pvPhys The HC mapping of that address.
* @param enmAccessType The access type.
* @param pvUser Pointer to the MMIO range entry.
*/
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.
*/
{
CTXALLSUFF(PIOMIOPORTRANGE) pRange = (CTXALLSUFF(PIOMIOPORTRANGE))RTAvlroIOPortRangeGet(&pIOM->CTXSUFF(pTrees)->CTXALLSUFF(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.
*/
{
PIOMIOPORTRANGER3 pRange = (PIOMIOPORTRANGER3)RTAvlroIOPortRangeGet(&pIOM->CTXSUFF(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.
*/
{
if ( !pRange
CTXALLSUFF(pIOM->pMMIORangeLast) = pRange = (PIOMMMIORANGE)RTAvlroGCPhysRangeGet(&pIOM->CTXSUFF(pTrees)->MMIOTree, GCPhys);
return pRange;
}
#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
/* 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 */