ReactOS 0.4.15-dev-8127-g6338913
pcrtc.c File Reference
#include <freeldr.h>
Include dependency graph for pcrtc.c:

Go to the source code of this file.

Macros

#define BCD_INT(bcd)   (((bcd & 0xf0) >> 4) * 10 + (bcd &0x0f))
 

Functions

TIMEINFOPcGetTime (VOID)
 

Macro Definition Documentation

◆ BCD_INT

#define BCD_INT (   bcd)    (((bcd & 0xf0) >> 4) * 10 + (bcd &0x0f))

Definition at line 21 of file pcrtc.c.

Function Documentation

◆ PcGetTime()

TIMEINFO * PcGetTime ( VOID  )

Definition at line 24 of file pcrtc.c.

25{
26 static TIMEINFO TimeInfo;
27 REGS Regs;
28
29 for (;;)
30 {
31 /* Some BIOSes, such as the 1998/07/25 system ROM
32 * in the Compaq Deskpro EP/SB, leave CF unchanged
33 * if successful, so CF should be cleared before
34 * calling this function. */
35 Regs.x.eflags = 0;
36// __writeeflags(__readeflags() & ~EFLAGS_CF);
37
38 /* Int 1Ah AH=04h
39 * TIME - GET REAL-TIME CLOCK DATE (AT,XT286,PS)
40 *
41 * AH = 04h
42 * CF clear to avoid bug
43 * Return:
44 * CF clear if successful
45 * CH = century (BCD)
46 * CL = year (BCD)
47 * DH = month (BCD)
48 * DL = day (BCD)
49 * CF set on error
50 */
51 Regs.b.ah = 0x04;
52 Int386(0x1A, &Regs, &Regs);
53
54 if (!INT386_SUCCESS(Regs)) continue;
55
56 TimeInfo.Year = 100 * BCD_INT(Regs.b.ch) + BCD_INT(Regs.b.cl);
57 TimeInfo.Month = BCD_INT(Regs.b.dh);
58 TimeInfo.Day = BCD_INT(Regs.b.dl);
59
60 /* Some BIOSes leave CF unchanged if successful,
61 * so CF should be cleared before calling this function. */
62 Regs.x.eflags = 0;
63// __writeeflags(__readeflags() & ~EFLAGS_CF);
64
65 /* Int 1Ah AH=02h
66 * TIME - GET REAL-TIME CLOCK TIME (AT,XT286,PS)
67 *
68 * AH = 02h
69 * CF clear to avoid bug
70 * Return:
71 * CF clear if successful
72 * CH = hour (BCD)
73 * CL = minutes (BCD)
74 * DH = seconds (BCD)
75 * DL = daylight savings flag (00h standard time, 01h daylight time)
76 * CF set on error (i.e. clock not running or in middle of update)
77 */
78 Regs.b.ah = 0x02;
79 Int386(0x1A, &Regs, &Regs);
80
81 if (!INT386_SUCCESS(Regs)) continue;
82
83 TimeInfo.Hour = BCD_INT(Regs.b.ch);
84 TimeInfo.Minute = BCD_INT(Regs.b.cl);
85 TimeInfo.Second = BCD_INT(Regs.b.dh);
86
87 break;
88 }
89 return &TimeInfo;
90}
#define INT386_SUCCESS(regs)
Definition: pcbios.h:179
int __cdecl Int386(int ivec, REGS *in, REGS *out)
#define BCD_INT(bcd)
Definition: pcrtc.c:21
unsigned char ch
Definition: pcbios.h:138
unsigned char dl
Definition: pcbios.h:140
unsigned char cl
Definition: pcbios.h:137
unsigned char ah
Definition: pcbios.h:132
unsigned char dh
Definition: pcbios.h:141
unsigned long eflags
Definition: pcbios.h:105
Definition: fw.h:10
USHORT Month
Definition: fw.h:12
USHORT Day
Definition: fw.h:13
USHORT Minute
Definition: fw.h:15
USHORT Hour
Definition: fw.h:14
USHORT Second
Definition: fw.h:16
USHORT Year
Definition: fw.h:11
Definition: pcbios.h:159
DWORDREGS x
Definition: pcbios.h:160
BYTEREGS b
Definition: pcbios.h:163

Referenced by MachInit().