2013-11-03 21:33:22 +00:00
|
|
|
/*
|
|
|
|
* COPYRIGHT: GPL - See COPYING in the top level directory
|
|
|
|
* PROJECT: ReactOS Virtual DOS Machine
|
2015-09-18 17:01:49 +00:00
|
|
|
* FILE: subsystems/mvdm/ntvdm/hardware/cmos.h
|
2013-11-10 13:12:02 +00:00
|
|
|
* PURPOSE: CMOS Real Time Clock emulation
|
2013-11-03 21:33:22 +00:00
|
|
|
* PROGRAMMERS: Aleksandar Andrejevic <theflash AT sdf DOT lonestar DOT org>
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _CMOS_H_
|
|
|
|
#define _CMOS_H_
|
|
|
|
|
|
|
|
/* DEFINES ********************************************************************/
|
|
|
|
|
|
|
|
#define RTC_IRQ_NUMBER 8
|
|
|
|
#define CMOS_ADDRESS_PORT 0x70
|
|
|
|
#define CMOS_DATA_PORT 0x71
|
|
|
|
#define CMOS_DISABLE_NMI (1 << 7)
|
|
|
|
#define CMOS_BATTERY_OK 0x80
|
|
|
|
|
|
|
|
/* Status Register B flags */
|
[NTVDM]
- Add some level of "Advanced debugging" (see ntvdm.h) which one can adjust to enable/disable debugging features inside NTVDM (this can be useful as long as NTVDM is under heavy bugfixing. When it will be more perfect, this stuff will be removed).
- Add the possibility to load option ROMs at a given segment. Currently their list should be specified from inside ntvdm.c (in the BiosInitialize call), but I plan to make it available from a registry option (or via command-line for NTVDM-standalone mode).
- Start to separate the initialization of "static" BIOS data (stuff that lives in ROM space) and initialization of "dynamic" BIOS data (eg. initializing the interrupt vector table, the BIOS data area at segment 40h, ...) so that we may be able to reuse part of our code to be able to more-or-less run external (16-bit) BIOSes, or the Windows NTVDM BIOS that uses BOPs to run some of its stuff in ntvdm in 32-bit (as we do for our 32-bit BIOS, except that *all* of our bios is 32-bit, not just some parts). Also, some file reorganization will be in order there soon...
- Add video BIOS version information in memory so that tools such as Microsoft Diagnostics can correctly recognize our video BIOS (btw, we try to emulate the functionality of Cirrus' CL-GD5434).
- Correctly put video BIOS ROM header (+ checksum) in memory so that it is recognized as such by diagnostics tools.
- During BIOS POST, scan for ROMs starting segment 0xC000 (where video ROMs reside).
- Store statically the BIOS configuration table.
- Fix INT 16h, AH=12h "Get extended shift states" so that it correctly returns the state of right Ctrl and Alt keys.
- Fix bit-setting state; report that our keyboard is 101/102 enhanced keyboard.
- Correctly set the error return values (AH=86h and CF set) when a function of INT 15h is unsupported.
- Implement INT 15h, AH=C9h "Get CPU Type and Mask Revision"; INT 1Ah, AH=02h "Get Real-Time Clock Time" and Ah=04h "Get Real-Time Clock Date" by reading the CMOS.
- Implement CMOS century register support.
svn path=/trunk/; revision=68598
2015-08-04 20:17:05 +00:00
|
|
|
#define CMOS_STB_DST (1 << 0)
|
2013-11-03 21:33:22 +00:00
|
|
|
#define CMOS_STB_24HOUR (1 << 1)
|
|
|
|
#define CMOS_STB_BINARY (1 << 2)
|
|
|
|
#define CMOS_STB_SQUARE_WAVE (1 << 3)
|
|
|
|
#define CMOS_STB_INT_ON_UPDATE (1 << 4)
|
|
|
|
#define CMOS_STB_INT_ON_ALARM (1 << 5)
|
|
|
|
#define CMOS_STB_INT_PERIODIC (1 << 6)
|
[NTVDM]
- Add some level of "Advanced debugging" (see ntvdm.h) which one can adjust to enable/disable debugging features inside NTVDM (this can be useful as long as NTVDM is under heavy bugfixing. When it will be more perfect, this stuff will be removed).
- Add the possibility to load option ROMs at a given segment. Currently their list should be specified from inside ntvdm.c (in the BiosInitialize call), but I plan to make it available from a registry option (or via command-line for NTVDM-standalone mode).
- Start to separate the initialization of "static" BIOS data (stuff that lives in ROM space) and initialization of "dynamic" BIOS data (eg. initializing the interrupt vector table, the BIOS data area at segment 40h, ...) so that we may be able to reuse part of our code to be able to more-or-less run external (16-bit) BIOSes, or the Windows NTVDM BIOS that uses BOPs to run some of its stuff in ntvdm in 32-bit (as we do for our 32-bit BIOS, except that *all* of our bios is 32-bit, not just some parts). Also, some file reorganization will be in order there soon...
- Add video BIOS version information in memory so that tools such as Microsoft Diagnostics can correctly recognize our video BIOS (btw, we try to emulate the functionality of Cirrus' CL-GD5434).
- Correctly put video BIOS ROM header (+ checksum) in memory so that it is recognized as such by diagnostics tools.
- During BIOS POST, scan for ROMs starting segment 0xC000 (where video ROMs reside).
- Store statically the BIOS configuration table.
- Fix INT 16h, AH=12h "Get extended shift states" so that it correctly returns the state of right Ctrl and Alt keys.
- Fix bit-setting state; report that our keyboard is 101/102 enhanced keyboard.
- Correctly set the error return values (AH=86h and CF set) when a function of INT 15h is unsupported.
- Implement INT 15h, AH=C9h "Get CPU Type and Mask Revision"; INT 1Ah, AH=02h "Get Real-Time Clock Time" and Ah=04h "Get Real-Time Clock Date" by reading the CMOS.
- Implement CMOS century register support.
svn path=/trunk/; revision=68598
2015-08-04 20:17:05 +00:00
|
|
|
#define CMOS_STB_UPDATE_CYCLE (1 << 7)
|
2013-11-03 21:33:22 +00:00
|
|
|
|
|
|
|
/* Status Register C flags */
|
[NTVDM]
- Add some level of "Advanced debugging" (see ntvdm.h) which one can adjust to enable/disable debugging features inside NTVDM (this can be useful as long as NTVDM is under heavy bugfixing. When it will be more perfect, this stuff will be removed).
- Add the possibility to load option ROMs at a given segment. Currently their list should be specified from inside ntvdm.c (in the BiosInitialize call), but I plan to make it available from a registry option (or via command-line for NTVDM-standalone mode).
- Start to separate the initialization of "static" BIOS data (stuff that lives in ROM space) and initialization of "dynamic" BIOS data (eg. initializing the interrupt vector table, the BIOS data area at segment 40h, ...) so that we may be able to reuse part of our code to be able to more-or-less run external (16-bit) BIOSes, or the Windows NTVDM BIOS that uses BOPs to run some of its stuff in ntvdm in 32-bit (as we do for our 32-bit BIOS, except that *all* of our bios is 32-bit, not just some parts). Also, some file reorganization will be in order there soon...
- Add video BIOS version information in memory so that tools such as Microsoft Diagnostics can correctly recognize our video BIOS (btw, we try to emulate the functionality of Cirrus' CL-GD5434).
- Correctly put video BIOS ROM header (+ checksum) in memory so that it is recognized as such by diagnostics tools.
- During BIOS POST, scan for ROMs starting segment 0xC000 (where video ROMs reside).
- Store statically the BIOS configuration table.
- Fix INT 16h, AH=12h "Get extended shift states" so that it correctly returns the state of right Ctrl and Alt keys.
- Fix bit-setting state; report that our keyboard is 101/102 enhanced keyboard.
- Correctly set the error return values (AH=86h and CF set) when a function of INT 15h is unsupported.
- Implement INT 15h, AH=C9h "Get CPU Type and Mask Revision"; INT 1Ah, AH=02h "Get Real-Time Clock Time" and Ah=04h "Get Real-Time Clock Date" by reading the CMOS.
- Implement CMOS century register support.
svn path=/trunk/; revision=68598
2015-08-04 20:17:05 +00:00
|
|
|
#define CMOS_STC_UF (1 << 4)
|
|
|
|
#define CMOS_STC_AF (1 << 5)
|
|
|
|
#define CMOS_STC_PF (1 << 6)
|
2013-11-03 21:33:22 +00:00
|
|
|
#define CMOS_STC_IRQF (1 << 7)
|
|
|
|
|
|
|
|
/* Default register values */
|
[NTVDM]
- Add some level of "Advanced debugging" (see ntvdm.h) which one can adjust to enable/disable debugging features inside NTVDM (this can be useful as long as NTVDM is under heavy bugfixing. When it will be more perfect, this stuff will be removed).
- Add the possibility to load option ROMs at a given segment. Currently their list should be specified from inside ntvdm.c (in the BiosInitialize call), but I plan to make it available from a registry option (or via command-line for NTVDM-standalone mode).
- Start to separate the initialization of "static" BIOS data (stuff that lives in ROM space) and initialization of "dynamic" BIOS data (eg. initializing the interrupt vector table, the BIOS data area at segment 40h, ...) so that we may be able to reuse part of our code to be able to more-or-less run external (16-bit) BIOSes, or the Windows NTVDM BIOS that uses BOPs to run some of its stuff in ntvdm in 32-bit (as we do for our 32-bit BIOS, except that *all* of our bios is 32-bit, not just some parts). Also, some file reorganization will be in order there soon...
- Add video BIOS version information in memory so that tools such as Microsoft Diagnostics can correctly recognize our video BIOS (btw, we try to emulate the functionality of Cirrus' CL-GD5434).
- Correctly put video BIOS ROM header (+ checksum) in memory so that it is recognized as such by diagnostics tools.
- During BIOS POST, scan for ROMs starting segment 0xC000 (where video ROMs reside).
- Store statically the BIOS configuration table.
- Fix INT 16h, AH=12h "Get extended shift states" so that it correctly returns the state of right Ctrl and Alt keys.
- Fix bit-setting state; report that our keyboard is 101/102 enhanced keyboard.
- Correctly set the error return values (AH=86h and CF set) when a function of INT 15h is unsupported.
- Implement INT 15h, AH=C9h "Get CPU Type and Mask Revision"; INT 1Ah, AH=02h "Get Real-Time Clock Time" and Ah=04h "Get Real-Time Clock Date" by reading the CMOS.
- Implement CMOS century register support.
svn path=/trunk/; revision=68598
2015-08-04 20:17:05 +00:00
|
|
|
#define CMOS_DEFAULT_STA 0x26
|
|
|
|
#define CMOS_DEFAULT_STB CMOS_STB_24HOUR
|
2013-11-03 21:33:22 +00:00
|
|
|
|
2015-09-26 17:35:31 +00:00
|
|
|
// Bit 0: Floppy, Bit 1: FPU, Bit 2: Mouse, Bits 4-5: 80x25 Color Video, Bits 6-7: 2 floppy drives
|
|
|
|
#define CMOS_EQUIPMENT_LIST 0x6F
|
|
|
|
|
|
|
|
|
2013-11-10 13:12:02 +00:00
|
|
|
#define WRITE_CMOS_DATA(Cmos, Value) \
|
|
|
|
((Cmos).StatusRegB & CMOS_STB_BINARY) ? (Value) : BCD_TO_BINARY(Value)
|
|
|
|
|
|
|
|
#define READ_CMOS_DATA(Cmos, Value) \
|
|
|
|
((Cmos).StatusRegB & CMOS_STB_BINARY) ? (Value) : BINARY_TO_BCD(Value)
|
|
|
|
|
2013-11-03 21:33:22 +00:00
|
|
|
typedef enum _CMOS_REGISTERS
|
|
|
|
{
|
|
|
|
CMOS_REG_SECONDS,
|
|
|
|
CMOS_REG_ALARM_SEC,
|
|
|
|
CMOS_REG_MINUTES,
|
|
|
|
CMOS_REG_ALARM_MIN,
|
|
|
|
CMOS_REG_HOURS,
|
|
|
|
CMOS_REG_ALARM_HRS,
|
|
|
|
CMOS_REG_DAY_OF_WEEK,
|
|
|
|
CMOS_REG_DAY,
|
|
|
|
CMOS_REG_MONTH,
|
|
|
|
CMOS_REG_YEAR,
|
|
|
|
CMOS_REG_STATUS_A,
|
|
|
|
CMOS_REG_STATUS_B,
|
|
|
|
CMOS_REG_STATUS_C,
|
|
|
|
CMOS_REG_STATUS_D,
|
|
|
|
CMOS_REG_DIAGNOSTICS,
|
2013-11-10 13:12:02 +00:00
|
|
|
CMOS_REG_SHUTDOWN_STATUS,
|
2015-09-26 17:35:31 +00:00
|
|
|
CMOS_REG_EQUIPMENT_LIST = 0x14,
|
2014-01-25 00:21:51 +00:00
|
|
|
CMOS_REG_BASE_MEMORY_LOW = 0x15,
|
|
|
|
CMOS_REG_BASE_MEMORY_HIGH = 0x16,
|
|
|
|
CMOS_REG_EXT_MEMORY_LOW = 0x17,
|
|
|
|
CMOS_REG_EXT_MEMORY_HIGH = 0x18,
|
2015-10-01 00:09:24 +00:00
|
|
|
CMOS_REG_SYSOP = 0x2D,
|
2014-01-25 00:21:51 +00:00
|
|
|
CMOS_REG_ACTUAL_EXT_MEMORY_LOW = 0x30,
|
|
|
|
CMOS_REG_ACTUAL_EXT_MEMORY_HIGH = 0x31,
|
[NTVDM]
- Add some level of "Advanced debugging" (see ntvdm.h) which one can adjust to enable/disable debugging features inside NTVDM (this can be useful as long as NTVDM is under heavy bugfixing. When it will be more perfect, this stuff will be removed).
- Add the possibility to load option ROMs at a given segment. Currently their list should be specified from inside ntvdm.c (in the BiosInitialize call), but I plan to make it available from a registry option (or via command-line for NTVDM-standalone mode).
- Start to separate the initialization of "static" BIOS data (stuff that lives in ROM space) and initialization of "dynamic" BIOS data (eg. initializing the interrupt vector table, the BIOS data area at segment 40h, ...) so that we may be able to reuse part of our code to be able to more-or-less run external (16-bit) BIOSes, or the Windows NTVDM BIOS that uses BOPs to run some of its stuff in ntvdm in 32-bit (as we do for our 32-bit BIOS, except that *all* of our bios is 32-bit, not just some parts). Also, some file reorganization will be in order there soon...
- Add video BIOS version information in memory so that tools such as Microsoft Diagnostics can correctly recognize our video BIOS (btw, we try to emulate the functionality of Cirrus' CL-GD5434).
- Correctly put video BIOS ROM header (+ checksum) in memory so that it is recognized as such by diagnostics tools.
- During BIOS POST, scan for ROMs starting segment 0xC000 (where video ROMs reside).
- Store statically the BIOS configuration table.
- Fix INT 16h, AH=12h "Get extended shift states" so that it correctly returns the state of right Ctrl and Alt keys.
- Fix bit-setting state; report that our keyboard is 101/102 enhanced keyboard.
- Correctly set the error return values (AH=86h and CF set) when a function of INT 15h is unsupported.
- Implement INT 15h, AH=C9h "Get CPU Type and Mask Revision"; INT 1Ah, AH=02h "Get Real-Time Clock Time" and Ah=04h "Get Real-Time Clock Date" by reading the CMOS.
- Implement CMOS century register support.
svn path=/trunk/; revision=68598
2015-08-04 20:17:05 +00:00
|
|
|
CMOS_REG_CENTURY = 0x32,
|
2014-01-25 00:21:51 +00:00
|
|
|
CMOS_REG_MAX = 0x40
|
2013-11-03 21:33:22 +00:00
|
|
|
} CMOS_REGISTERS, *PCMOS_REGISTERS;
|
|
|
|
|
2013-11-10 13:12:02 +00:00
|
|
|
/*
|
|
|
|
* CMOS Memory Map
|
|
|
|
*
|
|
|
|
* See the following documentation for more information:
|
|
|
|
* http://www.intel-assembler.it/portale/5/cmos-memory-map-123/cmos-memory-map-123.asp
|
|
|
|
* http://wiki.osdev.org/CMOS
|
2013-11-11 02:35:06 +00:00
|
|
|
* http://www.walshcomptech.com/ohlandl/config/cmos_registers.html
|
|
|
|
* http://www.fysnet.net/cmosinfo.htm
|
2013-11-10 13:12:02 +00:00
|
|
|
* http://www.bioscentral.com/misc/cmosmap.htm
|
|
|
|
*/
|
|
|
|
#pragma pack(push, 1)
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
BYTE Second; // 0x00
|
|
|
|
BYTE AlarmSecond; // 0x01
|
|
|
|
BYTE Minute; // 0x02
|
|
|
|
BYTE AlarmMinute; // 0x03
|
|
|
|
BYTE Hour; // 0x04
|
|
|
|
BYTE AlarmHour; // 0x05
|
|
|
|
BYTE DayOfWeek; // 0x06
|
|
|
|
BYTE Day; // 0x07
|
|
|
|
BYTE Month; // 0x08
|
|
|
|
BYTE Year; // 0x09
|
|
|
|
|
|
|
|
BYTE StatusRegA; // 0x0a
|
|
|
|
BYTE StatusRegB; // 0x0b
|
|
|
|
} CMOS_CLOCK, *PCMOS_CLOCK;
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
union
|
|
|
|
{
|
|
|
|
struct
|
|
|
|
{
|
2015-09-26 17:35:31 +00:00
|
|
|
CMOS_CLOCK; // 0x00 - 0x0b
|
|
|
|
BYTE StatusRegC; // 0x0c
|
|
|
|
BYTE StatusRegD; // 0x0d
|
|
|
|
BYTE Diagnostics; // 0x0e
|
|
|
|
BYTE ShutdownStatus; // 0x0f
|
|
|
|
BYTE FloppyDrivesType; // 0x10
|
|
|
|
BYTE Reserved0; // 0x11
|
|
|
|
BYTE HardDrivesType; // 0x12
|
|
|
|
BYTE Reserved1; // 0x13
|
|
|
|
BYTE EquipmentList; // 0x14
|
|
|
|
BYTE BaseMemoryLow; // 0x15
|
|
|
|
BYTE BaseMemoryHigh; // 0x16
|
|
|
|
BYTE ExtMemoryLow; // 0x17
|
|
|
|
BYTE ExtMemoryHigh; // 0x18
|
|
|
|
BYTE ExtHardDrivesType[2]; // 0x19 - 0x1a
|
|
|
|
BYTE Reserved2[0x15]; // 0x1b
|
|
|
|
BYTE ActualExtMemoryLow; // 0x30
|
|
|
|
BYTE ActualExtMemoryHigh; // 0x31
|
|
|
|
BYTE Century; // 0x32
|
2013-11-10 13:12:02 +00:00
|
|
|
};
|
2015-09-26 17:35:31 +00:00
|
|
|
BYTE Regs1[0x10]; // 0x00 - 0x0f
|
|
|
|
BYTE Regs [0x40]; // 0x00 - 0x3f
|
2013-11-10 13:12:02 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Extended information 0x40 - 0x7f
|
|
|
|
*/
|
|
|
|
} CMOS_MEMORY, *PCMOS_MEMORY;
|
|
|
|
#pragma pack(pop)
|
|
|
|
|
|
|
|
C_ASSERT(sizeof(CMOS_MEMORY) == 0x40);
|
|
|
|
|
|
|
|
/* FUNCTIONS ******************************************************************/
|
|
|
|
|
2013-11-03 21:33:22 +00:00
|
|
|
BOOLEAN IsNmiEnabled(VOID);
|
|
|
|
DWORD RtcGetTicksPerSecond(VOID);
|
2013-11-10 13:12:02 +00:00
|
|
|
|
2014-01-11 20:59:27 +00:00
|
|
|
VOID CmosInitialize(VOID);
|
2013-11-10 13:12:02 +00:00
|
|
|
VOID CmosCleanup(VOID);
|
|
|
|
|
2015-10-03 21:47:46 +00:00
|
|
|
#endif /* _CMOS_H_ */
|