VirtualBox

Ignore:
Timestamp:
Oct 22, 2009 2:19:37 PM (15 years ago)
Author:
vboxsync
Message:

DevVGA: Save and verify the basic config.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/Graphics/DevVGA.cpp

    r23793 r23985  
    26362636    uint32_t u32Dummy;
    26372637
     2638#ifndef VBOX /* checked by the caller. */
    26382639    if (version_id > VGA_SAVEDSTATE_VERSION)
    2639 #ifndef VBOX
    26402640        return -EINVAL;
    2641 #else /* VBOX */
    2642     {
    2643         Log(("vga_load: version_id=%d - UNKNOWN\n", version_id));
    2644         return VERR_SSM_UNSUPPORTED_DATA_UNIT_VERSION;
    2645     }
    26462641#endif /* VBOX */
    26472642
     
    46074602
    46084603    src = pThis->vram_ptrR3;
    4609     if (src) {
    4610         for (col = 0; col < num_cols; ++col) pHlp->pfnPrintf(pHlp, "-"); pHlp->pfnPrintf(pHlp, "\n");
     4604    if (src)
     4605    {
     4606        for (col = 0; col < num_cols; ++col)
     4607            pHlp->pfnPrintf(pHlp, "-");
     4608        pHlp->pfnPrintf(pHlp, "\n");
    46114609        for (row = 0; row < num_rows; ++row)
    46124610        {
     
    46184616            pHlp->pfnPrintf(pHlp, "\n");
    46194617        }
    4620         for (col = 0; col < num_cols; ++col) pHlp->pfnPrintf(pHlp, "-"); pHlp->pfnPrintf(pHlp, "\n");
     4618        for (col = 0; col < num_cols; ++col)
     4619            pHlp->pfnPrintf(pHlp, "-");
     4620        pHlp->pfnPrintf(pHlp, "\n");
    46214621    }
    46224622    else
     
    53445344
    53455345
    5346 /* -=-=-=-=-=- Ring3: Misc Wrappers -=-=-=-=-=- */
     5346/* -=-=-=-=-=- Ring3: Misc Wrappers & Sidekicks -=-=-=-=-=- */
    53475347
    53485348/**
    5349  * Saves a state of the VGA device.
    5350  *
    5351  * @returns VBox status code.
    5352  * @param   pDevIns     The device instance.
    5353  * @param   pSSMHandle  The handle to save the state to.
     5349 * Saves a important bits of the VGA device config.
     5350 *
     5351 * @param   pThis       The VGA instance data.
     5352 * @param   pSSM        The saved state handle.
    53545353 */
    5355 static DECLCALLBACK(int) vgaR3SaveExec(PPDMDEVINS pDevIns, PSSMHANDLE pSSMHandle)
    5356 {
    5357     vga_save(pSSMHandle, PDMINS_2_DATA(pDevIns, PVGASTATE));
    5358 #ifdef VBOX_WITH_HGSMI
    5359     return vboxVBVASaveStateExec(pDevIns, pSSMHandle);
     5354static void vgaR3SaveConfig(PVGASTATE pThis, PSSMHANDLE pSSM)
     5355{
     5356    SSMR3PutU32(pSSM, pThis->vram_size);
     5357    SSMR3PutU32(pSSM, pThis->cMonitors);
     5358}
     5359
     5360
     5361/**
     5362 * @copydoc FNSSMDEVLIVEEXEC
     5363 */
     5364static DECLCALLBACK(int) vgaR3LiveExec(PPDMDEVINS pDevIns, PSSMHANDLE pSSM, uint32_t uPass)
     5365{
     5366    PVGASTATE pThis = PDMINS_2_DATA(pDevIns, PVGASTATE);
     5367    Assert(uPass == 0); NOREF(uPass);
     5368    vgaR3SaveConfig(pThis, pSSM);
     5369    return VINF_SSM_DONT_CALL_AGAIN;
     5370}
     5371
     5372
     5373/**
     5374 * @copydoc FNSSMDEVSAVEPREP
     5375 */
     5376static DECLCALLBACK(int) vgaR3SavePrep(PPDMDEVINS pDevIns, PSSMHANDLE pSSM)
     5377{
     5378#ifdef VBOX_WITH_VIDEOHWACCEL
     5379    return vboxVBVASaveStatePrep(pDevIns, pSSM);
    53605380#else
    53615381    return VINF_SUCCESS;
     
    53635383}
    53645384
    5365 #ifdef VBOX_WITH_VIDEOHWACCEL
    5366 static DECLCALLBACK(int) vgaR3SavePrep(PPDMDEVINS pDevIns, PSSMHANDLE pSSM)
    5367 {
    5368     return vboxVBVASaveStatePrep(pDevIns, pSSM);
    5369 }
    5370 #endif
    53715385
    53725386/**
    5373  * Loads a saved VGA device state.
    5374  *
    5375  * @returns VBox status code.
    5376  * @param   pDevIns     The device instance.
    5377  * @param   pSSMHandle  The handle to the saved state.
    5378  * @param   uVersion    The data unit version number.
    5379  * @param   uPass       The data pass.
     5387 * @copydoc FNSSMDEVSAVEEXEC
    53805388 */
    5381 static DECLCALLBACK(int) vgaR3LoadExec(PPDMDEVINS pDevIns, PSSMHANDLE pSSMHandle, uint32_t uVersion, uint32_t uPass)
    5382 {
    5383     Assert(uPass == SSM_PASS_FINAL); NOREF(uPass);
    5384     int rc = vga_load(pSSMHandle, PDMINS_2_DATA(pDevIns, PVGASTATE), uVersion);
    5385     if (RT_FAILURE(rc))
    5386         return rc;
     5389static DECLCALLBACK(int) vgaR3SaveExec(PPDMDEVINS pDevIns, PSSMHANDLE pSSM)
     5390{
     5391    PVGASTATE pThis = PDMINS_2_DATA(pDevIns, PVGASTATE);
     5392    vgaR3SaveConfig(pThis, pSSM);
     5393    vga_save(pSSM, PDMINS_2_DATA(pDevIns, PVGASTATE));
    53875394#ifdef VBOX_WITH_HGSMI
    5388     return vboxVBVALoadStateExec(pDevIns, pSSMHandle, uVersion);
     5395    SSMR3PutBool(pSSM, true);
     5396    return vboxVBVASaveStateExec(pDevIns, pSSM);
     5397#else
     5398    SSMR3PutBool(pSSM, false);
     5399    return VINF_SUCCESS;
     5400#endif
     5401}
     5402
     5403
     5404/**
     5405 * @copydoc FNSSMDEVSAVEEXEC
     5406 */
     5407static DECLCALLBACK(int) vgaR3LoadExec(PPDMDEVINS pDevIns, PSSMHANDLE pSSM, uint32_t uVersion, uint32_t uPass)
     5408{
     5409    PVGASTATE   pThis = PDMINS_2_DATA(pDevIns, PVGASTATE);
     5410    int         rc;
     5411
     5412    if (    uVersion != VGA_SAVEDSTATE_VERSION
     5413        &&  uVersion != VGA_SAVEDSTATE_VERSION_HGSMI
     5414        &&  uVersion != VGA_SAVEDSTATE_VERSION_PRE_HGSMI)
     5415        return VERR_SSM_UNSUPPORTED_DATA_UNIT_VERSION;
     5416
     5417    if (uVersion > VGA_SAVEDSTATE_VERSION_HGSMI)
     5418    {
     5419        /* Check the config */
     5420        uint32_t cbVRam;
     5421        rc = SSMR3GetU32(pSSM, &cbVRam);
     5422        AssertRCReturn(rc, rc);
     5423        if (pThis->vram_size != cbVRam)
     5424        {
     5425            LogRel(("DevVGA: VRAM size changed: config=%#x state=%#x\n", pThis->vram_size, cbVRam));
     5426            return VERR_SSM_LOAD_CONFIG_MISMATCH;
     5427        }
     5428
     5429        uint32_t cMonitors;
     5430        rc = SSMR3GetU32(pSSM, &cMonitors);
     5431        AssertRCReturn(rc, rc);
     5432        if (pThis->cMonitors != cMonitors)
     5433        {
     5434            LogRel(("DevVGA: Monitor count changed: config=%u state=%u\n", pThis->cMonitors, cMonitors));
     5435            return VERR_SSM_LOAD_CONFIG_MISMATCH;
     5436        }
     5437    }
     5438
     5439    if (uPass == SSM_PASS_FINAL)
     5440    {
     5441        rc = vga_load(pSSM, pThis, uVersion);
     5442        if (RT_FAILURE(rc))
     5443            return rc;
     5444        bool fWithHgsmi = uVersion == VGA_SAVEDSTATE_VERSION_HGSMI;
     5445        if (uVersion > VGA_SAVEDSTATE_VERSION_HGSMI)
     5446        {
     5447            rc = SSMR3GetBool(pSSM, &fWithHgsmi);
     5448            AssertRCReturn(rc, rc);
     5449        }
     5450        if (fWithHgsmi)
     5451        {
     5452#ifdef VBOX_WITH_HGSMI
     5453            rc = vboxVBVALoadStateExec(pDevIns, pSSM, uVersion);
     5454            AssertRCReturn(rc, rc);
     5455#else
     5456            AssertLogRelFailedReturn(VERR_SSM_LOAD_CONFIG_MISMATCH);
     5457#endif
     5458        }
     5459    }
     5460    return VINF_SUCCESS;
     5461}
     5462
     5463
     5464/**
     5465 * @copydoc FNSSMDEVLOADDONE
     5466 */
     5467static DECLCALLBACK(int) vgaR3LoadDone(PPDMDEVINS pDevIns, PSSMHANDLE pSSM)
     5468{
     5469#ifdef VBOX_WITH_HGSMI
     5470    return vboxVBVALoadStateDone(pDevIns, pSSM);
    53895471#else
    53905472    return VINF_SUCCESS;
    5391 #endif
    5392 }
    5393 
    5394 /** @copydoc FNSSMDEVLOADDONE */
    5395 static DECLCALLBACK(int) vgaR3LoadDone(PPDMDEVINS pDevIns, PSSMHANDLE pSSM)
    5396 {
    5397 #ifndef VBOX_WITH_HGSMI
    5398     return VINF_SUCCESS;
    5399 #else
    5400     return vboxVBVALoadStateDone(pDevIns, pSSM);
    54015473#endif
    54025474}
     
    60376109    /* save */
    60386110    rc = PDMDevHlpSSMRegisterEx(pDevIns, VGA_SAVEDSTATE_VERSION, sizeof(*pThis), NULL,
    6039                                 NULL, NULL, NULL,
    6040 #ifdef VBOX_WITH_VIDEOHWACCEL
     6111                                NULL,          vgaR3LiveExec, NULL,
    60416112                                vgaR3SavePrep, vgaR3SaveExec, NULL,
    6042 #else
    6043                                 NULL, vgaR3SaveExec, NULL,
    6044 #endif
    6045                                 NULL, vgaR3LoadExec, vgaR3LoadDone);
     6113                                NULL,          vgaR3LoadExec, vgaR3LoadDone);
    60466114    if (RT_FAILURE(rc))
    60476115        return rc;
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