ReactOS 0.4.16-dev-2208-g6350669
xboxrtc.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#define RTC_REGISTER_A 0x0A
22#define RTC_REG_A_UIP 0x80 /* Update In Progress bit */
23
24static
27 _In_ UCHAR Bcd)
28{
29 return ((Bcd & 0xF0) >> 4) * 10 + (Bcd & 0x0F);
30}
31
32static UCHAR
34{
35 UCHAR Val;
36 Reg |= 0x80;
37
38 WRITE_PORT_UCHAR((PUCHAR)0x70, Reg);
39 Val = READ_PORT_UCHAR((PUCHAR)0x71);
40 WRITE_PORT_UCHAR((PUCHAR)0x70, 0);
41
42 return(Val);
43}
44
47{
48 static TIMEINFO TimeInfo;
49
51 {
52 ;
53 }
54
55 TimeInfo.Second = BCD_INT(HalpQueryCMOS(0));
56 TimeInfo.Minute = BCD_INT(HalpQueryCMOS(2));
57 TimeInfo.Hour = BCD_INT(HalpQueryCMOS(4));
58 TimeInfo.Day = BCD_INT(HalpQueryCMOS(7));
59 TimeInfo.Month = BCD_INT(HalpQueryCMOS(8));
60 TimeInfo.Year = BCD_INT(HalpQueryCMOS(9));
61 if (TimeInfo.Year > 80)
62 TimeInfo.Year += 1900;
63 else
64 TimeInfo.Year += 2000;
65
66 return &TimeInfo;
67}
68
69/* EOF */
#define _In_
Definition: no_sal2.h:158
#define READ_PORT_UCHAR(p)
Definition: pc98vid.h:22
#define WRITE_PORT_UCHAR(p, d)
Definition: pc98vid.h:21
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
unsigned char * PUCHAR
Definition: typedefs.h:53
static UCHAR BCD_INT(_In_ UCHAR Bcd)
Definition: xboxrtc.c:26
static UCHAR HalpQueryCMOS(UCHAR Reg)
Definition: xboxrtc.c:33
#define RTC_REG_A_UIP
Definition: xboxrtc.c:22
#define RTC_REGISTER_A
Definition: xboxrtc.c:21
TIMEINFO * XboxGetTime(VOID)
Definition: xboxrtc.c:46
unsigned char UCHAR
Definition: xmlstorage.h:181