ReactOS
0.4.16-dev-2216-ga08d639
pcrtc.c
Go to the documentation of this file.
1
/*
2
* FreeLoader
3
*
4
* This program is free software; you can redistribute it and/or modify
5
* it under the terms of the GNU General Public License as published by
6
* the Free Software Foundation; either version 2 of the License, or
7
* (at your option) any later version.
8
*
9
* This program is distributed in the hope that it will be useful,
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
* GNU General Public License for more details.
13
*
14
* You should have received a copy of the GNU General Public License along
15
* with this program; if not, write to the Free Software Foundation, Inc.,
16
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
17
*/
18
19
#include <
freeldr.h
>
20
21
static
22
UCHAR
23
BCD_INT
(
24
_In_
UCHAR
Bcd)
25
{
26
return
((Bcd & 0xF0) >> 4) * 10 + (Bcd & 0x0F);
27
}
28
29
TIMEINFO
*
30
PcGetTime
(
VOID
)
31
{
32
static
TIMEINFO
TimeInfo;
33
REGS
Regs;
34
35
for
(;;)
36
{
37
/* Some BIOSes, such as the 1998/07/25 system ROM
38
* in the Compaq Deskpro EP/SB, leave CF unchanged
39
* if successful, so CF should be cleared before
40
* calling this function. */
41
Regs.
x
.
eflags
= 0;
42
// __writeeflags(__readeflags() & ~EFLAGS_CF);
43
44
/* Int 1Ah AH=04h
45
* TIME - GET REAL-TIME CLOCK DATE (AT,XT286,PS)
46
*
47
* AH = 04h
48
* CF clear to avoid bug
49
* Return:
50
* CF clear if successful
51
* CH = century (BCD)
52
* CL = year (BCD)
53
* DH = month (BCD)
54
* DL = day (BCD)
55
* CF set on error
56
*/
57
Regs.
b
.
ah
= 0x04;
58
Int386
(0x1A, &Regs, &Regs);
59
60
if
(!
INT386_SUCCESS
(Regs))
continue
;
61
62
TimeInfo.
Year
= 100 *
BCD_INT
(Regs.
b
.
ch
) +
BCD_INT
(Regs.
b
.
cl
);
63
TimeInfo.
Month
=
BCD_INT
(Regs.
b
.
dh
);
64
TimeInfo.
Day
=
BCD_INT
(Regs.
b
.
dl
);
65
66
/* Some BIOSes leave CF unchanged if successful,
67
* so CF should be cleared before calling this function. */
68
Regs.
x
.
eflags
= 0;
69
// __writeeflags(__readeflags() & ~EFLAGS_CF);
70
71
/* Int 1Ah AH=02h
72
* TIME - GET REAL-TIME CLOCK TIME (AT,XT286,PS)
73
*
74
* AH = 02h
75
* CF clear to avoid bug
76
* Return:
77
* CF clear if successful
78
* CH = hour (BCD)
79
* CL = minutes (BCD)
80
* DH = seconds (BCD)
81
* DL = daylight savings flag (00h standard time, 01h daylight time)
82
* CF set on error (i.e. clock not running or in middle of update)
83
*/
84
Regs.
b
.
ah
= 0x02;
85
Int386
(0x1A, &Regs, &Regs);
86
87
if
(!
INT386_SUCCESS
(Regs))
continue
;
88
89
TimeInfo.
Hour
=
BCD_INT
(Regs.
b
.
ch
);
90
TimeInfo.
Minute
=
BCD_INT
(Regs.
b
.
cl
);
91
TimeInfo.
Second
=
BCD_INT
(Regs.
b
.
dh
);
92
93
break
;
94
}
95
return
&TimeInfo;
96
}
97
98
/* EOF */
freeldr.h
void
Definition:
nsiface.idl:2307
_In_
#define _In_
Definition:
no_sal2.h:158
INT386_SUCCESS
#define INT386_SUCCESS(regs)
Definition:
pcbios.h:181
Int386
int __cdecl Int386(int ivec, REGS *in, REGS *out)
BCD_INT
static UCHAR BCD_INT(_In_ UCHAR Bcd)
Definition:
pcrtc.c:23
PcGetTime
TIMEINFO * PcGetTime(VOID)
Definition:
pcrtc.c:30
BYTEREGS::ch
unsigned char ch
Definition:
pcbios.h:140
BYTEREGS::dl
unsigned char dl
Definition:
pcbios.h:142
BYTEREGS::cl
unsigned char cl
Definition:
pcbios.h:139
BYTEREGS::ah
unsigned char ah
Definition:
pcbios.h:134
BYTEREGS::dh
unsigned char dh
Definition:
pcbios.h:143
DWORDREGS::eflags
unsigned long eflags
Definition:
pcbios.h:107
_TIMEINFO
Definition:
fw.h:10
_TIMEINFO::Month
USHORT Month
Definition:
fw.h:12
_TIMEINFO::Day
USHORT Day
Definition:
fw.h:13
_TIMEINFO::Minute
USHORT Minute
Definition:
fw.h:15
_TIMEINFO::Hour
USHORT Hour
Definition:
fw.h:14
_TIMEINFO::Second
USHORT Second
Definition:
fw.h:16
_TIMEINFO::Year
USHORT Year
Definition:
fw.h:11
REGS
Definition:
pcbios.h:161
REGS::x
DWORDREGS x
Definition:
pcbios.h:162
REGS::b
BYTEREGS b
Definition:
pcbios.h:165
UCHAR
unsigned char UCHAR
Definition:
xmlstorage.h:181
boot
freeldr
freeldr
arch
i386
pc
pcrtc.c
Generated on Thu Jan 29 2026 06:03:04 for ReactOS by
1.9.6