The strange thing is: The CMOS (ports 0x70-0x71, as well as alternative timer source XT RTC at ports 0x240-0x249 and 0x250-0x257, which is mapped as an extension to the CMOS RTC(only thing that's extended is the microseconds time subdivision, which isn't supported on the plain CMOS RTC used in the AT and up)) is already emulated:
https://bitbucket.org/superfury/unipcemu/src/ … MOS.c?at=master
Also, when the emulator is terminated (doneEMU is called from the emulator core before the application is quit), it calls saveCMOS, which saves the CMOS in the Settings file(which is reloaded when the emulator is restarted or started for the first time). Thus the 'CMOS RAM' is virtual static RAM(it keeps it's values between sessions until cleared using the Settings menu option, or when the SETTINGS.DAT is deleted).
The CMOS data is copied from the emulator Settings file when emulation is started. It's saved back into the Settings file when the emulator is terminated (it's also flagged as present from that point on, until it's 'erased', which in the case of UniPCemu means setting a special flag in the emulator SETTINGS.DAT to zero (which causes the CMOS data to be invalidated)).
Btw, just tried to reinstall Windows 3.0 on the XT 286 configuration(With Turbo XT BIOS and XTIDE BIOS), but it eventually seems to hang when installing the applications. Looking using the debugger reveals it's in a infinite loop checking the head against the tail of the keyboard buffer? The head isn't the same as the buffer, and it only jumps back(JNZ) when the head and tail don't match, which is OK. But after that, it executes a STI and jumps back to the start of the handler, which in turn executes CLI and starts the head-tail check again. This results in an infinite loop?
UniPCemu_SETTINGS.zip
Address 2047 is the flag indicating validity (1 for valid).
Immediately before that is the CMOS data itself, which consists of:
1. 128 bytes of static CMOS RAM.
2. Actual time divergeance in seconds (64-bit signed integer)
3. Actual time divergeance in us(64-bit signed integer). These two divergeances together create the time divergeance used by the emulator to get and set the virtual time.
4. 100th seconds, for the XT RTC (byte).
5. 10000th seconds, for the XT RTC (byte).
6. 8 bytes of extra RAM (Extra RAM data from XT RTC(UM82C8167), for 56 bits of extra RAM!).
So the complete CMOS data is 154 bytes large, starting at address 1893 in the Settings file(that location has the entire 128 bytes of CMOS RAM followed by the data mentioned at points 2-6).
The AT RTC is based on http://wiki.osdev.org/RTC and http://wiki.osdev.org/CMOS . The XT RTC (UM82C8167) is directly based on the datasheets of the chip itself.
Using a little hex editor (XVI32) to extract the CMOS data from it:
SETTINGS.DAT_CMOSRAM.zip