VirtualBox

Changeset 44510 in vbox for trunk/src


Ignore:
Timestamp:
Feb 1, 2013 1:24:40 PM (12 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
83547
Message:

PDM takes the RTC cirtical section before calling the PDMRTCREG callbacks. Documented DMA and IOAPIC locking.

Location:
trunk/src/VBox
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/PC/DevRTC.cpp

    r43241 r44510  
    897897static void rtcCalcCRC(RTCState *pThis)
    898898{
    899     uint16_t u16;
    900     unsigned i;
    901 
    902     for (i = RTC_CRC_START, u16 = 0; i <= RTC_CRC_LAST; i++)
     899    uint16_t u16 = 0;
     900    for (unsigned i = RTC_CRC_START; i <= RTC_CRC_LAST; i++)
    903901        u16 += pThis->cmos_data[i];
     902
    904903    pThis->cmos_data[RTC_CRC_LOW]  = u16 & 0xff;
    905904    pThis->cmos_data[RTC_CRC_HIGH] = (u16 >> 8) & 0xff;
     
    908907
    909908/**
    910  * Write to a CMOS register and update the checksum if necessary.
    911  *
    912  * @returns VBox status code.
    913  * @param   pDevIns     Device instance of the RTC.
    914  * @param   iReg        The CMOS register index; bit 8 determines bank.
    915  * @param   u8Value     The CMOS register value.
     909 * @interface_method_impl{PDMRTCREG,pfnWrite}
    916910 */
    917911static DECLCALLBACK(int) rtcCMOSWrite(PPDMDEVINS pDevIns, unsigned iReg, uint8_t u8Value)
    918912{
    919913    RTCState *pThis = PDMINS_2_DATA(pDevIns, RTCState *);
     914    Assert(PDMCritSectIsOwner(pDevIns->pCritSectRoR3));
    920915    if (iReg < RT_ELEMENTS(pThis->cmos_data))
    921916    {
    922         PDMCritSectEnter(pDevIns->pCritSectRoR3, VERR_IGNORED);
    923 
    924917        pThis->cmos_data[iReg] = u8Value;
    925918
     
    929922            rtcCalcCRC(pThis);
    930923
    931         PDMCritSectLeave(pDevIns->pCritSectRoR3);
    932924        return VINF_SUCCESS;
    933925    }
     
    939931
    940932/**
    941  * Read a CMOS register.
    942  *
    943  * @returns VBox status code.
    944  * @param   pDevIns     Device instance of the RTC.
    945  * @param   iReg        The CMOS register index; bit 8 determines bank.
    946  * @param   pu8Value    Where to store the CMOS register value.
     933 * @interface_method_impl{PDMRTCREG,pfnRead}
    947934 */
    948935static DECLCALLBACK(int) rtcCMOSRead(PPDMDEVINS pDevIns, unsigned iReg, uint8_t *pu8Value)
    949936{
    950937    RTCState   *pThis = PDMINS_2_DATA(pDevIns, RTCState *);
     938    Assert(PDMCritSectIsOwner(pDevIns->pCritSectRoR3));
     939
    951940    if (iReg < RT_ELEMENTS(pThis->cmos_data))
    952941    {
    953         PDMCritSectEnter(pDevIns->pCritSectRoR3, VERR_IGNORED);
    954 
    955942        *pu8Value = pThis->cmos_data[iReg];
    956 
    957         PDMCritSectLeave(pDevIns->pCritSectRoR3);
    958943        return VINF_SUCCESS;
    959944    }
  • trunk/src/VBox/VMM/VMMR3/PDMDevHlp.cpp

    r44508 r44510  
    19841984    int rc;
    19851985    if (pVM->pdm.s.pRtc)
    1986         rc = pVM->pdm.s.pRtc->Reg.pfnWrite(pVM->pdm.s.pRtc->pDevIns, iReg, u8Value);
     1986    {
     1987        PPDMDEVINS pDevInsRtc = pVM->pdm.s.pRtc->pDevIns;
     1988        rc = PDMCritSectEnter(pDevInsRtc->pCritSectRoR3, VERR_IGNORED);
     1989        if (RT_SUCCESS(rc))
     1990        {
     1991            rc = pVM->pdm.s.pRtc->Reg.pfnWrite(pDevInsRtc, iReg, u8Value);
     1992            PDMCritSectLeave(pDevInsRtc->pCritSectRoR3);
     1993        }
     1994    }
    19871995    else
    19881996        rc = VERR_PDM_NO_RTC_INSTANCE;
     
    20052013    int rc;
    20062014    if (pVM->pdm.s.pRtc)
    2007         rc = pVM->pdm.s.pRtc->Reg.pfnRead(pVM->pdm.s.pRtc->pDevIns, iReg, pu8Value);
     2015    {
     2016        PPDMDEVINS pDevInsRtc = pVM->pdm.s.pRtc->pDevIns;
     2017        rc = PDMCritSectEnter(pDevInsRtc->pCritSectRoR3, VERR_IGNORED);
     2018        if (RT_SUCCESS(rc))
     2019        {
     2020            rc = pVM->pdm.s.pRtc->Reg.pfnRead(pDevInsRtc, iReg, pu8Value);
     2021            PDMCritSectLeave(pDevInsRtc->pCritSectRoR3);
     2022        }
     2023    }
    20082024    else
    20092025        rc = VERR_PDM_NO_RTC_INSTANCE;
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