VirtualBox

Changeset 83281 in vbox


Ignore:
Timestamp:
Mar 13, 2020 1:02:08 PM (5 years ago)
Author:
vboxsync
Message:

PDMDevHlp,tstDevice: Create two more wrappers used by the graphics device to eliminate direct imports from the VMM library

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/VBox/vmm/pdmdev.h

    r83263 r83281  
    4444#include <VBox/vmm/ssm.h>
    4545#include <VBox/vmm/cfgm.h>
     46#include <VBox/vmm/cpum.h>
    4647#include <VBox/vmm/dbgf.h>
     48#include <VBox/vmm/pgm.h> /* PGMR3HandlerPhysicalTypeRegister() argument types. */
    4749#include <VBox/err.h>  /* VINF_EM_DBG_STOP, also 120+ source files expecting this. */
    4850#include <iprt/stdarg.h>
     
    20862088
    20872089/** Current PDMDEVHLPR3 version number. */
    2088 #define PDM_DEVHLPR3_VERSION                    PDM_VERSION_MAKE_PP(0xffe7, 42, 0)
     2090#define PDM_DEVHLPR3_VERSION                    PDM_VERSION_MAKE_PP(0xffe7, 43, 0)
    20892091
    20902092/**
     
    39053907    DECLR3CALLBACKMEMBER(void, pfnPhysBulkReleasePageMappingLocks,(PPDMDEVINS pDevIns, uint32_t cPages, PPGMPAGEMAPLOCK paLocks));
    39063908
     3909    /**
     3910     * Returns the micro architecture used for the guest.
     3911     *
     3912     * @returns CPU micro architecture enum.
     3913     * @param   pDevIns             The device instance.
     3914     */
     3915    DECLR3CALLBACKMEMBER(CPUMMICROARCH, pfnCpuGetGuestMicroarch,(PPDMDEVINS pDevIns));
     3916
    39073917    /** Space reserved for future members.
    39083918     * @{ */
     
    41154125     */
    41164126    DECLR3CALLBACKMEMBER(void *, pfnQueryGenericUserObject,(PPDMDEVINS pDevIns, PCRTUUID pUuid));
     4127
     4128    /**
     4129     * Register a physical page access handler type.
     4130     *
     4131     * @returns VBox status code.
     4132     * @param   pDevIns             The device instance.
     4133     * @param   enmKind             The kind of access handler.
     4134     * @param   pfnHandlerR3        Pointer to the ring-3 handler callback.
     4135     * @param   pszModR0            The name of the ring-0 module, NULL is an alias for
     4136     *                              the main ring-0 module.
     4137     * @param   pszHandlerR0        The name of the ring-0 handler, NULL if the ring-3
     4138     *                              handler should be called.
     4139     * @param   pszPfHandlerR0      The name of the ring-0 \#PF handler, NULL if the
     4140     *                              ring-3 handler should be called.
     4141     * @param   pszModRC            The name of the raw-mode context module, NULL is an
     4142     *                              alias for the main RC module.
     4143     * @param   pszHandlerRC        The name of the raw-mode context handler, NULL if
     4144     *                              the ring-3 handler should be called.
     4145     * @param   pszPfHandlerRC      The name of the raw-mode context \#PF handler, NULL
     4146     *                              if the ring-3 handler should be called.
     4147     * @param   pszDesc             The type description.
     4148     * @param   phType              Where to return the type handle (cross context
     4149     *                              safe).
     4150     */
     4151    DECLR3CALLBACKMEMBER(int, pfnPGMHandlerPhysicalTypeRegister, (PPDMDEVINS pDevIns, PGMPHYSHANDLERKIND enmKind,
     4152                                                                  R3PTRTYPE(PFNPGMPHYSHANDLER) pfnHandlerR3,
     4153                                                                  const char *pszHandlerR0, const char *pszPfHandlerR0,
     4154                                                                  const char *pszHandlerRC, const char *pszPfHandlerRC,
     4155                                                                  const char *pszDesc, PPGMPHYSHANDLERTYPE phType));
    41174156
    41184157    /** @} */
     
    61976236{
    61986237    pDevIns->CTX_SUFF(pHlp)->pfnPhysBulkReleasePageMappingLocks(pDevIns, cPages, paLocks);
     6238}
     6239
     6240/**
     6241 * @copydoc PDMDEVHLPR3::pfnCpuGetGuestMicroarch
     6242 */
     6243DECLINLINE(CPUMMICROARCH) PDMDevHlpCpuGetGuestMicroarch(PPDMDEVINS pDevIns)
     6244{
     6245    return pDevIns->CTX_SUFF(pHlp)->pfnCpuGetGuestMicroarch(pDevIns);
    61996246}
    62006247
     
    76847731}
    76857732
     7733/**
     7734 * @copydoc PDMDEVHLPR3::pfnPGMHandlerPhysicalTypeRegister
     7735 */
     7736DECLINLINE(int) PDMDevHlpPGMHandlerPhysicalTypeRegister(PPDMDEVINS pDevIns, PGMPHYSHANDLERKIND enmKind,
     7737                                                        R3PTRTYPE(PFNPGMPHYSHANDLER) pfnHandlerR3,
     7738                                                        const char *pszHandlerR0, const char *pszPfHandlerR0,
     7739                                                        const char *pszHandlerRC, const char *pszPfHandlerRC,
     7740                                                        const char *pszDesc, PPGMPHYSHANDLERTYPE phType)
     7741{
     7742    return pDevIns->pHlpR3->pfnPGMHandlerPhysicalTypeRegister(pDevIns, enmKind, pfnHandlerR3,
     7743                                                              pszHandlerR0, pszPfHandlerR0,
     7744                                                              pszHandlerRC, pszPfHandlerRC,
     7745                                                              pszDesc, phType);
     7746}
     7747
    76867748/** Wrapper around SSMR3GetU32 for simplifying getting enum values saved as uint32_t. */
    76877749# define PDMDEVHLP_SSM_GET_ENUM32_RET(a_pHlp, a_pSSM, a_enmDst, a_EnumType) \
  • trunk/src/VBox/Devices/testcase/tstDevicePdmDevHlp.cpp

    r83264 r83281  
    26922692
    26932693
     2694/** @interface_method_impl{PDMDEVHLPR3,pfnPGMHandlerPhysicalTypeRegister} */
     2695static DECLCALLBACK(int) pdmR3DevHlp_PGMHandlerPhysicalTypeRegister(PPDMDEVINS pDevIns, PGMPHYSHANDLERKIND enmKind,
     2696                                                                    R3PTRTYPE(PFNPGMPHYSHANDLER) pfnHandlerR3,
     2697                                                                    const char *pszHandlerR0, const char *pszPfHandlerR0,
     2698                                                                    const char *pszHandlerRC, const char *pszPfHandlerRC,
     2699                                                                    const char *pszDesc, PPGMPHYSHANDLERTYPE phType)
     2700{
     2701    PDMDEV_ASSERT_DEVINS(pDevIns);
     2702    RT_NOREF(enmKind, pfnHandlerR3, pszHandlerR0, pszPfHandlerR0, pszHandlerRC, pszPfHandlerRC, pszDesc, phType);
     2703    LogFlow(("pdmR3DevHlp_PGMHandlerPhysicalTypeRegister: caller='%s'/%d: enmKind=%d pfnHandlerR3=%p pszHandlerR0=%p:{%s} pszPfHandlerR0=%p:{%s} pszHandlerRC=%p:{%s} pszPfHandlerRC=%p:{%s} pszDesc=%p:{%s} phType=%p\n",
     2704             pDevIns->pReg->szName, pDevIns->iInstance, pfnHandlerR3,
     2705             pszHandlerR0, pszHandlerR0, pszPfHandlerR0, pszPfHandlerR0,
     2706             pszHandlerRC, pszHandlerRC, pszPfHandlerRC, pszPfHandlerRC,
     2707             pszDesc, pszDesc, phType));
     2708
     2709    int rc = VERR_NOT_IMPLEMENTED;
     2710    AssertFailed();
     2711
     2712    LogRel(("pdmR3DevHlp_PGMHandlerPhysicalTypeRegister: caller='%s'/%d: returns %Rrc\n",
     2713            pDevIns->pReg->szName, pDevIns->iInstance, rc));
     2714    return rc;
     2715}
     2716
     2717
    26942718/** @interface_method_impl{PDMDEVHLPR3,pfnPhysRead} */
    26952719static DECLCALLBACK(int) pdmR3DevHlp_PhysRead(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, void *pvBuf, size_t cbRead)
     
    28142838
    28152839    Log(("pdmR3DevHlp_PhysBulkReleasePageMappingLocks: caller='%s'/%d: returns void\n", pDevIns->pReg->szName, pDevIns->iInstance));
     2840}
     2841
     2842
     2843/** @interface_method_impl{PDMDEVHLPR3,pfnCpuGetGuestMicroarch} */
     2844static DECLCALLBACK(CPUMMICROARCH) pdmR3DevHlp_CpuGetGuestMicroarch(PPDMDEVINS pDevIns)
     2845{
     2846    PDMDEV_ASSERT_DEVINS(pDevIns);
     2847    LogFlow(("pdmR3DevHlp_CpuGetGuestMicroarch: caller='%s'/%d\n",
     2848             pDevIns->pReg->szName, pDevIns->iInstance));
     2849
     2850    CPUMMICROARCH enmMicroarch = kCpumMicroarch_Intel_P6;
     2851
     2852    Log(("pdmR3DevHlp_CpuGetGuestMicroarch: caller='%s'/%d: returns %u\n", pDevIns->pReg->szName, pDevIns->iInstance, enmMicroarch));
     2853    return enmMicroarch;
    28162854}
    28172855
     
    46274665
    46284666/** @interface_method_impl{PDMDEVHLPR3,pfnIommuRegister} */
    4629 static DECLCALLBACK(int) pdmR3DevHlp_IommuRegister(PPDMDEVINS pDevIns, PPDMIOMMUREG pIommuReg, PCPDMIOMMUHLP *ppIommuHlp)
     4667static DECLCALLBACK(int) pdmR3DevHlp_IommuRegister(PPDMDEVINS pDevIns, PPDMIOMMUREGR3 pIommuReg, PCPDMIOMMUHLPR3 *ppIommuHlp)
    46304668{
    46314669    PDMDEV_ASSERT_DEVINS(pDevIns);
     
    46364674     * Validate input.
    46374675     */
    4638     AssertMsgReturn(pIommuReg->u32Version == PDM_IOMMUREG_VERSION,
    4639                     ("%s/%d: u32Version=%#x expected %#x\n", pDevIns->pReg->szName, pDevIns->iInstance, pIommuReg->u32Version, PDM_IOMMUREG_VERSION),
     4676    AssertMsgReturn(pIommuReg->u32Version == PDM_IOMMUREGR3_VERSION,
     4677                    ("%s/%d: u32Version=%#x expected %#x\n", pDevIns->pReg->szName, pDevIns->iInstance, pIommuReg->u32Version, PDM_IOMMUREGR3_VERSION),
    46404678                    VERR_INVALID_PARAMETER);
    46414679
    46424680    /** @todo IOMMU: Validate other parameters */
    46434681
    4644     AssertMsgReturn(pIommuReg->u32TheEnd == PDM_IOMMUREG_VERSION,
    4645                     ("%s/%d: u32TheEnd=%#x expected %#x\n", pDevIns->pReg->szName, pDevIns->iInstance, pIommuReg->u32TheEnd, PDM_IOMMUREG_VERSION),
     4682    AssertMsgReturn(pIommuReg->u32TheEnd == PDM_IOMMUREGR3_VERSION,
     4683                    ("%s/%d: u32TheEnd=%#x expected %#x\n", pDevIns->pReg->szName, pDevIns->iInstance, pIommuReg->u32TheEnd, PDM_IOMMUREGR3_VERSION),
    46464684                    VERR_INVALID_PARAMETER);
    46474685    AssertPtrReturn(ppIommuHlp, VERR_INVALID_POINTER);
     
    53015339    pdmR3DevHlp_PhysBulkGCPhys2CCPtrReadOnly,
    53025340    pdmR3DevHlp_PhysBulkReleasePageMappingLocks,
     5341    pdmR3DevHlp_CpuGetGuestMicroarch,
    53035342    NULL,
    53045343    NULL,
     
    53295368    pdmR3DevHlp_GetSupDrvSession,
    53305369    pdmR3DevHlp_QueryGenericUserObject,
     5370    pdmR3DevHlp_PGMHandlerPhysicalTypeRegister,
    53315371    PDM_DEVHLPR3_VERSION /* the end */
    53325372};
  • trunk/src/VBox/VMM/VMMR3/PDMDevHlp.cpp

    r83263 r83281  
    732732
    733733
     734/** @interface_method_impl{PDMDEVHLPR3,pfnPGMHandlerPhysicalTypeRegister} */
     735static DECLCALLBACK(int) pdmR3DevHlp_PGMHandlerPhysicalTypeRegister(PPDMDEVINS pDevIns, PGMPHYSHANDLERKIND enmKind,
     736                                                                    R3PTRTYPE(PFNPGMPHYSHANDLER) pfnHandlerR3,
     737                                                                    const char *pszHandlerR0, const char *pszPfHandlerR0,
     738                                                                    const char *pszHandlerRC, const char *pszPfHandlerRC,
     739                                                                    const char *pszDesc, PPGMPHYSHANDLERTYPE phType)
     740{
     741    PDMDEV_ASSERT_DEVINS(pDevIns);
     742    PVM  pVM = pDevIns->Internal.s.pVMR3;
     743    LogFlow(("pdmR3DevHlp_PGMHandlerPhysicalTypeRegister: caller='%s'/%d: enmKind=%d pfnHandlerR3=%p pszHandlerR0=%p:{%s} pszPfHandlerR0=%p:{%s} pszHandlerRC=%p:{%s} pszPfHandlerRC=%p:{%s} pszDesc=%p:{%s} phType=%p\n",
     744             pDevIns->pReg->szName, pDevIns->iInstance, pfnHandlerR3,
     745             pszHandlerR0, pszHandlerR0, pszPfHandlerR0, pszPfHandlerR0,
     746             pszHandlerRC, pszHandlerRC, pszPfHandlerRC, pszPfHandlerRC,
     747             pszDesc, pszDesc, phType));
     748
     749    int rc = PGMR3HandlerPhysicalTypeRegister(pVM, enmKind, pfnHandlerR3,
     750                                              pDevIns->pReg->pszR0Mod, pszHandlerR0, pszPfHandlerR0,
     751                                              pDevIns->pReg->pszRCMod, pszHandlerRC, pszPfHandlerRC,
     752                                              pszDesc, phType);
     753
     754    Log(("pdmR3DevHlp_PGMHandlerPhysicalTypeRegister: caller='%s'/%d: returns %Rrc\n",
     755         pDevIns->pReg->szName, pDevIns->iInstance, rc));
     756    return rc;
     757}
     758
     759
    734760/** @interface_method_impl{PDMDEVHLPR3,pfnPhysRead} */
    735761static DECLCALLBACK(int) pdmR3DevHlp_PhysRead(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, void *pvBuf, size_t cbRead)
     
    920946
    921947    Log(("pdmR3DevHlp_PhysBulkReleasePageMappingLocks: caller='%s'/%d: returns void\n", pDevIns->pReg->szName, pDevIns->iInstance));
     948}
     949
     950
     951/** @interface_method_impl{PDMDEVHLPR3,pfnCpuGetGuestMicroarch} */
     952static DECLCALLBACK(CPUMMICROARCH) pdmR3DevHlp_CpuGetGuestMicroarch(PPDMDEVINS pDevIns)
     953{
     954    PDMDEV_ASSERT_DEVINS(pDevIns);
     955    PVM pVM = pDevIns->Internal.s.pVMR3;
     956    LogFlow(("pdmR3DevHlp_CpuGetGuestMicroarch: caller='%s'/%d\n",
     957             pDevIns->pReg->szName, pDevIns->iInstance));
     958
     959    CPUMMICROARCH enmMicroarch = CPUMGetGuestMicroarch(pVM);
     960
     961    Log(("pdmR3DevHlp_CpuGetGuestMicroarch: caller='%s'/%d: returns %u\n", pDevIns->pReg->szName, pDevIns->iInstance, enmMicroarch));
     962    return enmMicroarch;
    922963}
    923964
     
    41944235    pdmR3DevHlp_PhysBulkGCPhys2CCPtrReadOnly,
    41954236    pdmR3DevHlp_PhysBulkReleasePageMappingLocks,
     4237    pdmR3DevHlp_CpuGetGuestMicroarch,
    41964238    0,
    41974239    0,
     
    42224264    pdmR3DevHlp_GetSupDrvSession,
    42234265    pdmR3DevHlp_QueryGenericUserObject,
     4266    pdmR3DevHlp_PGMHandlerPhysicalTypeRegister,
    42244267    PDM_DEVHLPR3_VERSION /* the end */
    42254268};
     
    43654408                            pDevIns->pReg->szName, pDevIns->iInstance, pUuid));
    43664409    return NULL;
     4410}
     4411
     4412
     4413/** @interface_method_impl{PDMDEVHLPR3,pfnPGMHandlerPhysicalTypeRegister} */
     4414static DECLCALLBACK(int) pdmR3DevHlp_Untrusted_PGMHandlerPhysicalTypeRegister(PPDMDEVINS pDevIns, PGMPHYSHANDLERKIND enmKind,
     4415                                                                              R3PTRTYPE(PFNPGMPHYSHANDLER) pfnHandlerR3,
     4416                                                                              const char *pszHandlerR0, const char *pszPfHandlerR0,
     4417                                                                              const char *pszHandlerRC, const char *pszPfHandlerRC,
     4418                                                                              const char *pszDesc, PPGMPHYSHANDLERTYPE phType)
     4419{
     4420    PDMDEV_ASSERT_DEVINS(pDevIns);
     4421    RT_NOREF(enmKind, pfnHandlerR3, pszHandlerR0, pszPfHandlerR0, pszHandlerRC, pszPfHandlerRC, pszDesc, phType);
     4422    AssertReleaseMsgFailed(("Untrusted device called trusted helper! '%s'/%d\n",
     4423                            pDevIns->pReg->szName, pDevIns->iInstance));
     4424    return VERR_ACCESS_DENIED;
    43674425}
    43684426
     
    46794737    pdmR3DevHlp_PhysBulkGCPhys2CCPtrReadOnly,
    46804738    pdmR3DevHlp_PhysBulkReleasePageMappingLocks,
     4739    pdmR3DevHlp_CpuGetGuestMicroarch,
    46814740    0,
    46824741    0,
     
    47074766    pdmR3DevHlp_Untrusted_GetSupDrvSession,
    47084767    pdmR3DevHlp_Untrusted_QueryGenericUserObject,
     4768    pdmR3DevHlp_Untrusted_PGMHandlerPhysicalTypeRegister,
    47094769    PDM_DEVHLPR3_VERSION /* the end */
    47104770};
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