VirtualBox

Changeset 100143 in vbox


Ignore:
Timestamp:
Jun 9, 2023 3:36:00 PM (20 months ago)
Author:
vboxsync
Message:

Devices/Misc/DevPL031.cpp: Add option to load the current time into the load register so the guest sees a valid time, bugref:10435

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/Misc/DevPL031.cpp

    r100137 r100143  
    122122    /** The IRQ value. */
    123123    uint16_t                        u16Irq;
     124    /** Flag whether to preload the load rgeister with the current time. */
     125    bool                            fLoadTime;
     126    /** Flag whether to use UTC for the time offset. */
     127    bool                            fUtcOffset;
    124128
    125129    /** @name Registers.
     
    467471    pThis->fRtcIrqMasked    = false;
    468472    pThis->fRtcIrqSts       = false;
     473
     474    if (pThis->fLoadTime)
     475    {
     476        RTTIMESPEC  Now;
     477        PDMDevHlpTMUtcNow(pDevIns, &Now);
     478        if (!pThis->fUtcOffset)
     479        {
     480            RTTIME Time;
     481            RTTimeLocalExplode(&Time, &Now);
     482            RTTimeImplode(&Now, &Time);
     483        }
     484
     485        pThis->u32RtcLr = (uint32_t)RTTimeSpecGetSeconds(&Now);
     486    }
    469487}
    470488
     
    498516     * Validate and read the configuration.
    499517     */
    500     PDMDEV_VALIDATE_CONFIG_RETURN(pDevIns, "Irq|MmioBase", "");
     518    PDMDEV_VALIDATE_CONFIG_RETURN(pDevIns, "Irq|MmioBase|LoadTime|UtcOffset", "");
    501519
    502520    uint16_t u16Irq = 0;
     
    510528        return PDMDEV_SET_ERROR(pDevIns, rc,
    511529                                N_("Configuration error: Failed to get the \"MmioBase\" value"));
     530
     531    rc = pHlp->pfnCFGMQueryBoolDef(pCfg, "LoadTime", &pThis->fLoadTime, true);
     532    if (RT_FAILURE(rc))
     533        return PDMDEV_SET_ERROR(pDevIns, rc,
     534                                N_("Configuration error: Querying \"LoadTime\" as a bool failed"));
     535
     536    rc = pHlp->pfnCFGMQueryBoolDef(pCfg, "UtcOffset", &pThis->fUtcOffset, false);
     537    if (RT_FAILURE(rc))
     538        return PDMDEV_SET_ERROR(pDevIns, rc,
     539                                N_("Configuration error: Querying \"UtcOffset\" as a bool failed"));
    512540
    513541    pThis->u16Irq         = u16Irq;
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