ReactOS  0.4.15-dev-1177-g6cb3b62
pc98rtc.c
Go to the documentation of this file.
1 /*
2  * PROJECT: FreeLoader
3  * LICENSE: GPL-2.0-or-later (https://spdx.org/licenses/GPL-2.0-or-later)
4  * PURPOSE: Real-time clock access routine for NEC PC-98 series
5  * COPYRIGHT: Copyright 2020 Dmitry Borisov (di.sean@protonmail.com)
6  */
7 
8 #include <freeldr.h>
9 
10 #define BCD_INT(bcd) (((bcd & 0xF0) >> 4) * 10 + (bcd & 0x0F))
11 
12 TIMEINFO*
14 {
15  static TIMEINFO TimeInfo;
16  REGS Regs;
17  UCHAR SysTime[6];
18 
19  /* Int 1Ch AH=00h
20  * TIMER BIOS - Read system time
21  *
22  * Call with:
23  * ES:BX -> data buffer
24  */
25  Regs.b.ah = 0x00;
26  Regs.w.es = ((ULONG_PTR)SysTime) >> 4;
27  Regs.w.bx = ((ULONG_PTR)SysTime) & 0x0F;
28  Int386(0x1C, &Regs, &Regs);
29 
30  TimeInfo.Year = BCD_INT(SysTime[0]);
31  TimeInfo.Month = BCD_INT(SysTime[1] >> 4);
32  TimeInfo.Day = BCD_INT(SysTime[2]);
33  TimeInfo.Hour = BCD_INT(SysTime[3]);
34  TimeInfo.Minute = BCD_INT(SysTime[4]);
35  TimeInfo.Second = BCD_INT(SysTime[5]);
36  if (TimeInfo.Year >= 80)
37  TimeInfo.Year += 1900;
38  else
39  TimeInfo.Year += 2000;
40 
41  return &TimeInfo;
42 }
unsigned short es
Definition: pcbios.h:115
unsigned char ah
Definition: pcbios.h:126
USHORT Second
Definition: fw.h:16
USHORT Month
Definition: fw.h:12
int __cdecl Int386(int ivec, REGS *in, REGS *out)
USHORT Minute
Definition: fw.h:15
Definition: fw.h:9
#define BCD_INT(bcd)
Definition: pc98rtc.c:10
USHORT Year
Definition: fw.h:11
unsigned char UCHAR
Definition: xmlstorage.h:181
TIMEINFO * Pc98GetTime(VOID)
Definition: pc98rtc.c:13
BYTEREGS b
Definition: pcbios.h:157
USHORT Hour
Definition: fw.h:14
unsigned short bx
Definition: pcbios.h:106
Definition: pcbios.h:152
#define ULONG_PTR
Definition: config.h:101
USHORT Day
Definition: fw.h:13
WORDREGS w
Definition: pcbios.h:156