VirtualBox

Changeset 2613 in vbox


Ignore:
Timestamp:
May 14, 2007 8:25:02 AM (18 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
21126
Message:

Use TM as UCT source.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/PC/DevRTC.cpp

    r2468 r2613  
    5858#include "vl_vbox.h"
    5959
    60 /** @todo Implement time/localtime/gmtime  replacements in Runtime! */
     60/** @todo Replace struct tm with RTTIME. */
    6161#include <time.h>
    6262
     
    166166        s->next_periodic_time = ASMMultU64ByU32DivByU32(next_irq_clock, freq, 32768) + 1;
    167167        TMTimerSet(s->CTXSUFF(pPeriodicTimer), s->next_periodic_time);
    168        
     168
    169169    } else {
    170170        TMTimerStop(s->CTXSUFF(pPeriodicTimer));
     
    692692static DECLCALLBACK(int)  rtcInitComplete(PPDMDEVINS pDevIns)
    693693{
     694    /** @todo this should be (re)done at power on if we didn't load a state... */
    694695    RTCState   *pData = PDMINS2DATA(pDevIns, RTCState *);
    695     time_t      Ti;
    696696    struct tm   Tm;
    697697    struct tm  *pTm;
    698     int         iYear;
    699698
    700699    /*
    701700     * Set the CMOS date/time.
    702701     */
    703 #if 0 /* later */
    704702    RTTIMESPEC  Now;
    705     RTTIME      Time;
    706     RTTimeNow(&Now);
     703    PDMDevHlpUCTNow(pDevIns, &Now);
     704    RTTIME Time;
    707705    if (pData->fUCT)
    708706        RTTimeExplode(&Time, &Now);
    709707    else
    710708        RTTimeLocalExplode(&Time, &Now);
    711     pTm = RTTimeToPosixTm(&Tm, &Time);
    712 #else
    713     time(&Ti);
    714 #ifndef __WIN__
    715     if (pData->fUCT)
    716         pTm = gmtime_r(&Ti, &Tm);
    717     else
    718         pTm = localtime_r(&Ti, &Tm);
    719     Assert(pTm);
    720 #else
    721     /* Win32 doesn't have thread safe stuff, let's just hope this works out fine :/ */
    722     if (pData->fUCT)
    723         pTm = gmtime(&Ti);
    724     else
    725         pTm = localtime(&Ti);
    726     Assert(pTm);
    727     Tm = *pTm;
     709
     710    memset(&Tm, 0, sizeof(Tm));
     711    Tm.tm_year = Time.i32Year - 1900;
     712    Tm.tm_mon  = Time.u8Month;
     713    Tm.tm_mday = Time.u8MonthDay;
     714    Tm.tm_wday = Time.u8WeekDay;
     715    Tm.tm_yday = Time.u16YearDay;
     716    Tm.tm_hour = Time.u8Hour;
     717    Tm.tm_min  = Time.u8Minute;
     718    Tm.tm_sec  = Time.u8Second;
     719    Tm.tm_isdst = -1;
    728720    pTm = &Tm;
    729 #endif
    730 #endif
     721
    731722    rtc_set_date(pData, pTm);
    732723
    733     iYear = to_bcd(pData, (Tm.tm_year / 100) + 19); /* tm_year is 1900 based (stupid) */
     724    int iYear = to_bcd(pData, (Tm.tm_year / 100) + 19); /* tm_year is 1900 based */
    734725    rtc_set_memory(pData, 0x32, iYear);                                     /* 32h - Century Byte (BCD value for the century */
    735726    rtc_set_memory(pData, 0x37, iYear);                                     /* 37h - (IBM PS/2) Date Century Byte */
     
    851842#else
    852843    rc = PDMDevHlpTMTimerCreate(pDevIns, TMCLOCK_VIRTUAL, rtcTimerSecond, "MC146818 RTC/CMOS - Second", &pData->pSecondTimerHC);
    853 #endif 
     844#endif
    854845    if (VBOX_FAILURE(rc))
    855846    {
     
    861852#else
    862853    rc = PDMDevHlpTMTimerCreate(pDevIns, TMCLOCK_VIRTUAL, rtcTimerSecond2, "MC146818 RTC/CMOS - Second2", &pData->pSecondTimer2HC);
    863 #endif 
     854#endif
    864855    if (VBOX_FAILURE(rc))
    865856    {
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