Menu

#565 Real Time Clock /CMOS fix

applied_to_SVN
closed
None
1
2023-12-04
2021-11-16
No

Observed issues:

Due to some limitations only dates between 1980 and 2038 can be used in a reliable way.
Bochs incorrectly assumes a one to one correspondence between the data returned by <time.h> functions localtime() and mktime(), and isn't setting the latter properly.
Bochs keeps its internal time value dependent to these functions after setup, assuming that their internal settings won't change during runtime - which is not the case.
In my os, and in my timezone, this leads to incorrect startup values for 5 months each year and unreliable values if the simulation is kept going for some time. (a feedback between localtime() and mktime() is created which keeps shifting back the time).
Also, the RTC simulation is not realistic since the clock fixes itself across DST changes, without updating any DST related flag, a behaviour that no guest OS expects.</time.h>

This patch addresses these problems by adding support for any time value that can be represented by the CMOS, making the time act in a linear way, and detaching it from the OS time related functions by implementing a few local, portable ones in a small library. This also solves Y2K38 issues.
A summary of what this patch does can be found in the patchfile, and a more detailed explanation of what I have done and why can be found inside the newly created "iodev/utctime.h" library file.
Feel free to contact me for any doubts or problems regarding this.

1 Attachments

Discussion

  • Michele Giacomone

    I did finally find an issue I didn't detect before, I did not set up the time0 parameter acquisition for time-formatted strings properly. I'm also unable to load date and time information from a cmos memory image. I'll provide a new attachment as soon as I've fixed those problems

     
  • Michele Giacomone

    In the following attachment, I've solved the issues I talked about in the previous post (they were minor fixes), however I've encountered two other problems I can't fix:

    1 - Somehow the rtc_init parameter is read correctly from config files (tested with code in config.cc) but is reset to 0 somewhere closely following, so it has to be set to 1 (=image) manually at runtime each time (Issue not correlated to my changes)
    2 - I've completed the support for 12hour and Binary modes for the RTC, in cmos.cc and rombios.c, since it was only partially present. Despite these being really minor changes, I couldn't test them since I couldn't make BIOS-bochs-latest in the usual manner, due to some broken reference (again, not related to my changes), so this need thorough checking

    All the other issues I observed are now solved, finally I can get my simulated machines' clocks to run consistently

     
  • Stanislav Shwartsman

    Merged into master

     
  • Stanislav Shwartsman

    • status: open --> closed
    • assigned_to: Volker Ruppert
    • Group: to_be_validated --> applied_to_SVN
     

Log in to post a comment.