MMAll.cpp revision 4d80b7e0ad6f5737c5868cf2deae6015fa39f2b9
/* $Id$ */
/** @file
* MM - Memory Monitor(/Manager) - Any Context.
*/
/*
* Copyright (C) 2006 InnoTek Systemberatung 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.
*/
/*******************************************************************************
* 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)((char*)CTXSUFF(pVM->mm.s.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) */
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.
*/
{
/*
* Translate Ring-0 VM addresses into Ring-3 VM addresses before feeding it to mmHyperLookupR3.
*/
/** @todo fix this properly; the ring 0 pVM address differs from the R3 one. (#1865) */
}
/**
* Lookup a guest context address.
*
* @returns Pointer to the corresponding lookup record.
* @returns NULL on failure.
* @param pVM The VM handle.
* @param GCPtr The guest 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)((char*)CTXSUFF(pVM->mm.s.pHyperHeap) + pVM->mm.s.offLookupHyper);
for (;;)
{
{
{
case MMLOOKUPHYPERTYPE_LOCKED:
case MMLOOKUPHYPERTYPE_HCPHYS:
return pLookup;
default:
break;
}
return NULL;
}
/* next */
break;
}
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_GC
#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 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.
*/
{
}
/**
* 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_GC
#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 guest context address.
*
* @returns guest 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_RTGCPTR;
}
/**
* 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.
*/
#ifndef IN_RING0
{
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_RTGCPTR;
}
/**
* 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.
*/
#ifndef IN_RING3
{
if (pLookup)
return NULL;
}
#endif
/**
* Converts a guest 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 guest context address.
* You'll be damned if this is not in the HMA! :-)
* @thread The Emulation Thread.
*/
{
if (pLookup)
return NIL_RTR3PTR;
}
/**
* Converts a guest 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 GCPtr The guest context address.
* You'll be damned if this is not in the HMA! :-)
* @thread The Emulation Thread.
*/
{
if (pLookup)
return NIL_RTR0PTR;
}
/**
* Converts a guest context address in the Hypervisor memory region to a current context address.
*
* @returns current context address.
* @param pVM The VM to operate on.
* @param GCPtr The guest host context address.
* You'll be damned if this is not in the HMA! :-)
* @thread The Emulation Thread.
*/
#ifndef IN_GC
{
if (pLookup)
return NULL;
}
#endif
/**
* 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.
*/
#ifndef IN_RING3
{
if (pLookup)
return NIL_RTR3PTR;
}
#endif
/**
* 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.
*/
#ifndef IN_RING0
{
if (pLookup)
return NIL_RTR0PTR;
}
#endif
/**
* Converts a current context address in the Hypervisor memory region to a guest 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.
*/
#ifndef IN_GC
{
if (pLookup)
return NIL_RTGCPTR;
}
#endif
/**
* Converts a HC address in the Hypervisor memory region to a GC address.
* The memory must have been allocated with MMGCHyperAlloc() or MMR3HyperAlloc().
*
* @returns GC address.
* @param pVM The VM to operate on.
* @param HCPtr The host context address.
* You'll be damed if this is not in the hypervisor region! :-)
* @deprecated
*/
{
PMMLOOKUPHYPER pLookup = (PMMLOOKUPHYPER)((char*)CTXSUFF(pVM->mm.s.pHyperHeap) + pVM->mm.s.offLookupHyper);
for (;;)
{
{
case MMLOOKUPHYPERTYPE_LOCKED:
{
break;
}
case MMLOOKUPHYPERTYPE_HCPHYS:
{
break;
}
case MMLOOKUPHYPERTYPE_GCPHYS: /* (for now we'll not allow these kind of conversions) */
break;
default:
break;
}
/* next */
break;
}
return (RTGCPTR)0;
}
/**
* Converts a GC address in the Hypervisor memory region to a HC address.
* The memory must have been allocated with MMHyperAlloc().
*
* @returns HC address.
* @param pVM The VM to operate on.
* @param GCPtr The guest context address.
* You'll be damed if this is not in the hypervisor region! :-)
* @deprecated
*/
{
PMMLOOKUPHYPER pLookup = (PMMLOOKUPHYPER)((char*)CTXSUFF(pVM->mm.s.pHyperHeap) + pVM->mm.s.offLookupHyper);
for (;;)
{
{
{
case MMLOOKUPHYPERTYPE_LOCKED:
case MMLOOKUPHYPERTYPE_HCPHYS:
default:
break;
}
return (RTHCPTR)0;
}
/* next */
break;
}
return (RTHCPTR)0;
}
#ifdef IN_GC
/**
* Converts a current context address in the Hypervisor memory region to a HC address.
* The memory must have been allocated with MMGCHyperAlloc() or MMR3HyperAlloc().
*
* @returns HC address.
* @param pVM The VM to operate on.
* @param Ptr The current context address.
* @deprecated
*/
{
}
#else /* !IN_GC */
/**
* Converts a current context address in the Hypervisor memory region to a GC address.
* The memory must have been allocated with MMHyperAlloc().
*
* @returns HC address.
* @param pVM The VM to operate on.
* @param Ptr The current context address.
* @thread The Emulation Thread.
* @deprecated
*/
{
}
#endif /* !IN_GC */