VirtualBox

Changeset 19500 in vbox for trunk/src/VBox


Ignore:
Timestamp:
May 7, 2009 6:23:22 PM (16 years ago)
Author:
vboxsync
Message:

TM: Moved the WarpDrive feature out of TMVirtual and made the setter ring-3 only.

Location:
trunk/src/VBox
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/MachineDebuggerImpl.cpp

    r19300 r19500  
    585585
    586586    if (pVM.isOk())
    587         *aPct = TMVirtualGetWarpDrive (pVM);
     587        *aPct = TMGetWarpDrive (pVM);
    588588    else
    589589        *aPct = 100;
     
    618618    CheckComRCReturnRC (pVM.rc());
    619619
    620     int vrc = TMVirtualSetWarpDrive (pVM, aPct);
     620    int vrc = TMR3SetWarpDrive (pVM, aPct);
    621621    if (RT_FAILURE (vrc))
    622622    {
  • trunk/src/VBox/VMM/TM.cpp

    r19497 r19500  
    166166static void                 tmR3TimerQueueRun(PVM pVM, PTMTIMERQUEUE pQueue);
    167167static void                 tmR3TimerQueueRunVirtualSync(PVM pVM);
     168static DECLCALLBACK(int)    tmR3SetWarpDrive(PVM pVM, uint32_t u32Percent);
    168169static DECLCALLBACK(void)   tmR3TimerInfo(PVM pVM, PCDBGFINFOHLP pHlp, const char *pszArgs);
    169170static DECLCALLBACK(void)   tmR3TimerInfoActive(PVM pVM, PCDBGFINFOHLP pHlp, const char *pszArgs);
     
    20472048
    20482049/**
     2050 * Sets the warp drive percent of the virtual time.
     2051 *
     2052 * @returns VBox status code.
     2053 * @param   pVM         The VM handle.
     2054 * @param   u32Percent  The new percentage. 100 means normal operation.
     2055 *
     2056 * @todo    Move to Ring-3!
     2057 */
     2058VMMDECL(int) TMR3SetWarpDrive(PVM pVM, uint32_t u32Percent)
     2059{
     2060    PVMREQ pReq;
     2061    int rc = VMR3ReqCall(pVM, VMCPUID_ANY, &pReq, RT_INDEFINITE_WAIT,
     2062                         (PFNRT)tmR3SetWarpDrive, 2, pVM, u32Percent);
     2063    if (RT_SUCCESS(rc))
     2064        rc = pReq->iStatus;
     2065    VMR3ReqFree(pReq);
     2066    return rc;
     2067}
     2068
     2069
     2070/**
     2071 * EMT worker for TMR3SetWarpDrive.
     2072 *
     2073 * @returns VBox status code.
     2074 * @param   pVM         The VM handle.
     2075 * @param   u32Percent  See TMR3SetWarpDrive().
     2076 * @internal
     2077 */
     2078static DECLCALLBACK(int) tmR3SetWarpDrive(PVM pVM, uint32_t u32Percent)
     2079{
     2080    PVMCPU pVCpu = VMMGetCpu(pVM);
     2081
     2082    /*
     2083     * Validate it.
     2084     */
     2085    AssertMsgReturn(u32Percent >= 2 && u32Percent <= 20000,
     2086                    ("%RX32 is not between 2 and 20000 (inclusive).\n", u32Percent),
     2087                    VERR_INVALID_PARAMETER);
     2088    tmLock(pVM); /* paranoia */
     2089
     2090/** @todo This isn't a feature specific to virtual time, move the variables to
     2091 * TM level and make it affect TMR3UCTNow as well! */
     2092
     2093    /*
     2094     * If the time is running we'll have to pause it before we can change
     2095     * the warp drive settings.
     2096     */
     2097    bool fPaused = !!pVM->tm.s.cVirtualTicking;
     2098    if (fPaused)
     2099    {
     2100        int rc = TMVirtualPause(pVM);
     2101        AssertRC(rc);
     2102        rc = TMCpuTickPause(pVCpu);
     2103        AssertRC(rc);
     2104    }
     2105
     2106    pVM->tm.s.u32VirtualWarpDrivePercentage = u32Percent;
     2107    pVM->tm.s.fVirtualWarpDrive = u32Percent != 100;
     2108    LogRel(("TM: u32VirtualWarpDrivePercentage=%RI32 fVirtualWarpDrive=%RTbool\n",
     2109            pVM->tm.s.u32VirtualWarpDrivePercentage, pVM->tm.s.fVirtualWarpDrive));
     2110
     2111    if (fPaused)
     2112    {
     2113        int rc = TMVirtualResume(pVM);
     2114        AssertRC(rc);
     2115        rc = TMCpuTickResume(pVCpu);
     2116        AssertRC(rc);
     2117    }
     2118
     2119    tmUnlock(pVM);
     2120    return VINF_SUCCESS;
     2121}
     2122
     2123
     2124
     2125
     2126/**
    20492127 * Display all timers.
    20502128 *
  • trunk/src/VBox/VMM/VMMAll/TMAll.cpp

    r19498 r19500  
    17141714#endif /* !VBOX_STRICT */
    17151715
     1716
     1717/**
     1718 * Gets the current warp drive percent.
     1719 *
     1720 * @returns The warp drive percent.
     1721 * @param   pVM         The VM handle.
     1722 */
     1723VMMDECL(uint32_t) TMGetWarpDrive(PVM pVM)
     1724{
     1725    return pVM->tm.s.u32VirtualWarpDrivePercentage;
     1726}
     1727
  • trunk/src/VBox/VMM/VMMAll/TMAllVirtual.cpp

    r19444 r19500  
    4141#include <iprt/asm.h>
    4242
    43 
    44 /*******************************************************************************
    45 *   Internal Functions                                                         *
    46 *******************************************************************************/
    47 static DECLCALLBACK(int) tmVirtualSetWarpDrive(PVM pVM, uint32_t u32Percent);
    4843
    4944
     
    660655
    661656/**
    662  * Gets the current warp drive percent.
    663  *
    664  * @returns The warp drive percent.
    665  * @param   pVM         The VM handle.
    666  */
    667 VMMDECL(uint32_t) TMVirtualGetWarpDrive(PVM pVM)
    668 {
    669     return pVM->tm.s.u32VirtualWarpDrivePercentage;
    670 }
    671 
    672 
    673 /**
    674  * Sets the warp drive percent of the virtual time.
    675  *
    676  * @returns VBox status code.
    677  * @param   pVM         The VM handle.
    678  * @param   u32Percent  The new percentage. 100 means normal operation.
    679  */
    680 VMMDECL(int) TMVirtualSetWarpDrive(PVM pVM, uint32_t u32Percent)
    681 {
    682 /** @todo This isn't a feature specific to virtual time, move to TM level. (It
    683  * should affect the TMR3UCTNow as well! */
    684 #ifdef IN_RING3
    685     PVMREQ pReq;
    686     int rc = VMR3ReqCall(pVM, VMCPUID_ANY, &pReq, RT_INDEFINITE_WAIT, (PFNRT)tmVirtualSetWarpDrive, 2, pVM, u32Percent);
    687     if (RT_SUCCESS(rc))
    688         rc = pReq->iStatus;
    689     VMR3ReqFree(pReq);
    690     return rc;
    691 #else
    692 
    693     return tmVirtualSetWarpDrive(pVM, u32Percent);
    694 #endif
    695 }
    696 
    697 
    698 /**
    699  * EMT worker for tmVirtualSetWarpDrive.
    700  *
    701  * @returns VBox status code.
    702  * @param   pVM         The VM handle.
    703  * @param   u32Percent  See TMVirtualSetWarpDrive().
    704  * @internal
    705  */
    706 static DECLCALLBACK(int) tmVirtualSetWarpDrive(PVM pVM, uint32_t u32Percent)
    707 {
    708     PVMCPU pVCpu = VMMGetCpu(pVM);
    709 
    710     /*
    711      * Validate it.
    712      */
    713     AssertMsgReturn(u32Percent >= 2 && u32Percent <= 20000,
    714                     ("%RX32 is not between 2 and 20000 (inclusive).\n", u32Percent),
    715                     VERR_INVALID_PARAMETER);
    716     tmLock(pVM);
    717 
    718     /*
    719      * If the time is running we'll have to pause it before we can change
    720      * the warp drive settings.
    721      */
    722     bool fPaused = !!pVM->tm.s.cVirtualTicking;
    723     if (fPaused)
    724     {
    725         int rc = TMVirtualPause(pVM);
    726         AssertRC(rc);
    727         rc = TMCpuTickPause(pVCpu);
    728         AssertRC(rc);
    729     }
    730 
    731     pVM->tm.s.u32VirtualWarpDrivePercentage = u32Percent;
    732     pVM->tm.s.fVirtualWarpDrive = u32Percent != 100;
    733     LogRel(("TM: u32VirtualWarpDrivePercentage=%RI32 fVirtualWarpDrive=%RTbool\n",
    734             pVM->tm.s.u32VirtualWarpDrivePercentage, pVM->tm.s.fVirtualWarpDrive));
    735 
    736     if (fPaused)
    737     {
    738         int rc = TMVirtualResume(pVM);
    739         AssertRC(rc);
    740         rc = TMCpuTickResume(pVCpu);
    741         AssertRC(rc);
    742     }
    743 
    744     tmUnlock(pVM);
    745     return VINF_SUCCESS;
    746 }
    747 
    748 
    749 /**
    750657 * Converts from virtual ticks to nanoseconds.
    751658 *
  • trunk/src/VBox/VMM/testcase/tstAnimate.cpp

    r19300 r19500  
    863863                    if (u32WarpDrive != 100)
    864864                    {
    865                         rc = TMVirtualSetWarpDrive(pVM, u32WarpDrive);
     865                        rc = TMR3SetWarpDrive(pVM, u32WarpDrive);
    866866                        if (RT_FAILURE(rc))
    867867                            RTPrintf("warning: TMVirtualSetWarpDrive(,%u) -> %Rrc\n", u32WarpDrive, rc);
  • trunk/src/VBox/VMM/testcase/tstVMM.cpp

    r19467 r19500  
    105105            PTMTIMER pTimer = apTimers[i];
    106106
    107             if (cLeft == RT_ELEMENTS(apTimers) / 2
    108                 && TMTimerIsActive(pTimer))
     107            if (    cLeft == RT_ELEMENTS(apTimers) / 2
     108                &&  TMTimerIsActive(pTimer))
    109109            {
    110                 rc = TMTimerStop(pTimer);
    111                 RTTEST_CHECK_MSG(hTest, RT_SUCCESS(rc), (hTest, "TMTimerStop: %Rrc\n",  rc));
     110//                rc = TMTimerStop(pTimer);
     111//                RTTEST_CHECK_MSG(hTest, RT_SUCCESS(rc), (hTest, "TMTimerStop: %Rrc\n",  rc));
    112112            }
    113113            else
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