VirtualBox

Changeset 42196 in vbox


Ignore:
Timestamp:
Jul 18, 2012 6:25:55 AM (13 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
79201
Message:

Devices/DevAHCI: fix for the failure to load old saved states.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/Storage/DevAHCI.cpp

    r42104 r42196  
    7070
    7171/** The current saved state version. */
    72 #define AHCI_SAVED_STATE_VERSION                5
     72#define AHCI_SAVED_STATE_VERSION                6
     73/** Saved state version before legacy ATA emulation was dropped. */
     74#define AHCI_SAVED_STATE_VERSION_IDE_EMULATION  5
    7375/** Saved state version before ATAPI support was added. */
    7476#define AHCI_SAVED_STATE_VERSION_PRE_ATAPI      3
     
    7678 * This was before the config was added and ahciIOTasks was dropped. */
    7779#define AHCI_SAVED_STATE_VERSION_VBOX_30        2
    78 
     80/* for Older ATA state Read handling */
     81#define ATA_CTL_SAVED_STATE_VERSION 3
     82#define ATA_CTL_SAVED_STATE_VERSION_WITHOUT_FULL_SENSE 1
     83#define ATA_CTL_SAVED_STATE_VERSION_WITHOUT_EVENT_STATUS 2
    7984/**
    8085 * Maximum number of sectors to transfer in a READ/WRITE MULTIPLE request.
     
    67136718
    67146719/**
     6720 * Loads a saved legacy ATA emulated device state.
     6721 *
     6722 * @returns VBox status code.
     6723 * @param   pSSM  The handle to the saved state.
     6724 */
     6725int ahciR3LoadLegacyEmulationState(PSSMHANDLE pSSM)
     6726{
     6727    int             rc;
     6728    uint32_t        u32Version;
     6729    uint32_t        u32;
     6730    uint32_t        u32IOBuffer;
     6731
     6732        /* Test for correct version. */
     6733    rc = SSMR3GetU32(pSSM, &u32Version);
     6734    AssertRCReturn(rc, rc);
     6735    LogFlow(("LoadOldSavedStates u32Version = %d\n", u32Version));
     6736
     6737    if (u32Version != ATA_CTL_SAVED_STATE_VERSION
     6738        && u32Version != ATA_CTL_SAVED_STATE_VERSION_WITHOUT_FULL_SENSE
     6739        && u32Version != ATA_CTL_SAVED_STATE_VERSION_WITHOUT_EVENT_STATUS)
     6740    {
     6741        AssertMsgFailed(("u32Version=%d\n", u32Version));
     6742        return VERR_SSM_UNSUPPORTED_DATA_UNIT_VERSION;
     6743    }
     6744
     6745    SSMR3Skip(pSSM, 19 + 5 * sizeof(bool) + sizeof(BMDMAState));
     6746
     6747    for (uint32_t j = 0; j < 2; j++)
     6748    {
     6749        SSMR3Skip(pSSM, 88 + 5 * sizeof(bool) );
     6750
     6751        if (u32Version > ATA_CTL_SAVED_STATE_VERSION_WITHOUT_FULL_SENSE)
     6752        {
     6753            SSMR3Skip(pSSM, 64);
     6754        }
     6755        else
     6756        {
     6757            SSMR3Skip(pSSM, 2);
     6758        }
     6759        /** @todo triple-check this hack after passthrough is working */
     6760        SSMR3Skip(pSSM, 1);
     6761
     6762        if (u32Version > ATA_CTL_SAVED_STATE_VERSION_WITHOUT_EVENT_STATUS)
     6763            SSMR3Skip(pSSM, 4);
     6764
     6765        SSMR3Skip(pSSM, sizeof(PDMLED));
     6766        SSMR3GetU32(pSSM, &u32IOBuffer);
     6767        if (u32IOBuffer)
     6768        {
     6769            /* skip the buffer . IO Buffer is not required.. */
     6770            uint8_t u8Ignored;
     6771            size_t cbLeft = u32IOBuffer;
     6772            while (cbLeft-- > 0)
     6773                SSMR3GetU8(pSSM, &u8Ignored);
     6774        }
     6775    }
     6776
     6777    rc = SSMR3GetU32(pSSM, &u32);
     6778    if (RT_FAILURE(rc))
     6779        return rc;
     6780    if (u32 != ~0U)
     6781    {
     6782        AssertMsgFailed(("u32=%#x expected ~0\n", u32));
     6783        rc = VERR_SSM_DATA_UNIT_FORMAT_CHANGED;
     6784        return rc;
     6785    }
     6786
     6787    return VINF_SUCCESS;
     6788}
     6789
     6790/**
    67156791 * Loads a saved AHCI device state.
    67166792 *
     
    68496925                SSMR3Skip(pSSM, AHCI_NR_COMMAND_SLOTS * sizeof(uint8_t)); /* no active data here */
    68506926
    6851             if (uVersion < AHCI_SAVED_STATE_VERSION)
     6927            if (uVersion < AHCI_SAVED_STATE_VERSION_IDE_EMULATION)
    68526928            {
    68536929                /* The old positions in the FIFO, not required. */
     
    68586934            SSMR3GetU32(pSSM, (uint32_t *)&pThis->ahciPort[i].u32TasksFinished);
    68596935            SSMR3GetU32(pSSM, (uint32_t *)&pThis->ahciPort[i].u32QueuedTasksFinished);
    6860             if (uVersion >= AHCI_SAVED_STATE_VERSION)
     6936
     6937            if (uVersion >= AHCI_SAVED_STATE_VERSION_IDE_EMULATION)
    68616938                SSMR3GetU32(pSSM, (uint32_t *)&pThis->ahciPort[i].u32CurrentCommandSlot);
    68626939
     
    68866963            }
    68876964        }
     6965
     6966        if (uVersion <= AHCI_SAVED_STATE_VERSION_IDE_EMULATION)
     6967        {
     6968
     6969            for (uint32_t i = 0; i < RT_ELEMENTS(pThis->aCts); i++)
     6970                        {
     6971                                rc = ahciR3LoadLegacyEmulationState(pSSM);
     6972                                if(RT_FAILURE(rc))
     6973                                        return rc;
     6974                        }
     6975                }
     6976
    68886977                rc = SSMR3GetU32(pSSM, &u32);
    68896978        if (RT_FAILURE(rc))
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