VirtualBox

Changeset 26175 in vbox


Ignore:
Timestamp:
Feb 2, 2010 10:14:21 PM (15 years ago)
Author:
vboxsync
Message:

PDM: Ring-0 and raw-mode context driver helpers. Driver RC relcoations.

Location:
trunk
Files:
6 edited

Legend:

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

    r26172 r26175  
    507507
    508508
     509/**
     510 * PDM Driver API - raw-mode context variant.
     511 */
     512typedef struct PDMDRVHLPRC
     513{
     514    /** Structure version. PDM_DRVHLPRC_VERSION defines the current version. */
     515    uint32_t                    u32Version;
     516
     517    /**
     518     * Set the VM error message
     519     *
     520     * @returns rc.
     521     * @param   pDrvIns         Driver instance.
     522     * @param   rc              VBox status code.
     523     * @param   RT_SRC_POS_DECL Use RT_SRC_POS.
     524     * @param   pszFormat       Error message format string.
     525     * @param   ...             Error message arguments.
     526     */
     527    DECLRCCALLBACKMEMBER(int, pfnVMSetError,(PPDMDRVINS pDrvIns, int rc, RT_SRC_POS_DECL, const char *pszFormat, ...));
     528
     529    /**
     530     * Set the VM error message
     531     *
     532     * @returns rc.
     533     * @param   pDrvIns         Driver instance.
     534     * @param   rc              VBox status code.
     535     * @param   RT_SRC_POS_DECL Use RT_SRC_POS.
     536     * @param   pszFormat       Error message format string.
     537     * @param   va              Error message arguments.
     538     */
     539    DECLRCCALLBACKMEMBER(int, pfnVMSetErrorV,(PPDMDRVINS pDrvIns, int rc, RT_SRC_POS_DECL, const char *pszFormat, va_list va));
     540
     541    /**
     542     * Set the VM runtime error message
     543     *
     544     * @returns VBox status code.
     545     * @param   pDrvIns         Driver instance.
     546     * @param   fFlags          The action flags. See VMSETRTERR_FLAGS_*.
     547     * @param   pszErrorId      Error ID string.
     548     * @param   pszFormat       Error message format string.
     549     * @param   ...             Error message arguments.
     550     */
     551    DECLRCCALLBACKMEMBER(int, pfnVMSetRuntimeError,(PPDMDRVINS pDrvIns, uint32_t fFlags, const char *pszErrorId, const char *pszFormat, ...));
     552
     553    /**
     554     * Set the VM runtime error message
     555     *
     556     * @returns VBox status code.
     557     * @param   pDrvIns         Driver instance.
     558     * @param   fFlags          The action flags. See VMSETRTERR_FLAGS_*.
     559     * @param   pszErrorId      Error ID string.
     560     * @param   pszFormat       Error message format string.
     561     * @param   va              Error message arguments.
     562     */
     563    DECLRCCALLBACKMEMBER(int, pfnVMSetRuntimeErrorV,(PPDMDRVINS pDrvIns, uint32_t fFlags, const char *pszErrorId, const char *pszFormat, va_list va));
     564
     565    /**
     566     * Assert that the current thread is the emulation thread.
     567     *
     568     * @returns True if correct.
     569     * @returns False if wrong.
     570     * @param   pDrvIns         Driver instance.
     571     * @param   pszFile         Filename of the assertion location.
     572     * @param   iLine           Linenumber of the assertion location.
     573     * @param   pszFunction     Function of the assertion location.
     574     */
     575    DECLRCCALLBACKMEMBER(bool, pfnAssertEMT,(PPDMDRVINS pDrvIns, const char *pszFile, unsigned iLine, const char *pszFunction));
     576
     577    /**
     578     * Assert that the current thread is NOT the emulation thread.
     579     *
     580     * @returns True if correct.
     581     * @returns False if wrong.
     582     * @param   pDrvIns         Driver instance.
     583     * @param   pszFile         Filename of the assertion location.
     584     * @param   iLine           Linenumber of the assertion location.
     585     * @param   pszFunction     Function of the assertion location.
     586     */
     587    DECLRCCALLBACKMEMBER(bool, pfnAssertOther,(PPDMDRVINS pDrvIns, const char *pszFile, unsigned iLine, const char *pszFunction));
     588
     589    /** Just a safety precaution. */
     590    uint32_t                        u32TheEnd;
     591} PDMDRVHLPRC;
     592/** Current PDMDRVHLPRC version number. */
     593#define PDM_DRVHLPRC_VERSION                    PDM_VERSION_MAKE(0xf0f9, 1, 0)
     594
     595
     596/**
     597 * PDM Driver API, ring-0 context.
     598 */
     599typedef struct PDMDRVHLPR0
     600{
     601    /** Structure version. PDM_DRVHLPR0_VERSION defines the current version. */
     602    uint32_t                    u32Version;
     603
     604    /**
     605     * Set the VM error message
     606     *
     607     * @returns rc.
     608     * @param   pDrvIns         Driver instance.
     609     * @param   rc              VBox status code.
     610     * @param   RT_SRC_POS_DECL Use RT_SRC_POS.
     611     * @param   pszFormat       Error message format string.
     612     * @param   ...             Error message arguments.
     613     */
     614    DECLR0CALLBACKMEMBER(int, pfnVMSetError,(PPDMDRVINS pDrvIns, int rc, RT_SRC_POS_DECL, const char *pszFormat, ...));
     615
     616    /**
     617     * Set the VM error message
     618     *
     619     * @returns rc.
     620     * @param   pDrvIns         Driver instance.
     621     * @param   rc              VBox status code.
     622     * @param   RT_SRC_POS_DECL Use RT_SRC_POS.
     623     * @param   pszFormat       Error message format string.
     624     * @param   va              Error message arguments.
     625     */
     626    DECLR0CALLBACKMEMBER(int, pfnVMSetErrorV,(PPDMDRVINS pDrvIns, int rc, RT_SRC_POS_DECL, const char *pszFormat, va_list va));
     627
     628    /**
     629     * Set the VM runtime error message
     630     *
     631     * @returns VBox status code.
     632     * @param   pDrvIns         Driver instance.
     633     * @param   fFlags          The action flags. See VMSETRTERR_FLAGS_*.
     634     * @param   pszErrorId      Error ID string.
     635     * @param   pszFormat       Error message format string.
     636     * @param   ...             Error message arguments.
     637     */
     638    DECLR0CALLBACKMEMBER(int, pfnVMSetRuntimeError,(PPDMDRVINS pDrvIns, uint32_t fFlags, const char *pszErrorId, const char *pszFormat, ...));
     639
     640    /**
     641     * Set the VM runtime error message
     642     *
     643     * @returns VBox status code.
     644     * @param   pDrvIns         Driver instance.
     645     * @param   fFlags          The action flags. See VMSETRTERR_FLAGS_*.
     646     * @param   pszErrorId      Error ID string.
     647     * @param   pszFormat       Error message format string.
     648     * @param   va              Error message arguments.
     649     */
     650    DECLR0CALLBACKMEMBER(int, pfnVMSetRuntimeErrorV,(PPDMDRVINS pDrvIns, uint32_t fFlags, const char *pszErrorId, const char *pszFormat, va_list va));
     651
     652    /**
     653     * Assert that the current thread is the emulation thread.
     654     *
     655     * @returns True if correct.
     656     * @returns False if wrong.
     657     * @param   pDrvIns         Driver instance.
     658     * @param   pszFile         Filename of the assertion location.
     659     * @param   iLine           Linenumber of the assertion location.
     660     * @param   pszFunction     Function of the assertion location.
     661     */
     662    DECLR0CALLBACKMEMBER(bool, pfnAssertEMT,(PPDMDRVINS pDrvIns, const char *pszFile, unsigned iLine, const char *pszFunction));
     663
     664    /**
     665     * Assert that the current thread is NOT the emulation thread.
     666     *
     667     * @returns True if correct.
     668     * @returns False if wrong.
     669     * @param   pDrvIns         Driver instance.
     670     * @param   pszFile         Filename of the assertion location.
     671     * @param   iLine           Linenumber of the assertion location.
     672     * @param   pszFunction     Function of the assertion location.
     673     */
     674    DECLR0CALLBACKMEMBER(bool, pfnAssertOther,(PPDMDRVINS pDrvIns, const char *pszFile, unsigned iLine, const char *pszFunction));
     675
     676    /** Just a safety precaution. */
     677    uint32_t                        u32TheEnd;
     678} PDMDRVHLPR0;
     679/** Current DRVHLP version number. */
     680#define PDM_DRVHLPR0_VERSION                    PDM_VERSION_MAKE(0xf0f8, 1, 0)
     681
     682
    509683#ifdef IN_RING3
     684
    510685/**
    511686 * PDM Driver API.
     
    9351110#define PDM_DRVHLPR3_VERSION                    PDM_VERSION_MAKE(0xf0fb, 1, 0)
    9361111
     1112#endif /* IN_RING3 */
     1113
    9371114
    9381115/**
     
    9901167}
    9911168
    992 #endif /* IN_RING3 */
    9931169
    9941170
  • trunk/src/VBox/VMM/PDM.cpp

    r26169 r26175  
    452452
    453453    /*
    454      * Devices.
    455      */
    456     PCPDMDEVHLPRC pHlpRC;
    457     int rc = PDMR3LdrGetSymbolRC(pVM, NULL, "g_pdmRCDevHlp", &pHlpRC);
     454     * Devices & Drivers.
     455     */
     456    PCPDMDEVHLPRC pDevHlpRC;
     457    int rc = PDMR3LdrGetSymbolRC(pVM, NULL, "g_pdmRCDevHlp", &pDevHlpRC);
    458458    AssertReleaseMsgRC(rc, ("rc=%Rrc when resolving g_pdmRCDevHlp\n", rc));
     459
     460    PCPDMDRVHLPRC pDrvHlpRC;
     461    rc = PDMR3LdrGetSymbolRC(pVM, NULL, "g_pdmRCDevHlp", &pDrvHlpRC);
     462    AssertReleaseMsgRC(rc, ("rc=%Rrc when resolving g_pdmRCDevHlp\n", rc));
     463
    459464    for (PPDMDEVINS pDevIns = pVM->pdm.s.pDevInstances; pDevIns; pDevIns = pDevIns->Internal.s.pNextR3)
    460465    {
    461466        if (pDevIns->pReg->fFlags & PDM_DEVREG_FLAGS_RC)
    462467        {
    463             pDevIns->pHlpRC = pHlpRC;
     468            pDevIns->pHlpRC = pDevHlpRC;
    464469            pDevIns->pvInstanceDataRC = MMHyperR3ToRC(pVM, pDevIns->pvInstanceDataR3);
    465470            pDevIns->Internal.s.pVMRC = pVM->pVMRC;
     
    475480            }
    476481        }
     482
     483        for (PPDMLUN pLun = pDevIns->Internal.s.pLunsR3; pLun; pLun = pLun->pNext)
     484        {
     485            for (PPDMDRVINS pDrvIns = pLun->pTop; pDrvIns; pDrvIns = pDrvIns->Internal.s.pDown)
     486            {
     487                if (pDrvIns->pReg->fFlags & PDM_DRVREG_FLAGS_RC)
     488                {
     489                    pDrvIns->pHlpRC = pDrvHlpRC;
     490                    pDrvIns->pvInstanceDataRC = MMHyperR3ToRC(pVM, pDrvIns->pvInstanceDataR3);
     491                    pDrvIns->Internal.s.pVMRC = pVM->pVMRC;
     492                    if (pDrvIns->pReg->pfnRelocate)
     493                    {
     494                        LogFlow(("PDMR3Relocate: Relocating driver '%s'/%u attached to '%s'/%d/%u\n",
     495                                 pDrvIns->pReg->szName, pDrvIns->iInstance,
     496                                 pDevIns->pReg->szName, pDevIns->iInstance, pLun->iLun));
     497                        pDrvIns->pReg->pfnRelocate(pDrvIns, offDelta);
     498                    }
     499                }
     500            }
     501        }
     502
    477503    }
    478504}
  • trunk/src/VBox/VMM/PDMDriver.cpp

    r26172 r26175  
    6868*   Internal Functions                                                         *
    6969*******************************************************************************/
    70 /** @def PDMDRV_ASSERT_DRVINS
    71  * Asserts the validity of the driver instance.
    72  */
    73 #ifdef VBOX_STRICT
    74 # define PDMDRV_ASSERT_DRVINS(pDrvIns) \
    75     do { \
    76         AssertPtr(pDrvIns); \
    77         Assert(pDrvIns->u32Version == PDM_DRVINS_VERSION); \
    78         Assert(pDrvIns->pvInstanceDataR3 == (void *)&pDrvIns->achInstanceData[0]); \
    79     } while (0)
    80 #else
    81 # define PDMDRV_ASSERT_DRVINS(pDrvIns)   do { } while (0)
    82 #endif
    83 /** @} */
    84 
    8570static DECLCALLBACK(int) pdmR3DrvRegister(PCPDMDRVREGCB pCallbacks, PCPDMDRVREG pReg);
    8671static int pdmR3DrvLoad(PVM pVM, PPDMDRVREGCBINT pRegCB, const char *pszFilename, const char *pszName);
  • trunk/src/VBox/VMM/PDMInternal.h

    r26162 r26175  
    10761076#endif
    10771077
     1078/** @def PDMDRV_ASSERT_DRVINS
     1079 * Asserts the validity of the driver instance.
     1080 */
     1081#ifdef VBOX_STRICT
     1082# define PDMDRV_ASSERT_DRVINS(pDrvIns) \
     1083    do { \
     1084        AssertPtr(pDrvIns); \
     1085        Assert(pDrvIns->u32Version == PDM_DRVINS_VERSION); \
     1086        Assert(pDrvIns->CTX_SUFF(pvInstanceData) == (void *)&pDrvIns->achInstanceData[0]); \
     1087    } while (0)
     1088#else
     1089# define PDMDRV_ASSERT_DRVINS(pDrvIns)   do { } while (0)
     1090#endif
     1091
    10781092
    10791093/*******************************************************************************
  • trunk/src/VBox/VMM/VMMGC/PDMGCDevice.cpp

    r26152 r26175  
    5050extern DECLEXPORT(const PDMPCIHLPRC)    g_pdmRCPciHlp;
    5151extern DECLEXPORT(const PDMHPETHLPRC)   g_pdmRCHpetHlp;
     52extern DECLEXPORT(const PDMDRVHLPRC)    g_pdmRCDrvHlp;
    5253RT_C_DECLS_END
    5354
     
    6768
    6869/** @interface_method_impl{PDMDEVHLPRC,pfnPCISetIrq} */
    69 static DECLCALLBACK(void) pdmGCDevHlp_PCISetIrq(PPDMDEVINS pDevIns, int iIrq, int iLevel)
    70 {
    71     PDMDEV_ASSERT_DEVINS(pDevIns);
    72     LogFlow(("pdmGCDevHlp_PCISetIrq: caller=%p/%d: iIrq=%d iLevel=%d\n", pDevIns, pDevIns->iInstance, iIrq, iLevel));
     70static DECLCALLBACK(void) pdmRCDevHlp_PCISetIrq(PPDMDEVINS pDevIns, int iIrq, int iLevel)
     71{
     72    PDMDEV_ASSERT_DEVINS(pDevIns);
     73    LogFlow(("pdmRCDevHlp_PCISetIrq: caller=%p/%d: iIrq=%d iLevel=%d\n", pDevIns, pDevIns->iInstance, iIrq, iLevel));
    7374
    7475    PVM         pVM     = pDevIns->Internal.s.pVMRC;
     
    100101    }
    101102
    102     LogFlow(("pdmGCDevHlp_PCISetIrq: caller=%p/%d: returns void\n", pDevIns, pDevIns->iInstance));
    103 }
    104 
    105 
    106 /** @interface_method_impl{PDMDEVHLPRC,pfnPCISetIrq} */
    107 static DECLCALLBACK(void) pdmGCDevHlp_ISASetIrq(PPDMDEVINS pDevIns, int iIrq, int iLevel)
    108 {
    109     PDMDEV_ASSERT_DEVINS(pDevIns);
    110     LogFlow(("pdmGCDevHlp_ISASetIrq: caller=%p/%d: iIrq=%d iLevel=%d\n", pDevIns, pDevIns->iInstance, iIrq, iLevel));
     103    LogFlow(("pdmRCDevHlp_PCISetIrq: caller=%p/%d: returns void\n", pDevIns, pDevIns->iInstance));
     104}
     105
     106
     107/** @interface_method_impl{PDMDRVHLPRC,pfnPCISetIrq} */
     108static DECLCALLBACK(void) pdmRCDevHlp_ISASetIrq(PPDMDEVINS pDevIns, int iIrq, int iLevel)
     109{
     110    PDMDEV_ASSERT_DEVINS(pDevIns);
     111    LogFlow(("pdmRCDevHlp_ISASetIrq: caller=%p/%d: iIrq=%d iLevel=%d\n", pDevIns, pDevIns->iInstance, iIrq, iLevel));
    111112
    112113    pdmRCIsaSetIrq(pDevIns->Internal.s.pVMRC, iIrq, iLevel);
    113114
    114     LogFlow(("pdmGCDevHlp_ISASetIrq: caller=%p/%d: returns void\n", pDevIns, pDevIns->iInstance));
     115    LogFlow(("pdmRCDevHlp_ISASetIrq: caller=%p/%d: returns void\n", pDevIns, pDevIns->iInstance));
    115116}
    116117
    117118
    118119/** @interface_method_impl{PDMDEVHLPRC,pfnPhysRead} */
    119 static DECLCALLBACK(int) pdmGCDevHlp_PhysRead(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, void *pvBuf, size_t cbRead)
    120 {
    121     PDMDEV_ASSERT_DEVINS(pDevIns);
    122     LogFlow(("pdmGCDevHlp_PhysRead: caller=%p/%d: GCPhys=%RGp pvBuf=%p cbRead=%#x\n",
     120static DECLCALLBACK(int) pdmRCDevHlp_PhysRead(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, void *pvBuf, size_t cbRead)
     121{
     122    PDMDEV_ASSERT_DEVINS(pDevIns);
     123    LogFlow(("pdmRCDevHlp_PhysRead: caller=%p/%d: GCPhys=%RGp pvBuf=%p cbRead=%#x\n",
    123124             pDevIns, pDevIns->iInstance, GCPhys, pvBuf, cbRead));
    124125
     
    126127    AssertRC(rc); /** @todo track down the users for this bugger. */
    127128
    128     Log(("pdmGCDevHlp_PhysRead: caller=%p/%d: returns %Rrc\n", pDevIns, pDevIns->iInstance, rc));
     129    Log(("pdmRCDevHlp_PhysRead: caller=%p/%d: returns %Rrc\n", pDevIns, pDevIns->iInstance, rc));
    129130    return rc;
    130131}
     
    132133
    133134/** @interface_method_impl{PDMDEVHLPRC,pfnPhysWrite} */
    134 static DECLCALLBACK(int) pdmGCDevHlp_PhysWrite(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, const void *pvBuf, size_t cbWrite)
    135 {
    136     PDMDEV_ASSERT_DEVINS(pDevIns);
    137     LogFlow(("pdmGCDevHlp_PhysWrite: caller=%p/%d: GCPhys=%RGp pvBuf=%p cbWrite=%#x\n",
     135static DECLCALLBACK(int) pdmRCDevHlp_PhysWrite(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, const void *pvBuf, size_t cbWrite)
     136{
     137    PDMDEV_ASSERT_DEVINS(pDevIns);
     138    LogFlow(("pdmRCDevHlp_PhysWrite: caller=%p/%d: GCPhys=%RGp pvBuf=%p cbWrite=%#x\n",
    138139             pDevIns, pDevIns->iInstance, GCPhys, pvBuf, cbWrite));
    139140
     
    141142    AssertRC(rc); /** @todo track down the users for this bugger. */
    142143
    143     Log(("pdmGCDevHlp_PhysWrite: caller=%p/%d: returns %Rrc\n", pDevIns, pDevIns->iInstance, rc));
     144    Log(("pdmRCDevHlp_PhysWrite: caller=%p/%d: returns %Rrc\n", pDevIns, pDevIns->iInstance, rc));
    144145    return rc;
    145146}
     
    147148
    148149/** @interface_method_impl{PDMDEVHLPRC,pfnA20IsEnabled} */
    149 static DECLCALLBACK(bool) pdmGCDevHlp_A20IsEnabled(PPDMDEVINS pDevIns)
    150 {
    151     PDMDEV_ASSERT_DEVINS(pDevIns);
    152     LogFlow(("pdmGCDevHlp_A20IsEnabled: caller=%p/%d:\n", pDevIns, pDevIns->iInstance));
     150static DECLCALLBACK(bool) pdmRCDevHlp_A20IsEnabled(PPDMDEVINS pDevIns)
     151{
     152    PDMDEV_ASSERT_DEVINS(pDevIns);
     153    LogFlow(("pdmRCDevHlp_A20IsEnabled: caller=%p/%d:\n", pDevIns, pDevIns->iInstance));
    153154
    154155    bool fEnabled = PGMPhysIsA20Enabled(VMMGetCpu0(pDevIns->Internal.s.pVMRC));
    155156
    156     Log(("pdmGCDevHlp_A20IsEnabled: caller=%p/%d: returns %RTbool\n", pDevIns, pDevIns->iInstance, fEnabled));
     157    Log(("pdmRCDevHlp_A20IsEnabled: caller=%p/%d: returns %RTbool\n", pDevIns, pDevIns->iInstance, fEnabled));
    157158    return fEnabled;
    158159}
     
    160161
    161162/** @interface_method_impl{PDMDEVHLPRC,pfnVMSetError} */
    162 static DECLCALLBACK(int) pdmGCDevHlp_VMSetError(PPDMDEVINS pDevIns, int rc, RT_SRC_POS_DECL, const char *pszFormat, ...)
     163static DECLCALLBACK(int) pdmRCDevHlp_VMSetError(PPDMDEVINS pDevIns, int rc, RT_SRC_POS_DECL, const char *pszFormat, ...)
    163164{
    164165    PDMDEV_ASSERT_DEVINS(pDevIns);
     
    172173
    173174/** @interface_method_impl{PDMDEVHLPRC,pfnVMSetErrorV} */
    174 static DECLCALLBACK(int) pdmGCDevHlp_VMSetErrorV(PPDMDEVINS pDevIns, int rc, RT_SRC_POS_DECL, const char *pszFormat, va_list va)
     175static DECLCALLBACK(int) pdmRCDevHlp_VMSetErrorV(PPDMDEVINS pDevIns, int rc, RT_SRC_POS_DECL, const char *pszFormat, va_list va)
    175176{
    176177    PDMDEV_ASSERT_DEVINS(pDevIns);
     
    181182
    182183/** @interface_method_impl{PDMDEVHLPRC,pfnVMSetRuntimeError} */
    183 static DECLCALLBACK(int) pdmGCDevHlp_VMSetRuntimeError(PPDMDEVINS pDevIns, uint32_t fFlags, const char *pszErrorId, const char *pszFormat, ...)
     184static DECLCALLBACK(int) pdmRCDevHlp_VMSetRuntimeError(PPDMDEVINS pDevIns, uint32_t fFlags, const char *pszErrorId, const char *pszFormat, ...)
    184185{
    185186    PDMDEV_ASSERT_DEVINS(pDevIns);
     
    193194
    194195/** @interface_method_impl{PDMDEVHLPRC,pfnVMSetErrorV} */
    195 static DECLCALLBACK(int) pdmGCDevHlp_VMSetRuntimeErrorV(PPDMDEVINS pDevIns, uint32_t fFlags, const char *pszErrorId, const char *pszFormat, va_list va)
     196static DECLCALLBACK(int) pdmRCDevHlp_VMSetRuntimeErrorV(PPDMDEVINS pDevIns, uint32_t fFlags, const char *pszErrorId, const char *pszFormat, va_list va)
    196197{
    197198    PDMDEV_ASSERT_DEVINS(pDevIns);
     
    202203
    203204/** @interface_method_impl{PDMDEVHLPRC,pfnPATMSetMMIOPatchInfo} */
    204 static DECLCALLBACK(int) pdmGCDevHlp_PATMSetMMIOPatchInfo(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, RTGCPTR pCachedData)
    205 {
    206     PDMDEV_ASSERT_DEVINS(pDevIns);
    207     LogFlow(("pdmGCDevHlp_PATMSetMMIOPatchInfo: caller=%p/%d:\n", pDevIns, pDevIns->iInstance));
     205static DECLCALLBACK(int) pdmRCDevHlp_PATMSetMMIOPatchInfo(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, RTGCPTR pCachedData)
     206{
     207    PDMDEV_ASSERT_DEVINS(pDevIns);
     208    LogFlow(("pdmRCDevHlp_PATMSetMMIOPatchInfo: caller=%p/%d:\n", pDevIns, pDevIns->iInstance));
    208209
    209210    return PATMSetMMIOPatchInfo(pDevIns->Internal.s.pVMRC, GCPhys, (RTRCPTR)pCachedData);
     
    212213
    213214/** @interface_method_impl{PDMDEVHLPRC,pfnGetVM} */
    214 static DECLCALLBACK(PVM)  pdmGCDevHlp_GetVM(PPDMDEVINS pDevIns)
    215 {
    216     PDMDEV_ASSERT_DEVINS(pDevIns);
    217     LogFlow(("pdmGCDevHlp_GetVM: caller='%p'/%d\n", pDevIns, pDevIns->iInstance));
     215static DECLCALLBACK(PVM)  pdmRCDevHlp_GetVM(PPDMDEVINS pDevIns)
     216{
     217    PDMDEV_ASSERT_DEVINS(pDevIns);
     218    LogFlow(("pdmRCDevHlp_GetVM: caller='%p'/%d\n", pDevIns, pDevIns->iInstance));
    218219    return pDevIns->Internal.s.pVMRC;
    219220}
     
    221222
    222223/** @interface_method_impl{PDMDEVHLPRC,pfnGetVMCPU} */
    223 static DECLCALLBACK(PVMCPU) pdmGCDevHlp_GetVMCPU(PPDMDEVINS pDevIns)
    224 {
    225     PDMDEV_ASSERT_DEVINS(pDevIns);
    226     LogFlow(("pdmGCDevHlp_GetVMCPU: caller='%p'/%d\n", pDevIns, pDevIns->iInstance));
     224static DECLCALLBACK(PVMCPU) pdmRCDevHlp_GetVMCPU(PPDMDEVINS pDevIns)
     225{
     226    PDMDEV_ASSERT_DEVINS(pDevIns);
     227    LogFlow(("pdmRCDevHlp_GetVMCPU: caller='%p'/%d\n", pDevIns, pDevIns->iInstance));
    227228    return VMMGetCpu(pDevIns->Internal.s.pVMRC);
    228229}
     
    235236{
    236237    PDM_DEVHLPRC_VERSION,
    237     pdmGCDevHlp_PCISetIrq,
    238     pdmGCDevHlp_ISASetIrq,
    239     pdmGCDevHlp_PhysRead,
    240     pdmGCDevHlp_PhysWrite,
    241     pdmGCDevHlp_A20IsEnabled,
    242     pdmGCDevHlp_VMSetError,
    243     pdmGCDevHlp_VMSetErrorV,
    244     pdmGCDevHlp_VMSetRuntimeError,
    245     pdmGCDevHlp_VMSetRuntimeErrorV,
    246     pdmGCDevHlp_PATMSetMMIOPatchInfo,
    247     pdmGCDevHlp_GetVM,
    248     pdmGCDevHlp_GetVMCPU,
     238    pdmRCDevHlp_PCISetIrq,
     239    pdmRCDevHlp_ISASetIrq,
     240    pdmRCDevHlp_PhysRead,
     241    pdmRCDevHlp_PhysWrite,
     242    pdmRCDevHlp_A20IsEnabled,
     243    pdmRCDevHlp_VMSetError,
     244    pdmRCDevHlp_VMSetErrorV,
     245    pdmRCDevHlp_VMSetRuntimeError,
     246    pdmRCDevHlp_VMSetRuntimeErrorV,
     247    pdmRCDevHlp_PATMSetMMIOPatchInfo,
     248    pdmRCDevHlp_GetVM,
     249    pdmRCDevHlp_GetVMCPU,
    249250    PDM_DEVHLPRC_VERSION
    250251};
     
    618619
    619620
     621/** @name Raw-Mode Context Driver Helpers
     622 * @{
     623 */
     624
     625/** @interface_method_impl{PDMDRVHLPRC,pfnVMSetError} */
     626static DECLCALLBACK(int) pdmRCDrvHlp_VMSetError(PPDMDRVINS pDrvIns, int rc, RT_SRC_POS_DECL, const char *pszFormat, ...)
     627{
     628    PDMDRV_ASSERT_DRVINS(pDrvIns);
     629    va_list args;
     630    va_start(args, pszFormat);
     631    int rc2 = VMSetErrorV(pDrvIns->Internal.s.pVMRC, rc, RT_SRC_POS_ARGS, pszFormat, args); Assert(rc2 == rc); NOREF(rc2);
     632    va_end(args);
     633    return rc;
     634}
     635
     636
     637/** @interface_method_impl{PDMDRVHLPRC,pfnVMSetErrorV} */
     638static DECLCALLBACK(int) pdmRCDrvHlp_VMSetErrorV(PPDMDRVINS pDrvIns, int rc, RT_SRC_POS_DECL, const char *pszFormat, va_list va)
     639{
     640    PDMDRV_ASSERT_DRVINS(pDrvIns);
     641    int rc2 = VMSetErrorV(pDrvIns->Internal.s.pVMRC, rc, RT_SRC_POS_ARGS, pszFormat, va); Assert(rc2 == rc); NOREF(rc2);
     642    return rc;
     643}
     644
     645
     646/** @interface_method_impl{PDMDRVHLPRC,pfnVMSetRuntimeError} */
     647static DECLCALLBACK(int) pdmRCDrvHlp_VMSetRuntimeError(PPDMDRVINS pDrvIns, uint32_t fFlags, const char *pszErrorId, const char *pszFormat, ...)
     648{
     649    PDMDRV_ASSERT_DRVINS(pDrvIns);
     650    va_list va;
     651    va_start(va, pszFormat);
     652    int rc = VMSetRuntimeErrorV(pDrvIns->Internal.s.pVMRC, fFlags, pszErrorId, pszFormat, va);
     653    va_end(va);
     654    return rc;
     655}
     656
     657
     658/** @interface_method_impl{PDMDRVHLPRC,pfnVMSetErrorV} */
     659static DECLCALLBACK(int) pdmRCDrvHlp_VMSetRuntimeErrorV(PPDMDRVINS pDrvIns, uint32_t fFlags, const char *pszErrorId, const char *pszFormat, va_list va)
     660{
     661    PDMDRV_ASSERT_DRVINS(pDrvIns);
     662    int rc = VMSetRuntimeErrorV(pDrvIns->Internal.s.pVMRC, fFlags, pszErrorId, pszFormat, va);
     663    return rc;
     664}
     665
     666
     667/** @interface_method_impl{PDMDRVHLPRC,pfnAssertEMT} */
     668static DECLCALLBACK(bool) pdmRCDrvHlp_AssertEMT(PPDMDRVINS pDrvIns, const char *pszFile, unsigned iLine, const char *pszFunction)
     669{
     670    PDMDRV_ASSERT_DRVINS(pDrvIns);
     671    if (VM_IS_EMT(pDrvIns->Internal.s.pVMRC))
     672        return true;
     673
     674    RTAssertMsg1Weak("AssertEMT", iLine, pszFile, pszFunction);
     675    RTAssertPanic();
     676    return false;
     677}
     678
     679
     680/** @interface_method_impl{PDMDRVHLPRC,pfnAssertOther} */
     681static DECLCALLBACK(bool) pdmRCDrvHlp_AssertOther(PPDMDRVINS pDrvIns, const char *pszFile, unsigned iLine, const char *pszFunction)
     682{
     683    PDMDRV_ASSERT_DRVINS(pDrvIns);
     684    if (!VM_IS_EMT(pDrvIns->Internal.s.pVMRC))
     685        return true;
     686
     687    /* Note: While we don't have any other threads but EMT(0) in RC, might
     688       still have drive code compiled in which it shouldn't execute. */
     689    RTAssertMsg1Weak("AssertOther", iLine, pszFile, pszFunction);
     690    RTAssertPanic();
     691    return false;
     692}
     693
     694
     695/**
     696 * The Raw-Mode Context Driver Helper Callbacks.
     697 */
     698extern DECLEXPORT(const PDMDRVHLPRC) g_pdmRCDrvHlp =
     699{
     700    PDM_DRVHLPRC_VERSION,
     701    pdmRCDrvHlp_VMSetError,
     702    pdmRCDrvHlp_VMSetErrorV,
     703    pdmRCDrvHlp_VMSetRuntimeError,
     704    pdmRCDrvHlp_VMSetRuntimeErrorV,
     705    pdmRCDrvHlp_AssertEMT,
     706    pdmRCDrvHlp_AssertOther,
     707    PDM_DRVHLPRC_VERSION
     708};
     709
     710/** @} */
     711
     712
     713
     714
    620715/**
    621716 * Sets an irq on the I/O APIC.
  • trunk/src/VBox/VMM/VMMR0/PDMR0Device.cpp

    r26152 r26175  
    5252extern DECLEXPORT(const PDMPCIHLPR0)    g_pdmR0PciHlp;
    5353extern DECLEXPORT(const PDMHPETHLPR0)   g_pdmR0HpetHlp;
     54extern DECLEXPORT(const PDMDRVHLPR0)    g_pdmR0DrvHlp;
    5455RT_C_DECLS_END
    5556
     
    652653
    653654
     655
     656/** @name Ring-0 Context Driver Helpers
     657 * @{
     658 */
     659
     660/** @interface_method_impl{PDMDRVHLPR0,pfnVMSetError} */
     661static DECLCALLBACK(int) pdmR0DrvHlp_VMSetError(PPDMDRVINS pDrvIns, int rc, RT_SRC_POS_DECL, const char *pszFormat, ...)
     662{
     663    PDMDRV_ASSERT_DRVINS(pDrvIns);
     664    va_list args;
     665    va_start(args, pszFormat);
     666    int rc2 = VMSetErrorV(pDrvIns->Internal.s.pVMR0, rc, RT_SRC_POS_ARGS, pszFormat, args); Assert(rc2 == rc); NOREF(rc2);
     667    va_end(args);
     668    return rc;
     669}
     670
     671
     672/** @interface_method_impl{PDMDRVHLPR0,pfnVMSetErrorV} */
     673static DECLCALLBACK(int) pdmR0DrvHlp_VMSetErrorV(PPDMDRVINS pDrvIns, int rc, RT_SRC_POS_DECL, const char *pszFormat, va_list va)
     674{
     675    PDMDRV_ASSERT_DRVINS(pDrvIns);
     676    int rc2 = VMSetErrorV(pDrvIns->Internal.s.pVMR0, rc, RT_SRC_POS_ARGS, pszFormat, va); Assert(rc2 == rc); NOREF(rc2);
     677    return rc;
     678}
     679
     680
     681/** @interface_method_impl{PDMDRVHLPR0,pfnVMSetRuntimeError} */
     682static DECLCALLBACK(int) pdmR0DrvHlp_VMSetRuntimeError(PPDMDRVINS pDrvIns, uint32_t fFlags, const char *pszErrorId, const char *pszFormat, ...)
     683{
     684    PDMDRV_ASSERT_DRVINS(pDrvIns);
     685    va_list va;
     686    va_start(va, pszFormat);
     687    int rc = VMSetRuntimeErrorV(pDrvIns->Internal.s.pVMR0, fFlags, pszErrorId, pszFormat, va);
     688    va_end(va);
     689    return rc;
     690}
     691
     692
     693/** @interface_method_impl{PDMDRVHLPR0,pfnVMSetErrorV} */
     694static DECLCALLBACK(int) pdmR0DrvHlp_VMSetRuntimeErrorV(PPDMDRVINS pDrvIns, uint32_t fFlags, const char *pszErrorId, const char *pszFormat, va_list va)
     695{
     696    PDMDRV_ASSERT_DRVINS(pDrvIns);
     697    int rc = VMSetRuntimeErrorV(pDrvIns->Internal.s.pVMR0, fFlags, pszErrorId, pszFormat, va);
     698    return rc;
     699}
     700
     701
     702/** @interface_method_impl{PDMDRVHLPR0,pfnAssertEMT} */
     703static DECLCALLBACK(bool) pdmR0DrvHlp_AssertEMT(PPDMDRVINS pDrvIns, const char *pszFile, unsigned iLine, const char *pszFunction)
     704{
     705    PDMDRV_ASSERT_DRVINS(pDrvIns);
     706    if (VM_IS_EMT(pDrvIns->Internal.s.pVMR0))
     707        return true;
     708
     709    RTAssertMsg1Weak("AssertEMT", iLine, pszFile, pszFunction);
     710    RTAssertPanic();
     711    return false;
     712}
     713
     714
     715/** @interface_method_impl{PDMDRVHLPR0,pfnAssertOther} */
     716static DECLCALLBACK(bool) pdmR0DrvHlp_AssertOther(PPDMDRVINS pDrvIns, const char *pszFile, unsigned iLine, const char *pszFunction)
     717{
     718    PDMDRV_ASSERT_DRVINS(pDrvIns);
     719    if (!VM_IS_EMT(pDrvIns->Internal.s.pVMR0))
     720        return true;
     721
     722    RTAssertMsg1Weak("AssertOther", iLine, pszFile, pszFunction);
     723    RTAssertPanic();
     724    return false;
     725}
     726
     727
     728/**
     729 * The Raw-Mode Context Driver Helper Callbacks.
     730 */
     731extern DECLEXPORT(const PDMDRVHLPR0) g_pdmR0DrvHlp =
     732{
     733    PDM_DRVHLPRC_VERSION,
     734    pdmR0DrvHlp_VMSetError,
     735    pdmR0DrvHlp_VMSetErrorV,
     736    pdmR0DrvHlp_VMSetRuntimeError,
     737    pdmR0DrvHlp_VMSetRuntimeErrorV,
     738    pdmR0DrvHlp_AssertEMT,
     739    pdmR0DrvHlp_AssertOther,
     740    PDM_DRVHLPRC_VERSION
     741};
     742
     743/** @} */
     744
     745
     746
     747
    654748/**
    655749 * Sets an irq on the I/O APIC.
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