ReactOS  0.4.13-dev-257-gfabbd7c
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 BCD_INT(bcd)
Definition: pcrtc.c:21
DWORDREGS x
Definition: pcbios.h:140
unsigned char ah
Definition: pcbios.h:112
USHORT Second
Definition: fw.h:16
USHORT Month
Definition: fw.h:12
unsigned char dh
Definition: pcbios.h:121
int __cdecl Int386(int ivec, REGS *in, REGS *out)
USHORT Minute
Definition: fw.h:15
unsigned char dl
Definition: pcbios.h:120
#define INT386_SUCCESS(regs)
Definition: pcbios.h:159
Definition: fw.h:9
USHORT Year
Definition: fw.h:11
unsigned char ch
Definition: pcbios.h:118
unsigned char cl
Definition: pcbios.h:117
BYTEREGS b
Definition: pcbios.h:143
unsigned long eflags
Definition: pcbios.h:85
USHORT Hour
Definition: fw.h:14
Definition: pcbios.h:138
USHORT Day
Definition: fw.h:13

Referenced by PcMachInit().