DBGFAddr.cpp revision 4bc520c260844219a996679e2b2b0baaa5f47881
/* $Id$ */
/** @file
* DBGF - Debugger Facility, Mixed Address Methods.
*/
/*
* 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_DBGF
#include "DBGFInternal.h"
/**
* Checks if an address is in the HMA or not.
* @returns true if it's inside the HMA.
* @returns flase if it's not inside the HMA.
* @param pVM The VM handle.
* @param FlatPtr The address in question.
*/
{
}
/**
* Common worker for DBGFR3AddrFromSelOff and DBGFR3AddrFromSelInfoOff.
*/
static int dbgfR3AddrFromSelInfoOffWorker(PDBGFADDRESS pAddress, PCDBGFSELINFO pSelInfo, RTUINTPTR off)
{
/** @todo This all goes voodoo in long mode. */
/* check limit. */
{
return VERR_OUT_OF_SELECTOR_BOUNDS;
return VERR_OUT_OF_SELECTOR_BOUNDS;
}
return VERR_OUT_OF_SELECTOR_BOUNDS;
/** @todo fix all these selector tests! */
else
return VINF_SUCCESS;
}
/**
* Creates a mixed address from a Sel:off pair.
*
* @returns VBox status code.
* @param pVM The VM handle.
* @param idCpu The CPU ID.
* @param pAddress Where to store the mixed address.
* @param Sel The selector part.
* @param off The offset part.
*/
VMMR3DECL(int) DBGFR3AddrFromSelOff(PVM pVM, VMCPUID idCpu, PDBGFADDRESS pAddress, RTSEL Sel, RTUINTPTR off)
{
if (Sel != DBGF_SEL_FLAT)
{
int rc = DBGFR3SelQueryInfo(pVM, idCpu, Sel, DBGFSELQI_FLAGS_DT_GUEST | DBGFSELQI_FLAGS_DT_ADJ_64BIT_MODE, &SelInfo);
if (RT_FAILURE(rc))
return rc;
if (RT_FAILURE(rc))
return rc;
}
else
{
}
return VINF_SUCCESS;
}
/**
* Creates a mixed address from selector info and an offset into the segment
* described by it.
*
* @returns VBox status code.
* @param pVM The VM handle.
* @param idCpu The CPU ID.
* @param pAddress Where to store the mixed address.
* @param pSelInfo The selector info.
* @param off The offset part.
*/
VMMR3DECL(int) DBGFR3AddrFromSelInfoOff(PVM pVM, PDBGFADDRESS pAddress, PCDBGFSELINFO pSelInfo, RTUINTPTR off)
{
if (RT_FAILURE(rc))
return rc;
return VINF_SUCCESS;
}
/**
* Creates a mixed address from a flat address.
*
* @returns pAddress.
* @param pVM The VM handle.
* @param pAddress Where to store the mixed address.
* @param FlatPtr The flat pointer.
*/
{
return pAddress;
}
/**
* Creates a mixed address from a guest physical address.
*
* @returns pAddress.
* @param pVM The VM handle.
* @param pAddress Where to store the mixed address.
* @param PhysAddr The guest physical address.
*/
{
return pAddress;
}
/**
* Checks if the specified address is valid (checks the structure pointer too).
*
* @returns true if valid.
* @returns false if invalid.
* @param pVM The VM handle.
* @param pAddress The address to validate.
*/
{
return false;
if (!DBGFADDRESS_IS_VALID(pAddress))
return false;
/* more? */
return true;
}
/**
* Called on the EMT for the VCpu.
*
* @returns VBox status code.
* @param pVCpu The virtual CPU handle.
* @param pAddress The address.
* @param pGCPhys Where to return the physical address.
*/
static DECLCALLBACK(int) dbgfR3AddrToPhysOnVCpu(PVMCPU pVCpu, PDBGFADDRESS pAddress, PRTGCPHYS pGCPhys)
{
/* This is just a wrapper because we cannot pass FlatPtr thru VMR3ReqCall directly. */
}
/**
* Converts an address to a guest physical address.
*
* @returns VBox status code.
* @retval VINF_SUCCESS
* @retval VERR_INVALID_PARAMETER if the address is invalid.
* @retval VERR_INVALID_STATE if the VM is being terminated or if the virtual
* CPU handle is invalid.
* @retval VERR_NOT_SUPPORTED is the type of address cannot be converted.
* @retval VERR_PAGE_NOT_PRESENT
* @retval VERR_PAGE_TABLE_NOT_PRESENT
* @retval VERR_PAGE_DIRECTORY_PTR_NOT_PRESENT
* @retval VERR_PAGE_MAP_LEVEL4_NOT_PRESENT
*
* @param pVM The VM handle.
* @param idCpu The ID of the CPU context to convert virtual
* addresses.
* @param pAddress The address.
* @param pGCPhys Where to return the physical address.
*/
{
/*
* Parameter validation.
*/
*pGCPhys = NIL_RTGCPHYS;
/*
* Convert by address type.
*/
int rc;
{
rc = VINF_SUCCESS;
}
else
{
if (VMCPU_IS_EMT(pVCpu))
else
}
return rc;
}
/**
* Converts an address to a host physical address.
*
* @returns VBox status code.
* @retval VINF_SUCCESS
* @retval VERR_INVALID_PARAMETER if the address is invalid.
* @retval VERR_INVALID_STATE if the VM is being terminated or if the virtual
* CPU handle is invalid.
* @retval VERR_NOT_SUPPORTED is the type of address cannot be converted.
* @retval VERR_PAGE_NOT_PRESENT
* @retval VERR_PAGE_TABLE_NOT_PRESENT
* @retval VERR_PAGE_DIRECTORY_PTR_NOT_PRESENT
* @retval VERR_PAGE_MAP_LEVEL4_NOT_PRESENT
* @retval VERR_PGM_PHYS_PAGE_RESERVED
* @retval VERR_PGM_INVALID_GC_PHYSICAL_ADDRESS
*
* @param pVM The VM handle.
* @param idCpu The ID of the CPU context to convert virtual
* addresses.
* @param pAddress The address.
* @param pHCPhys Where to return the physical address.
*/
VMMR3DECL(int) DBGFR3AddrToHostPhys(PVM pVM, VMCPUID idCpu, PDBGFADDRESS pAddress, PRTHCPHYS pHCPhys)
{
/*
* Parameter validation.
*/
*pHCPhys = NIL_RTHCPHYS;
/*
* Convert it if we can.
*/
int rc;
else
{
if (RT_SUCCESS(rc))
}
return rc;
}
/**
* Called on the EMT for the VCpu.
*
* @returns VBox status code.
*
* @param pVM The VM handle.
* @param idCpu The ID of the CPU context.
* @param pAddress The address.
* @param fReadOnly Whether returning a read-only page is fine or not.
* @param ppvR3Ptr Where to return the address.
*/
static DECLCALLBACK(int) dbgfR3AddrToVolatileR3PtrOnVCpu(PVM pVM, VMCPUID idCpu, PDBGFADDRESS pAddress, bool fReadOnly, void **ppvR3Ptr)
{
int rc;
{
/** @todo this may assert, create a debug version of this which doesn't. */
{
if (pv)
{
rc = VINF_SUCCESS;
}
}
}
else
{
/*
* This is a tad ugly, but it gets the job done.
*/
{
if (fReadOnly)
else
}
else
{
if (fReadOnly)
else
}
if (RT_SUCCESS(rc))
}
return rc;
}
/**
* Converts an address to a volatile host virtual address.
*
* @returns VBox status code.
* @retval VINF_SUCCESS
* @retval VERR_INVALID_PARAMETER if the address is invalid.
* @retval VERR_INVALID_STATE if the VM is being terminated or if the virtual
* CPU handle is invalid.
* @retval VERR_NOT_SUPPORTED is the type of address cannot be converted.
* @retval VERR_PAGE_NOT_PRESENT
* @retval VERR_PAGE_TABLE_NOT_PRESENT
* @retval VERR_PAGE_DIRECTORY_PTR_NOT_PRESENT
* @retval VERR_PAGE_MAP_LEVEL4_NOT_PRESENT
* @retval VERR_PGM_PHYS_PAGE_RESERVED
* @retval VERR_PGM_INVALID_GC_PHYSICAL_ADDRESS
*
* @param pVM The VM handle.
* @param idCpu The ID of the CPU context to convert virtual
* addresses.
* @param pAddress The address.
* @param fReadOnly Whether returning a read-only page is fine or not.
* If set to thru the page may have to be made writable
* before we return.
* @param ppvR3Ptr Where to return the address.
*/
VMMR3DECL(int) DBGFR3AddrToVolatileR3Ptr(PVM pVM, VMCPUID idCpu, PDBGFADDRESS pAddress, bool fReadOnly, void **ppvR3Ptr)
{
/*
* Parameter validation.
*/
/*
* Convert it.
*/
return VMR3ReqCallWait(pVM, idCpu, (PFNRT)dbgfR3AddrToVolatileR3PtrOnVCpu, 5, pVM, idCpu, pAddress, fReadOnly, ppvR3Ptr);
}
/**
* Adds an offset to an address.
*
* @returns pAddress.
*
* @param pAddress The address.
* @param uAddend How much to add.
*
* @remarks No address space or segment limit checks are performed,
*/
{
/*
* Parameter validation.
*/
/*
* Add the stuff.
*/
return pAddress;
}
/**
* Subtracts an offset from an address.
*
* @returns VINF_SUCCESS on success.
*
* @param pAddress The address.
* @param uSubtrahend How much to subtract.
*
* @remarks No address space or segment limit checks are performed,
*/
{
/*
* Parameter validation.
*/
/*
* Add the stuff.
*/
return pAddress;
}