From: Hervé Poussineau Date: Thu, 4 Mar 2010 06:32:13 +0000 (+0000) Subject: Revert part of r45817 to try to fix build X-Git-Tag: backups/header-work@57446~208^2~139 X-Git-Url: https://git.reactos.org/?p=reactos.git;a=commitdiff_plain;h=97f9d48ec35e788424c71078294e4fee53976c1a;hp=12d0dbfe9e7140f388e7adfdd1263d68e8958439 Revert part of r45817 to try to fix build svn path=/trunk/; revision=45823 --- diff --git a/reactos/boot/freeldr/freeldr/arch/i386/pcrtc.c b/reactos/boot/freeldr/freeldr/arch/i386/pcrtc.c index a03cc2a5575..1141753aa92 100644 --- a/reactos/boot/freeldr/freeldr/arch/i386/pcrtc.c +++ b/reactos/boot/freeldr/freeldr/arch/i386/pcrtc.c @@ -19,25 +19,63 @@ #include -BOOLEAN -NTAPI -HalQueryRealTimeClock(OUT PTIME_FIELDS Time); +#define BCD_INT(bcd) (((bcd & 0xf0) >> 4) * 10 + (bcd &0x0f)) TIMEINFO* PcGetTime(VOID) { static TIMEINFO TimeInfo; - TIME_FIELDS Time; + REGS Regs; - if (!HalQueryRealTimeClock(&Time)) - return NULL; + /* Some BIOSes, such as the 1998/07/25 system ROM + * in the Compaq Deskpro EP/SB, leave CF unchanged + * if successful, so CF should be cleared before + * calling this function. */ + __writeeflags(__readeflags() & ~EFLAGS_CF); - TimeInfo.Year = Time.Year; - TimeInfo.Month = Time.Month; - TimeInfo.Day = Time.Day; - TimeInfo.Hour = Time.Hour; - TimeInfo.Minute = Time.Minute; - TimeInfo.Second = Time.Second; + /* Int 1Ah AH=04h + * TIME - GET REAL-TIME CLOCK DATE (AT,XT286,PS) + * + * AH = 04h + * CF clear to avoid bug + * Return: + * CF clear if successful + * CH = century (BCD) + * CL = year (BCD) + * DH = month (BCD) + * DL = day (BCD) + * CF set on error + */ + Regs.b.ah = 0x04; + Int386(0x1A, &Regs, &Regs); + + TimeInfo.Year = 100 * BCD_INT(Regs.b.ch) + BCD_INT(Regs.b.cl); + TimeInfo.Month = BCD_INT(Regs.b.dh); + TimeInfo.Day = BCD_INT(Regs.b.dl); + + /* Some BIOSes leave CF unchanged if successful, + * so CF should be cleared before calling this function. */ + __writeeflags(__readeflags() & ~EFLAGS_CF); + + /* Int 1Ah AH=02h + * TIME - GET REAL-TIME CLOCK TIME (AT,XT286,PS) + * + * AH = 02h + * CF clear to avoid bug + * Return: + * CF clear if successful + * CH = hour (BCD) + * CL = minutes (BCD) + * DH = seconds (BCD) + * DL = daylight savings flag (00h standard time, 01h daylight time) + * CF set on error (i.e. clock not running or in middle of update) + */ + Regs.b.ah = 0x02; + Int386(0x1A, &Regs, &Regs); + + TimeInfo.Hour = BCD_INT(Regs.b.ch); + TimeInfo.Minute = BCD_INT(Regs.b.cl); + TimeInfo.Second = BCD_INT(Regs.b.dh); return &TimeInfo; }