VirtualBox

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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.
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