ReactOS 0.4.15-dev-5667-ged97270
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
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}
#define ULONG_PTR
Definition: config.h:101
#define BCD_INT(bcd)
Definition: pc98rtc.c:10
TIMEINFO * Pc98GetTime(VOID)
Definition: pc98rtc.c:13
int __cdecl Int386(int ivec, REGS *in, REGS *out)
unsigned char ah
Definition: pcbios.h:132
unsigned short es
Definition: pcbios.h:121
unsigned short bx
Definition: pcbios.h:112
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
BYTEREGS b
Definition: pcbios.h:163
WORDREGS w
Definition: pcbios.h:162
unsigned char UCHAR
Definition: xmlstorage.h:181