MMAll.cpp revision 1509a69ee98d4fc8d0490e0b054d28712558afb0
/* $Id$ */
/** @file
* MM - Memory Manager - Any Context.
*/
/*
* 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.
*/
/*******************************************************************************
* Header Files *
*******************************************************************************/
#define LOG_GROUP LOG_GROUP_MM_HYPER
#include "MMInternal.h"
/**
* Lookup a host context ring-3 address.
*
* @returns Pointer to the corresponding lookup record.
* @returns NULL on failure.
* @param pVM The VM handle.
* @param R3Ptr The host context ring-3 address to lookup.
* @param poff Where to store the offset into the HMA memory chunk.
*/
{
/** @todo cache last lookup, this stuff ain't cheap! */
PMMLOOKUPHYPER pLookup = (PMMLOOKUPHYPER)((uint8_t *)pVM->mm.s.CTX_SUFF(pHyperHeap) + pVM->mm.s.offLookupHyper);
for (;;)
{
{
case MMLOOKUPHYPERTYPE_LOCKED:
{
{
return pLookup;
}
break;
}
case MMLOOKUPHYPERTYPE_HCPHYS:
{
{
return pLookup;
}
break;
}
case MMLOOKUPHYPERTYPE_GCPHYS: /* (for now we'll not allow these kind of conversions) */
case MMLOOKUPHYPERTYPE_MMIO2:
break;
default:
break;
}
/* next */
break;
}
return NULL;
}
/**
* Lookup a host context ring-0 address.
*
* @returns Pointer to the corresponding lookup record.
* @returns NULL on failure.
* @param pVM The VM handle.
* @param R0Ptr The host context ring-0 address to lookup.
* @param poff Where to store the offset into the HMA memory chunk.
*/
{
/** @todo cache last lookup, this stuff ain't cheap! */
PMMLOOKUPHYPER pLookup = (PMMLOOKUPHYPER)((uint8_t *)pVM->mm.s.CTX_SUFF(pHyperHeap) + pVM->mm.s.offLookupHyper);
for (;;)
{
{
case MMLOOKUPHYPERTYPE_LOCKED:
{
{
return pLookup;
}
break;
}
case MMLOOKUPHYPERTYPE_HCPHYS:
{
{
return pLookup;
}
break;
}
case MMLOOKUPHYPERTYPE_GCPHYS: /* (for now we'll not allow these kind of conversions) */
case MMLOOKUPHYPERTYPE_MMIO2:
break;
default:
break;
}
/* next */
break;
}
return NULL;
}
/**
* Lookup a raw-mode context address.
*
* @returns Pointer to the corresponding lookup record.
* @returns NULL on failure.
* @param pVM The VM handle.
* @param RCPtr The raw-mode context address to lookup.
* @param poff Where to store the offset into the HMA memory chunk.
*/
{
/** @todo cache last lookup this stuff ain't cheap! */
PMMLOOKUPHYPER pLookup = (PMMLOOKUPHYPER)((uint8_t *)pVM->mm.s.CTX_SUFF(pHyperHeap) + pVM->mm.s.offLookupHyper);
for (;;)
{
{
{
case MMLOOKUPHYPERTYPE_LOCKED:
case MMLOOKUPHYPERTYPE_HCPHYS:
return pLookup;
default:
break;
}
*poff = 0; /* shut up gcc */
return NULL;
}
/* next */
break;
}
*poff = 0; /* shut up gcc */
return NULL;
}
/**
* Lookup a current context address.
*
* @returns Pointer to the corresponding lookup record.
* @returns NULL on failure.
* @param pVM The VM handle.
* @param pv The current context address to lookup.
* @param poff Where to store the offset into the HMA memory chunk.
*/
{
#ifdef IN_RC
#else
#endif
}
/**
* Calculate the host context ring-3 address of an offset into the HMA memory chunk.
*
* @returns the host context ring-3 address.
* @param pLookup The HMA lookup record.
* @param off The offset into the HMA memory chunk.
*/
{
{
case MMLOOKUPHYPERTYPE_LOCKED:
case MMLOOKUPHYPERTYPE_HCPHYS:
default:
return NIL_RTR3PTR;
}
}
/**
* Calculate the host context ring-0 address of an offset into the HMA memory chunk.
*
* @returns the host context ring-0 address.
* @param pVM Pointer to the shared VM structure.
* @param pLookup The HMA lookup record.
* @param off The offset into the HMA memory chunk.
*/
{
{
case MMLOOKUPHYPERTYPE_LOCKED:
#ifdef VBOX_WITH_2X_4GB_ADDR_SPACE
#else
#endif
return NIL_RTR0PTR;
case MMLOOKUPHYPERTYPE_HCPHYS:
return NIL_RTR0PTR;
default:
return NIL_RTR0PTR;
}
}
/**
* Calculate the raw-mode context address of an offset into the HMA memory chunk.
*
* @returns the raw-mode context base address.
* @param pVM The the VM handle.
* @param pLookup The HMA lookup record.
* @param off The offset into the HMA memory chunk.
*/
{
}
/**
* Calculate the guest context address of an offset into the HMA memory chunk.
*
* @returns the guest context base address.
* @param pVM The the VM handle.
* @param pLookup The HMA lookup record.
* @param off The offset into the HMA memory chunk.
*/
{
#ifdef IN_RC
#else
#endif
}
/**
* Converts a ring-0 host context address in the Hypervisor memory region to a ring-3 host context address.
*
* @returns ring-3 host context address.
* @param pVM The VM to operate on.
* @param R0Ptr The ring-0 host context address.
* You'll be damned if this is not in the HMA! :-)
* @thread The Emulation Thread.
*/
{
if (pLookup)
return NIL_RTR3PTR;
}
/**
* Converts a ring-0 host context address in the Hypervisor memory region to a raw-mode context address.
*
* @returns raw-mode context address.
* @param pVM The VM to operate on.
* @param R0Ptr The ring-0 host context address.
* You'll be damned if this is not in the HMA! :-)
* @thread The Emulation Thread.
*/
{
if (pLookup)
return NIL_RTRCPTR;
}
#ifndef IN_RING0
/**
* Converts a ring-0 host context address in the Hypervisor memory region to a current context address.
*
* @returns current context address.
* @param pVM The VM to operate on.
* @param R0Ptr The ring-0 host context address.
* You'll be damned if this is not in the HMA! :-)
* @thread The Emulation Thread.
*/
{
if (pLookup)
return NULL;
}
#endif
/**
* Converts a ring-3 host context address in the Hypervisor memory region to a ring-0 host context address.
*
* @returns ring-0 host context address.
* @param pVM The VM to operate on.
* @param R3Ptr The ring-3 host context address.
* You'll be damned if this is not in the HMA! :-)
* @thread The Emulation Thread.
*/
{
if (pLookup)
return NIL_RTR0PTR;
}
/**
* Converts a ring-3 host context address in the Hypervisor memory region to a guest context address.
*
* @returns guest context address.
* @param pVM The VM to operate on.
* @param R3Ptr The ring-3 host context address.
* You'll be damned if this is not in the HMA! :-)
* @thread The Emulation Thread.
*/
{
if (pLookup)
return NIL_RTRCPTR;
}
#ifndef IN_RING3
/**
* Converts a ring-3 host context address in the Hypervisor memory region to a current context address.
*
* @returns current context address.
* @param pVM The VM to operate on.
* @param R3Ptr The ring-3 host context address.
* You'll be damned if this is not in the HMA! :-)
* @thread The Emulation Thread.
*/
{
if (pLookup)
return NULL;
}
#endif
/**
* Converts a raw-mode context address in the Hypervisor memory region to a ring-3 context address.
*
* @returns ring-3 host context address.
* @param pVM The VM to operate on.
* @param GCPtr The raw-mode context address.
* You'll be damned if this is not in the HMA! :-)
* @thread The Emulation Thread.
*/
{
if (pLookup)
return NIL_RTR3PTR;
}
/**
* Converts a raw-mode context address in the Hypervisor memory region to a ring-0 host context address.
*
* @returns ring-0 host context address.
* @param pVM The VM to operate on.
* @param RCPtr The raw-mode context address.
* You'll be damned if this is not in the HMA! :-)
* @thread The Emulation Thread.
*/
{
if (pLookup)
return NIL_RTR0PTR;
}
#ifndef IN_RC
/**
* Converts a raw-mode context address in the Hypervisor memory region to a current context address.
*
* @returns current context address.
* @param pVM The VM to operate on.
* @param RCPtr The raw-mode host context address.
* You'll be damned if this is not in the HMA! :-)
* @thread The Emulation Thread.
*/
{
if (pLookup)
return NULL;
}
#endif
#ifndef IN_RING3
/**
* Converts a current context address in the Hypervisor memory region to a ring-3 host context address.
*
* @returns ring-3 host context address.
* @param pVM The VM to operate on.
* @param pv The current context address.
* You'll be damned if this is not in the HMA! :-)
* @thread The Emulation Thread.
*/
{
if (pLookup)
return NIL_RTR3PTR;
}
#endif
#ifndef IN_RING0
/**
* Converts a current context address in the Hypervisor memory region to a ring-0 host context address.
*
* @returns ring-0 host context address.
* @param pVM The VM to operate on.
* @param pv The current context address.
* You'll be damned if this is not in the HMA! :-)
* @thread The Emulation Thread.
*/
{
if (pLookup)
return NIL_RTR0PTR;
}
#endif
#ifndef IN_RC
/**
* Converts a current context address in the Hypervisor memory region to a raw-mode context address.
*
* @returns guest context address.
* @param pVM The VM to operate on.
* @param pv The current context address.
* You'll be damned if this is not in the HMA! :-)
* @thread The Emulation Thread.
*/
{
if (pLookup)
return NIL_RTRCPTR;
}
#endif
/**
* Gets the string name of a memory tag.
*
* @returns name of enmTag.
* @param enmTag The tag.
*/
{
switch (enmTag)
{
default:
{
#ifdef IN_RING3
static char sz[48];
return sz;
#else
return "unknown tag!";
#endif
}
}
}