ReactOS  0.4.14-dev-337-gf981a68
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 
50 typedef 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)
91 typedef struct
92 {
93  BYTE Second; // 0x00
94  BYTE AlarmSecond; // 0x01
95  BYTE Minute; // 0x02
96  BYTE AlarmMinute; // 0x03
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 
104  BYTE StatusRegA; // 0x0a
105  BYTE StatusRegB; // 0x0b
107 
108 typedef struct
109 {
110  union
111  {
112  struct
113  {
114  CMOS_CLOCK; // 0x00 - 0x0b
115  BYTE StatusRegC; // 0x0c
116  BYTE StatusRegD; // 0x0d
117  BYTE Diagnostics; // 0x0e
120  BYTE Reserved0; // 0x11
122  BYTE Reserved1; // 0x13
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 
144 C_ASSERT(sizeof(CMOS_MEMORY) == 0x40);
145 
146 /* FUNCTIONS ******************************************************************/
147 
150 
153 
154 #endif /* _CMOS_H_ */
BYTE StatusRegD
Definition: cmos.h:116
BYTE DayOfWeek
Definition: cmos.h:99
BYTE Diagnostics
Definition: cmos.h:117
BYTE StatusRegB
Definition: cmos.h:105
struct CMOS_CLOCK * PCMOS_CLOCK
BYTE Hour
Definition: cmos.h:97
BYTE Month
Definition: cmos.h:101
BYTE Second
Definition: cmos.h:93
BYTE StatusRegC
Definition: cmos.h:115
BYTE ActualExtMemoryLow
Definition: cmos.h:130
BYTE Reserved1
Definition: cmos.h:122
enum _CMOS_REGISTERS * PCMOS_REGISTERS
BYTE Reserved0
Definition: cmos.h:120
unsigned char BOOLEAN
BYTE FloppyDrivesType
Definition: cmos.h:119
enum _CMOS_REGISTERS CMOS_REGISTERS
C_ASSERT(sizeof(CMOS_MEMORY)==0x40)
BYTE AlarmHour
Definition: cmos.h:98
BYTE ExtMemoryHigh
Definition: cmos.h:127
Definition: bcd.h:202
BYTE Day
Definition: cmos.h:100
_CMOS_REGISTERS
Definition: cmos.h:50
BYTE AlarmSecond
Definition: cmos.h:94
VOID CmosInitialize(VOID)
Definition: cmos.c:441
unsigned long DWORD
Definition: ntddk_ex.h:95
CMOS_CLOCK
Definition: cmos.h:114
BYTE EquipmentList
Definition: cmos.h:123
BYTE BaseMemoryLow
Definition: cmos.h:124
BYTE StatusRegA
Definition: cmos.h:104
DWORD RtcGetTicksPerSecond(VOID)
unsigned char BYTE
Definition: mem.h:68
BYTE ShutdownStatus
Definition: cmos.h:118
BOOLEAN IsNmiEnabled(VOID)
Definition: cmos.c:436
BYTE HardDrivesType
Definition: cmos.h:121
struct CMOS_MEMORY * PCMOS_MEMORY
BYTE ExtMemoryLow
Definition: cmos.h:126
BYTE Year
Definition: cmos.h:102
BYTE AlarmMinute
Definition: cmos.h:96
BYTE BaseMemoryHigh
Definition: cmos.h:125
BYTE Century
Definition: cmos.h:132
VOID CmosCleanup(VOID)
Definition: cmos.c:519
BYTE ActualExtMemoryHigh
Definition: cmos.h:131
BYTE Minute
Definition: cmos.h:95