Changeset 2613 in vbox
- Timestamp:
- May 14, 2007 8:25:02 AM (18 years ago)
- svn:sync-xref-src-repo-rev:
- 21126
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/PC/DevRTC.cpp
r2468 r2613 58 58 #include "vl_vbox.h" 59 59 60 /** @todo Implement time/localtime/gmtime replacements in Runtime!*/60 /** @todo Replace struct tm with RTTIME. */ 61 61 #include <time.h> 62 62 … … 166 166 s->next_periodic_time = ASMMultU64ByU32DivByU32(next_irq_clock, freq, 32768) + 1; 167 167 TMTimerSet(s->CTXSUFF(pPeriodicTimer), s->next_periodic_time); 168 168 169 169 } else { 170 170 TMTimerStop(s->CTXSUFF(pPeriodicTimer)); … … 692 692 static DECLCALLBACK(int) rtcInitComplete(PPDMDEVINS pDevIns) 693 693 { 694 /** @todo this should be (re)done at power on if we didn't load a state... */ 694 695 RTCState *pData = PDMINS2DATA(pDevIns, RTCState *); 695 time_t Ti;696 696 struct tm Tm; 697 697 struct tm *pTm; 698 int iYear;699 698 700 699 /* 701 700 * Set the CMOS date/time. 702 701 */ 703 #if 0 /* later */704 702 RTTIMESPEC Now; 705 RTTIME Time;706 RTT imeNow(&Now);703 PDMDevHlpUCTNow(pDevIns, &Now); 704 RTTIME Time; 707 705 if (pData->fUCT) 708 706 RTTimeExplode(&Time, &Now); 709 707 else 710 708 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; 728 720 pTm = &Tm; 729 #endif 730 #endif 721 731 722 rtc_set_date(pData, pTm); 732 723 733 i Year = 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 */ 734 725 rtc_set_memory(pData, 0x32, iYear); /* 32h - Century Byte (BCD value for the century */ 735 726 rtc_set_memory(pData, 0x37, iYear); /* 37h - (IBM PS/2) Date Century Byte */ … … 851 842 #else 852 843 rc = PDMDevHlpTMTimerCreate(pDevIns, TMCLOCK_VIRTUAL, rtcTimerSecond, "MC146818 RTC/CMOS - Second", &pData->pSecondTimerHC); 853 #endif 844 #endif 854 845 if (VBOX_FAILURE(rc)) 855 846 { … … 861 852 #else 862 853 rc = PDMDevHlpTMTimerCreate(pDevIns, TMCLOCK_VIRTUAL, rtcTimerSecond2, "MC146818 RTC/CMOS - Second2", &pData->pSecondTimer2HC); 863 #endif 854 #endif 864 855 if (VBOX_FAILURE(rc)) 865 856 {
Note:
See TracChangeset
for help on using the changeset viewer.