IOMInternal.h revision 17ba03925269c071aa1567eb8c5a49c37a65f62f
/* $Id$ */
/** @file
* IOM - 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 ___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, R3 version.
*/
typedef struct IOMMMIORANGER3
{
/** 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. */
/** Description / Name. For easing debugging. */
/** Pointer to a MMIO range descriptor, R3 version. */
typedef struct IOMMMIORANGER3 *PIOMMMIORANGER3;
/**
* MMIO range descriptor, R0 version.
*/
typedef struct IOMMMIORANGER0
{
/** 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. */
/** Description / Name. For easing debugging. */
/** Pointer to a MMIO range descriptor, R0 version. */
typedef struct IOMMMIORANGER0 *PIOMMMIORANGER0;
/**
* MMIO range descriptor, GC version.
*/
typedef struct IOMMMIORANGEGC
{
/** 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. */
/** Description / Name. For easing debugging. */
/** Pointer to a MMIO range descriptor, GC version. */
typedef struct IOMMMIORANGEGC *PIOMMMIORANGEGC;
/**
* 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. */
/** 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. */
/** 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. */
/** 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. */
/** 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 MMIO range descriptors registered for HC (IOMMMIORANGEHC). */
/** Tree containing MMIO range descriptors registered for R0 (IOMMMIORANGER0). */
/** Tree containing MMIO range descriptors registered for GC (IOMMMIORANGEGC). */
/** 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. */
/** @name Caching of I/O Port 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, void *pvFault, RTGCPHYS GCPhysFault, void *pvUser);
/**
* 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.
*/
{
CTXALLSUFF(PIOMMMIORANGE) pRange = (CTXALLSUFF(PIOMMMIORANGE))RTAvlroGCPhysRangeGet(&pIOM->CTXSUFF(pTrees)->CTXALLSUFF(MMIOTree), GCPhys);
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.
*/
{
PIOMMMIORANGER3 pRange = (PIOMMMIORANGER3)RTAvlroGCPhysRangeGet(&pIOM->CTXSUFF(pTrees)->MMIOTreeR3, GCPhys);
return pRange;
}
#ifdef VBOX_WITH_STATISTICS
/**
* Gets the MMIO statistics record.
* @returns Pointer to MMIO stats.
* @returns NULL if not found.
*
* @param pIOM IOM instance data.
* @param GCPhys Physical address to lookup.
*/
{
PIOMMMIOSTATS pStats = (PIOMMMIOSTATS)RTAvloGCPhysGet(&pIOM->CTXSUFF(pTrees)->MMIOStatTree, GCPhys);
return pStats;
}
#endif
#ifdef IN_RING3
#endif
/** @} */
#endif /* ___IOMInternal_h */