VirtualBox

Changeset 6821 in vbox for trunk/include/VBox


Ignore:
Timestamp:
Feb 5, 2008 10:08:16 PM (17 years ago)
Author:
vboxsync
Message:

Removed duplicate documentation (functions are documented where they are implemented from now on - unless there are more than one implementation (IPRT)).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/VBox/pgm.h

    r6820 r6821  
    272272} PGMMODE;
    273273
    274 
    275 /**
    276  * Gets the current CR3 register value for the shadow memory context.
    277  * @returns CR3 value.
    278  * @param   pVM         The VM handle.
    279  */
    280274PGMDECL(uint32_t) PGMGetHyperCR3(PVM pVM);
    281 
    282 /**
    283  * Gets the CR3 register value for the 32-Bit shadow memory context.
    284  * @returns CR3 value.
    285  * @param   pVM         The VM handle.
    286  */
    287275PGMDECL(uint32_t) PGMGetHyper32BitCR3(PVM pVM);
    288 
    289 /**
    290  * Gets the CR3 register value for the PAE shadow memory context.
    291  * @returns CR3 value.
    292  * @param   pVM         The VM handle.
    293  */
    294276PGMDECL(uint32_t) PGMGetHyperPaeCR3(PVM pVM);
    295 
    296 /**
    297  * Gets the CR3 register value for the AMD64 shadow memory context.
    298  * @returns CR3 value.
    299  * @param   pVM         The VM handle.
    300  */
    301277PGMDECL(uint32_t) PGMGetHyperAmd64CR3(PVM pVM);
    302 
    303 /**
    304  * Gets the current CR3 register value for the HC intermediate memory context.
    305  * @returns CR3 value.
    306  * @param   pVM         The VM handle.
    307  */
    308278PGMDECL(uint32_t) PGMGetInterHCCR3(PVM pVM);
    309 
    310 /**
    311  * Gets the current CR3 register value for the GC intermediate memory context.
    312  * @returns CR3 value.
    313  * @param   pVM         The VM handle.
    314  */
    315279PGMDECL(uint32_t) PGMGetInterGCCR3(PVM pVM);
    316 
    317 /**
    318  * Gets the CR3 register value for the 32-Bit intermediate memory context.
    319  * @returns CR3 value.
    320  * @param   pVM         The VM handle.
    321  */
    322280PGMDECL(uint32_t) PGMGetInter32BitCR3(PVM pVM);
    323 
    324 /**
    325  * Gets the CR3 register value for the PAE intermediate memory context.
    326  * @returns CR3 value.
    327  * @param   pVM         The VM handle.
    328  */
    329281PGMDECL(uint32_t) PGMGetInterPaeCR3(PVM pVM);
    330 
    331 /**
    332  * Gets the CR3 register value for the AMD64 intermediate memory context.
    333  * @returns CR3 value.
    334  * @param   pVM         The VM handle.
    335  */
    336282PGMDECL(uint32_t) PGMGetInterAmd64CR3(PVM pVM);
    337 
    338 /**
    339  * \#PF Handler.
    340  *
    341  * @returns VBox status code (appropriate for GC return).
    342  * @param   pVM         VM Handle.
    343  * @param   uErr        The trap error code.
    344  * @param   pRegFrame   Trap register frame.
    345  * @param   pvFault     The fault address.
    346  */
    347 PGMDECL(int) PGMTrap0eHandler(PVM pVM, RTGCUINT uErr, PCPUMCTXCORE pRegFrame, RTGCPTR pvFault);
    348 
    349 /**
    350  * Prefetch a page/set of pages.
    351  *
    352  * Typically used to sync commonly used pages before entering raw mode
    353  * after a CR3 reload.
    354  *
    355  * @returns VBox status code suitable for scheduling.
    356  * @retval  VINF_SUCCESS on success.
    357  * @retval  VINF_PGM_SYNC_CR3 if we're out of shadow pages or something like that.
    358  * @param   pVM         VM handle.
    359  * @param   GCPtrPage   Page to prefetch.
    360  */
    361 PGMDECL(int) PGMPrefetchPage(PVM pVM, RTGCPTR GCPtrPage);
    362 
    363 /**
    364  * Verifies a range of pages for read or write access.
    365  *
    366  * Supports handling of pages marked for dirty bit tracking and CSAM.
    367  *
    368  * @returns VBox status code.
    369  * @param   pVM         VM handle.
    370  * @param   Addr        Guest virtual address to check.
    371  * @param   cbSize      Access size.
    372  * @param   fAccess     Access type (r/w, user/supervisor (X86_PTE_*).
    373  */
    374 PGMDECL(int) PGMVerifyAccess(PVM pVM, RTGCUINTPTR Addr, uint32_t cbSize, uint32_t fAccess);
    375 
    376 /**
    377  * Verifies a range of pages for read or write access
    378  *
    379  * Only checks the guest's page tables
    380  *
    381  * @returns VBox status code.
    382  * @param   pVM         VM handle.
    383  * @param   Addr        Guest virtual address to check
    384  * @param   cbSize      Access size
    385  * @param   fAccess     Access type (r/w, user/supervisor (X86_PTE_*))
    386  */
    387 PGMDECL(int) PGMIsValidAccess(PVM pVM, RTGCUINTPTR Addr, uint32_t cbSize, uint32_t fAccess);
    388 
    389 /**
    390  * Executes an instruction using the interpreter.
    391  *
    392  * @returns VBox status code (appropriate for trap handling and GC return).
    393  * @param   pVM         VM handle.
    394  * @param   pRegFrame   Register frame.
    395  * @param   pvFault     Fault address.
    396  */
    397 PGMDECL(int) PGMInterpretInstruction(PVM pVM, PCPUMCTXCORE pRegFrame, RTGCPTR pvFault);
    398 
    399 /**
    400  * Maps a range of physical pages at a given virtual address
    401  * in the guest context.
    402  *
    403  * The GC virtual address range must be within an existing mapping.
    404  *
    405  * @returns VBox status code.
    406  * @param   pVM         The virtual machine.
    407  * @param   GCPtr       Where to map the page(s). Must be page aligned.
    408  * @param   HCPhys      Start of the range of physical pages. Must be page aligned.
    409  * @param   cbPages     Number of bytes to map. Must be page aligned.
    410  * @param   fFlags      Page flags (X86_PTE_*).
    411  */
    412 PGMDECL(int) PGMMap(PVM pVM, RTGCUINTPTR GCPtr, RTHCPHYS HCPhys, uint32_t cbPages, unsigned fFlags);
    413 
    414 /**
    415  * Sets (replaces) the page flags for a range of pages in a mapping.
    416  *
    417  * The pages must be mapped pages, it's not possible to change the flags of
    418  * Guest OS pages.
    419  *
    420  * @returns VBox status.
    421  * @param   pVM         VM handle.
    422  * @param   GCPtr       Virtual address of the first page in the range.
    423  * @param   cb          Size (in bytes) of the range to apply the modification to.
    424  * @param   fFlags      Page flags X86_PTE_*, excluding the page mask of course.
    425  */
    426 PGMDECL(int) PGMMapSetPage(PVM pVM, RTGCPTR GCPtr, uint64_t cb, uint64_t fFlags);
    427 
    428 /**
    429  * Modify page flags for a range of pages in a mapping.
    430  *
    431  * The existing flags are ANDed with the fMask and ORed with the fFlags.
    432  *
    433  * @returns VBox status code.
    434  * @param   pVM         VM handle.
    435  * @param   GCPtr       Virtual address of the first page in the range.
    436  * @param   cb          Size (in bytes) of the range to apply the modification to.
    437  * @param   fFlags      The OR  mask - page flags X86_PTE_*, excluding the page mask of course.
    438  * @param   fMask       The AND mask - page flags X86_PTE_*.
    439  *                      Be very CAREFUL when ~'ing constants which could be 32-bit!
    440  */
    441 PGMDECL(int) PGMMapModifyPage(PVM pVM, RTGCPTR GCPtr, size_t cb, uint64_t fFlags, uint64_t fMask);
    442 
    443 /**
    444  * Gets effective page information (from the VMM page directory).
    445  *
    446  * @returns VBox status.
    447  * @param   pVM         VM Handle.
    448  * @param   GCPtr       Guest Context virtual address of the page.
    449  * @param   pfFlags     Where to store the flags. These are X86_PTE_*.
    450  * @param   pHCPhys     Where to store the HC physical address of the page.
    451  *                      This is page aligned.
    452  * @remark  You should use PGMMapGetPage() for pages in a mapping.
    453  */
    454 PGMDECL(int) PGMShwGetPage(PVM pVM, RTGCPTR GCPtr, uint64_t *pfFlags, PRTHCPHYS pHCPhys);
    455 
    456 /**
    457  * Sets (replaces) the page flags for a range of pages in the shadow context.
    458  *
    459  * @returns VBox status.
    460  * @param   pVM         VM handle.
    461  * @param   GCPtr       The address of the first page.
    462  * @param   cb          The size of the range in bytes.
    463  * @param   fFlags      Page flags X86_PTE_*, excluding the page mask of course.
    464  * @remark  You must use PGMMapSetPage() for pages in a mapping.
    465  */
    466 PGMDECL(int) PGMShwSetPage(PVM pVM, RTGCPTR GCPtr, size_t cb, uint64_t fFlags);
    467 
    468 /**
    469  * Modify page flags for a range of pages in the shadow context.
    470  *
    471  * The existing flags are ANDed with the fMask and ORed with the fFlags.
    472  *
    473  * @returns VBox status code.
    474  * @param   pVM         VM handle.
    475  * @param   GCPtr       Virtual address of the first page in the range.
    476  * @param   cb          Size (in bytes) of the range to apply the modification to.
    477  * @param   fFlags      The OR  mask - page flags X86_PTE_*, excluding the page mask of course.
    478  * @param   fMask       The AND mask - page flags X86_PTE_*.
    479  *                      Be very CAREFUL when ~'ing constants which could be 32-bit!
    480  * @remark  You must use PGMMapModifyPage() for pages in a mapping.
    481  */
    482 PGMDECL(int)  PGMShwModifyPage(PVM pVM, RTGCPTR GCPtr, size_t cb, uint64_t fFlags, uint64_t fMask);
    483 
    484 /**
    485  * Gets effective Guest OS page information.
    486  *
    487  * When GCPtr is in a big page, the function will return as if it was a normal
    488  * 4KB page. If the need for distinguishing between big and normal page becomes
    489  * necessary at a later point, a PGMGstGetPageEx() will be created for that
    490  * purpose.
    491  *
    492  * @returns VBox status.
    493  * @param   pVM         VM Handle.
    494  * @param   GCPtr       Guest Context virtual address of the page.
    495  * @param   pfFlags     Where to store the flags. These are X86_PTE_*, even for big pages.
    496  * @param   pGCPhys     Where to store the GC physical address of the page.
    497  *                      This is page aligned. The fact that the
    498  */
    499 PGMDECL(int) PGMGstGetPage(PVM pVM, RTGCPTR GCPtr, uint64_t *pfFlags, PRTGCPHYS pGCPhys);
    500 
    501 /**
    502  * Checks if the page is present.
    503  *
    504  * @returns true if the page is present.
    505  * @returns false if the page is not present.
    506  * @param   pVM         The VM handle.
    507  * @param   GCPtr       Address within the page.
    508  */
    509 PGMDECL(bool) PGMGstIsPagePresent(PVM pVM, RTGCPTR GCPtr);
    510 
    511 /**
    512  * Sets (replaces) the page flags for a range of pages in the guest's tables.
    513  *
    514  * @returns VBox status.
    515  * @param   pVM         VM handle.
    516  * @param   GCPtr       The address of the first page.
    517  * @param   cb          The size of the range in bytes.
    518  * @param   fFlags      Page flags X86_PTE_*, excluding the page mask of course.
    519  */
    520 PGMDECL(int)  PGMGstSetPage(PVM pVM, RTGCPTR GCPtr, size_t cb, uint64_t fFlags);
    521 
    522 /**
    523  * Modify page flags for a range of pages in the guest's tables
    524  *
    525  * The existing flags are ANDed with the fMask and ORed with the fFlags.
    526  *
    527  * @returns VBox status code.
    528  * @param   pVM         VM handle.
    529  * @param   GCPtr       Virtual address of the first page in the range.
    530  * @param   cb          Size (in bytes) of the range to apply the modification to.
    531  * @param   fFlags      The OR  mask - page flags X86_PTE_*, excluding the page mask of course.
    532  * @param   fMask       The AND mask - page flags X86_PTE_*, excluding the page mask of course.
    533  *                      Be very CAREFUL when ~'ing constants which could be 32-bit!
    534  */
    535 PGMDECL(int)  PGMGstModifyPage(PVM pVM, RTGCPTR GCPtr, size_t cb, uint64_t fFlags, uint64_t fMask);
    536 
    537 /**
    538  * Performs and schedules necessary updates following a CR3 load or reload.
    539  *
    540  * This will normally involve mapping the guest PD or nPDPTR
    541  *
    542  * @returns VBox status code.
    543  * @retval  VINF_PGM_SYNC_CR3 if monitoring requires a CR3 sync. This can
    544  *          safely be ignored and overridden since the FF will be set too then.
    545  * @param   pVM         VM handle.
    546  * @param   cr3         The new cr3.
    547  * @param   fGlobal     Indicates whether this is a global flush or not.
    548  */
    549 PGMDECL(int) PGMFlushTLB(PVM pVM, uint32_t cr3, bool fGlobal);
    550 
    551 /**
    552  * Synchronize the paging structures.
    553  *
    554  * This function is called in response to the VM_FF_PGM_SYNC_CR3 and
    555  * VM_FF_PGM_SYNC_CR3_NONGLOBAL. Those two force action flags are set
    556  * in several places, most importantly whenever the CR3 is loaded.
    557  *
    558  * @returns VBox status code.
    559  * @param   pVM         The virtual machine.
    560  * @param   cr0         Guest context CR0 register
    561  * @param   cr3         Guest context CR3 register
    562  * @param   cr4         Guest context CR4 register
    563  * @param   fGlobal     Including global page directories or not
    564  */
    565 PGMDECL(int) PGMSyncCR3(PVM pVM, uint32_t cr0, uint32_t cr3, uint32_t cr4, bool fGlobal);
    566 
    567 /**
    568  * Called whenever CR0 or CR4 in a way which may change
    569  * the paging mode.
    570  *
    571  * @returns VBox status code fit for scheduling in GC and R0.
    572  * @retval  VINF_SUCCESS if the was no change, or it was successfully dealt with.
    573  * @retval  VINF_PGM_CHANGE_MODE if we're in GC or R0 and the mode changes.
    574  * @param   pVM         VM handle.
    575  * @param   cr0         The new cr0.
    576  * @param   cr4         The new cr4.
    577  * @param   efer        The new extended feature enable register.
    578  */
    579 PGMDECL(int) PGMChangeMode(PVM pVM, uint32_t cr0, uint32_t cr4, uint64_t efer);
    580 
    581 /**
    582  * Gets the current guest paging mode.
    583  *
    584  * If you just need the CPU mode (real/protected/long), use CPUMGetGuestMode().
    585  *
    586  * @returns The current paging mode.
    587  * @param   pVM             The VM handle.
    588  */
     283PGMDECL(int)    PGMTrap0eHandler(PVM pVM, RTGCUINT uErr, PCPUMCTXCORE pRegFrame, RTGCPTR pvFault);
     284PGMDECL(int)    PGMPrefetchPage(PVM pVM, RTGCPTR GCPtrPage);
     285PGMDECL(int)    PGMVerifyAccess(PVM pVM, RTGCUINTPTR Addr, uint32_t cbSize, uint32_t fAccess);
     286PGMDECL(int)    PGMIsValidAccess(PVM pVM, RTGCUINTPTR Addr, uint32_t cbSize, uint32_t fAccess);
     287PGMDECL(int)    PGMInterpretInstruction(PVM pVM, PCPUMCTXCORE pRegFrame, RTGCPTR pvFault);
     288PGMDECL(int)    PGMMap(PVM pVM, RTGCUINTPTR GCPtr, RTHCPHYS HCPhys, uint32_t cbPages, unsigned fFlags);
     289PGMDECL(int)    PGMMapSetPage(PVM pVM, RTGCPTR GCPtr, uint64_t cb, uint64_t fFlags);
     290PGMDECL(int)    PGMMapModifyPage(PVM pVM, RTGCPTR GCPtr, size_t cb, uint64_t fFlags, uint64_t fMask);
     291PGMDECL(int)    PGMShwGetPage(PVM pVM, RTGCPTR GCPtr, uint64_t *pfFlags, PRTHCPHYS pHCPhys);
     292PGMDECL(int)    PGMShwSetPage(PVM pVM, RTGCPTR GCPtr, size_t cb, uint64_t fFlags);
     293PGMDECL(int)    PGMShwModifyPage(PVM pVM, RTGCPTR GCPtr, size_t cb, uint64_t fFlags, uint64_t fMask);
     294PGMDECL(int)    PGMGstGetPage(PVM pVM, RTGCPTR GCPtr, uint64_t *pfFlags, PRTGCPHYS pGCPhys);
     295PGMDECL(bool)   PGMGstIsPagePresent(PVM pVM, RTGCPTR GCPtr);
     296PGMDECL(int)    PGMGstSetPage(PVM pVM, RTGCPTR GCPtr, size_t cb, uint64_t fFlags);
     297PGMDECL(int)    PGMGstModifyPage(PVM pVM, RTGCPTR GCPtr, size_t cb, uint64_t fFlags, uint64_t fMask);
     298PGMDECL(int)    PGMFlushTLB(PVM pVM, uint32_t cr3, bool fGlobal);
     299PGMDECL(int)    PGMSyncCR3(PVM pVM, uint32_t cr0, uint32_t cr3, uint32_t cr4, bool fGlobal);
     300PGMDECL(int)    PGMChangeMode(PVM pVM, uint32_t cr0, uint32_t cr4, uint64_t efer);
    589301PGMDECL(PGMMODE) PGMGetGuestMode(PVM pVM);
    590 
    591 /**
    592  * Gets the current shadow paging mode.
    593  *
    594  * @returns The current paging mode.
    595  * @param   pVM             The VM handle.
    596  */
    597302PGMDECL(PGMMODE) PGMGetShadowMode(PVM pVM);
    598 
    599 /**
    600  * Get mode name.
    601  *
    602  * @returns read-only name string.
    603  * @param   enmMode     The mode which name is desired.
    604  */
    605303PGMDECL(const char *) PGMGetModeName(PGMMODE enmMode);
    606 
    607 /**
    608  * Register a access handler for a physical range.
    609  *
    610  * @returns VBox status code.
    611  * @param   pVM             VM Handle.
    612  * @param   enmType         Handler type. Any of the PGMPHYSHANDLERTYPE_PHYSICAL* enums.
    613  * @param   GCPhys          Start physical address.
    614  * @param   GCPhysLast      Last physical address. (inclusive)
    615  * @param   pfnHandlerR3    The R3 handler.
    616  * @param   pvUserR3        User argument to the R3 handler.
    617  * @param   pfnHandlerR0    The R0 handler.
    618  * @param   pvUserR0        User argument to the R0 handler.
    619  * @param   pfnHandlerGC    The GC handler.
    620  * @param   pvUserGC        User argument to the GC handler.
    621  *                          This must be a GC pointer because it will be relocated!
    622  * @param   pszDesc         Pointer to description string. This must not be freed.
    623  */
    624 PGMDECL(int) PGMHandlerPhysicalRegisterEx(PVM pVM, PGMPHYSHANDLERTYPE enmType, RTGCPHYS GCPhys, RTGCPHYS GCPhysLast,
    625                                           R3PTRTYPE(PFNPGMR3PHYSHANDLER) pfnHandlerR3, RTR3PTR pvUserR3,
    626                                           R0PTRTYPE(PFNPGMR0PHYSHANDLER) pfnHandlerR0, RTR0PTR pvUserR0,
    627                                           GCPTRTYPE(PFNPGMGCPHYSHANDLER) pfnHandlerGC, RTGCPTR pvUserGC,
    628                                           R3PTRTYPE(const char *) pszDesc);
    629 
    630 /**
    631  * Modify a physical page access handler.
    632  *
    633  * Modification can only be done to the range it self, not the type or anything else.
    634  *
    635  * @returns VBox status code.
    636  *          For all return codes other than VERR_PGM_HANDLER_NOT_FOUND and VINF_SUCCESS the range is deregistered
    637  *          and a new registration must be performed!
    638  * @param   pVM             VM handle.
    639  * @param   GCPhysCurrent   Current location.
    640  * @param   GCPhys          New location.
    641  * @param   GCPhysLast      New last location.
    642  */
    643 PGMDECL(int) PGMHandlerPhysicalModify(PVM pVM, RTGCPHYS GCPhysCurrent, RTGCPHYS GCPhys, RTGCPHYS GCPhysLast);
    644 
    645 /**
    646  * Register a physical page access handler.
    647  *
    648  * @returns VBox status code.
    649  * @param   pVM         VM Handle.
    650  * @param   GCPhys      Start physical address earlier passed to PGMR3HandlerPhysicalRegister().
    651  */
    652 PGMDECL(int) PGMHandlerPhysicalDeregister(PVM pVM, RTGCPHYS GCPhys);
    653 
    654 /**
    655  * Changes the callbacks associated with a physical access handler.
    656  *
    657  * @returns VBox status code.
    658  * @param   pVM             VM Handle.
    659  * @param   GCPhys          Start physical address.
    660  * @param   pfnHandlerR3    The R3 handler.
    661  * @param   pvUserR3        User argument to the R3 handler.
    662  * @param   pfnHandlerR0    The R0 handler.
    663  * @param   pvUserR0        User argument to the R0 handler.
    664  * @param   pfnHandlerGC    The GC handler.
    665  * @param   pvUserGC        User argument to the GC handler.
    666  *                          This must be a GC pointer because it will be relocated!
    667  * @param   pszDesc         Pointer to description string. This must not be freed.
    668  */
    669 PGMDECL(int) PGMHandlerPhysicalChangeCallbacks(PVM pVM, RTGCPHYS GCPhys,
    670                                                R3PTRTYPE(PFNPGMR3PHYSHANDLER) pfnHandlerR3, RTR3PTR pvUserR3,
    671                                                R0PTRTYPE(PFNPGMR0PHYSHANDLER) pfnHandlerR0, RTR0PTR pvUserR0,
    672                                                GCPTRTYPE(PFNPGMGCPHYSHANDLER) pfnHandlerGC, RTGCPTR pvUserGC,
    673                                                R3PTRTYPE(const char *) pszDesc);
    674 
    675 /**
    676  * Splitts a physical access handler in two.
    677  *
    678  * @returns VBox status code.
    679  * @param   pVM             VM Handle.
    680  * @param   GCPhys          Start physical address of the handler.
    681  * @param   GCPhysSplit     The split address.
    682  */
    683 PGMDECL(int) PGMHandlerPhysicalSplit(PVM pVM, RTGCPHYS GCPhys, RTGCPHYS GCPhysSplit);
    684 
    685 /**
    686  * Joins up two adjacent physical access handlers which has the same callbacks.
    687  *
    688  * @returns VBox status code.
    689  * @param   pVM             VM Handle.
    690  * @param   GCPhys1         Start physical address of the first handler.
    691  * @param   GCPhys2         Start physical address of the second handler.
    692  */
    693 PGMDECL(int) PGMHandlerPhysicalJoin(PVM pVM, RTGCPHYS GCPhys1, RTGCPHYS GCPhys2);
    694 
    695 /**
    696  * Temporarily turns off the access monitoring of a page within a monitored
    697  * physical write/all page access handler region.
    698  *
    699  * Use this when no further #PFs are required for that page. Be aware that
    700  * a page directory sync might reset the flags, and turn on access monitoring
    701  * for the page.
    702  *
    703  * The caller must do required page table modifications.
    704  *
    705  * @returns VBox status code.
    706  * @param   pVM         VM Handle
    707  * @param   GCPhys      Start physical address earlier passed to PGMR3HandlerPhysicalRegister().
    708  * @param   GCPhysPage  Physical address of the page to turn off access monitoring for.
    709  */
    710 PGMDECL(int)  PGMHandlerPhysicalPageTempOff(PVM pVM, RTGCPHYS GCPhys, RTGCPHYS GCPhysPage);
    711 
    712 
    713 /**
    714  * Resets any modifications to individual pages in a physical
    715  * page access handler region.
    716  *
    717  * This is used in pair with PGMHandlerPhysicalModify().
    718  *
    719  * @returns VBox status code.
    720  * @param   pVM         VM Handle
    721  * @param   GCPhys      Start physical address earlier passed to PGMR3HandlerPhysicalRegister().
    722  */
    723 PGMDECL(int) PGMHandlerPhysicalReset(PVM pVM, RTGCPHYS GCPhys);
    724 
    725 /**
    726  * Turns access monitoring of a page within a monitored
    727  * physical write/all page access handler region back on.
    728  *
    729  * The caller must do required page table modifications.
    730  *
    731  * @returns VBox status code.
    732  * @param   pVM         VM Handle
    733  * @param   GCPhys      Start physical address earlier passed to PGMR3HandlerPhysicalRegister().
    734  * @param   GCPhysPage  Physical address of the page to turn on access monitoring for.
    735  */
    736 PGMDECL(int)  PGMHandlerPhysicalPageReset(PVM pVM, RTGCPHYS GCPhys, RTGCPHYS GCPhysPage);
    737 
    738 /**
    739  * Checks if a physical range is handled
    740  *
    741  * @returns boolean.
    742  * @param   pVM         VM Handle
    743  * @param   GCPhys      Start physical address earlier passed to PGMR3HandlerPhysicalRegister().
    744  */
    745 PGMDECL(bool)  PGMHandlerPhysicalIsRegistered(PVM pVM, RTGCPHYS GCPhys);
    746 
    747 /**
    748  * Checks if Address Gate 20 is enabled or not.
    749  *
    750  * @returns true if enabled.
    751  * @returns false if disabled.
    752  * @param   pVM     VM handle.
    753  */
    754 PGMDECL(bool) PGMPhysIsA20Enabled(PVM pVM);
    755 
    756 /**
    757  * Validates a GC physical address.
    758  *
    759  * @returns true if valid.
    760  * @returns false if invalid.
    761  * @param   pVM     The VM handle.
    762  * @param   GCPhys  The physical address to validate.
    763  */
    764 PGMDECL(bool) PGMPhysIsGCPhysValid(PVM pVM, RTGCPHYS GCPhys);
    765 
    766 /**
    767  * Checks if a GC physical address is a normal page,
    768  * i.e. not ROM, MMIO or reserved.
    769  *
    770  * @returns true if normal.
    771  * @returns false if invalid, ROM, MMIO or reserved page.
    772  * @param   pVM     The VM handle.
    773  * @param   GCPhys  The physical address to check.
    774  */
    775 PGMDECL(bool) PGMPhysIsGCPhysNormal(PVM pVM, RTGCPHYS GCPhys);
    776 
    777 /**
    778  * Converts a GC physical address to a HC physical address.
    779  *
    780  * @returns VINF_SUCCESS on success.
    781  * @returns VERR_PGM_PHYS_PAGE_RESERVED it it's a valid GC physical
    782  *          page but has no physical backing.
    783  * @returns VERR_PGM_INVALID_GC_PHYSICAL_ADDRESS if it's not a valid
    784  *          GC physical address.
    785  * @param   pVM     The VM handle.
    786  * @param   GCPhys  The GC physical address to convert.
    787  * @param   pHCPhys Where to store the HC physical address on success.
    788  */
    789 PGMDECL(int) PGMPhysGCPhys2HCPhys(PVM pVM, RTGCPHYS GCPhys, PRTHCPHYS pHCPhys);
    790 
    791 /**
    792  * Converts a guest pointer to a GC physical address.
    793  *
    794  * This uses the current CR3/CR0/CR4 of the guest.
    795  *
    796  * @returns VBox status code.
    797  * @param   pVM         The VM Handle
    798  * @param   GCPtr       The guest pointer to convert.
    799  * @param   pGCPhys     Where to store the GC physical address.
    800  */
    801 PGMDECL(int) PGMPhysGCPtr2GCPhys(PVM pVM, RTGCPTR GCPtr, PRTGCPHYS pGCPhys);
    802 
    803 /**
    804  * Converts a guest pointer to a HC physical address.
    805  *
    806  * This uses the current CR3/CR0/CR4 of the guest.
    807  *
    808  * @returns VBox status code.
    809  * @param   pVM         The VM Handle
    810  * @param   GCPtr       The guest pointer to convert.
    811  * @param   pHCPhys     Where to store the HC physical address.
    812  */
    813 PGMDECL(int) PGMPhysGCPtr2HCPhys(PVM pVM, RTGCPTR GCPtr, PRTHCPHYS pHCPhys);
    814 
    815 
    816 /**
    817  * Invalidates the GC page mapping TLB.
    818  *
    819  * @param   pVM     The VM handle.
    820  */
    821 PDMDECL(void) PGMPhysInvalidatePageGCMapTLB(PVM pVM);
    822 
    823 /**
    824  * Invalidates the ring-0 page mapping TLB.
    825  *
    826  * @param   pVM     The VM handle.
    827  */
    828 PDMDECL(void) PGMPhysInvalidatePageR0MapTLB(PVM pVM);
    829 
    830 /**
    831  * Invalidates the ring-3 page mapping TLB.
    832  *
    833  * @param   pVM     The VM handle.
    834  */
    835 PDMDECL(void) PGMPhysInvalidatePageR3MapTLB(PVM pVM);
     304PGMDECL(int)    PGMHandlerPhysicalRegisterEx(PVM pVM, PGMPHYSHANDLERTYPE enmType, RTGCPHYS GCPhys, RTGCPHYS GCPhysLast,
     305                                             R3PTRTYPE(PFNPGMR3PHYSHANDLER) pfnHandlerR3, RTR3PTR pvUserR3,
     306                                             R0PTRTYPE(PFNPGMR0PHYSHANDLER) pfnHandlerR0, RTR0PTR pvUserR0,
     307                                             GCPTRTYPE(PFNPGMGCPHYSHANDLER) pfnHandlerGC, RTGCPTR pvUserGC,
     308                                             R3PTRTYPE(const char *) pszDesc);
     309PGMDECL(int)    PGMHandlerPhysicalModify(PVM pVM, RTGCPHYS GCPhysCurrent, RTGCPHYS GCPhys, RTGCPHYS GCPhysLast);
     310PGMDECL(int)    PGMHandlerPhysicalDeregister(PVM pVM, RTGCPHYS GCPhys);
     311PGMDECL(int)    PGMHandlerPhysicalChangeCallbacks(PVM pVM, RTGCPHYS GCPhys,
     312                                                  R3PTRTYPE(PFNPGMR3PHYSHANDLER) pfnHandlerR3, RTR3PTR pvUserR3,
     313                                                  R0PTRTYPE(PFNPGMR0PHYSHANDLER) pfnHandlerR0, RTR0PTR pvUserR0,
     314                                                  GCPTRTYPE(PFNPGMGCPHYSHANDLER) pfnHandlerGC, RTGCPTR pvUserGC,
     315                                                  R3PTRTYPE(const char *) pszDesc);
     316PGMDECL(int)    PGMHandlerPhysicalSplit(PVM pVM, RTGCPHYS GCPhys, RTGCPHYS GCPhysSplit);
     317PGMDECL(int)    PGMHandlerPhysicalJoin(PVM pVM, RTGCPHYS GCPhys1, RTGCPHYS GCPhys2);
     318PGMDECL(int)    PGMHandlerPhysicalPageTempOff(PVM pVM, RTGCPHYS GCPhys, RTGCPHYS GCPhysPage);
     319PGMDECL(int)    PGMHandlerPhysicalReset(PVM pVM, RTGCPHYS GCPhys);
     320PGMDECL(int)    PGMHandlerPhysicalPageReset(PVM pVM, RTGCPHYS GCPhys, RTGCPHYS GCPhysPage);
     321PGMDECL(bool)   PGMHandlerPhysicalIsRegistered(PVM pVM, RTGCPHYS GCPhys);
     322PGMDECL(bool)   PGMPhysIsA20Enabled(PVM pVM);
     323PGMDECL(bool)   PGMPhysIsGCPhysValid(PVM pVM, RTGCPHYS GCPhys);
     324PGMDECL(bool)   PGMPhysIsGCPhysNormal(PVM pVM, RTGCPHYS GCPhys);
     325PGMDECL(int)    PGMPhysGCPhys2HCPhys(PVM pVM, RTGCPHYS GCPhys, PRTHCPHYS pHCPhys);
     326PGMDECL(int)    PGMPhysGCPtr2GCPhys(PVM pVM, RTGCPTR GCPtr, PRTGCPHYS pGCPhys);
     327PGMDECL(int)    PGMPhysGCPtr2HCPhys(PVM pVM, RTGCPTR GCPtr, PRTHCPHYS pHCPhys);
     328PDMDECL(void)   PGMPhysInvalidatePageGCMapTLB(PVM pVM);
     329PDMDECL(void)   PGMPhysInvalidatePageR0MapTLB(PVM pVM);
     330PDMDECL(void)   PGMPhysInvalidatePageR3MapTLB(PVM pVM);
    836331
    837332/**
     
    857352typedef PGMPAGEMAPLOCK *PPGMPAGEMAPLOCK;
    858353
    859 /**
    860  * Requests the mapping of a guest page into the current context.
    861  *
    862  * This API should only be used for very short term, as it will consume
    863  * scarse resources (R0 and GC) in the mapping cache. When you're done
    864  * with the page, call PGMPhysReleasePageMappingLock() ASAP to release it.
    865  *
    866  * This API will assume your intention is to write to the page, and will
    867  * therefore replace shared and zero pages. If you do not intend to modify
    868  * the page, use the PGMPhysGCPhys2CCPtrReadOnly() API.
    869  *
    870  * @returns VBox status code.
    871  * @retval  VINF_SUCCESS on success.
    872  * @retval  VERR_PGM_PHYS_PAGE_RESERVED it it's a valid page but has no physical backing.
    873  * @retval  VERR_PGM_INVALID_GC_PHYSICAL_ADDRESS if it's not a valid physical address.
    874  *
    875  * @param   pVM         The VM handle.
    876  * @param   GCPhys      The guest physical address of the page that should be mapped.
    877  * @param   ppv         Where to store the address corresponding to GCPhys.
    878  * @param   pLock       Where to store the lock information that PGMPhysReleasePageMappingLock needs.
    879  *
    880  * @remark  Avoid calling this API from within critical sections (other than
    881  *          the PGM one) because of the deadlock risk.
    882  * @thread  Any thread.
    883  */
    884 PGMDECL(int) PGMPhysGCPhys2CCPtr(PVM pVM, RTGCPHYS GCPhys, void **ppv, PPGMPAGEMAPLOCK pLock);
    885 
    886 /**
    887  * Requests the mapping of a guest page into the current context.
    888  *
    889  * This API should only be used for very short term, as it will consume
    890  * scarse resources (R0 and GC) in the mapping cache. When you're done
    891  * with the page, call PGMPhysReleasePageMappingLock() ASAP to release it.
    892  *
    893  * @returns VBox status code.
    894  * @retval  VINF_SUCCESS on success.
    895  * @retval  VERR_PGM_PHYS_PAGE_RESERVED it it's a valid page but has no physical backing.
    896  * @retval  VERR_PGM_INVALID_GC_PHYSICAL_ADDRESS if it's not a valid physical address.
    897  *
    898  * @param   pVM         The VM handle.
    899  * @param   GCPhys      The guest physical address of the page that should be mapped.
    900  * @param   ppv         Where to store the address corresponding to GCPhys.
    901  * @param   pLock       Where to store the lock information that PGMPhysReleasePageMappingLock needs.
    902  *
    903  * @remark  Avoid calling this API from within critical sections (other than
    904  *          the PGM one) because of the deadlock risk.
    905  * @thread  Any thread.
    906  */
    907 PGMDECL(int) PGMPhysGCPhys2CCPtrReadOnly(PVM pVM, RTGCPHYS GCPhys, void const **ppv, PPGMPAGEMAPLOCK pLock);
    908 
    909 /**
    910  * Requests the mapping of a guest page given by virtual address into the current context.
    911  *
    912  * This API should only be used for very short term, as it will consume
    913  * scarse resources (R0 and GC) in the mapping cache. When you're done
    914  * with the page, call PGMPhysReleasePageMappingLock() ASAP to release it.
    915  *
    916  * This API will assume your intention is to write to the page, and will
    917  * therefore replace shared and zero pages. If you do not intend to modify
    918  * the page, use the PGMPhysGCPtr2CCPtrReadOnly() API.
    919  *
    920  * @returns VBox status code.
    921  * @retval  VINF_SUCCESS on success.
    922  * @retval  VERR_PAGE_TABLE_NOT_PRESENT if the page directory for the virtual address isn't present.
    923  * @retval  VERR_PAGE_NOT_PRESENT if the page at the virtual address isn't present.
    924  * @retval  VERR_PGM_PHYS_PAGE_RESERVED it it's a valid page but has no physical backing.
    925  * @retval  VERR_PGM_INVALID_GC_PHYSICAL_ADDRESS if it's not a valid physical address.
    926  *
    927  * @param   pVM         The VM handle.
    928  * @param   GCPhys      The guest physical address of the page that should be mapped.
    929  * @param   ppv         Where to store the address corresponding to GCPhys.
    930  * @param   pLock       Where to store the lock information that PGMPhysReleasePageMappingLock needs.
    931  *
    932  * @remark  Avoid calling this API from within critical sections (other than
    933  *          the PGM one) because of the deadlock risk.
    934  * @thread  EMT
    935  */
    936 PGMDECL(int) PGMPhysGCPtr2CCPtr(PVM pVM, RTGCPTR GCPtr, void **ppv, PPGMPAGEMAPLOCK pLock);
    937 
    938 /**
    939  * Requests the mapping of a guest page given by virtual address into the current context.
    940  *
    941  * This API should only be used for very short term, as it will consume
    942  * scarse resources (R0 and GC) in the mapping cache. When you're done
    943  * with the page, call PGMPhysReleasePageMappingLock() ASAP to release it.
    944  *
    945  * @returns VBox status code.
    946  * @retval  VINF_SUCCESS on success.
    947  * @retval  VERR_PAGE_TABLE_NOT_PRESENT if the page directory for the virtual address isn't present.
    948  * @retval  VERR_PAGE_NOT_PRESENT if the page at the virtual address isn't present.
    949  * @retval  VERR_PGM_PHYS_PAGE_RESERVED it it's a valid page but has no physical backing.
    950  * @retval  VERR_PGM_INVALID_GC_PHYSICAL_ADDRESS if it's not a valid physical address.
    951  *
    952  * @param   pVM         The VM handle.
    953  * @param   GCPhys      The guest physical address of the page that should be mapped.
    954  * @param   ppv         Where to store the address corresponding to GCPhys.
    955  * @param   pLock       Where to store the lock information that PGMPhysReleasePageMappingLock needs.
    956  *
    957  * @remark  Avoid calling this API from within critical sections (other than
    958  *          the PGM one) because of the deadlock risk.
    959  * @thread  EMT
    960  */
    961 PGMDECL(int) PGMPhysGCPtr2CCPtrReadOnly(PVM pVM, RTGCPTR GCPtr, void const **ppv, PPGMPAGEMAPLOCK pLock);
    962 
    963 /**
    964  * Release the mapping of a guest page.
    965  *
    966  * This is the counter part of PGMPhysGCPhys2CCPtr, PGMPhysGCPhys2CCPtrReadOnly
    967  * PGMPhysGCPtr2CCPtr and PGMPhysGCPtr2CCPtrReadOnly.
    968  *
    969  * @param   pVM         The VM handle.
    970  * @param   pLock       The lock structure initialized by the mapping function.
    971  */
    972 PGMDECL(void) PGMPhysReleasePageMappingLock(PVM pVM, PPGMPAGEMAPLOCK pLock);
    973 
     354PGMDECL(int)    PGMPhysGCPhys2CCPtr(PVM pVM, RTGCPHYS GCPhys, void **ppv, PPGMPAGEMAPLOCK pLock);
     355PGMDECL(int)    PGMPhysGCPhys2CCPtrReadOnly(PVM pVM, RTGCPHYS GCPhys, void const **ppv, PPGMPAGEMAPLOCK pLock);
     356PGMDECL(int)    PGMPhysGCPtr2CCPtr(PVM pVM, RTGCPTR GCPtr, void **ppv, PPGMPAGEMAPLOCK pLock);
     357PGMDECL(int)    PGMPhysGCPtr2CCPtrReadOnly(PVM pVM, RTGCPTR GCPtr, void const **ppv, PPGMPAGEMAPLOCK pLock);
     358PGMDECL(void)   PGMPhysReleasePageMappingLock(PVM pVM, PPGMPAGEMAPLOCK pLock);
    974359
    975360/**
     
    989374}
    990375
    991 /**
    992  * Converts a GC physical address to a HC pointer.
    993  *
    994  * @returns VINF_SUCCESS on success.
    995  * @returns VERR_PGM_PHYS_PAGE_RESERVED it it's a valid GC physical
    996  *          page but has no physical backing.
    997  * @returns VERR_PGM_INVALID_GC_PHYSICAL_ADDRESS if it's not a valid
    998  *          GC physical address.
    999  * @param   pVM     The VM handle.
    1000  * @param   GCPhys  The GC physical address to convert.
    1001  * @param   cbRange Physical range
    1002  * @param   pHCPtr  Where to store the HC pointer on success.
    1003  *
    1004  * @remark  Do *not* assume this mapping will be around forever!
    1005  */
    1006 PGMDECL(int) PGMPhysGCPhys2HCPtr(PVM pVM, RTGCPHYS GCPhys, RTUINT cbRange, PRTHCPTR pHCPtr);
    1007 
    1008 /**
    1009  * Converts a guest pointer to a HC pointer.
    1010  *
    1011  * This uses the current CR3/CR0/CR4 of the guest.
    1012  *
    1013  * @returns VBox status code.
    1014  * @param   pVM         The VM Handle
    1015  * @param   GCPtr       The guest pointer to convert.
    1016  * @param   pHCPtr      Where to store the HC virtual address.
    1017  *
    1018  * @remark  Do *not* assume this mapping will be around forever!
    1019  */
    1020 PGMDECL(int) PGMPhysGCPtr2HCPtr(PVM pVM, RTGCPTR GCPtr, PRTHCPTR pHCPtr);
    1021 
    1022 /**
    1023  * Converts a guest virtual address to a HC pointer by specfied CR3 and flags.
    1024  *
    1025  * @returns VBox status code.
    1026  * @param   pVM         The VM Handle
    1027  * @param   GCPtr       The guest pointer to convert.
    1028  * @param   cr3         The guest CR3.
    1029  * @param   fFlags      Flags used for interpreting the PD correctly: X86_CR4_PSE and X86_CR4_PAE
    1030  * @param   pHCPtr      Where to store the HC pointer.
    1031  *
    1032  * @remark  Do *not* assume this mapping will be around forever!
    1033  * @remark  This function is used by the REM at a time where PGM could
    1034  *          potentially not be in sync. It could also be used by a
    1035  *          future DBGF API to cpu state independent conversions.
    1036  */
    1037 PGMDECL(int) PGMPhysGCPtr2HCPtrByGstCR3(PVM pVM, RTGCPTR GCPtr, uint32_t cr3, unsigned fFlags, PRTHCPTR pHCPtr);
    1038 
    1039 /**
    1040  * Read physical memory.
    1041  *
    1042  * This API respects access handlers and MMIO. Use PGMPhysReadGCPhys() if you
    1043  * want to ignore those.
    1044  *
    1045  * @param   pVM             VM Handle.
    1046  * @param   GCPhys          Physical address start reading from.
    1047  * @param   pvBuf           Where to put the read bits.
    1048  * @param   cbRead          How many bytes to read.
    1049  */
    1050 PGMDECL(void) PGMPhysRead(PVM pVM, RTGCPHYS GCPhys, void *pvBuf, size_t cbRead);
    1051 
    1052 /**
    1053  * Write to physical memory.
    1054  *
    1055  * This API respects access handlers and MMIO. Use PGMPhysReadGCPhys() if you
    1056  * want to ignore those.
    1057  *
    1058  * @param   pVM             VM Handle.
    1059  * @param   GCPhys          Physical address to write to.
    1060  * @param   pvBuf           What to write.
    1061  * @param   cbWrite         How many bytes to write.
    1062  */
    1063 PGMDECL(void) PGMPhysWrite(PVM pVM, RTGCPHYS GCPhys, const void *pvBuf, size_t cbWrite);
    1064 
    1065 
     376PGMDECL(int)    PGMPhysGCPhys2HCPtr(PVM pVM, RTGCPHYS GCPhys, RTUINT cbRange, PRTHCPTR pHCPtr);
     377PGMDECL(int)    PGMPhysGCPtr2HCPtr(PVM pVM, RTGCPTR GCPtr, PRTHCPTR pHCPtr);
     378PGMDECL(int)    PGMPhysGCPtr2HCPtrByGstCR3(PVM pVM, RTGCPTR GCPtr, uint32_t cr3, unsigned fFlags, PRTHCPTR pHCPtr);
     379PGMDECL(void)   PGMPhysRead(PVM pVM, RTGCPHYS GCPhys, void *pvBuf, size_t cbRead);
     380PGMDECL(void)   PGMPhysWrite(PVM pVM, RTGCPHYS GCPhys, const void *pvBuf, size_t cbWrite);
    1066381#ifndef IN_GC /* Only ring 0 & 3. */
    1067 
    1068 /**
    1069  * Read from guest physical memory by GC physical address, bypassing
    1070  * MMIO and access handlers.
    1071  *
    1072  * @returns VBox status.
    1073  * @param   pVM         VM handle.
    1074  * @param   pvDst       The destination address.
    1075  * @param   GCPhysSrc   The source address (GC physical address).
    1076  * @param   cb          The number of bytes to read.
    1077  */
    1078 PGMDECL(int) PGMPhysReadGCPhys(PVM pVM, void *pvDst, RTGCPHYS GCPhysSrc, size_t cb);
    1079 
    1080 /**
    1081  * Write to guest physical memory referenced by GC pointer.
    1082  * Write memory to GC physical address in guest physical memory.
    1083  *
    1084  * This will bypass MMIO and access handlers.
    1085  *
    1086  * @returns VBox status.
    1087  * @param   pVM         VM handle.
    1088  * @param   GCPhysDst   The GC physical address of the destination.
    1089  * @param   pvSrc       The source buffer.
    1090  * @param   cb          The number of bytes to write.
    1091  */
    1092 PGMDECL(int) PGMPhysWriteGCPhys(PVM pVM, RTGCPHYS GCPhysDst, const void *pvSrc, size_t cb);
    1093 
    1094 /**
    1095  * Read from guest physical memory referenced by GC pointer.
    1096  *
    1097  * This function uses the current CR3/CR0/CR4 of the guest and will
    1098  * bypass access handlers and not set any accessed bits.
    1099  *
    1100  * @returns VBox status.
    1101  * @param   pVM         VM handle.
    1102  * @param   pvDst       The destination address.
    1103  * @param   GCPtrSrc    The source address (GC pointer).
    1104  * @param   cb          The number of bytes to read.
    1105  */
    1106 PGMDECL(int) PGMPhysReadGCPtr(PVM pVM, void *pvDst, RTGCPTR GCPtrSrc, size_t cb);
    1107 
    1108 /**
    1109  * Write to guest physical memory referenced by GC pointer.
    1110  *
    1111  * This function uses the current CR3/CR0/CR4 of the guest and will
    1112  * bypass access handlers and not set dirty or accessed bits.
    1113  *
    1114  * @returns VBox status.
    1115  * @param   pVM         VM handle.
    1116  * @param   GCPtrDst    The destination address (GC pointer).
    1117  * @param   pvSrc       The source address.
    1118  * @param   cb          The number of bytes to write.
    1119  */
    1120 PGMDECL(int) PGMPhysWriteGCPtr(PVM pVM, RTGCPTR GCPtrDst, const void *pvSrc, size_t cb);
    1121 
    1122 /**
    1123  * Read from guest physical memory referenced by GC pointer.
    1124  *
    1125  * This function uses the current CR3/CR0/CR4 of the guest and will
    1126  * respect access handlers and set accessed bits.
    1127  *
    1128  * @returns VBox status.
    1129  * @param   pVM         VM handle.
    1130  * @param   pvDst       The destination address.
    1131  * @param   GCPtrSrc    The source address (GC pointer).
    1132  * @param   cb          The number of bytes to read.
    1133  */
    1134 PGMDECL(int) PGMPhysReadGCPtrSafe(PVM pVM, void *pvDst, RTGCPTR GCPtrSrc, size_t cb);
    1135 
    1136 /**
    1137  * Write to guest physical memory referenced by GC pointer.
    1138  *
    1139  * This function uses the current CR3/CR0/CR4 of the guest and will
    1140  * respect access handlers and set dirty and accessed bits.
    1141  *
    1142  * @returns VBox status.
    1143  * @param   pVM         VM handle.
    1144  * @param   GCPtrDst    The destination address (GC pointer).
    1145  * @param   pvSrc       The source address.
    1146  * @param   cb          The number of bytes to write.
    1147  */
    1148 PGMDECL(int) PGMPhysWriteGCPtrSafe(PVM pVM, RTGCPTR GCPtrDst, const void *pvSrc, size_t cb);
    1149 
    1150 /**
    1151  * Write to guest physical memory referenced by GC pointer and update the PTE.
    1152  *
    1153  * This function uses the current CR3/CR0/CR4 of the guest and will
    1154  * bypass access handlers and set any dirty and accessed bits in the PTE.
    1155  *
    1156  * If you don't want to set the dirty bit, use PGMR3PhysWriteGCPtr().
    1157  *
    1158  * @returns VBox status.
    1159  * @param   pVM         VM handle.
    1160  * @param   GCPtrDst    The destination address (GC pointer).
    1161  * @param   pvSrc       The source address.
    1162  * @param   cb          The number of bytes to write.
    1163  */
    1164 PGMDECL(int) PGMPhysWriteGCPtrDirty(PVM pVM, RTGCPTR GCPtrDst, const void *pvSrc, size_t cb);
    1165 
    1166 /**
    1167  * Emulation of the invlpg instruction (HC only actually).
    1168  *
    1169  * @returns VBox status code.
    1170  * @param   pVM         VM handle.
    1171  * @param   GCPtrPage   Page to invalidate.
    1172  * @remark  ASSUMES the page table entry or page directory is
    1173  *          valid. Fairly safe, but there could be edge cases!
    1174  * @todo    Flush page or page directory only if necessary!
    1175  */
    1176 PGMDECL(int) PGMInvalidatePage(PVM pVM, RTGCPTR GCPtrPage);
    1177 
     382PGMDECL(int)    PGMPhysReadGCPhys(PVM pVM, void *pvDst, RTGCPHYS GCPhysSrc, size_t cb);
     383PGMDECL(int)    PGMPhysWriteGCPhys(PVM pVM, RTGCPHYS GCPhysDst, const void *pvSrc, size_t cb);
     384PGMDECL(int)    PGMPhysReadGCPtr(PVM pVM, void *pvDst, RTGCPTR GCPtrSrc, size_t cb);
     385PGMDECL(int)    PGMPhysWriteGCPtr(PVM pVM, RTGCPTR GCPtrDst, const void *pvSrc, size_t cb);
     386PGMDECL(int)    PGMPhysReadGCPtrSafe(PVM pVM, void *pvDst, RTGCPTR GCPtrSrc, size_t cb);
     387PGMDECL(int)    PGMPhysWriteGCPtrSafe(PVM pVM, RTGCPTR GCPtrDst, const void *pvSrc, size_t cb);
     388PGMDECL(int)    PGMPhysWriteGCPtrDirty(PVM pVM, RTGCPTR GCPtrDst, const void *pvSrc, size_t cb);
     389PGMDECL(int)    PGMInvalidatePage(PVM pVM, RTGCPTR GCPtrPage);
    1178390#endif /* !IN_GC */
    1179 
    1180 /**
    1181  * Performs a read of guest virtual memory for instruction emulation.
    1182  *
    1183  * This will check permissions, raise exceptions and update the access bits.
    1184  *
    1185  * The current implementation will bypass all access handlers. It may later be
    1186  * changed to at least respect MMIO.
    1187  *
    1188  *
    1189  * @returns VBox status code suitable to scheduling.
    1190  * @retval  VINF_SUCCESS if the read was performed successfully.
    1191  * @retval  VINF_EM_RAW_GUEST_TRAP if an exception was raised but not dispatched yet.
    1192  * @retval  VINF_TRPM_XCPT_DISPATCHED if an exception was raised and dispatched.
    1193  *
    1194  * @param   pVM         The VM handle.
    1195  * @param   pCtxCore    The context core.
    1196  * @param   pvDst       Where to put the bytes we've read.
    1197  * @param   GCPtrSrc    The source address.
    1198  * @param   cb          The number of bytes to read. Not more than a page.
    1199  *
    1200  * @remark  This function will dynamically map physical pages in GC. This may unmap
    1201  *          mappings done by the caller. Be careful!
    1202  */
    1203 PGMDECL(int) PGMPhysInterpretedRead(PVM pVM, PCPUMCTXCORE pCtxCore, void *pvDst, RTGCUINTPTR GCPtrSrc, size_t cb);
    1204 
     391PGMDECL(int)    PGMPhysInterpretedRead(PVM pVM, PCPUMCTXCORE pCtxCore, void *pvDst, RTGCUINTPTR GCPtrSrc, size_t cb);
    1205392#ifdef VBOX_STRICT
    1206 /**
    1207  * Asserts that the handlers+guest-page-tables == ramrange-flags and
    1208  * that the physical addresses associated with virtual handlers are correct.
    1209  *
    1210  * @returns Number of mismatches.
    1211  * @param   pVM     The VM handle.
    1212  */
    1213393PGMDECL(unsigned) PGMAssertHandlerAndFlagsInSync(PVM pVM);
    1214 
    1215 /**
    1216  * Asserts that there are no mapping conflicts.
    1217  *
    1218  * @returns Number of conflicts.
    1219  * @param   pVM     The VM Handle.
    1220  */
    1221394PGMDECL(unsigned) PGMAssertNoMappingConflicts(PVM pVM);
    1222 
    1223 /**
    1224  * Asserts that everything related to the guest CR3 is correctly shadowed.
    1225  *
    1226  * This will call PGMAssertNoMappingConflicts() and PGMAssertHandlerAndFlagsInSync(),
    1227  * and assert the correctness of the guest CR3 mapping before asserting that the
    1228  * shadow page tables is in sync with the guest page tables.
    1229  *
    1230  * @returns Number of conflicts.
    1231  * @param   pVM     The VM Handle.
    1232  * @param   cr3     The current guest CR3 register value.
    1233  * @param   cr4     The current guest CR4 register value.
    1234  */
    1235395PGMDECL(unsigned) PGMAssertCR3(PVM pVM, uint32_t cr3, uint32_t cr4);
    1236396#endif /* VBOX_STRICT */
     
    1238398
    1239399#ifdef IN_GC
    1240 
    1241400/** @defgroup grp_pgm_gc  The PGM Guest Context API
    1242401 * @ingroup grp_pgm
    1243402 * @{
    1244403 */
    1245 
    1246 /**
    1247  * Temporarily maps one guest page specified by GC physical address.
    1248  * These pages must have a physical mapping in HC, i.e. they cannot be MMIO pages.
    1249  *
    1250  * Be WARNED that the dynamic page mapping area is small, 8 pages, thus the space is
    1251  * reused after 8 mappings (or perhaps a few more if you score with the cache).
    1252  *
    1253  * @returns VBox status.
    1254  * @param   pVM         VM handle.
    1255  * @param   GCPhys      GC Physical address of the page.
    1256  * @param   ppv         Where to store the address of the mapping.
    1257  */
    1258 PGMGCDECL(int) PGMGCDynMapGCPage(PVM pVM, RTGCPHYS GCPhys, void **ppv);
    1259 
    1260 /**
    1261  * Temporarily maps one guest page specified by unaligned GC physical address.
    1262  * These pages must have a physical mapping in HC, i.e. they cannot be MMIO pages.
    1263  *
    1264  * Be WARNED that the dynamic page mapping area is small, 8 pages, thus the space is
    1265  * reused after 8 mappings (or perhaps a few more if you score with the cache).
    1266  *
    1267  * The caller is aware that only the speicifed page is mapped and that really bad things
    1268  * will happen if writing beyond the page!
    1269  *
    1270  * @returns VBox status.
    1271  * @param   pVM         VM handle.
    1272  * @param   GCPhys      GC Physical address within the page to be mapped.
    1273  * @param   ppv         Where to store the address of the mapping address corresponding to GCPhys.
    1274  */
    1275 PGMGCDECL(int) PGMGCDynMapGCPageEx(PVM pVM, RTGCPHYS GCPhys, void **ppv);
    1276 
    1277 /**
    1278  * Temporarily maps one host page specified by HC physical address.
    1279  *
    1280  * Be WARNED that the dynamic page mapping area is small, 8 pages, thus the space is
    1281  * reused after 8 mappings (or perhaps a few more if you score with the cache).
    1282  *
    1283  * @returns VBox status.
    1284  * @param   pVM         VM handle.
    1285  * @param   HCPhys      HC Physical address of the page.
    1286  * @param   ppv         Where to store the address of the mapping.
    1287  */
    1288 PGMGCDECL(int) PGMGCDynMapHCPage(PVM pVM, RTHCPHYS HCPhys, void **ppv);
    1289 
    1290 /**
    1291  * Syncs a guest os page table.
    1292  *
    1293  * @returns VBox status code.
    1294  * @param   pVM         VM handle.
    1295  * @param   iPD         Page directory index.
    1296  * @param   pPDSrc      Source page directory (i.e. Guest OS page directory).
    1297  *                      Assume this is a temporary mapping.
    1298  */
    1299 PGMGCDECL(int) PGMGCSyncPT(PVM pVM, unsigned iPD, PVBOXPD pPDSrc);
    1300 
    1301 /**
    1302  * Emulation of the invlpg instruction.
    1303  *
    1304  * @returns VBox status code.
    1305  * @param   pVM         VM handle.
    1306  * @param   GCPtrPage   Page to invalidate.
    1307  */
    1308 PGMGCDECL(int) PGMGCInvalidatePage(PVM pVM, RTGCPTR GCPtrPage);
    1309 
     404PGMGCDECL(int)  PGMGCDynMapGCPage(PVM pVM, RTGCPHYS GCPhys, void **ppv);
     405PGMGCDECL(int)  PGMGCDynMapGCPageEx(PVM pVM, RTGCPHYS GCPhys, void **ppv);
     406PGMGCDECL(int)  PGMGCDynMapHCPage(PVM pVM, RTHCPHYS HCPhys, void **ppv);
     407PGMGCDECL(int)  PGMGCSyncPT(PVM pVM, unsigned iPD, PVBOXPD pPDSrc);
     408PGMGCDECL(int)  PGMGCInvalidatePage(PVM pVM, RTGCPTR GCPtrPage);
    1310409/** @} */
    1311 #endif
     410#endif /* IN_GC */
    1312411
    1313412
     
    1317416 * @{
    1318417 */
    1319 /**
    1320  * Worker function for PGMR3PhysAllocateHandyPages and pgmPhysEnsureHandyPage.
    1321  *
    1322  * @returns The following VBox status codes.
    1323  * @retval  VINF_SUCCESS on success. FF cleared.
    1324  * @retval  VINF_EM_NO_MEMORY if we're out of memory. The FF is set in this case.
    1325  *
    1326  * @param   pVM         The VM handle.
    1327  *
    1328  * @remarks Must be called from within the PGM critical section.
    1329  */
    1330 PGMR0DECL(int) PGMR0PhysAllocateHandyPages(PVM pVM);
    1331 
     418PGMR0DECL(int)  PGMR0PhysAllocateHandyPages(PVM pVM);
    1332419/** @} */
    1333 #endif
     420#endif /* IN_RING0 */
    1334421
    1335422
     
    1340427 * @{
    1341428 */
    1342 /**
    1343  * Initiates the paging of VM.
    1344  *
    1345  * @returns VBox status code.
    1346  * @param   pVM     Pointer to VM structure.
    1347  */
    1348 PGMR3DECL(int) PGMR3Init(PVM pVM);
    1349 
    1350 /**
    1351  * Init the PGM bits that rely on VMMR0 and MM to be fully initialized.
    1352  *
    1353  * The dynamic mapping area will also be allocated and initialized at this
    1354  * time. We could allocate it during PGMR3Init of course, but the mapping
    1355  * wouldn't be allocated at that time preventing us from setting up the
    1356  * page table entries with the dummy page.
    1357  *
    1358  * @returns VBox status code.
    1359  * @param   pVM     VM handle.
    1360  */
    1361 PGMR3DECL(int) PGMR3InitDynMap(PVM pVM);
    1362 
    1363 /**
    1364  * Ring-3 init finalizing.
    1365  *
    1366  * @returns VBox status code.
    1367  * @param   pVM         The VM handle.
    1368  */
    1369 PGMR3DECL(int) PGMR3InitFinalize(PVM pVM);
    1370 
    1371 /**
    1372  * Applies relocations to data and code managed by this
    1373  * component. This function will be called at init and
    1374  * whenever the VMM need to relocate it self inside the GC.
    1375  *
    1376  * @param   pVM     The VM.
    1377  * @param   offDelta    Relocation delta relative to old location.
    1378  */
     429PGMR3DECL(int)  PGMR3Init(PVM pVM);
     430PGMR3DECL(int)  PGMR3InitDynMap(PVM pVM);
     431PGMR3DECL(int)  PGMR3InitFinalize(PVM pVM);
    1379432PGMR3DECL(void) PGMR3Relocate(PVM pVM, RTGCINTPTR offDelta);
    1380 
    1381 /**
    1382  * The VM is being reset.
    1383  *
    1384  * For the PGM component this means that any PD write monitors
    1385  * needs to be removed.
    1386  *
    1387  * @param   pVM     VM handle.
    1388  */
    1389433PGMR3DECL(void) PGMR3Reset(PVM pVM);
    1390 
    1391 /**
    1392  * Terminates the PGM.
    1393  *
    1394  * @returns VBox status code.
    1395  * @param   pVM     Pointer to VM structure.
    1396  */
    1397 PGMR3DECL(int) PGMR3Term(PVM pVM);
    1398 
    1399 /**
    1400  * Serivce a VMMCALLHOST_PGM_LOCK call.
    1401  *
    1402  * @returns VBox status code.
    1403  * @param   pVM     The VM handle.
    1404  */
    1405 PDMR3DECL(int) PGMR3LockCall(PVM pVM);
    1406 
    1407 /**
    1408  * Inform PGM if we want all mappings to be put into the shadow page table. (necessary for e.g. VMX)
    1409  *
    1410  * @returns VBox status code.
    1411  * @param   pVM         VM handle.
    1412  * @param   fEnable     Enable or disable shadow mappings
    1413  */
    1414 PGMR3DECL(int) PGMR3ChangeShwPDMappings(PVM pVM, bool fEnable);
    1415 
     434PGMR3DECL(int)  PGMR3Term(PVM pVM);
     435PDMR3DECL(int)  PGMR3LockCall(PVM pVM);
     436PGMR3DECL(int)  PGMR3ChangeShwPDMappings(PVM pVM, bool fEnable);
    1416437#ifndef VBOX_WITH_NEW_PHYS_CODE
    1417 /**
    1418  * Allocate missing physical pages for an existing guest RAM range.
    1419  *
    1420  * @returns VBox status.
    1421  * @param   pVM             The VM handle.
    1422  * @param   GCPhys          GC physical address of the RAM range. (page aligned)
    1423  */
    1424 PGMR3DECL(int) PGM3PhysGrowRange(PVM pVM, RTGCPHYS GCPhys);
     438PGMR3DECL(int)  PGM3PhysGrowRange(PVM pVM, RTGCPHYS GCPhys);
    1425439#endif /* !VBOX_WITH_NEW_PHYS_CODE */
    1426 
    1427 PGMR3DECL(int) PGMR3PhysRegisterRam(PVM pVM, RTGCPHYS GCPhys, RTGCPHYS cb, const char *pszDesc);
    1428 
    1429 /**
    1430  * Interface that the MMR3RamRegister(), MMR3RomRegister() and MMIO handler
    1431  * registration APIs calls to inform PGM about memory registrations.
    1432  *
    1433  * It registers the physical memory range with PGM. MM is responsible
    1434  * for the toplevel things - allocation and locking - while PGM is taking
    1435  * care of all the details and implements the physical address space virtualization.
    1436  *
    1437  * @returns VBox status.
    1438  * @param   pVM             The VM handle.
    1439  * @param   pvRam           HC virtual address of the RAM range. (page aligned)
    1440  * @param   GCPhys          GC physical address of the RAM range. (page aligned)
    1441  * @param   cb              Size of the RAM range. (page aligned)
    1442  * @param   fFlags          Flags, MM_RAM_*.
    1443  * @param   paPages         Pointer an array of physical page descriptors.
    1444  * @param   pszDesc         Description string.
    1445  */
    1446 PGMR3DECL(int) PGMR3PhysRegister(PVM pVM, void *pvRam, RTGCPHYS GCPhys, size_t cb, unsigned fFlags, const SUPPAGE *paPages, const char *pszDesc);
    1447 
     440PGMR3DECL(int)  PGMR3PhysRegisterRam(PVM pVM, RTGCPHYS GCPhys, RTGCPHYS cb, const char *pszDesc);
     441PGMR3DECL(int)  PGMR3PhysRegister(PVM pVM, void *pvRam, RTGCPHYS GCPhys, size_t cb, unsigned fFlags, const SUPPAGE *paPages, const char *pszDesc);
    1448442#ifndef VBOX_WITH_NEW_PHYS_CODE
    1449 /**
    1450  * Register a chunk of a the physical memory range with PGM. MM is responsible
    1451  * for the toplevel things - allocation and locking - while PGM is taking
    1452  * care of all the details and implements the physical address space virtualization.
    1453  *
    1454  * @returns VBox status.
    1455  * @param   pVM             The VM handle.
    1456  * @param   pvRam           HC virtual address of the RAM range. (page aligned)
    1457  * @param   GCPhys          GC physical address of the RAM range. (page aligned)
    1458  * @param   cb              Size of the RAM range. (page aligned)
    1459  * @param   fFlags          Flags, MM_RAM_*.
    1460  * @param   paPages         Pointer an array of physical page descriptors.
    1461  * @param   pszDesc         Description string.
    1462  */
    1463 PGMR3DECL(int) PGMR3PhysRegisterChunk(PVM pVM, void *pvRam, RTGCPHYS GCPhys, size_t cb, unsigned fFlags, const SUPPAGE *paPages, const char *pszDesc);
     443PGMR3DECL(int)  PGMR3PhysRegisterChunk(PVM pVM, void *pvRam, RTGCPHYS GCPhys, size_t cb, unsigned fFlags, const SUPPAGE *paPages, const char *pszDesc);
    1464444#endif /* !VBOX_WITH_NEW_PHYS_CODE */
    1465 
    1466 /**
    1467  * Interface MMIO handler relocation calls.
    1468  *
    1469  * It relocates an existing physical memory range with PGM.
    1470  *
    1471  * @returns VBox status.
    1472  * @param   pVM             The VM handle.
    1473  * @param   GCPhysOld       Previous GC physical address of the RAM range. (page aligned)
    1474  * @param   GCPhysNew       New GC physical address of the RAM range. (page aligned)
    1475  * @param   cb              Size of the RAM range. (page aligned)
    1476  */
    1477 PGMR3DECL(int) PGMR3PhysRelocate(PVM pVM, RTGCPHYS GCPhysOld, RTGCPHYS GCPhysNew, size_t cb);
    1478 
    1479 /**
    1480  * Interface MMR3RomRegister() and MMR3PhysReserve calls to update the
    1481  * flags of existing RAM ranges.
    1482  *
    1483  * @returns VBox status.
    1484  * @param   pVM             The VM handle.
    1485  * @param   GCPhys          GC physical address of the RAM range. (page aligned)
    1486  * @param   cb              Size of the RAM range. (page aligned)
    1487  * @param   fFlags          The Or flags, MM_RAM_* #defines.
    1488  * @param   fMask           The and mask for the flags.
    1489  */
    1490 PGMR3DECL(int) PGMR3PhysSetFlags(PVM pVM, RTGCPHYS GCPhys, size_t cb, unsigned fFlags, unsigned fMask);
    1491 
    1492 /**
    1493  * Sets the Address Gate 20 state.
    1494  *
    1495  * @param   pVM         VM handle.
    1496  * @param   fEnable     True if the gate should be enabled.
    1497  *                      False if the gate should be disabled.
    1498  */
    1499 PGMDECL(void) PGMR3PhysSetA20(PVM pVM, bool fEnable);
    1500 
    1501 /**
    1502  * Creates a page table based mapping in GC.
    1503  *
    1504  * @returns VBox status code.
    1505  * @param   pVM             VM Handle.
    1506  * @param   GCPtr           Virtual Address. (Page table aligned!)
    1507  * @param   cb              Size of the range. Must be a 4MB aligned!
    1508  * @param   pfnRelocate     Relocation callback function.
    1509  * @param   pvUser          User argument to the callback.
    1510  * @param   pszDesc         Pointer to description string. This must not be freed.
    1511  */
     445PGMR3DECL(int)  PGMR3PhysRelocate(PVM pVM, RTGCPHYS GCPhysOld, RTGCPHYS GCPhysNew, size_t cb);
     446PGMR3DECL(int)  PGMR3PhysSetFlags(PVM pVM, RTGCPHYS GCPhys, size_t cb, unsigned fFlags, unsigned fMask);
     447PGMDECL(void)   PGMR3PhysSetA20(PVM pVM, bool fEnable);
    1512448PGMR3DECL(int)  PGMR3MapPT(PVM pVM, RTGCPTR GCPtr, size_t cb, PFNPGMRELOCATE pfnRelocate, void *pvUser, const char *pszDesc);
    1513 
    1514 /**
    1515  * Removes a page table based mapping.
    1516  *
    1517  * @returns VBox status code.
    1518  * @param   pVM     VM Handle.
    1519  * @param   GCPtr   Virtual Address. (Page table aligned!)
    1520  */
    1521449PGMR3DECL(int)  PGMR3UnmapPT(PVM pVM, RTGCPTR GCPtr);
    1522 
    1523 /**
    1524  * Gets the size of the current guest mappings if they were to be
    1525  * put next to oneanother.
    1526  *
    1527  * @returns VBox status code.
    1528  * @param   pVM     The VM.
    1529  * @param   pcb     Where to store the size.
    1530  */
    1531 PGMR3DECL(int) PGMR3MappingsSize(PVM pVM, size_t *pcb);
    1532 
    1533 /**
    1534  * Fixes the guest context mappings in a range reserved from the Guest OS.
    1535  *
    1536  * @returns VBox status code.
    1537  * @param   pVM         The VM.
    1538  * @param   GCPtrBase   The address of the reserved range of guest memory.
    1539  * @param   cb          The size of the range starting at GCPtrBase.
    1540  */
    1541 PGMR3DECL(int) PGMR3MappingsFix(PVM pVM, RTGCPTR GCPtrBase, size_t cb);
    1542 
    1543 /**
    1544  * Unfixes the mappings.
    1545  * After calling this function mapping conflict detection will be enabled.
    1546  *
    1547  * @returns VBox status code.
    1548  * @param   pVM         The VM.
    1549  */
    1550 PGMR3DECL(int) PGMR3MappingsUnfix(PVM pVM);
    1551 
    1552 /**
    1553  * Map pages into the intermediate context (switcher code).
    1554  * These pages are mapped at both the give virtual address and at
    1555  * the physical address (for identity mapping).
    1556  *
    1557  * @returns VBox status code.
    1558  * @param   pVM         The virtual machine.
    1559  * @param   Addr        Intermediate context address of the mapping.
    1560  * @param   HCPhys      Start of the range of physical pages. This must be entriely below 4GB!
    1561  * @param   cbPages     Number of bytes to map.
    1562  *
    1563  * @remark  This API shall not be used to anything but mapping the switcher code.
    1564  */
    1565 PGMR3DECL(int) PGMR3MapIntermediate(PVM pVM, RTUINTPTR Addr, RTHCPHYS HCPhys, unsigned cbPages);
    1566 
    1567 /**
    1568  * Checks guest PD for conflicts with VMM GC mappings.
    1569  *
    1570  * @returns true if conflict detected.
    1571  * @returns false if not.
    1572  * @param   pVM         The virtual machine.
    1573  * @param   cr3         Guest context CR3 register.
    1574  * @param   fRawR0      Whether RawR0 is enabled or not.
    1575  */
     450PGMR3DECL(int)  PGMR3MappingsSize(PVM pVM, size_t *pcb);
     451PGMR3DECL(int)  PGMR3MappingsFix(PVM pVM, RTGCPTR GCPtrBase, size_t cb);
     452PGMR3DECL(int)  PGMR3MappingsUnfix(PVM pVM);
     453PGMR3DECL(int)  PGMR3MapIntermediate(PVM pVM, RTUINTPTR Addr, RTHCPHYS HCPhys, unsigned cbPages);
    1576454PGMR3DECL(bool) PGMR3MapHasConflicts(PVM pVM, uint32_t cr3, bool fRawR0);
    1577 
    1578 /**
    1579  * Read memory from the guest mappings.
    1580  *
    1581  * This will use the page tables associated with the mappings to
    1582  * read the memory. This means that not all kind of memory is readable
    1583  * since we don't necessarily know how to convert that physical address
    1584  * to a HC virtual one.
    1585  *
    1586  * @returns VBox status.
    1587  * @param   pVM         VM handle.
    1588  * @param   pvDst       The destination address (HC of course).
    1589  * @param   GCPtrSrc    The source address (GC virtual address).
    1590  * @param   cb          Number of bytes to read.
    1591  */
    1592 PGMR3DECL(int) PGMR3MapRead(PVM pVM, void *pvDst, RTGCPTR GCPtrSrc, size_t cb);
    1593 
    1594 /**
    1595  * Register a access handler for a physical range.
    1596  *
    1597  * @returns VBox status code.
    1598  * @param   pVM             VM handle.
    1599  * @param   enmType         Handler type. Any of the PGMPHYSHANDLERTYPE_PHYSICAL* enums.
    1600  * @param   GCPhys          Start physical address.
    1601  * @param   GCPhysLast      Last physical address. (inclusive)
    1602  * @param   pfnHandlerR3    The R3 handler.
    1603  * @param   pvUserR3        User argument to the R3 handler.
    1604  * @param   pszModR0        The R0 handler module. NULL means default R0 module.
    1605  * @param   pszHandlerR0    The R0 handler symbol name.
    1606  * @param   pvUserR0        User argument to the R0 handler.
    1607  * @param   pszModGC        The GC handler module. NULL means default GC module.
    1608  * @param   pszHandlerGC    The GC handler symbol name.
    1609  * @param   pvUserGC        User argument to the GC handler.
    1610  *                          This must be a GC pointer because it will be relocated!
    1611  * @param   pszDesc         Pointer to description string. This must not be freed.
    1612  */
    1613 PGMR3DECL(int) PGMR3HandlerPhysicalRegister(PVM pVM, PGMPHYSHANDLERTYPE enmType, RTGCPHYS GCPhys, RTGCPHYS GCPhysLast,
    1614                                             PFNPGMR3PHYSHANDLER pfnHandlerR3, void *pvUserR3,
    1615                                             const char *pszModR0, const char *pszHandlerR0, RTR0PTR pvUserR0,
    1616                                             const char *pszModGC, const char *pszHandlerGC, RTGCPTR pvUserGC, const char *pszDesc);
    1617 
    1618 /**
    1619  * Register an access handler for a virtual range.
    1620  *
    1621  * @returns VBox status code.
    1622  * @param   pVM             VM handle.
    1623  * @param   enmType         Handler type. Any of the PGMVIRTHANDLERTYPE_* enums.
    1624  * @param   GCPtr           Start address.
    1625  * @param   GCPtrLast       Last address. (inclusive)
    1626  * @param   pfnInvalidateHC The HC invalidate callback (can be 0)
    1627  * @param   pfnHandlerHC    The HC handler.
    1628  * @param   pfnHandlerGC    The GC handler.
    1629  * @param   pszDesc         Pointer to description string. This must not be freed.
    1630  */
    1631 PGMDECL(int) PGMHandlerVirtualRegisterEx(PVM pVM, PGMVIRTHANDLERTYPE enmType, RTGCPTR GCPtr, RTGCPTR GCPtrLast,
    1632                                          PFNPGMHCVIRTINVALIDATE pfnInvalidateHC,
    1633                                          PFNPGMHCVIRTHANDLER pfnHandlerHC, RTGCPTR pfnHandlerGC,
    1634                                          R3PTRTYPE(const char *) pszDesc);
    1635 
    1636 /**
    1637  * Register a access handler for a virtual range.
    1638  *
    1639  * @returns VBox status code.
    1640  * @param   pVM             VM handle.
    1641  * @param   enmType         Handler type. Any of the PGMVIRTHANDLERTYPE_* enums.
    1642  * @param   GCPtr           Start address.
    1643  * @param   GCPtrLast       Last address. (inclusive)
    1644  * @param   pfnInvalidateHC The HC invalidate callback (can be 0)
    1645  * @param   pfnHandlerHC    The HC handler.
    1646  * @param   pszHandlerGC    The GC handler symbol name.
    1647  * @param   pszModGC        The GC handler module.
    1648  * @param   pszDesc         Pointer to description string. This must not be freed.
    1649  */
    1650 PGMR3DECL(int) PGMR3HandlerVirtualRegister(PVM pVM, PGMVIRTHANDLERTYPE enmType, RTGCPTR GCPtr, RTGCPTR GCPtrLast,
    1651                                            PFNPGMHCVIRTINVALIDATE pfnInvalidateHC,
    1652                                            PFNPGMHCVIRTHANDLER pfnHandlerHC,
    1653                                            const char *pszHandlerGC, const char *pszModGC, const char *pszDesc);
    1654 
    1655 /**
    1656  * Modify the page invalidation callback handler for a registered virtual range
    1657  * (add more when needed)
    1658  *
    1659  * @returns VBox status code.
    1660  * @param   pVM             VM handle.
    1661  * @param   GCPtr           Start address.
    1662  * @param   pfnInvalidateHC The HC invalidate callback (can be 0)
    1663  */
    1664 PGMDECL(int) PGMHandlerVirtualChangeInvalidateCallback(PVM pVM, RTGCPTR GCPtr, PFNPGMHCVIRTINVALIDATE pfnInvalidateHC);
    1665 
    1666 
    1667 /**
    1668  * Deregister an access handler for a virtual range.
    1669  *
    1670  * @returns VBox status code.
    1671  * @param   pVM         VM handle.
    1672  * @param   GCPtr       Start address.
    1673  */
    1674 PGMDECL(int) PGMHandlerVirtualDeregister(PVM pVM, RTGCPTR GCPtr);
    1675 
    1676 /**
    1677  * Grows the shadow page pool.
    1678  *
    1679  * I.e. adds more pages to it, assuming that hasn't reached cMaxPages yet.
    1680  *
    1681  * @returns VBox status code.
    1682  * @param   pVM     The VM handle.
    1683  */
    1684 PDMR3DECL(int) PGMR3PoolGrow(PVM pVM);
    1685 
     455PGMR3DECL(int)  PGMR3MapRead(PVM pVM, void *pvDst, RTGCPTR GCPtrSrc, size_t cb);
     456PGMR3DECL(int)  PGMR3HandlerPhysicalRegister(PVM pVM, PGMPHYSHANDLERTYPE enmType, RTGCPHYS GCPhys, RTGCPHYS GCPhysLast,
     457                                             PFNPGMR3PHYSHANDLER pfnHandlerR3, void *pvUserR3,
     458                                             const char *pszModR0, const char *pszHandlerR0, RTR0PTR pvUserR0,
     459                                             const char *pszModGC, const char *pszHandlerGC, RTGCPTR pvUserGC, const char *pszDesc);
     460PGMDECL(int)    PGMHandlerVirtualRegisterEx(PVM pVM, PGMVIRTHANDLERTYPE enmType, RTGCPTR GCPtr, RTGCPTR GCPtrLast,
     461                                            PFNPGMHCVIRTINVALIDATE pfnInvalidateHC,
     462                                            PFNPGMHCVIRTHANDLER pfnHandlerHC, RTGCPTR pfnHandlerGC,
     463                                            R3PTRTYPE(const char *) pszDesc);
     464PGMR3DECL(int)  PGMR3HandlerVirtualRegister(PVM pVM, PGMVIRTHANDLERTYPE enmType, RTGCPTR GCPtr, RTGCPTR GCPtrLast,
     465                                            PFNPGMHCVIRTINVALIDATE pfnInvalidateHC,
     466                                            PFNPGMHCVIRTHANDLER pfnHandlerHC,
     467                                            const char *pszHandlerGC, const char *pszModGC, const char *pszDesc);
     468PGMDECL(int)    PGMHandlerVirtualChangeInvalidateCallback(PVM pVM, RTGCPTR GCPtr, PFNPGMHCVIRTINVALIDATE pfnInvalidateHC);
     469PGMDECL(int)    PGMHandlerVirtualDeregister(PVM pVM, RTGCPTR GCPtr);
     470PDMR3DECL(int)  PGMR3PoolGrow(PVM pVM);
    1686471#ifdef ___VBox_dbgf_h /** @todo fix this! */
    1687 /**
    1688  * Dumps a page table hierarchy use only physical addresses and cr4/lm flags.
    1689  *
    1690  * @returns VBox status code (VINF_SUCCESS).
    1691  * @param   pVM         The VM handle.
    1692  * @param   cr3         The root of the hierarchy.
    1693  * @param   cr4         The cr4, only PAE and PSE is currently used.
    1694  * @param   fLongMode   Set if long mode, false if not long mode.
    1695  * @param   cMaxDepth   Number of levels to dump.
    1696  * @param   pHlp        Pointer to the output functions.
    1697  */
    1698 PGMR3DECL(int) PGMR3DumpHierarchyHC(PVM pVM, uint32_t cr3, uint32_t cr4, bool fLongMode, unsigned cMaxDepth, PCDBGFINFOHLP pHlp);
     472PGMR3DECL(int)  PGMR3DumpHierarchyHC(PVM pVM, uint32_t cr3, uint32_t cr4, bool fLongMode, unsigned cMaxDepth, PCDBGFINFOHLP pHlp);
    1699473#endif
    1700 
    1701 /**
    1702  * Dumps a 32-bit guest page directory and page tables.
    1703  *
    1704  * @returns VBox status code (VINF_SUCCESS).
    1705  * @param   pVM         The VM handle.
    1706  * @param   cr3         The root of the hierarchy.
    1707  * @param   cr4         The CR4, PSE is currently used.
    1708  * @param   PhysSearch  Address to search for.
    1709  */
    1710 PGMR3DECL(int) PGMR3DumpHierarchyGC(PVM pVM, uint32_t cr3, uint32_t cr4, RTGCPHYS PhysSearch);
    1711 
    1712 /**
    1713  * Debug helper - Dumps the supplied page directory.
    1714  *
    1715  * @internal
    1716  */
     474PGMR3DECL(int)  PGMR3DumpHierarchyGC(PVM pVM, uint32_t cr3, uint32_t cr4, RTGCPHYS PhysSearch);
    1717475PGMR3DECL(void) PGMR3DumpPD(PVM pVM, PVBOXPD pPD);
    1718 
    1719 /**
    1720  * Dumps the the PGM mappings..
    1721  *
    1722  * @param   pVM     VM handle.
    1723  */
    1724476PGMR3DECL(void) PGMR3DumpMappings(PVM pVM);
    1725477
    1726478/** @todo r=bird: s/Byte/U8/ s/Word/U16/ s/Dword/U32/ to match other functions names and returned types. */
    1727 /**
    1728  * Read physical memory. (one byte)
    1729  *
    1730  * This API respects access handlers and MMIO. Use PGMPhysReadGCPhys() if you
    1731  * want to ignore those.
    1732  *
    1733  * @param   pVM             VM Handle.
    1734  * @param   GCPhys          Physical address start reading from.
    1735  */
    1736479PGMR3DECL(uint8_t) PGMR3PhysReadByte(PVM pVM, RTGCPHYS GCPhys);
    1737 
    1738 /**
    1739  * Read physical memory. (one word)
    1740  *
    1741  * This API respects access handlers and MMIO. Use PGMPhysReadGCPhys() if you
    1742  * want to ignore those.
    1743  *
    1744  * @param   pVM             VM Handle.
    1745  * @param   GCPhys          Physical address start reading from.
    1746  */
    1747480PGMR3DECL(uint16_t) PGMR3PhysReadWord(PVM pVM, RTGCPHYS GCPhys);
    1748 
    1749 /**
    1750  * Read physical memory. (one dword)
    1751  *
    1752  * This API respects access handlers and MMIO. Use PGMPhysReadGCPhys() if you
    1753  * want to ignore those.
    1754  *
    1755  * @param   pVM             VM Handle.
    1756  * @param   GCPhys          Physical address start reading from.
    1757  */
    1758481PGMR3DECL(uint32_t) PGMR3PhysReadDword(PVM pVM, RTGCPHYS GCPhys);
    1759 
    1760 /**
    1761  * Write to physical memory. (one byte)
    1762  *
    1763  * This API respects access handlers and MMIO. Use PGMPhysReadGCPhys() if you
    1764  * want to ignore those.
    1765  *
    1766  * @param   pVM             VM Handle.
    1767  * @param   GCPhys          Physical address to write to.
    1768  * @param   val             What to write.
    1769  */
    1770482PGMR3DECL(void) PGMR3PhysWriteByte(PVM pVM, RTGCPHYS GCPhys, uint8_t val);
    1771 
    1772 /**
    1773  * Write to physical memory. (one word)
    1774  *
    1775  * This API respects access handlers and MMIO. Use PGMPhysReadGCPhys() if you
    1776  * want to ignore those.
    1777  *
    1778  * @param   pVM             VM Handle.
    1779  * @param   GCPhys          Physical address to write to.
    1780  * @param   val             What to write.
    1781  */
    1782483PGMR3DECL(void) PGMR3PhysWriteWord(PVM pVM, RTGCPHYS GCPhys, uint16_t val);
    1783 
    1784 /**
    1785  * Write to physical memory. (one dword)
    1786  *
    1787  * This API respects access handlers and MMIO. Use PGMPhysReadGCPhys() if you
    1788  * want to ignore those.
    1789  *
    1790  * @param   pVM             VM Handle.
    1791  * @param   GCPhys          Physical address to write to.
    1792  * @param   val             What to write.
    1793  */
    1794484PGMR3DECL(void) PGMR3PhysWriteDword(PVM pVM, RTGCPHYS GCPhys, uint32_t val);
    1795 
    1796 /**
    1797  * For VMMCALLHOST_PGM_MAP_CHUNK, considered internal.
    1798  *
    1799  * @returns see pgmR3PhysChunkMap.
    1800  * @param   pVM         The VM handle.
    1801  * @param   idChunk     The chunk to map.
    1802  */
    1803 PDMR3DECL(int) PGMR3PhysChunkMap(PVM pVM, uint32_t idChunk);
    1804 
    1805 /**
    1806  * Invalidates the TLB for the ring-3 mapping cache.
    1807  *
    1808  * @param   pVM         The VM handle.
    1809  */
     485PDMR3DECL(int)  PGMR3PhysChunkMap(PVM pVM, uint32_t idChunk);
    1810486PGMR3DECL(void) PGMR3PhysChunkInvalidateTLB(PVM pVM);
    1811 
    1812 /**
    1813  * Response to VM_FF_PGM_NEED_HANDY_PAGES and VMMCALLHOST_PGM_ALLOCATE_HANDY_PAGES.
    1814  *
    1815  * @returns VBox status code.
    1816  * @retval  VINF_SUCCESS on success. FF cleared.
    1817  * @retval  VINF_EM_NO_MEMORY if we're out of memory. The FF is not cleared in this case.
    1818  *
    1819  * @param   pVM         The VM handle.
    1820  */
    1821 PDMR3DECL(int) PGMR3PhysAllocateHandyPages(PVM pVM);
    1822 
    1823 /**
    1824  * Perform an integrity check on the PGM component.
    1825  *
    1826  * @returns VINF_SUCCESS if everything is fine.
    1827  * @returns VBox error status after asserting on integrity breach.
    1828  * @param   pVM     The VM handle.
    1829  */
    1830 PDMR3DECL(int) PGMR3CheckIntegrity(PVM pVM);
    1831 
    1832 /**
    1833  * Converts a HC pointer to a GC physical address.
    1834  *
    1835  * Only for the debugger.
    1836  *
    1837  * @returns VBox status code.
    1838  * @retval  VINF_SUCCESS on success, *pGCPhys is set.
    1839  * @retval  VERR_INVALID_POINTER if the pointer is not within the GC physical memory.
    1840  *
    1841  * @param   pVM     The VM handle.
    1842  * @param   HCPtr   The HC pointer to convert.
    1843  * @param   pGCPhys Where to store the GC physical address on success.
    1844  */
    1845 PGMR3DECL(int) PGMR3DbgHCPtr2GCPhys(PVM pVM, RTHCPTR HCPtr, PRTGCPHYS pGCPhys);
    1846 
    1847 /**
    1848  * Converts a HC pointer to a GC physical address.
    1849  *
    1850  * @returns VBox status code.
    1851  * @retval  VINF_SUCCESS on success, *pHCPhys is set.
    1852  * @retval  VERR_PGM_PHYS_PAGE_RESERVED it it's a valid GC physical page but has no physical backing.
    1853  * @retval  VERR_INVALID_POINTER if the pointer is not within the GC physical memory.
    1854  *
    1855  * @param   pVM     The VM handle.
    1856  * @param   HCPtr   The HC pointer to convert.
    1857  * @param   pHCPhys Where to store the HC physical address on success.
    1858  */
    1859 PGMR3DECL(int) PGMR3DbgHCPtr2HCPhys(PVM pVM, RTHCPTR HCPtr, PRTHCPHYS pHCPhys);
    1860 
    1861 /**
    1862  * Converts a HC physical address to a GC physical address.
    1863  *
    1864  * Only for the debugger.
    1865  *
    1866  * @returns VBox status code
    1867  * @retval  VINF_SUCCESS on success, *pGCPhys is set.
    1868  * @retval  VERR_INVALID_POINTER if the HC physical address is not within the GC physical memory.
    1869  *
    1870  * @param   pVM     The VM handle.
    1871  * @param   HCPhys  The HC physical address to convert.
    1872  * @param   pGCPhys Where to store the GC physical address on success.
    1873  */
    1874 PGMR3DECL(int) PGMR3DbgHCPhys2GCPhys(PVM pVM, RTHCPHYS HCPhys, PRTGCPHYS pGCPhys);
    1875 
    1876 /**
    1877  * Scans guest physical memory for a byte string.
    1878  *
    1879  * Only for the debugger.
    1880  *
    1881  * @returns VBox status codes:
    1882  * @retval  VINF_SUCCESS and *pGCPtrHit on success.
    1883  * @retval  VERR_DBGF_MEM_NOT_FOUND if not found.
    1884  * @retval  VERR_INVALID_POINTER if any of the pointer arguments are invalid.
    1885  * @retval  VERR_INVALID_ARGUMENT if any other arguments are invalid.
    1886  *
    1887  * @param   pVM             Pointer to the shared VM structure.
    1888  * @param   GCPhys          Where to start searching.
    1889  * @param   cbRange         The number of bytes to search. Max 256 bytes.
    1890  * @param   pabNeedle       The byte string to search for.
    1891  * @param   cbNeedle        The length of the byte string.
    1892  * @param   pGCPhysHit      Where to store the address of the first occurence on success.
    1893  */
    1894 PDMR3DECL(int) PGMR3DbgScanPhysical(PVM pVM, RTGCPHYS GCPhys, RTGCPHYS cbRange, const uint8_t *pabNeedle, size_t cbNeedle, PRTGCPHYS pGCPhysHit);
    1895 
    1896 /**
    1897  * Scans virtual memory for a byte string.
    1898  *
    1899  * Only for the debugger.
    1900  *
    1901  * @returns VBox status codes:
    1902  * @retval  VINF_SUCCESS and *pGCPtrHit on success.
    1903  * @retval  VERR_DBGF_MEM_NOT_FOUND if not found.
    1904  * @retval  VERR_INVALID_POINTER if any of the pointer arguments are invalid.
    1905  * @retval  VERR_INVALID_ARGUMENT if any other arguments are invalid.
    1906  *
    1907  * @param   pVM             Pointer to the shared VM structure.
    1908  * @param   GCPtr           Where to start searching.
    1909  * @param   cbRange         The number of bytes to search. Max 256 bytes.
    1910  * @param   pabNeedle       The byte string to search for.
    1911  * @param   cbNeedle        The length of the byte string.
    1912  * @param   pGCPtrHit       Where to store the address of the first occurence on success.
    1913  */
    1914 PDMR3DECL(int) PGMR3DbgScanVirtual(PVM pVM, RTGCUINTPTR GCPtr, RTGCUINTPTR cbRange, const uint8_t *pabNeedle, size_t cbNeedle, PRTGCUINTPTR pGCPhysHit);
    1915 
     487PDMR3DECL(int)  PGMR3PhysAllocateHandyPages(PVM pVM);
     488
     489PDMR3DECL(int)  PGMR3CheckIntegrity(PVM pVM);
     490
     491PGMR3DECL(int)  PGMR3DbgHCPtr2GCPhys(PVM pVM, RTHCPTR HCPtr, PRTGCPHYS pGCPhys);
     492PGMR3DECL(int)  PGMR3DbgHCPtr2HCPhys(PVM pVM, RTHCPTR HCPtr, PRTHCPHYS pHCPhys);
     493PGMR3DECL(int)  PGMR3DbgHCPhys2GCPhys(PVM pVM, RTHCPHYS HCPhys, PRTGCPHYS pGCPhys);
     494PDMR3DECL(int)  PGMR3DbgScanPhysical(PVM pVM, RTGCPHYS GCPhys, RTGCPHYS cbRange, const uint8_t *pabNeedle, size_t cbNeedle, PRTGCPHYS pGCPhysHit);
     495PDMR3DECL(int)  PGMR3DbgScanVirtual(PVM pVM, RTGCUINTPTR GCPtr, RTGCUINTPTR cbRange, const uint8_t *pabNeedle, size_t cbNeedle, PRTGCUINTPTR pGCPhysHit);
    1916496/** @} */
    1917 
    1918497#endif /* IN_RING3 */
    1919498
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette