VirtualBox

Changeset 75134 in vbox for trunk/src/VBox/Devices/Serial


Ignore:
Timestamp:
Oct 28, 2018 7:14:47 PM (6 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
126211
Message:

DevSerial,UartCore: Attempt and getting old states to load. Needs proper testing that includes live saved states/migration.

Location:
trunk/src/VBox/Devices/Serial
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/Serial/DevSerial.cpp

    r74754 r75134  
    184184{
    185185    PDEVSERIAL pThis = PDMINS_2_DATA(pDevIns, PDEVSERIAL);
    186     uint8_t    uIrq;
     186    uint8_t    bIrq;
    187187    RTIOPORT   PortBase;
    188188    UARTTYPE   enmType;
     189    int rc;
    189190
    190191    AssertMsgReturn(uVersion >= UART_SAVED_STATE_VERSION_16450, ("%d\n", uVersion), VERR_SSM_UNSUPPORTED_DATA_UNIT_VERSION);
    191 
    192     if (uPass != SSM_PASS_FINAL)
    193     {
    194         SSMR3GetU8(pSSM, &uIrq);
     192    if (uVersion > UART_SAVED_STATE_VERSION_LEGACY_CODE)
     193    {
     194        SSMR3GetU8(    pSSM, &bIrq);
    195195        SSMR3GetIOPort(pSSM, &PortBase);
    196         int rc = SSMR3GetU32(pSSM, (uint32_t *)&enmType);
     196        rc = SSMR3GetU32(   pSSM, (uint32_t *)&enmType);
    197197        AssertRCReturn(rc, rc);
     198        if (uPass == SSM_PASS_FINAL)
     199        {
     200            rc = uartR3LoadExec(&pThis->UartCore, pSSM, uVersion, uPass, NULL, NULL);
     201            AssertRCReturn(rc, rc);
     202        }
    198203    }
    199204    else
    200205    {
    201         int rc = VINF_SUCCESS;
    202 
    203         if (uVersion > UART_SAVED_STATE_VERSION_LEGACY_CODE)
     206        enmType = uVersion > UART_SAVED_STATE_VERSION_16450 ? UARTTYPE_16550A : UARTTYPE_16450;
     207        if (uPass != SSM_PASS_FINAL)
    204208        {
    205             SSMR3GetU8(    pSSM, &uIrq);
    206             SSMR3GetIOPort(pSSM, &PortBase);
    207             SSMR3GetU32(   pSSM, (uint32_t *)&enmType);
    208             rc = uartR3LoadExec(&pThis->UartCore, pSSM, uVersion, uPass, NULL, NULL);
     209            int32_t iIrqTmp;
     210            SSMR3GetS32(pSSM, &iIrqTmp);
     211            uint32_t uPortBaseTmp;
     212            rc = SSMR3GetU32(pSSM, &uPortBaseTmp);
     213            AssertRCReturn(rc, rc);
     214
     215            bIrq     = (uint8_t)iIrqTmp;
     216            PortBase = (uint32_t)uPortBaseTmp;
    209217        }
    210218        else
    211219        {
    212             if (uVersion > UART_SAVED_STATE_VERSION_16450)
    213                 enmType = UARTTYPE_16550A;
    214             else
    215                 enmType = UARTTYPE_16450;
    216             rc = uartR3LoadExec(&pThis->UartCore, pSSM, uVersion, uPass, &uIrq, &PortBase);
     220            rc = uartR3LoadExec(&pThis->UartCore, pSSM, uVersion, uPass, &bIrq, &PortBase);
     221            AssertRCReturn(rc, rc);
    217222        }
    218         if (RT_SUCCESS(rc))
    219         {
    220             /* The marker. */
    221             uint32_t u32;
    222             rc = SSMR3GetU32(pSSM, &u32);
    223             if (RT_FAILURE(rc))
    224                 return rc;
    225             AssertMsgReturn(u32 == UINT32_MAX, ("%#x\n", u32), VERR_SSM_DATA_UNIT_FORMAT_CHANGED);
    226         }
     223    }
     224
     225    if (uPass == SSM_PASS_FINAL)
     226    {
     227        /* The marker. */
     228        uint32_t u32;
     229        rc = SSMR3GetU32(pSSM, &u32);
     230        AssertRCReturn(rc, rc);
     231        AssertMsgReturn(u32 == UINT32_MAX, ("%#x\n", u32), VERR_SSM_DATA_UNIT_FORMAT_CHANGED);
    227232    }
    228233
     
    230235     * Check the config.
    231236     */
    232     if (    pThis->uIrq     != uIrq
     237    if (    pThis->uIrq     != bIrq
    233238        ||  pThis->PortBase != PortBase
    234239        ||  pThis->UartCore.enmType != enmType)
    235240        return SSMR3SetCfgError(pSSM, RT_SRC_POS,
    236241                                N_("Config mismatch - saved IRQ=%#x PortBase=%#x Type=%d; configured IRQ=%#x PortBase=%#x Type=%d"),
    237                                 uIrq, PortBase, enmType, pThis->uIrq, pThis->PortBase, pThis->UartCore.enmType);
     242                                bIrq, PortBase, enmType, pThis->uIrq, pThis->PortBase, pThis->UartCore.enmType);
    238243
    239244    return VINF_SUCCESS;
  • trunk/src/VBox/Devices/Serial/UartCore.cpp

    r74919 r75134  
    15821582
    15831583DECLHIDDEN(int) uartR3LoadExec(PUARTCORE pThis, PSSMHANDLE pSSM, uint32_t uVersion, uint32_t uPass,
    1584                                uint8_t *puIrq, RTIOPORT *pPortBase)
     1584                               uint8_t *pbIrq, RTIOPORT *pPortBase)
    15851585{
    15861586    RT_NOREF(uPass);
    1587     int rc = VINF_SUCCESS;
     1587    int rc;
    15881588
    15891589    if (uVersion > UART_SAVED_STATE_VERSION_LEGACY_CODE)
     
    16071607        SSMR3GetU8(pSSM,   &pThis->FifoRecv.cbItl);
    16081608
    1609         TMR3TimerLoad(pThis->pTimerRcvFifoTimeoutR3, pSSM);
     1609        rc = TMR3TimerLoad(pThis->pTimerRcvFifoTimeoutR3, pSSM);
    16101610        if (uVersion > UART_SAVED_STATE_VERSION_PRE_UNCONNECTED_TX_TIMER)
    1611             TMR3TimerLoad(pThis->pTimerTxUnconnectedR3, pSSM);
     1611            rc = TMR3TimerLoad(pThis->pTimerTxUnconnectedR3, pSSM);
    16121612    }
    16131613    else
    16141614    {
     1615        AssertPtr(pbIrq);
     1616        AssertPtr(pPortBase);
    16151617        if (uVersion == UART_SAVED_STATE_VERSION_16450)
    16161618        {
     
    16181620            LogRel(("Serial#%d: falling back to 16450 mode from load state\n", pThis->pDevInsR3->iInstance));
    16191621        }
    1620 
    1621         int      uIrq;
    1622         int32_t  iTmp;
    1623         uint32_t PortBase;
    16241622
    16251623        SSMR3GetU16(pSSM, &pThis->uRegDivisor);
     
    16331631        if (uVersion > UART_SAVED_STATE_VERSION_16450)
    16341632            SSMR3GetU8(pSSM, &pThis->uRegFcr);
     1633
     1634        int32_t iTmp = 0;
    16351635        SSMR3GetS32(pSSM, &iTmp);
    16361636        pThis->fThreEmptyPending = RT_BOOL(iTmp);
    1637         SSMR3GetS32(pSSM, &uIrq);
    1638         SSMR3Skip(pSSM, sizeof(int32_t));
    1639         SSMR3GetU32(pSSM, &PortBase);
    1640         rc = SSMR3Skip(pSSM, sizeof(int32_t));
    1641 
     1637
     1638        rc = SSMR3GetS32(pSSM, &iTmp);
     1639        AssertRCReturn(rc, rc);
     1640        *pbIrq = (uint8_t)iTmp;
     1641
     1642        SSMR3Skip(pSSM, sizeof(int32_t)); /* was: last_break_enable */
     1643
     1644        uint32_t uPortBaseTmp = 0;
     1645        rc = SSMR3GetU32(pSSM, &uPortBaseTmp);
     1646        AssertRCReturn(rc, rc);
     1647        *pPortBase = (RTIOPORT)uPortBaseTmp;
     1648
     1649        rc = SSMR3Skip(pSSM, sizeof(bool)); /* was: msr_changed */
    16421650        if (   RT_SUCCESS(rc)
    16431651            && uVersion > UART_SAVED_STATE_VERSION_MISSING_BITS)
     
    16471655            SSMR3GetU8(pSSM, &pThis->uRegIir);
    16481656
    1649             int iTimeoutPending = 0;
     1657            int32_t iTimeoutPending = 0;
    16501658            SSMR3GetS32(pSSM, &iTimeoutPending);
    16511659            pThis->fIrqCtiPending = RT_BOOL(iTimeoutPending);
    16521660
    1653             TMR3TimerLoad(pThis->pTimerRcvFifoTimeoutR3, pSSM);
    1654             TMR3TimerSkip(pSSM, NULL);
     1661            rc = TMR3TimerLoad(pThis->pTimerRcvFifoTimeoutR3, pSSM);
     1662            AssertRCReturn(rc, rc);
     1663
     1664            bool fWasActiveIgn;
     1665            rc = TMR3TimerSkip(pSSM, &fWasActiveIgn);  /* was: transmit_timerR3 */
     1666            AssertRCReturn(rc, rc);
     1667
    16551668            SSMR3GetU8(pSSM, &pThis->FifoRecv.cbItl);
    16561669            rc = SSMR3GetU8(pSSM, &pThis->FifoRecv.cbItl);
    1657         }
    1658 
    1659         if (RT_SUCCESS(rc))
    1660         {
    1661             AssertPtr(puIrq);
    1662             AssertPtr(pPortBase);
    1663             *puIrq     = (uint8_t)uIrq;
    1664             *pPortBase = (RTIOPORT)PortBase;
    16651670        }
    16661671    }
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