ReactOS 0.4.15-dev-5667-ged97270
cmos.h
Go to the documentation of this file.
1/*
2 * COPYRIGHT: GPL - See COPYING in the top level directory
3 * PROJECT: ReactOS Virtual DOS Machine
4 * FILE: subsystems/mvdm/ntvdm/hardware/cmos.h
5 * PURPOSE: CMOS Real Time Clock emulation
6 * PROGRAMMERS: Aleksandar Andrejevic <theflash AT sdf DOT lonestar DOT org>
7 */
8
9#ifndef _CMOS_H_
10#define _CMOS_H_
11
12/* DEFINES ********************************************************************/
13
14#define RTC_IRQ_NUMBER 8
15#define CMOS_ADDRESS_PORT 0x70
16#define CMOS_DATA_PORT 0x71
17#define CMOS_DISABLE_NMI (1 << 7)
18#define CMOS_BATTERY_OK 0x80
19
20/* Status Register B flags */
21#define CMOS_STB_DST (1 << 0)
22#define CMOS_STB_24HOUR (1 << 1)
23#define CMOS_STB_BINARY (1 << 2)
24#define CMOS_STB_SQUARE_WAVE (1 << 3)
25#define CMOS_STB_INT_ON_UPDATE (1 << 4)
26#define CMOS_STB_INT_ON_ALARM (1 << 5)
27#define CMOS_STB_INT_PERIODIC (1 << 6)
28#define CMOS_STB_UPDATE_CYCLE (1 << 7)
29
30/* Status Register C flags */
31#define CMOS_STC_UF (1 << 4)
32#define CMOS_STC_AF (1 << 5)
33#define CMOS_STC_PF (1 << 6)
34#define CMOS_STC_IRQF (1 << 7)
35
36/* Default register values */
37#define CMOS_DEFAULT_STA 0x26
38#define CMOS_DEFAULT_STB CMOS_STB_24HOUR
39
40// Bit 0: Floppy, Bit 1: FPU, Bit 2: Mouse, Bits 4-5: 80x25 Color Video, Bits 6-7: 2 floppy drives
41#define CMOS_EQUIPMENT_LIST 0x6F
42
43
44#define WRITE_CMOS_DATA(Cmos, Value) \
45 ((Cmos).StatusRegB & CMOS_STB_BINARY) ? (Value) : BCD_TO_BINARY(Value)
46
47#define READ_CMOS_DATA(Cmos, Value) \
48 ((Cmos).StatusRegB & CMOS_STB_BINARY) ? (Value) : BINARY_TO_BCD(Value)
49
50typedef enum _CMOS_REGISTERS
51{
77 CMOS_REG_MAX = 0x40
79
80/*
81 * CMOS Memory Map
82 *
83 * See the following documentation for more information:
84 * http://www.intel-assembler.it/portale/5/cmos-memory-map-123/cmos-memory-map-123.asp
85 * http://wiki.osdev.org/CMOS
86 * http://www.walshcomptech.com/ohlandl/config/cmos_registers.html
87 * http://www.fysnet.net/cmosinfo.htm
88 * http://www.bioscentral.com/misc/cmosmap.htm
89 */
90#pragma pack(push, 1)
91typedef struct
92{
93 BYTE Second; // 0x00
95 BYTE Minute; // 0x02
97 BYTE Hour; // 0x04
98 BYTE AlarmHour; // 0x05
99 BYTE DayOfWeek; // 0x06
100 BYTE Day; // 0x07
101 BYTE Month; // 0x08
102 BYTE Year; // 0x09
103
107
108typedef struct
109{
110 union
111 {
112 struct
113 {
114 CMOS_CLOCK; // 0x00 - 0x0b
128 BYTE ExtHardDrivesType[2]; // 0x19 - 0x1a
129 BYTE Reserved2[0x15]; // 0x1b
132 BYTE Century; // 0x32
133 };
134 BYTE Regs1[0x10]; // 0x00 - 0x0f
135 BYTE Regs [0x40]; // 0x00 - 0x3f
136 };
137
138 /*
139 * Extended information 0x40 - 0x7f
140 */
142#pragma pack(pop)
143
144C_ASSERT(sizeof(CMOS_MEMORY) == 0x40);
145
146/* FUNCTIONS ******************************************************************/
147
150
153
154#endif /* _CMOS_H_ */
unsigned char BOOLEAN
@ Reserved2
Definition: bcd.h:202
enum _CMOS_REGISTERS * PCMOS_REGISTERS
BOOLEAN IsNmiEnabled(VOID)
Definition: cmos.c:438
enum _CMOS_REGISTERS CMOS_REGISTERS
DWORD RtcGetTicksPerSecond(VOID)
struct CMOS_MEMORY * PCMOS_MEMORY
_CMOS_REGISTERS
Definition: cmos.h:51
@ CMOS_REG_DAY
Definition: cmos.h:59
@ CMOS_REG_STATUS_A
Definition: cmos.h:62
@ CMOS_REG_EXT_MEMORY_HIGH
Definition: cmos.h:72
@ CMOS_REG_ALARM_HRS
Definition: cmos.h:57
@ CMOS_REG_ACTUAL_EXT_MEMORY_LOW
Definition: cmos.h:74
@ CMOS_REG_SHUTDOWN_STATUS
Definition: cmos.h:67
@ CMOS_REG_STATUS_B
Definition: cmos.h:63
@ CMOS_REG_MAX
Definition: cmos.h:77
@ CMOS_REG_MONTH
Definition: cmos.h:60
@ CMOS_REG_BASE_MEMORY_HIGH
Definition: cmos.h:70
@ CMOS_REG_MINUTES
Definition: cmos.h:54
@ CMOS_REG_DAY_OF_WEEK
Definition: cmos.h:58
@ CMOS_REG_EXT_MEMORY_LOW
Definition: cmos.h:71
@ CMOS_REG_ALARM_MIN
Definition: cmos.h:55
@ CMOS_REG_STATUS_C
Definition: cmos.h:64
@ CMOS_REG_BASE_MEMORY_LOW
Definition: cmos.h:69
@ CMOS_REG_YEAR
Definition: cmos.h:61
@ CMOS_REG_SECONDS
Definition: cmos.h:52
@ CMOS_REG_HOURS
Definition: cmos.h:56
@ CMOS_REG_DIAGNOSTICS
Definition: cmos.h:66
@ CMOS_REG_ALARM_SEC
Definition: cmos.h:53
@ CMOS_REG_ACTUAL_EXT_MEMORY_HIGH
Definition: cmos.h:75
@ CMOS_REG_CENTURY
Definition: cmos.h:76
@ CMOS_REG_EQUIPMENT_LIST
Definition: cmos.h:68
@ CMOS_REG_STATUS_D
Definition: cmos.h:65
@ CMOS_REG_SYSOP
Definition: cmos.h:73
VOID CmosCleanup(VOID)
Definition: cmos.c:568
struct CMOS_CLOCK * PCMOS_CLOCK
VOID CmosInitialize(VOID)
Definition: cmos.c:460
unsigned long DWORD
Definition: ntddk_ex.h:95
#define C_ASSERT(e)
Definition: intsafe.h:73
BYTE Day
Definition: cmos.h:100
BYTE StatusRegA
Definition: cmos.h:104
BYTE Month
Definition: cmos.h:101
BYTE Hour
Definition: cmos.h:97
BYTE Year
Definition: cmos.h:102
BYTE AlarmSecond
Definition: cmos.h:94
BYTE Second
Definition: cmos.h:93
BYTE AlarmHour
Definition: cmos.h:98
BYTE AlarmMinute
Definition: cmos.h:96
BYTE StatusRegB
Definition: cmos.h:105
BYTE Minute
Definition: cmos.h:95
BYTE DayOfWeek
Definition: cmos.h:99
BYTE StatusRegD
Definition: cmos.h:116
BYTE ActualExtMemoryHigh
Definition: cmos.h:131
BYTE HardDrivesType
Definition: cmos.h:121
BYTE Reserved0
Definition: cmos.h:120
CMOS_CLOCK
Definition: cmos.h:114
BYTE Century
Definition: cmos.h:132
BYTE ExtMemoryHigh
Definition: cmos.h:127
BYTE ShutdownStatus
Definition: cmos.h:118
BYTE EquipmentList
Definition: cmos.h:123
BYTE FloppyDrivesType
Definition: cmos.h:119
BYTE ExtMemoryLow
Definition: cmos.h:126
BYTE BaseMemoryHigh
Definition: cmos.h:125
BYTE Diagnostics
Definition: cmos.h:117
BYTE StatusRegC
Definition: cmos.h:115
BYTE ActualExtMemoryLow
Definition: cmos.h:130
BYTE BaseMemoryLow
Definition: cmos.h:124
BYTE Reserved1
Definition: cmos.h:122
unsigned char BYTE
Definition: xxhash.c:193