VOGONS


First post, by superfury

User metadata
Rank l33t++
Rank
l33t++

Just thought I'd mention that little project of mine here.

https://bitbucket.org/superfury/unipcemu_pcxtbios_at/

It's a simple option ROM, which adds support for interrupt 1Ah date/time support like the TIMER.COM 1.2 performs, but as a BIOS ROM with actual BIOS support instead.

So the added functionality (implemented by hooking INT 15h for it's special storage reserved (function call FE00h for setting DS to the data area for storing private data like hooked interrupt data and other settings) from the BIOS and INT 19h for performing the INT 1Ah hook and initialization).

I've currently left the AT functionality for the RTC to simply let the original BIOS handle it (as it has a CMOS on the AT anyways).
The XT otoh actually implements INT 1Ah function 02h and up (the date/time functions), while erroring out (setting the carry flag) on the alarm functions (as the alarm isn't usable anyways with said chip, as well as it's IRQ being unknown).

Tried it under UniPCemu with it's slightly updated RTC (the current commit, which is ahead of the current release) and it seems to work fine. Both the date and time seem to be set correctly on the RTC chip, as well as MS-DOS reading the date/time from the chip. 😁

Verified it's functionality with MS-DOS 6.22 running inside UniPCemu built from the current commit. The current release version of UniPCemu should also work, but lacks some new advanced features (time counter ripple detection while reading the counters and starting newly set time (INT 1Ah function 03h/05h) with sub-second counters properly cleared).

Although it only supports the base address of 240h and no autodetection of any kind is performed (AT is detected by the CMOS chip and disables the whole functionality. I might implement the CMOS method later as well).

Although when testing, I noticed it requires at least a cycle count of ~700 KIPS to operate properly (due to the time update ripple otherwise occurring for all loops trying to read the time fields from the RTC, causing the BIOS to try to keep reading it infinitely, never returning to the caller).

Thoughts?

Last edited by superfury on 2022-12-19, 01:02. Edited 2 times in total.

Author of the UniPCemu emulator.
UniPCemu Git repository
UniPCemu for Android, Windows, PSP, Vita and Switch on itch.io

Reply 1 of 3, by superfury

User metadata
Rank l33t++
Rank
l33t++

I've done some more testing, but although the MS-DOS 6.22 installation seems to properly use the date, the time is ignored?
Setting the date and time seems to work properly, as both TIMER.COM and the hardware itself displays the correct time.
Using the date and time command to modify the date/time respectively properly updates the RTC chip as well, which is also confirmed by the TIMER.COM as well (UniPCemu's time divergeance field when saving the current CMOS by terminating the app also confirms that the time is properly updated by the INT 1Ah handler).

The weird thing is that somehow MS-DOS counts the read time (hours:minutes:seconds:DST fields) as invalid it seems? It always sets it's own clock to midnight (although the date is set properly)?
TIMER.COM displays the correct values (it effectively does the same thing as the option ROM performs, reading the clock from the XT-RTC chip).

Author of the UniPCemu emulator.
UniPCemu Git repository
UniPCemu for Android, Windows, PSP, Vita and Switch on itch.io

Reply 2 of 3, by superfury

User metadata
Rank l33t++
Rank
l33t++

One interesting thing is that it uses INT 15h function FE00h (result becomes AX=00FEh, swapping the two registers AL and AH) to get it's own data segment it allocated during POST.
Is AH=FEh AL=00h a good combination to use for that function number? According to Ralf Brown's interrupt list it's free, but I don't know for sure if such a function number (in this case a 16-bit function number as it were, as it needs to match AX entirely)?
Anyone knows if it's safe to use that function number or if a better option for such a function number should be made?

Author of the UniPCemu emulator.
UniPCemu Git repository
UniPCemu for Android, Windows, PSP, Vita and Switch on itch.io

Reply 3 of 3, by superfury

User metadata
Rank l33t++
Rank
l33t++

Just improved the BIOS option ROM a bit. It will now set the system time based on the retrieved RTC time when the INT19h handler initializes and hooks the INT 1Ah handler.

So that seems to fix MS-DOS displaying the wrong time, as long as the onboard clock runs at the correct rate relative to the RTC clock.
The convert-and-set code for setting the BIOS time to the RTC time was simply grabbed from the RTC code of the 8088 BIOS (https://github.com/skiselev/8088_bios) by Sergey Kiselev.

So now MS-DOS correctly can get and set the date (although the time isn't synchronized after initial loading because of the obvious BIOS timer issue in loading it).
It is actually loaded when the BIOS option ROM initializes itself using the INT19h hook (which is done once only).

Author of the UniPCemu emulator.
UniPCemu Git repository
UniPCemu for Android, Windows, PSP, Vita and Switch on itch.io