Changeset 81541 in vbox
- Timestamp:
- Oct 25, 2019 1:30:49 PM (6 years ago)
- svn:sync-xref-src-repo-rev:
- 134274
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/USB/DevOHCI.cpp
r81536 r81541 113 113 *********************************************************************************************************************************/ 114 114 /** The current saved state version. */ 115 #define OHCI_SAVED_STATE_VERSION 5 /* Introduced post-4.3. */ 116 /** The saved state with support of up to 8 ports. */ 117 #define OHCI_SAVED_STATE_VERSION_8PORTS 4 /* Introduced in 3.1 or so. */ 115 #define OHCI_SAVED_STATE_VERSION OHCI_SAVED_STATE_VERSION_NO_EOF_TIMER 116 /** The current saved state version. 117 * @since 6.1.0beta3/rc1 */ 118 #define OHCI_SAVED_STATE_VERSION_NO_EOF_TIMER 6 119 /** The current saved with the start-of-frame timer. 120 * @since 4.3.x */ 121 #define OHCI_SAVED_STATE_VERSION_EOF_TIMER 5 122 /** The saved state with support of up to 8 ports. 123 * @since 3.1 or so */ 124 #define OHCI_SAVED_STATE_VERSION_8PORTS 4 118 125 119 126 … … 269 276 typedef struct OHCI 270 277 { 271 /** The End-Of-Frame timer. */272 TMTIMERHANDLE hEndOfFrameTimer;273 274 278 /** Start of current frame. */ 275 279 uint64_t SofTime; … … 332 336 /** @} */ 333 337 338 /** This member and all the following are not part of saved state. */ 339 uint64_t SavedStateEnd; 340 334 341 /** The number of virtual time ticks per frame. */ 335 342 uint64_t cTicksPerFrame; … … 345 352 /** Profiling ohciR3FrameBoundaryTimer. */ 346 353 STAMPROFILE StatTimer; 347 348 /** This member and all the following are not part of saved state. */349 uint64_t SavedStateEnd;350 354 351 355 /** VM timer frequency used for frame timer calculations. */ … … 423 427 /** Pointer to state load data. */ 424 428 R3PTRTYPE(POHCILOAD) pLoad; 429 /** The restored periodic frame rate. */ 430 uint32_t uRestoredPeriodicFrameRate; 425 431 } OHCIR3; 426 432 /** Pointer to ring-3 OHCI state. */ … … 4491 4497 case OHCI_USB_OPERATIONAL: 4492 4498 LogRel(("OHCI: USB Operational\n")); 4493 ohciR3BusStart(pDevIns, pThis, 4499 ohciR3BusStart(pDevIns, pThis, pThisCC); 4494 4500 break; 4495 4501 case OHCI_USB_SUSPEND: … … 5595 5601 } 5596 5602 } 5597 5598 /*5599 * If the bus was started set the timer. This is ugly but avoids changing the5600 * saved state version for now so we can backport the changes to other branches.5601 */5602 /** @todo Do it properly for 4.4 by changing the saved state. */5603 if (VUSBIRhGetPeriodicFrameRate(pThisCC->RootHub.pIRhConn) != 0)5604 {5605 /* Calculate a new timer expiration so this saved state works with older releases. */5606 uint64_t u64Expire = PDMDevHlpTMTimeVirtGet(pDevIns) + pThis->cTicksPerFrame;5607 5608 LogFlowFunc(("Bus is active, setting timer to %llu\n", u64Expire));5609 int rc = PDMDevHlpTimerSet(pDevIns, pThis->hEndOfFrameTimer, u64Expire);5610 AssertRC(rc);5611 }5612 5613 5603 PDMDevHlpCritSectLeave(pDevIns, pDevIns->pCritSectRoR3); 5614 5604 … … 5635 5625 static DECLCALLBACK(int) ohciR3SaveExec(PPDMDEVINS pDevIns, PSSMHANDLE pSSM) 5636 5626 { 5637 POHCI pThis = PDMINS_2_DATA(pDevIns, POHCI); 5638 PCPDMDEVHLPR3 pHlp = pDevIns->pHlpR3; 5639 LogFlow(("ohciR3SaveExec: \n")); 5640 5641 int rc = pHlp->pfnSSMPutStructEx(pSSM, pThis, sizeof(*pThis), 0 /*fFlags*/, &g_aOhciFields[0], NULL); 5642 if (RT_SUCCESS(rc)) 5643 rc = PDMDevHlpTimerSave(pDevIns, pThis->hEndOfFrameTimer, pSSM); 5644 return rc; 5627 POHCI pThis = PDMINS_2_DATA(pDevIns, POHCI); 5628 POHCICC pThisCC = PDMINS_2_DATA_CC(pDevIns, POHCICC); 5629 LogFlow(("ohciR3SaveExec:\n")); 5630 5631 int rc = pDevIns->pHlpR3->pfnSSMPutStructEx(pSSM, pThis, sizeof(*pThis), 0 /*fFlags*/, &g_aOhciFields[0], NULL); 5632 AssertRCReturn(rc, rc); 5633 5634 /* Save the periodic frame rate so we can we can tell if the bus was started or not when restoring. */ 5635 return pDevIns->pHlpR3->pfnSSMPutU32(pSSM, VUSBIRhGetPeriodicFrameRate(pThisCC->RootHub.pIRhConn)); 5645 5636 } 5646 5637 … … 5664 5655 */ 5665 5656 POHCIROOTHUB pRh = &pThis->RootHub; 5666 OHCIROOTHUB Rh = *pRh;5657 OHCIROOTHUB Rh = *pRh; 5667 5658 for (unsigned i = 0; i < RT_ELEMENTS(pRh->aPorts); i++) 5668 5659 { … … 5753 5744 static DECLCALLBACK(int) ohciR3LoadExec(PPDMDEVINS pDevIns, PSSMHANDLE pSSM, uint32_t uVersion, uint32_t uPass) 5754 5745 { 5755 POHCI pThis = PDMINS_2_DATA(pDevIns, POHCI); 5756 PCPDMDEVHLPR3 pHlp = pDevIns->pHlpR3; 5746 POHCI pThis = PDMINS_2_DATA(pDevIns, POHCI); 5747 POHCICC pThisCC = PDMINS_2_DATA_CC(pDevIns, POHCICC); 5748 PCPDMDEVHLPR3 pHlp = pDevIns->pHlpR3; 5757 5749 int rc; 5758 5750 LogFlow(("ohciR3LoadExec:\n")); 5751 5759 5752 Assert(uPass == SSM_PASS_FINAL); NOREF(uPass); 5760 5753 5761 if (uVersion == OHCI_SAVED_STATE_VERSION) 5762 { 5754 if (uVersion >= OHCI_SAVED_STATE_VERSION_EOF_TIMER) 5763 5755 rc = pHlp->pfnSSMGetStructEx(pSSM, pThis, sizeof(*pThis), 0 /*fFlags*/, &g_aOhciFields[0], NULL); 5764 if (RT_FAILURE(rc))5765 return rc;5766 }5767 5756 else if (uVersion == OHCI_SAVED_STATE_VERSION_8PORTS) 5768 {5769 5757 rc = pHlp->pfnSSMGetStructEx(pSSM, pThis, sizeof(*pThis), 0 /*fFlags*/, &g_aOhciFields8Ports[0], NULL); 5770 if (RT_FAILURE(rc))5771 return rc;5772 }5773 5758 else 5774 5759 AssertMsgFailedReturn(("%d\n", uVersion), VERR_SSM_UNSUPPORTED_DATA_UNIT_VERSION); 5775 5776 /* 5777 * Finally restore the timer. 5778 */ 5779 return PDMDevHlpTimerLoad(pDevIns, pThis->hEndOfFrameTimer, pSSM); 5760 AssertRCReturn(rc, rc); 5761 5762 /* 5763 * Get the frame rate / started indicator. 5764 * 5765 * For older versions there is a timer saved here. We'll skip it and deduce 5766 * the periodic frame rate from the host controller functional state. 5767 */ 5768 if (uVersion > OHCI_SAVED_STATE_VERSION_EOF_TIMER) 5769 { 5770 rc = pHlp->pfnSSMGetU32(pSSM, &pThisCC->uRestoredPeriodicFrameRate); 5771 AssertRCReturn(rc, rc); 5772 } 5773 else 5774 { 5775 rc = pHlp->pfnSSMSkipToEndOfUnit(pSSM); 5776 AssertRCReturn(rc, rc); 5777 5778 uint32_t fHcfs = pThis->ctl & OHCI_CTL_HCFS; 5779 switch (fHcfs) 5780 { 5781 case OHCI_USB_OPERATIONAL: 5782 case OHCI_USB_RESUME: 5783 pThisCC->uRestoredPeriodicFrameRate = OHCI_DEFAULT_TIMER_FREQ; 5784 break; 5785 default: 5786 pThisCC->uRestoredPeriodicFrameRate = 0; 5787 break; 5788 } 5789 } 5790 5791 /** @todo could we restore the frame rate here instead of in ohciR3Resume? */ 5792 return VINF_SUCCESS; 5780 5793 } 5781 5794 … … 5869 5882 static DECLCALLBACK(void) ohciR3Resume(PPDMDEVINS pDevIns) 5870 5883 { 5871 POHCI pThis = PDMINS_2_DATA(pDevIns, POHCI);5872 5884 POHCICC pThisCC = PDMINS_2_DATA_CC(pDevIns, POHCICC); 5873 5885 LogFlowFunc(("\n")); 5874 5886 5875 /* Restart the frame thread if the timer is active. */ 5876 if (PDMDevHlpTimerIsActive(pDevIns, pThis->hEndOfFrameTimer)) 5877 { 5878 int rc = PDMDevHlpTimerStop(pDevIns, pThis->hEndOfFrameTimer); 5879 AssertRC(rc); 5880 5881 LogFlowFunc(("Bus was active, enable periodic frame processing\n")); 5882 rc = pThisCC->RootHub.pIRhConn->pfnSetPeriodicFrameProcessing(pThisCC->RootHub.pIRhConn, OHCI_DEFAULT_TIMER_FREQ); 5887 /* Restart the frame thread if it was active when the loaded state was saved. */ 5888 uint32_t uRestoredPeriodicFR = pThisCC->uRestoredPeriodicFrameRate; 5889 pThisCC->uRestoredPeriodicFrameRate = 0; 5890 if (uRestoredPeriodicFR) 5891 { 5892 LogFlowFunc(("Bus was active, enable periodic frame processing (rate: %u)\n", uRestoredPeriodicFR)); 5893 int rc = pThisCC->RootHub.pIRhConn->pfnSetPeriodicFrameProcessing(pThisCC->RootHub.pIRhConn, uRestoredPeriodicFR); 5883 5894 AssertRC(rc); 5884 5895 } … … 6085 6096 6086 6097 /* 6087 * Create the end-of-frame timer.6088 */6089 rc = PDMDevHlpTimerCreate(pDevIns, TMCLOCK_VIRTUAL, ohciR3FrameBoundaryTimer, pThis,6090 TMTIMER_FLAGS_DEFAULT_CRIT_SECT, "USB Frame Timer", &pThis->hEndOfFrameTimer);6091 AssertRCReturn(rc, rc);6092 6093 /*6094 6098 * Register the saved state data unit. 6095 6099 */ … … 6137 6141 6138 6142 /* 6139 * Calculate the timer intervals.6140 * This assumes that the VM timer doesn't change frequency during the run.6141 */ 6142 pThis->u64TimerHz = PDMDevHlpT imerGetFreq(pDevIns, pThis->hEndOfFrameTimer);6143 * Take down the virtual clock frequence for use in ohciR3FrameRateChanged(). 6144 * (Used to be a timer, thus the name.) 6145 */ 6146 pThis->u64TimerHz = PDMDevHlpTMTimeVirtGetFreq(pDevIns); 6143 6147 6144 6148 /*
Note:
See TracChangeset
for help on using the changeset viewer.