VirtualBox

Ignore:
Timestamp:
Apr 28, 2015 4:51:35 PM (10 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
99843
Message:

PGM,++: Separated physical access handler callback function pointers from the access handler registrations to reduce footprint and simplify adding a couple of more callbacks.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/VMM/include/PGMInternal.h

    r52764 r55493  
    55
    66/*
    7  * Copyright (C) 2006-2014 Oracle Corporation
     7 * Copyright (C) 2006-2015 Oracle Corporation
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    4040#include <iprt/avl.h>
    4141#include <iprt/critsect.h>
     42#include <iprt/list-off32.h>
    4243#include <iprt/sha.h>
    4344
     
    575576
    576577/**
     578 * Physical page access handler type registration.
     579 */
     580typedef struct PGMPHYSHANDLERTYPEINT
     581{
     582    /** Number of references.   */
     583    uint32_t volatile                   cRefs;
     584    /** Magic number (PGMPHYSHANDLERTYPEINT_MAGIC). */
     585    uint32_t                            u32Magic;
     586    /** Link of handler types anchored in PGMTREES::HeadPhysHandlerTypes.   */
     587    RTLISTOFF32NODE                     ListNode;
     588    /** The kind of accesses we're handling. */
     589    PGMPHYSHANDLERKIND                  enmKind;
     590    /** The PGM_PAGE_HNDL_PHYS_STATE_XXX value corresponding to enmKind. */
     591    uint32_t                            uState;
     592    /** Pointer to RC callback function. */
     593    RCPTRTYPE(PFNPGMRCPHYSHANDLER)      pfnHandlerRC;
     594    /** Explicit alignment padding. */
     595    RTRCPTR                             RCPtrPadding;
     596    /** Pointer to R3 callback function. */
     597    R3PTRTYPE(PFNPGMR3PHYSHANDLER)      pfnHandlerR3;
     598    /** Pointer to R0 callback function. */
     599    R0PTRTYPE(PFNPGMR0PHYSHANDLER)      pfnHandlerR0;
     600    /** Description / Name. For easing debugging. */
     601    R3PTRTYPE(const char *)             pszDesc;
     602} PGMPHYSHANDLERTYPEINT;
     603/** Pointer to a physical access handler type registration. */
     604typedef PGMPHYSHANDLERTYPEINT *PPGMPHYSHANDLERTYPEINT;
     605/** Magic value for the physical handler callbacks (Robert A. Heinlein). */
     606#define PGMPHYSHANDLERTYPEINT_MAGIC        UINT32_C(0x19070707)
     607/** Magic value for the physical handler callbacks. */
     608#define PGMPHYSHANDLERTYPEINT_MAGIC_DEAD   UINT32_C(0x19880508)
     609
     610/**
     611 * Converts a handle to a pointer.
     612 * @returns PPGMPHYSHANDLERTYPEINT
     613 * @param   a_pVM           Pointer to the cross context VM structure.
     614 * @param   a_hType         Physical access handler handle.
     615 */
     616#define PGMPHYSHANDLERTYPEINT_FROM_HANDLE(a_pVM, a_hType) ((PPGMPHYSHANDLERTYPEINT)MMHyperHeapOffsetToPtr(a_pVM, a_hType))
     617
     618
     619/**
    577620 * Physical page access handler structure.
    578621 *
     
    583626{
    584627    AVLROGCPHYSNODECORE                 Core;
    585     /** Access type. */
    586     PGMPHYSHANDLERTYPE                  enmType;
    587628    /** Number of pages to update. */
    588629    uint32_t                            cPages;
     
    591632    /** Set if we have pages that have temporarily been disabled. */
    592633    uint32_t                            cTmpOffPages;
    593     /** Pointer to R3 callback function. */
    594     R3PTRTYPE(PFNPGMR3PHYSHANDLER)      pfnHandlerR3;
     634    /** Registered handler type handle (heap offset). */
     635    PGMPHYSHANDLERTYPE                  hType;
     636    /** User argument for RC handlers. */
     637    RCPTRTYPE(void *)                   pvUserRC;
     638#if HC_ARCH_BITS == 64
     639    RTRCPTR                             Padding0; /**< Explicit alignment padding. */
     640#endif
    595641    /** User argument for R3 handlers. */
    596642    R3PTRTYPE(void *)                   pvUserR3;
    597     /** Pointer to R0 callback function. */
    598     R0PTRTYPE(PFNPGMR0PHYSHANDLER)      pfnHandlerR0;
    599643    /** User argument for R0 handlers. */
    600644    R0PTRTYPE(void *)                   pvUserR0;
    601     /** Pointer to RC callback function. */
    602     RCPTRTYPE(PFNPGMRCPHYSHANDLER)      pfnHandlerRC;
    603     /** User argument for RC handlers. */
    604     RCPTRTYPE(void *)                   pvUserRC;
    605645    /** Description / Name. For easing debugging. */
    606646    R3PTRTYPE(const char *)             pszDesc;
     
    612652/** Pointer to a physical page access handler structure. */
    613653typedef PGMPHYSHANDLER *PPGMPHYSHANDLER;
     654
     655/**
     656 * Gets the type record for a physical handler (no reference added).
     657 * @returns PPGMPHYSHANDLERTYPEINT
     658 * @param   a_pVM           Pointer to the cross context VM structure.
     659 * @param   a_pPhysHandler  Pointer to the physical handler structure
     660 *                          (PGMPHYSHANDLER).
     661 */
     662#define PGMPHYSHANDLER_GET_TYPE(a_pVM, a_pPhysHandler) PGMPHYSHANDLERTYPEINT_FROM_HANDLE(a_pVM, (a_pPhysHandler)->hType)
    614663
    615664
     
    23142363    /** The current number of modified pages. */
    23152364    uint16_t                    cModifiedPages;
    2316     /** Access handler, RC. */
    2317     RCPTRTYPE(PFNPGMRCPHYSHANDLER)  pfnAccessHandlerRC;
    2318     /** Access handler, R0. */
    2319     R0PTRTYPE(PFNPGMR0PHYSHANDLER)  pfnAccessHandlerR0;
    2320     /** Access handler, R3. */
    2321     R3PTRTYPE(PFNPGMR3PHYSHANDLER)  pfnAccessHandlerR3;
    2322     /** The access handler description (R3 ptr). */
    2323     R3PTRTYPE(const char *)         pszAccessHandler;
    2324 # if HC_ARCH_BITS == 32
    2325     /** Alignment padding. */
    2326     uint32_t                    u32Padding2;
    2327 # endif
     2365    /** Physical access handler type registration handle. */
     2366    PGMPHYSHANDLERTYPE          hAccessHandlerType;
    23282367    /** Next available slot (in aDirtyPages). */
    23292368    uint32_t                    idxFreeDirtyPage;
     
    26112650
    26122651/**
    2613  * Trees are using self relative offsets as pointers.
    2614  * So, all its data, including the root pointer, must be in the heap for HC and GC
    2615  * to have the same layout.
     2652 * Roots and anchors for trees and list employing self relative offsets as
     2653 * pointers.
     2654 *
     2655 * When using self-relative offsets instead of pointers, the offsets needs to be
     2656 * the same in all offsets.  Thus the roots and anchors needs to live on the
     2657 * hyper heap just like the nodes.
    26162658 */
    26172659typedef struct PGMTREES
     
    26252667    /** Virtual access handlers for the hypervisor (AVL range + GC ptr tree). */
    26262668    AVLROGCPTRTREE                  HyperVirtHandlers;
     2669    /** List of physical access handler types (offset pointers) of type
     2670     * PGMPHYSHANDLERTYPEINT.  This is needed for relocations. */
     2671    RTLISTOFF32ANCHOR               HeadPhysHandlerTypes;
    26272672} PGMTREES;
    26282673/** Pointer to PGM trees. */
     
    31563201    /** The address of the previous RAM range mapping. */
    31573202    RTGCPTR                         GCPtrPrevRamRangeMapping;
     3203
     3204    /** Physical access handler type for ROM protection. */
     3205    PGMPHYSHANDLERTYPE              hRomPhysHandlerType;
     3206    /** Alignment padding.   */
     3207    uint32_t                        u32Padding;
    31583208
    31593209    /** 4 MB page mask; 32 or 36 bits depending on PSE-36 (identical for all VCPUs) */
     
    40594109
    40604110#ifdef IN_RING3
     4111DECLCALLBACK(int) pgmR3PhysRomWriteHandler(PVM pVM, RTGCPHYS GCPhys, void *pvPhys, void *pvBuf, size_t cbBuf,
     4112                                           PGMACCESSTYPE enmAccessType, void *pvUser);
    40614113void            pgmR3PhysRelinkRamRanges(PVM pVM);
    40624114int             pgmR3PhysRamPreAllocate(PVM pVM);
Note: See TracChangeset for help on using the changeset viewer.

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