pgm.h revision a74c1d37f653a258a981c18485e9df00b6e86e2e
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync/** @file
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync * PGM - Page Monitor/Monitor.
35473cad6d5d5b57348c66f0cfdd7d51d6071ee7vboxsync */
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync/*
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync * Copyright (C) 2006-2007 innotek GmbH
f001425d2b0a661d4cd1f7ea07b4e7454538c829vboxsync *
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
fcae7923a3c756b333f1e33eba002edf4448fb54vboxsync * available from http://www.virtualbox.org. This file is free software;
fcae7923a3c756b333f1e33eba002edf4448fb54vboxsync * you can redistribute it and/or modify it under the terms of the GNU
fcae7923a3c756b333f1e33eba002edf4448fb54vboxsync * General Public License (GPL) as published by the Free Software
fcae7923a3c756b333f1e33eba002edf4448fb54vboxsync * Foundation, in version 2 as it comes in the "COPYING" file of the
fcae7923a3c756b333f1e33eba002edf4448fb54vboxsync * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
fcae7923a3c756b333f1e33eba002edf4448fb54vboxsync * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
fcae7923a3c756b333f1e33eba002edf4448fb54vboxsync *
f001425d2b0a661d4cd1f7ea07b4e7454538c829vboxsync * The contents of this file may alternatively be used under the terms
f001425d2b0a661d4cd1f7ea07b4e7454538c829vboxsync * of the Common Development and Distribution License Version 1.0
f001425d2b0a661d4cd1f7ea07b4e7454538c829vboxsync * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
f001425d2b0a661d4cd1f7ea07b4e7454538c829vboxsync * VirtualBox OSE distribution, in which case the provisions of the
f001425d2b0a661d4cd1f7ea07b4e7454538c829vboxsync * CDDL are applicable instead of those of the GPL.
f001425d2b0a661d4cd1f7ea07b4e7454538c829vboxsync *
f001425d2b0a661d4cd1f7ea07b4e7454538c829vboxsync * You may elect to license modified versions of this file under the
f001425d2b0a661d4cd1f7ea07b4e7454538c829vboxsync * terms and conditions of either the GPL or the CDDL or both.
f001425d2b0a661d4cd1f7ea07b4e7454538c829vboxsync */
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync#ifndef ___VBox_pgm_h
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync#define ___VBox_pgm_h
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync#include <VBox/cdefs.h>
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync#include <VBox/types.h>
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync#include <VBox/sup.h>
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync#include <VBox/vmapi.h>
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync#include <VBox/x86.h>
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync__BEGIN_DECLS
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync/** @defgroup grp_pgm The Page Monitor/Manager API
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync * @{
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync */
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync/** Chunk size for dynamically allocated physical memory. */
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync#define PGM_DYNAMIC_CHUNK_SIZE (1*1024*1024)
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync/** Shift GC physical address by 20 bits to get the offset into the pvHCChunkHC array. */
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync#define PGM_DYNAMIC_CHUNK_SHIFT 20
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync/** Dynamic chunk offset mask. */
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync#define PGM_DYNAMIC_CHUNK_OFFSET_MASK 0xfffff
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync/** Dynamic chunk base mask. */
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync#define PGM_DYNAMIC_CHUNK_BASE_MASK (~(RTGCPHYS)PGM_DYNAMIC_CHUNK_OFFSET_MASK)
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync/** Page flags used for PGMHyperSetPageFlags
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync * @deprecated
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync * @{ */
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync#define PGMPAGE_READ 1
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync#define PGMPAGE_WRITE 2
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync#define PGMPAGE_USER 4
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync#define PGMPAGE_SYSTEM 8
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync#define PGMPAGE_NOTPRESENT 16
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync/** @} */
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync/**
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync * FNPGMRELOCATE callback mode.
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync */
1403063c7e0c0a072d59e323b66068b06278fb9avboxsynctypedef enum PGMRELOCATECALL
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync{
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync /** The callback is for checking if the suggested address is suitable. */
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync PGMRELOCATECALL_SUGGEST = 1,
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync /** The callback is for executing the relocation. */
561b8d2b46fb10887829b7e4d7d29447817adbddvboxsync PGMRELOCATECALL_RELOCATE
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync} PGMRELOCATECALL;
f65dabff4474710524235022d328b737f174fc1dvboxsync
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync/**
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync * Callback function which will be called when PGM is trying to find
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync * a new location for the mapping.
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync *
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync * The callback is called in two modes, 1) the check mode and 2) the relocate mode.
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync * In 1) the callback should say if it objects to a suggested new location. If it
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync * accepts the new location, it is called again for doing it's relocation.
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync *
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync *
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync * @returns true if the location is ok.
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync * @returns false if another location should be found.
561b8d2b46fb10887829b7e4d7d29447817adbddvboxsync * @param GCPtrOld The old virtual address.
fb4eaa62a6bbeb82a89703d833d39339783feb4avboxsync * @param GCPtrNew The new virtual address.
fb4eaa62a6bbeb82a89703d833d39339783feb4avboxsync * @param enmMode Used to indicate the callback mode.
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync * @param pvUser User argument.
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync * @remark The return value is no a failure indicator, it's an acceptance
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync * indicator. Relocation can not fail!
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync */
1403063c7e0c0a072d59e323b66068b06278fb9avboxsynctypedef DECLCALLBACK(bool) FNPGMRELOCATE(PVM pVM, RTGCPTR GCPtrOld, RTGCPTR GCPtrNew, PGMRELOCATECALL enmMode, void *pvUser);
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync/** Pointer to a relocation callback function. */
6479169ec893c18a646cec595e4e214492d180f0vboxsynctypedef FNPGMRELOCATE *PFNPGMRELOCATE;
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync/**
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync * Physical page access handler type.
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync */
1403063c7e0c0a072d59e323b66068b06278fb9avboxsynctypedef enum PGMPHYSHANDLERTYPE
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync{
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync /** MMIO range. Pages are not present, all access is done in interpreter or recompiler. */
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync PGMPHYSHANDLERTYPE_MMIO = 1,
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync /** Handler all write access to a physical page range. */
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync PGMPHYSHANDLERTYPE_PHYSICAL_WRITE,
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync /** Handler all access to a physical page range. */
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync PGMPHYSHANDLERTYPE_PHYSICAL_ALL
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync} PGMPHYSHANDLERTYPE;
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync/**
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync * \#PF Handler callback for physical access handler ranges (MMIO among others) in GC.
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync *
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync * @returns VBox status code (appropriate for GC return).
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync * @param pVM VM Handle.
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync * @param uErrorCode CPU Error code.
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync * @param pRegFrame Trap register frame.
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync * NULL on DMA and other non CPU access.
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync * @param pvFault The fault address (cr2).
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync * @param GCPhysFault The GC physical address corresponding to pvFault.
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync * @param pvUser User argument.
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync */
1403063c7e0c0a072d59e323b66068b06278fb9avboxsynctypedef DECLCALLBACK(int) FNPGMGCPHYSHANDLER(PVM pVM, RTGCUINT uErrorCode, PCPUMCTXCORE pRegFrame, RTGCPTR pvFault, RTGCPHYS GCPhysFault, void *pvUser);
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync/** Pointer to PGM access callback. */
1403063c7e0c0a072d59e323b66068b06278fb9avboxsynctypedef FNPGMGCPHYSHANDLER *PFNPGMGCPHYSHANDLER;
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync/**
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync * \#PF Handler callback for physical access handler ranges (MMIO among others) in R0.
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync *
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync * @returns VBox status code (appropriate for GC return).
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync * @param pVM VM Handle.
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync * @param uErrorCode CPU Error code.
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync * @param pRegFrame Trap register frame.
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync * NULL on DMA and other non CPU access.
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync * @param pvFault The fault address (cr2).
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync * @param GCPhysFault The GC physical address corresponding to pvFault.
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync * @param pvUser User argument.
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync */
1403063c7e0c0a072d59e323b66068b06278fb9avboxsynctypedef DECLCALLBACK(int) FNPGMR0PHYSHANDLER(PVM pVM, RTGCUINT uErrorCode, PCPUMCTXCORE pRegFrame, RTGCPTR pvFault, RTGCPHYS GCPhysFault, void *pvUser);
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync/** Pointer to PGM access callback. */
1403063c7e0c0a072d59e323b66068b06278fb9avboxsynctypedef FNPGMR0PHYSHANDLER *PFNPGMR0PHYSHANDLER;
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync/**
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync * Guest Access type
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync */
1403063c7e0c0a072d59e323b66068b06278fb9avboxsynctypedef enum PGMACCESSTYPE
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync{
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync /** Read access. */
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync PGMACCESSTYPE_READ = 1,
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync /** Write access. */
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync PGMACCESSTYPE_WRITE
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync} PGMACCESSTYPE;
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync/**
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync * \#PF Handler callback for physical access handler ranges (MMIO among others) in HC.
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync *
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync * The handler can not raise any faults, it's mainly for monitoring write access
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync * to certain pages.
f48c3167a0f99da174686b66dc4e666f38ecae46vboxsync *
f48c3167a0f99da174686b66dc4e666f38ecae46vboxsync * @returns VINF_SUCCESS if the handler have carried out the operation.
f48c3167a0f99da174686b66dc4e666f38ecae46vboxsync * @returns VINF_PGM_HANDLER_DO_DEFAULT if the caller should carry out the access operation.
f48c3167a0f99da174686b66dc4e666f38ecae46vboxsync * @param pVM VM Handle.
f48c3167a0f99da174686b66dc4e666f38ecae46vboxsync * @param GCPhys The physical address the guest is writing to.
f48c3167a0f99da174686b66dc4e666f38ecae46vboxsync * @param pvPhys The HC mapping of that address.
f48c3167a0f99da174686b66dc4e666f38ecae46vboxsync * @param pvBuf What the guest is reading/writing.
f48c3167a0f99da174686b66dc4e666f38ecae46vboxsync * @param cbBuf How much it's reading/writing.
f48c3167a0f99da174686b66dc4e666f38ecae46vboxsync * @param enmAccessType The access type.
f48c3167a0f99da174686b66dc4e666f38ecae46vboxsync * @param pvUser User argument.
f48c3167a0f99da174686b66dc4e666f38ecae46vboxsync */
f48c3167a0f99da174686b66dc4e666f38ecae46vboxsynctypedef DECLCALLBACK(int) FNPGMR3PHYSHANDLER(PVM pVM, RTGCPHYS GCPhys, void *pvPhys, void *pvBuf, size_t cbBuf, PGMACCESSTYPE enmAccessType, void *pvUser);
f48c3167a0f99da174686b66dc4e666f38ecae46vboxsync/** Pointer to PGM access callback. */
6479169ec893c18a646cec595e4e214492d180f0vboxsynctypedef FNPGMR3PHYSHANDLER *PFNPGMR3PHYSHANDLER;
6479169ec893c18a646cec595e4e214492d180f0vboxsync
6479169ec893c18a646cec595e4e214492d180f0vboxsync
6479169ec893c18a646cec595e4e214492d180f0vboxsync/**
6479169ec893c18a646cec595e4e214492d180f0vboxsync * Virtual access handler type.
6479169ec893c18a646cec595e4e214492d180f0vboxsync */
f48c3167a0f99da174686b66dc4e666f38ecae46vboxsynctypedef enum PGMVIRTHANDLERTYPE
f48c3167a0f99da174686b66dc4e666f38ecae46vboxsync{
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync /** Write access handled. */
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync PGMVIRTHANDLERTYPE_WRITE = 1,
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync /** All access handled. */
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync PGMVIRTHANDLERTYPE_ALL,
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync /** Hypervisor write access handled.
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync * This is used to catch the guest trying to write to LDT, TSS and any other
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync * system structure which the brain dead intel guys let unprivilegde code find. */
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync PGMVIRTHANDLERTYPE_HYPERVISOR
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync} PGMVIRTHANDLERTYPE;
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync/**
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync * \#PF Handler callback for virtual access handler ranges.
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync *
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync * Important to realize that a physical page in a range can have aliases, and
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync * for ALL and WRITE handlers these will also trigger.
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync *
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync * @returns VBox status code (appropriate for GC return).
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync * @param pVM VM Handle.
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync * @param uErrorCode CPU Error code.
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync * @param pRegFrame Trap register frame.
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync * @param pvFault The fault address (cr2).
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync * @param pvRange The base address of the handled virtual range.
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync * @param offRange The offset of the access into this range.
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync * (If it's a EIP range this's the EIP, if not it's pvFault.)
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync */
1403063c7e0c0a072d59e323b66068b06278fb9avboxsynctypedef DECLCALLBACK(int) FNPGMGCVIRTHANDLER(PVM pVM, RTGCUINT uErrorCode, PCPUMCTXCORE pRegFrame, RTGCPTR pvFault, RTGCPTR pvRange, uintptr_t offRange);
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync/** Pointer to PGM access callback. */
1403063c7e0c0a072d59e323b66068b06278fb9avboxsynctypedef FNPGMGCVIRTHANDLER *PFNPGMGCVIRTHANDLER;
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync/**
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync * \#PF Handler callback for virtual access handler ranges.
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync *
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync * Important to realize that a physical page in a range can have aliases, and
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync * for ALL and WRITE handlers these will also trigger.
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync *
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync * @returns VINF_SUCCESS if the handler have carried out the operation.
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync * @returns VINF_PGM_HANDLER_DO_DEFAULT if the caller should carry out the access operation.
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync * @param pVM VM Handle.
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync * @param GCPtr The virtual address the guest is writing to. (not correct if it's an alias!)
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync * @param pvPtr The HC mapping of that address.
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync * @param pvBuf What the guest is reading/writing.
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync * @param cbBuf How much it's reading/writing.
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync * @param enmAccessType The access type.
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync * @param pvUser User argument.
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync */
1403063c7e0c0a072d59e323b66068b06278fb9avboxsynctypedef DECLCALLBACK(int) FNPGMHCVIRTHANDLER(PVM pVM, RTGCPTR GCPtr, void *pvPtr, void *pvBuf, size_t cbBuf, PGMACCESSTYPE enmAccessType, void *pvUser);
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync/** Pointer to PGM access callback. */
1403063c7e0c0a072d59e323b66068b06278fb9avboxsynctypedef FNPGMHCVIRTHANDLER *PFNPGMHCVIRTHANDLER;
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync/**
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync * \#PF Handler callback for invalidation of virtual access handler ranges.
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync *
6479169ec893c18a646cec595e4e214492d180f0vboxsync * @param pVM VM Handle.
6479169ec893c18a646cec595e4e214492d180f0vboxsync * @param GCPtr The virtual address the guest has changed.
6479169ec893c18a646cec595e4e214492d180f0vboxsync */
1403063c7e0c0a072d59e323b66068b06278fb9avboxsynctypedef DECLCALLBACK(int) FNPGMHCVIRTINVALIDATE(PVM pVM, RTGCPTR GCPtr);
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync/** Pointer to PGM invalidation callback. */
1403063c7e0c0a072d59e323b66068b06278fb9avboxsynctypedef FNPGMHCVIRTINVALIDATE *PFNPGMHCVIRTINVALIDATE;
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync/**
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync * Paging mode.
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync */
1403063c7e0c0a072d59e323b66068b06278fb9avboxsynctypedef enum PGMMODE
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync{
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync /** The usual invalid value. */
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync PGMMODE_INVALID = 0,
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync /** Real mode. */
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync PGMMODE_REAL,
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync /** Protected mode, no paging. */
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync PGMMODE_PROTECTED,
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync /** 32-bit paging. */
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync PGMMODE_32_BIT,
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync /** PAE paging. */
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync PGMMODE_PAE,
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync /** PAE paging with NX enabled. */
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync PGMMODE_PAE_NX,
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync /** 64-bit AMD paging (long mode). */
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync PGMMODE_AMD64,
f48c3167a0f99da174686b66dc4e666f38ecae46vboxsync /** 64-bit AMD paging (long mode) with NX enabled. */
6479169ec893c18a646cec595e4e214492d180f0vboxsync PGMMODE_AMD64_NX,
6479169ec893c18a646cec595e4e214492d180f0vboxsync /** The max number of modes */
6479169ec893c18a646cec595e4e214492d180f0vboxsync PGMMODE_MAX,
6479169ec893c18a646cec595e4e214492d180f0vboxsync /** 32bit hackishness. */
6479169ec893c18a646cec595e4e214492d180f0vboxsync PGMMODE_32BIT_HACK = 0x7fffffff
6479169ec893c18a646cec595e4e214492d180f0vboxsync} PGMMODE;
6479169ec893c18a646cec595e4e214492d180f0vboxsync
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync/**
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync * The current ROM page protection.
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync */
1403063c7e0c0a072d59e323b66068b06278fb9avboxsynctypedef enum PGMROMPROT
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync{
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync /** The customary invalid value. */
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync PGMROMPROT_INVALID = 0,
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync /** Read from the virgin ROM page, ignore writes.
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync * Map the virgin page, use write access handler to ignore writes. */
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync PGMROMPROT_READ_ROM_WRITE_IGNORE,
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync /** Read from the virgin ROM page, write to the shadow RAM.
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync * Map the virgin page, use write access handler change the RAM. */
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync PGMROMPROT_READ_ROM_WRITE_RAM,
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync /** Read from the shadow ROM page, ignore writes.
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync * Map the shadow page read-only, use write access handler to ignore writes. */
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync PGMROMPROT_READ_RAM_WRITE_IGNORE,
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync /** Read from the shadow ROM page, ignore writes.
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync * Map the shadow page read-write, disabled write access handler. */
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync PGMROMPROT_READ_RAM_WRITE_RAM,
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync /** The end of valid values. */
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync PGMROMPROT_END,
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync /** The usual 32-bit type size hack. */
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync PGMROMPROT_32BIT_HACK = 0x7fffffff
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync} PGMROMPROT;
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync
35473cad6d5d5b57348c66f0cfdd7d51d6071ee7vboxsync/**
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync * Is the ROM mapped (true) or is the shadow RAM mapped (false).
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync *
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync * @returns boolean.
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync * @param enmProt The PGMROMPROT value, must be valid.
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync */
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync#define PGMROMPROT_IS_ROM(enmProt) \
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync ( (enmProt) == PGMROMPROT_READ_ROM_WRITE_IGNORE \
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync || (enmProt) == PGMROMPROT_READ_ROM_WRITE_RAM )
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync
1403063c7e0c0a072d59e323b66068b06278fb9avboxsyncPGMDECL(uint32_t) PGMGetHyperCR3(PVM pVM);
1403063c7e0c0a072d59e323b66068b06278fb9avboxsyncPGMDECL(uint32_t) PGMGetHyper32BitCR3(PVM pVM);
f48c3167a0f99da174686b66dc4e666f38ecae46vboxsyncPGMDECL(uint32_t) PGMGetHyperPaeCR3(PVM pVM);
1403063c7e0c0a072d59e323b66068b06278fb9avboxsyncPGMDECL(uint32_t) PGMGetHyperAmd64CR3(PVM pVM);
1403063c7e0c0a072d59e323b66068b06278fb9avboxsyncPGMDECL(uint32_t) PGMGetInterHCCR3(PVM pVM);
1403063c7e0c0a072d59e323b66068b06278fb9avboxsyncPGMDECL(uint32_t) PGMGetInterGCCR3(PVM pVM);
f48c3167a0f99da174686b66dc4e666f38ecae46vboxsyncPGMDECL(uint32_t) PGMGetInter32BitCR3(PVM pVM);
1403063c7e0c0a072d59e323b66068b06278fb9avboxsyncPGMDECL(uint32_t) PGMGetInterPaeCR3(PVM pVM);
35473cad6d5d5b57348c66f0cfdd7d51d6071ee7vboxsyncPGMDECL(uint32_t) PGMGetInterAmd64CR3(PVM pVM);
1403063c7e0c0a072d59e323b66068b06278fb9avboxsyncPGMDECL(int) PGMTrap0eHandler(PVM pVM, RTGCUINT uErr, PCPUMCTXCORE pRegFrame, RTGCPTR pvFault);
1403063c7e0c0a072d59e323b66068b06278fb9avboxsyncPGMDECL(int) PGMPrefetchPage(PVM pVM, RTGCPTR GCPtrPage);
1403063c7e0c0a072d59e323b66068b06278fb9avboxsyncPGMDECL(int) PGMVerifyAccess(PVM pVM, RTGCUINTPTR Addr, uint32_t cbSize, uint32_t fAccess);
1403063c7e0c0a072d59e323b66068b06278fb9avboxsyncPGMDECL(int) PGMIsValidAccess(PVM pVM, RTGCUINTPTR Addr, uint32_t cbSize, uint32_t fAccess);
1403063c7e0c0a072d59e323b66068b06278fb9avboxsyncPGMDECL(int) PGMInterpretInstruction(PVM pVM, PCPUMCTXCORE pRegFrame, RTGCPTR pvFault);
1403063c7e0c0a072d59e323b66068b06278fb9avboxsyncPGMDECL(int) PGMMap(PVM pVM, RTGCUINTPTR GCPtr, RTHCPHYS HCPhys, uint32_t cbPages, unsigned fFlags);
1403063c7e0c0a072d59e323b66068b06278fb9avboxsyncPGMDECL(int) PGMMapSetPage(PVM pVM, RTGCPTR GCPtr, uint64_t cb, uint64_t fFlags);
1403063c7e0c0a072d59e323b66068b06278fb9avboxsyncPGMDECL(int) PGMMapModifyPage(PVM pVM, RTGCPTR GCPtr, size_t cb, uint64_t fFlags, uint64_t fMask);
1403063c7e0c0a072d59e323b66068b06278fb9avboxsyncPGMDECL(int) PGMShwGetPage(PVM pVM, RTGCPTR GCPtr, uint64_t *pfFlags, PRTHCPHYS pHCPhys);
1403063c7e0c0a072d59e323b66068b06278fb9avboxsyncPGMDECL(int) PGMShwSetPage(PVM pVM, RTGCPTR GCPtr, size_t cb, uint64_t fFlags);
1403063c7e0c0a072d59e323b66068b06278fb9avboxsyncPGMDECL(int) PGMShwModifyPage(PVM pVM, RTGCPTR GCPtr, size_t cb, uint64_t fFlags, uint64_t fMask);
1403063c7e0c0a072d59e323b66068b06278fb9avboxsyncPGMDECL(int) PGMGstGetPage(PVM pVM, RTGCPTR GCPtr, uint64_t *pfFlags, PRTGCPHYS pGCPhys);
1403063c7e0c0a072d59e323b66068b06278fb9avboxsyncPGMDECL(bool) PGMGstIsPagePresent(PVM pVM, RTGCPTR GCPtr);
1403063c7e0c0a072d59e323b66068b06278fb9avboxsyncPGMDECL(int) PGMGstSetPage(PVM pVM, RTGCPTR GCPtr, size_t cb, uint64_t fFlags);
1403063c7e0c0a072d59e323b66068b06278fb9avboxsyncPGMDECL(int) PGMGstModifyPage(PVM pVM, RTGCPTR GCPtr, size_t cb, uint64_t fFlags, uint64_t fMask);
1403063c7e0c0a072d59e323b66068b06278fb9avboxsyncPGMDECL(int) PGMFlushTLB(PVM pVM, uint32_t cr3, bool fGlobal);
1403063c7e0c0a072d59e323b66068b06278fb9avboxsyncPGMDECL(int) PGMSyncCR3(PVM pVM, uint32_t cr0, uint32_t cr3, uint32_t cr4, bool fGlobal);
1403063c7e0c0a072d59e323b66068b06278fb9avboxsyncPGMDECL(int) PGMChangeMode(PVM pVM, uint32_t cr0, uint32_t cr4, uint64_t efer);
1403063c7e0c0a072d59e323b66068b06278fb9avboxsyncPGMDECL(PGMMODE) PGMGetGuestMode(PVM pVM);
1403063c7e0c0a072d59e323b66068b06278fb9avboxsyncPGMDECL(PGMMODE) PGMGetShadowMode(PVM pVM);
1403063c7e0c0a072d59e323b66068b06278fb9avboxsyncPGMDECL(const char *) PGMGetModeName(PGMMODE enmMode);
1403063c7e0c0a072d59e323b66068b06278fb9avboxsyncPGMDECL(int) PGMHandlerPhysicalRegisterEx(PVM pVM, PGMPHYSHANDLERTYPE enmType, RTGCPHYS GCPhys, RTGCPHYS GCPhysLast,
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync R3PTRTYPE(PFNPGMR3PHYSHANDLER) pfnHandlerR3, RTR3PTR pvUserR3,
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync R0PTRTYPE(PFNPGMR0PHYSHANDLER) pfnHandlerR0, RTR0PTR pvUserR0,
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync GCPTRTYPE(PFNPGMGCPHYSHANDLER) pfnHandlerGC, RTGCPTR pvUserGC,
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync R3PTRTYPE(const char *) pszDesc);
1403063c7e0c0a072d59e323b66068b06278fb9avboxsyncPGMDECL(int) PGMHandlerPhysicalModify(PVM pVM, RTGCPHYS GCPhysCurrent, RTGCPHYS GCPhys, RTGCPHYS GCPhysLast);
1403063c7e0c0a072d59e323b66068b06278fb9avboxsyncPGMDECL(int) PGMHandlerPhysicalDeregister(PVM pVM, RTGCPHYS GCPhys);
1403063c7e0c0a072d59e323b66068b06278fb9avboxsyncPGMDECL(int) PGMHandlerPhysicalChangeCallbacks(PVM pVM, RTGCPHYS GCPhys,
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync R3PTRTYPE(PFNPGMR3PHYSHANDLER) pfnHandlerR3, RTR3PTR pvUserR3,
2084a447d1acb619df7c393fac41b79d517e4b3dvboxsync R0PTRTYPE(PFNPGMR0PHYSHANDLER) pfnHandlerR0, RTR0PTR pvUserR0,
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync GCPTRTYPE(PFNPGMGCPHYSHANDLER) pfnHandlerGC, RTGCPTR pvUserGC,
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync R3PTRTYPE(const char *) pszDesc);
1403063c7e0c0a072d59e323b66068b06278fb9avboxsyncPGMDECL(int) PGMHandlerPhysicalSplit(PVM pVM, RTGCPHYS GCPhys, RTGCPHYS GCPhysSplit);
1403063c7e0c0a072d59e323b66068b06278fb9avboxsyncPGMDECL(int) PGMHandlerPhysicalJoin(PVM pVM, RTGCPHYS GCPhys1, RTGCPHYS GCPhys2);
1403063c7e0c0a072d59e323b66068b06278fb9avboxsyncPGMDECL(int) PGMHandlerPhysicalPageTempOff(PVM pVM, RTGCPHYS GCPhys, RTGCPHYS GCPhysPage);
1403063c7e0c0a072d59e323b66068b06278fb9avboxsyncPGMDECL(int) PGMHandlerPhysicalReset(PVM pVM, RTGCPHYS GCPhys);
1403063c7e0c0a072d59e323b66068b06278fb9avboxsyncPGMDECL(int) PGMHandlerPhysicalPageReset(PVM pVM, RTGCPHYS GCPhys, RTGCPHYS GCPhysPage);
1403063c7e0c0a072d59e323b66068b06278fb9avboxsyncPGMDECL(bool) PGMHandlerPhysicalIsRegistered(PVM pVM, RTGCPHYS GCPhys);
1403063c7e0c0a072d59e323b66068b06278fb9avboxsyncPGMDECL(bool) PGMPhysIsA20Enabled(PVM pVM);
1403063c7e0c0a072d59e323b66068b06278fb9avboxsyncPGMDECL(bool) PGMPhysIsGCPhysValid(PVM pVM, RTGCPHYS GCPhys);
1403063c7e0c0a072d59e323b66068b06278fb9avboxsyncPGMDECL(bool) PGMPhysIsGCPhysNormal(PVM pVM, RTGCPHYS GCPhys);
1403063c7e0c0a072d59e323b66068b06278fb9avboxsyncPGMDECL(int) PGMPhysGCPhys2HCPhys(PVM pVM, RTGCPHYS GCPhys, PRTHCPHYS pHCPhys);
1403063c7e0c0a072d59e323b66068b06278fb9avboxsyncPGMDECL(int) PGMPhysGCPtr2GCPhys(PVM pVM, RTGCPTR GCPtr, PRTGCPHYS pGCPhys);
1403063c7e0c0a072d59e323b66068b06278fb9avboxsyncPGMDECL(int) PGMPhysGCPtr2HCPhys(PVM pVM, RTGCPTR GCPtr, PRTHCPHYS pHCPhys);
1403063c7e0c0a072d59e323b66068b06278fb9avboxsyncPDMDECL(void) PGMPhysInvalidatePageGCMapTLB(PVM pVM);
1403063c7e0c0a072d59e323b66068b06278fb9avboxsyncPDMDECL(void) PGMPhysInvalidatePageR0MapTLB(PVM pVM);
1403063c7e0c0a072d59e323b66068b06278fb9avboxsyncPDMDECL(void) PGMPhysInvalidatePageR3MapTLB(PVM pVM);
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync/**
f48c3167a0f99da174686b66dc4e666f38ecae46vboxsync * Page mapping lock.
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync *
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync * @remarks This doesn't work in structures shared between
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync * ring-3, ring-0 and/or GC.
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync */
1403063c7e0c0a072d59e323b66068b06278fb9avboxsynctypedef struct PGMPAGEMAPLOCK
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync{
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync /** @todo see PGMPhysIsPageMappingLockValid for possibly incorrect assumptions */
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync#ifdef IN_GC
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync /** Just a dummy for the time being. */
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync uint32_t u32Dummy;
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync#else
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync /** Pointer to the PGMPAGE. */
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync void *pvPage;
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync /** Pointer to the PGMCHUNKR3MAP. */
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync void *pvMap;
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync#endif
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync} PGMPAGEMAPLOCK;
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync/** Pointer to a page mapping lock. */
1403063c7e0c0a072d59e323b66068b06278fb9avboxsynctypedef PGMPAGEMAPLOCK *PPGMPAGEMAPLOCK;
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync
f48c3167a0f99da174686b66dc4e666f38ecae46vboxsyncPGMDECL(int) PGMPhysGCPhys2CCPtr(PVM pVM, RTGCPHYS GCPhys, void **ppv, PPGMPAGEMAPLOCK pLock);
f48c3167a0f99da174686b66dc4e666f38ecae46vboxsyncPGMDECL(int) PGMPhysGCPhys2CCPtrReadOnly(PVM pVM, RTGCPHYS GCPhys, void const **ppv, PPGMPAGEMAPLOCK pLock);
f48c3167a0f99da174686b66dc4e666f38ecae46vboxsyncPGMDECL(int) PGMPhysGCPtr2CCPtr(PVM pVM, RTGCPTR GCPtr, void **ppv, PPGMPAGEMAPLOCK pLock);
1403063c7e0c0a072d59e323b66068b06278fb9avboxsyncPGMDECL(int) PGMPhysGCPtr2CCPtrReadOnly(PVM pVM, RTGCPTR GCPtr, void const **ppv, PPGMPAGEMAPLOCK pLock);
1403063c7e0c0a072d59e323b66068b06278fb9avboxsyncPGMDECL(void) PGMPhysReleasePageMappingLock(PVM pVM, PPGMPAGEMAPLOCK pLock);
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync/**
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync * Checks if the lock structure is valid
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync *
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync * @param pVM The VM handle.
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync * @param pLock The lock structure initialized by the mapping function.
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync */
1403063c7e0c0a072d59e323b66068b06278fb9avboxsyncDECLINLINE(bool) PGMPhysIsPageMappingLockValid(PVM pVM, PPGMPAGEMAPLOCK pLock)
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync{
6479169ec893c18a646cec595e4e214492d180f0vboxsync /** @todo -> complete/change this */
6479169ec893c18a646cec595e4e214492d180f0vboxsync#ifdef IN_GC
6479169ec893c18a646cec595e4e214492d180f0vboxsync return !!(pLock->u32Dummy);
09e4ff0eddf453bdf8d622df2b48cff510f7d01dvboxsync#else
09e4ff0eddf453bdf8d622df2b48cff510f7d01dvboxsync return !!(pLock->pvPage);
6479169ec893c18a646cec595e4e214492d180f0vboxsync#endif
6479169ec893c18a646cec595e4e214492d180f0vboxsync}
6479169ec893c18a646cec595e4e214492d180f0vboxsync
6479169ec893c18a646cec595e4e214492d180f0vboxsyncPGMDECL(int) PGMPhysGCPhys2HCPtr(PVM pVM, RTGCPHYS GCPhys, RTUINT cbRange, PRTHCPTR pHCPtr);
6479169ec893c18a646cec595e4e214492d180f0vboxsyncPGMDECL(int) PGMPhysGCPtr2HCPtr(PVM pVM, RTGCPTR GCPtr, PRTHCPTR pHCPtr);
6479169ec893c18a646cec595e4e214492d180f0vboxsyncPGMDECL(int) PGMPhysGCPtr2HCPtrByGstCR3(PVM pVM, RTGCPTR GCPtr, uint32_t cr3, unsigned fFlags, PRTHCPTR pHCPtr);
6479169ec893c18a646cec595e4e214492d180f0vboxsyncPGMDECL(void) PGMPhysRead(PVM pVM, RTGCPHYS GCPhys, void *pvBuf, size_t cbRead);
6479169ec893c18a646cec595e4e214492d180f0vboxsyncPGMDECL(void) PGMPhysWrite(PVM pVM, RTGCPHYS GCPhys, const void *pvBuf, size_t cbWrite);
6479169ec893c18a646cec595e4e214492d180f0vboxsync#ifndef IN_GC /* Only ring 0 & 3. */
6479169ec893c18a646cec595e4e214492d180f0vboxsyncPGMDECL(int) PGMPhysReadGCPhys(PVM pVM, void *pvDst, RTGCPHYS GCPhysSrc, size_t cb);
6479169ec893c18a646cec595e4e214492d180f0vboxsyncPGMDECL(int) PGMPhysWriteGCPhys(PVM pVM, RTGCPHYS GCPhysDst, const void *pvSrc, size_t cb);
6479169ec893c18a646cec595e4e214492d180f0vboxsyncPGMDECL(int) PGMPhysReadGCPtr(PVM pVM, void *pvDst, RTGCPTR GCPtrSrc, size_t cb);
6479169ec893c18a646cec595e4e214492d180f0vboxsyncPGMDECL(int) PGMPhysWriteGCPtr(PVM pVM, RTGCPTR GCPtrDst, const void *pvSrc, size_t cb);
6479169ec893c18a646cec595e4e214492d180f0vboxsyncPGMDECL(int) PGMPhysReadGCPtrSafe(PVM pVM, void *pvDst, RTGCPTR GCPtrSrc, size_t cb);
6479169ec893c18a646cec595e4e214492d180f0vboxsyncPGMDECL(int) PGMPhysWriteGCPtrSafe(PVM pVM, RTGCPTR GCPtrDst, const void *pvSrc, size_t cb);
6479169ec893c18a646cec595e4e214492d180f0vboxsyncPGMDECL(int) PGMPhysWriteGCPtrDirty(PVM pVM, RTGCPTR GCPtrDst, const void *pvSrc, size_t cb);
6479169ec893c18a646cec595e4e214492d180f0vboxsyncPGMDECL(int) PGMInvalidatePage(PVM pVM, RTGCPTR GCPtrPage);
6479169ec893c18a646cec595e4e214492d180f0vboxsync#endif /* !IN_GC */
6479169ec893c18a646cec595e4e214492d180f0vboxsyncPGMDECL(int) PGMPhysInterpretedRead(PVM pVM, PCPUMCTXCORE pCtxCore, void *pvDst, RTGCUINTPTR GCPtrSrc, size_t cb);
6479169ec893c18a646cec595e4e214492d180f0vboxsync#ifdef VBOX_STRICT
6479169ec893c18a646cec595e4e214492d180f0vboxsyncPGMDECL(unsigned) PGMAssertHandlerAndFlagsInSync(PVM pVM);
6479169ec893c18a646cec595e4e214492d180f0vboxsyncPGMDECL(unsigned) PGMAssertNoMappingConflicts(PVM pVM);
6479169ec893c18a646cec595e4e214492d180f0vboxsyncPGMDECL(unsigned) PGMAssertCR3(PVM pVM, uint32_t cr3, uint32_t cr4);
6479169ec893c18a646cec595e4e214492d180f0vboxsync#endif /* VBOX_STRICT */
6479169ec893c18a646cec595e4e214492d180f0vboxsync
6479169ec893c18a646cec595e4e214492d180f0vboxsync
6479169ec893c18a646cec595e4e214492d180f0vboxsync#ifdef IN_GC
6479169ec893c18a646cec595e4e214492d180f0vboxsync/** @defgroup grp_pgm_gc The PGM Guest Context API
6479169ec893c18a646cec595e4e214492d180f0vboxsync * @ingroup grp_pgm
6479169ec893c18a646cec595e4e214492d180f0vboxsync * @{
6479169ec893c18a646cec595e4e214492d180f0vboxsync */
6479169ec893c18a646cec595e4e214492d180f0vboxsyncPGMGCDECL(int) PGMGCDynMapGCPage(PVM pVM, RTGCPHYS GCPhys, void **ppv);
6479169ec893c18a646cec595e4e214492d180f0vboxsyncPGMGCDECL(int) PGMGCDynMapGCPageEx(PVM pVM, RTGCPHYS GCPhys, void **ppv);
6479169ec893c18a646cec595e4e214492d180f0vboxsyncPGMGCDECL(int) PGMGCDynMapHCPage(PVM pVM, RTHCPHYS HCPhys, void **ppv);
6479169ec893c18a646cec595e4e214492d180f0vboxsyncPGMGCDECL(int) PGMGCSyncPT(PVM pVM, unsigned iPD, PVBOXPD pPDSrc);
6479169ec893c18a646cec595e4e214492d180f0vboxsyncPGMGCDECL(int) PGMGCInvalidatePage(PVM pVM, RTGCPTR GCPtrPage);
6479169ec893c18a646cec595e4e214492d180f0vboxsync/** @} */
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync#endif /* IN_GC */
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync#ifdef IN_RING0
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync/** @defgroup grp_pgm_r0 The PGM Host Context Ring-0 API
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync * @ingroup grp_pgm
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync * @{
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync */
1403063c7e0c0a072d59e323b66068b06278fb9avboxsyncPGMR0DECL(int) PGMR0PhysAllocateHandyPages(PVM pVM);
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync/** @} */
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync#endif /* IN_RING0 */
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync#ifdef IN_RING3
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync/** @defgroup grp_pgm_r3 The PGM Host Context Ring-3 API
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync * @ingroup grp_pgm
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync * @{
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync */
1403063c7e0c0a072d59e323b66068b06278fb9avboxsyncPGMR3DECL(int) PGMR3Init(PVM pVM);
1403063c7e0c0a072d59e323b66068b06278fb9avboxsyncPGMR3DECL(int) PGMR3InitDynMap(PVM pVM);
1403063c7e0c0a072d59e323b66068b06278fb9avboxsyncPGMR3DECL(int) PGMR3InitFinalize(PVM pVM);
1403063c7e0c0a072d59e323b66068b06278fb9avboxsyncPGMR3DECL(void) PGMR3Relocate(PVM pVM, RTGCINTPTR offDelta);
1403063c7e0c0a072d59e323b66068b06278fb9avboxsyncPGMR3DECL(void) PGMR3Reset(PVM pVM);
1403063c7e0c0a072d59e323b66068b06278fb9avboxsyncPGMR3DECL(int) PGMR3Term(PVM pVM);
1403063c7e0c0a072d59e323b66068b06278fb9avboxsyncPDMR3DECL(int) PGMR3LockCall(PVM pVM);
1403063c7e0c0a072d59e323b66068b06278fb9avboxsyncPGMR3DECL(int) PGMR3ChangeShwPDMappings(PVM pVM, bool fEnable);
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync#ifndef VBOX_WITH_NEW_PHYS_CODE
1403063c7e0c0a072d59e323b66068b06278fb9avboxsyncPGMR3DECL(int) PGM3PhysGrowRange(PVM pVM, RTGCPHYS GCPhys);
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync#endif /* !VBOX_WITH_NEW_PHYS_CODE */
1403063c7e0c0a072d59e323b66068b06278fb9avboxsyncPGMR3DECL(int) PGMR3PhysRegisterRam(PVM pVM, RTGCPHYS GCPhys, RTGCPHYS cb, const char *pszDesc);
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync/** @group PGMR3PhysRegisterRom flags.
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync * @{ */
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync/** Inidicates that ROM shadowing should be enabled. */
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync#define PGMPHYS_ROM_FLAG_SHADOWED RT_BIT_32(0)
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync/** Indicates that what pvBinary points to won't go away
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync * and can be used for strictness checks. */
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync#define PGMPHYS_ROM_FLAG_PERMANENT_BINARY RT_BIT_32(1)
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync/** @} */
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync
1403063c7e0c0a072d59e323b66068b06278fb9avboxsyncPGMR3DECL(int) PGMR3PhysRomRegister(PVM pVM, PPDMDEVINS pDevIns, RTGCPHYS GCPhys, RTGCPHYS cb,
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync const void *pvBinary, uint32_t fFlags, const char *pszDesc);
1403063c7e0c0a072d59e323b66068b06278fb9avboxsyncPGMR3DECL(int) PGMR3PhysRomProtect(PVM pVM, RTGCPHYS GCPhys, RTGCPHYS cb, PGMROMPROT enmProt);
1403063c7e0c0a072d59e323b66068b06278fb9avboxsyncPGMR3DECL(int) PGMR3PhysRegister(PVM pVM, void *pvRam, RTGCPHYS GCPhys, size_t cb, unsigned fFlags, const SUPPAGE *paPages, const char *pszDesc);
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync#ifndef VBOX_WITH_NEW_PHYS_CODE
1403063c7e0c0a072d59e323b66068b06278fb9avboxsyncPGMR3DECL(int) PGMR3PhysRegisterChunk(PVM pVM, void *pvRam, RTGCPHYS GCPhys, size_t cb, unsigned fFlags, const SUPPAGE *paPages, const char *pszDesc);
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync#endif /* !VBOX_WITH_NEW_PHYS_CODE */
1403063c7e0c0a072d59e323b66068b06278fb9avboxsyncPGMR3DECL(int) PGMR3PhysRelocate(PVM pVM, RTGCPHYS GCPhysOld, RTGCPHYS GCPhysNew, size_t cb);
1403063c7e0c0a072d59e323b66068b06278fb9avboxsyncPGMR3DECL(int) PGMR3PhysSetFlags(PVM pVM, RTGCPHYS GCPhys, size_t cb, unsigned fFlags, unsigned fMask);
ad27e1d5e48ca41245120c331cc88b50464813cevboxsyncPGMDECL(void) PGMR3PhysSetA20(PVM pVM, bool fEnable);
1403063c7e0c0a072d59e323b66068b06278fb9avboxsyncPGMR3DECL(int) PGMR3MapPT(PVM pVM, RTGCPTR GCPtr, uint32_t cb, PFNPGMRELOCATE pfnRelocate, void *pvUser, const char *pszDesc);
1403063c7e0c0a072d59e323b66068b06278fb9avboxsyncPGMR3DECL(int) PGMR3UnmapPT(PVM pVM, RTGCPTR GCPtr);
1403063c7e0c0a072d59e323b66068b06278fb9avboxsyncPGMR3DECL(int) PGMR3MappingsSize(PVM pVM, uint32_t *pcb);
1403063c7e0c0a072d59e323b66068b06278fb9avboxsyncPGMR3DECL(int) PGMR3MappingsFix(PVM pVM, RTGCPTR GCPtrBase, uint32_t cb);
1403063c7e0c0a072d59e323b66068b06278fb9avboxsyncPGMR3DECL(int) PGMR3MappingsUnfix(PVM pVM);
1403063c7e0c0a072d59e323b66068b06278fb9avboxsyncPGMR3DECL(int) PGMR3MapIntermediate(PVM pVM, RTUINTPTR Addr, RTHCPHYS HCPhys, unsigned cbPages);
1403063c7e0c0a072d59e323b66068b06278fb9avboxsyncPGMR3DECL(bool) PGMR3MapHasConflicts(PVM pVM, uint32_t cr3, bool fRawR0);
1403063c7e0c0a072d59e323b66068b06278fb9avboxsyncPGMR3DECL(int) PGMR3MapRead(PVM pVM, void *pvDst, RTGCPTR GCPtrSrc, size_t cb);
1403063c7e0c0a072d59e323b66068b06278fb9avboxsyncPGMR3DECL(int) PGMR3HandlerPhysicalRegister(PVM pVM, PGMPHYSHANDLERTYPE enmType, RTGCPHYS GCPhys, RTGCPHYS GCPhysLast,
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync PFNPGMR3PHYSHANDLER pfnHandlerR3, void *pvUserR3,
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync const char *pszModR0, const char *pszHandlerR0, RTR0PTR pvUserR0,
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync const char *pszModGC, const char *pszHandlerGC, RTGCPTR pvUserGC, const char *pszDesc);
1403063c7e0c0a072d59e323b66068b06278fb9avboxsyncPGMDECL(int) PGMHandlerVirtualRegisterEx(PVM pVM, PGMVIRTHANDLERTYPE enmType, RTGCPTR GCPtr, RTGCPTR GCPtrLast,
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync PFNPGMHCVIRTINVALIDATE pfnInvalidateHC,
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync PFNPGMHCVIRTHANDLER pfnHandlerHC, RTGCPTR pfnHandlerGC,
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync R3PTRTYPE(const char *) pszDesc);
1403063c7e0c0a072d59e323b66068b06278fb9avboxsyncPGMR3DECL(int) PGMR3HandlerVirtualRegister(PVM pVM, PGMVIRTHANDLERTYPE enmType, RTGCPTR GCPtr, RTGCPTR GCPtrLast,
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync PFNPGMHCVIRTINVALIDATE pfnInvalidateHC,
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync PFNPGMHCVIRTHANDLER pfnHandlerHC,
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync const char *pszHandlerGC, const char *pszModGC, const char *pszDesc);
1403063c7e0c0a072d59e323b66068b06278fb9avboxsyncPGMDECL(int) PGMHandlerVirtualChangeInvalidateCallback(PVM pVM, RTGCPTR GCPtr, PFNPGMHCVIRTINVALIDATE pfnInvalidateHC);
1403063c7e0c0a072d59e323b66068b06278fb9avboxsyncPGMDECL(int) PGMHandlerVirtualDeregister(PVM pVM, RTGCPTR GCPtr);
1403063c7e0c0a072d59e323b66068b06278fb9avboxsyncPDMR3DECL(int) PGMR3PoolGrow(PVM pVM);
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync#ifdef ___VBox_dbgf_h /** @todo fix this! */
1403063c7e0c0a072d59e323b66068b06278fb9avboxsyncPGMR3DECL(int) PGMR3DumpHierarchyHC(PVM pVM, uint32_t cr3, uint32_t cr4, bool fLongMode, unsigned cMaxDepth, PCDBGFINFOHLP pHlp);
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync#endif
1403063c7e0c0a072d59e323b66068b06278fb9avboxsyncPGMR3DECL(int) PGMR3DumpHierarchyGC(PVM pVM, uint32_t cr3, uint32_t cr4, RTGCPHYS PhysSearch);
1403063c7e0c0a072d59e323b66068b06278fb9avboxsyncPGMR3DECL(void) PGMR3DumpPD(PVM pVM, PVBOXPD pPD);
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync/** @todo r=bird: s/Byte/U8/ s/Word/U16/ s/Dword/U32/ to match other functions names and returned types. */
1403063c7e0c0a072d59e323b66068b06278fb9avboxsyncPGMR3DECL(uint8_t) PGMR3PhysReadByte(PVM pVM, RTGCPHYS GCPhys);
1403063c7e0c0a072d59e323b66068b06278fb9avboxsyncPGMR3DECL(uint16_t) PGMR3PhysReadWord(PVM pVM, RTGCPHYS GCPhys);
1403063c7e0c0a072d59e323b66068b06278fb9avboxsyncPGMR3DECL(uint32_t) PGMR3PhysReadDword(PVM pVM, RTGCPHYS GCPhys);
1403063c7e0c0a072d59e323b66068b06278fb9avboxsyncPGMR3DECL(void) PGMR3PhysWriteByte(PVM pVM, RTGCPHYS GCPhys, uint8_t val);
1403063c7e0c0a072d59e323b66068b06278fb9avboxsyncPGMR3DECL(void) PGMR3PhysWriteWord(PVM pVM, RTGCPHYS GCPhys, uint16_t val);
1403063c7e0c0a072d59e323b66068b06278fb9avboxsyncPGMR3DECL(void) PGMR3PhysWriteDword(PVM pVM, RTGCPHYS GCPhys, uint32_t val);
1403063c7e0c0a072d59e323b66068b06278fb9avboxsyncPDMR3DECL(int) PGMR3PhysChunkMap(PVM pVM, uint32_t idChunk);
1403063c7e0c0a072d59e323b66068b06278fb9avboxsyncPGMR3DECL(void) PGMR3PhysChunkInvalidateTLB(PVM pVM);
f48c3167a0f99da174686b66dc4e666f38ecae46vboxsyncPDMR3DECL(int) PGMR3PhysAllocateHandyPages(PVM pVM);
f48c3167a0f99da174686b66dc4e666f38ecae46vboxsync
1403063c7e0c0a072d59e323b66068b06278fb9avboxsyncPDMR3DECL(int) PGMR3CheckIntegrity(PVM pVM);
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync
1403063c7e0c0a072d59e323b66068b06278fb9avboxsyncPGMR3DECL(int) PGMR3DbgHCPtr2GCPhys(PVM pVM, RTHCPTR HCPtr, PRTGCPHYS pGCPhys);
1403063c7e0c0a072d59e323b66068b06278fb9avboxsyncPGMR3DECL(int) PGMR3DbgHCPtr2HCPhys(PVM pVM, RTHCPTR HCPtr, PRTHCPHYS pHCPhys);
1403063c7e0c0a072d59e323b66068b06278fb9avboxsyncPGMR3DECL(int) PGMR3DbgHCPhys2GCPhys(PVM pVM, RTHCPHYS HCPhys, PRTGCPHYS pGCPhys);
1403063c7e0c0a072d59e323b66068b06278fb9avboxsyncPDMR3DECL(int) PGMR3DbgScanPhysical(PVM pVM, RTGCPHYS GCPhys, RTGCPHYS cbRange, const uint8_t *pabNeedle, size_t cbNeedle, PRTGCPHYS pGCPhysHit);
1403063c7e0c0a072d59e323b66068b06278fb9avboxsyncPDMR3DECL(int) PGMR3DbgScanVirtual(PVM pVM, RTGCUINTPTR GCPtr, RTGCUINTPTR cbRange, const uint8_t *pabNeedle, size_t cbNeedle, PRTGCUINTPTR pGCPhysHit);
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync/** @} */
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync#endif /* IN_RING3 */
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync__END_DECLS
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync/** @} */
1403063c7e0c0a072d59e323b66068b06278fb9avboxsync#endif
6479169ec893c18a646cec595e4e214492d180f0vboxsync
6479169ec893c18a646cec595e4e214492d180f0vboxsync