ReactOS 0.4.15-dev-7994-gb388cb6
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
24#define BCD_INT(bcd) (((bcd & 0xf0) >> 4) * 10 + (bcd &0x0f))
25
26static UCHAR
28{
29 UCHAR Val;
30 Reg |= 0x80;
31
32 WRITE_PORT_UCHAR((PUCHAR)0x70, Reg);
33 Val = READ_PORT_UCHAR((PUCHAR)0x71);
34 WRITE_PORT_UCHAR((PUCHAR)0x70, 0);
35
36 return(Val);
37}
38
41{
42 static TIMEINFO TimeInfo;
43
45 {
46 ;
47 }
48
49 TimeInfo.Second = BCD_INT(HalpQueryCMOS(0));
50 TimeInfo.Minute = BCD_INT(HalpQueryCMOS(2));
51 TimeInfo.Hour = BCD_INT(HalpQueryCMOS(4));
52 TimeInfo.Day = BCD_INT(HalpQueryCMOS(7));
53 TimeInfo.Month = BCD_INT(HalpQueryCMOS(8));
54 TimeInfo.Year = BCD_INT(HalpQueryCMOS(9));
55 if (TimeInfo.Year > 80)
56 TimeInfo.Year += 1900;
57 else
58 TimeInfo.Year += 2000;
59
60 return &TimeInfo;
61}
62
63/* EOF */
#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
#define BCD_INT(bcd)
Definition: xboxrtc.c:24
static UCHAR HalpQueryCMOS(UCHAR Reg)
Definition: xboxrtc.c:27
#define RTC_REG_A_UIP
Definition: xboxrtc.c:22
#define RTC_REGISTER_A
Definition: xboxrtc.c:21
TIMEINFO * XboxGetTime(VOID)
Definition: xboxrtc.c:40
unsigned char UCHAR
Definition: xmlstorage.h:181