Bochs/bochs/gui
Stanislav Shwartsman ffc722f4e8
Porting #SF patch #565 Real Time Clock /CMOS fix (#4)
by Michele Giacomone

Detailed description:

  -Observed issues

   Due to some limitations only dates between 1980 and 2038 can be
   used in a reliable way.
   Also, bochs incorrectly assumes a linear correspondence between
   the data returned by the <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
   on the go - 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 a long 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 behavior that no guest OS expects.

  -Proposed fix

   This is implemented in such way that no bochs' previous behavior
   is changed, a part from the broken ones, with legacy in mind
   == the user can keep using bochs exactly as before knowing nothing
      of this patch

   +Make the internal s.timeval variable a Bit64s, so it can fit all
    values that the cmos can correctly represent, reported below:
    MIN     setting  -62167219200 =>  0000/01/01 SAT  0:00:00
    MAX BCD setting  253402300799 =>  9999/12/31 FRI 23:59:59
    MAX BIN setting  745690751999 => 25599/12/31 FRI 23:59:59
    And then fix each reference to these so it can handle such values
    And make bochs correctly wrap around for under/overflows, so that
    only the most significant bits of the century are lost.

   +Do the same thing to the bochs time0 parameter, so all the above
    values can be chosen at startup (despite being now legal values,
    1 and 2 will still be treated as "local" and "utc"). Note that
    normally only BCD settings are valid since bochs' CMOS defaults
    to such operating mode - the only way to use the binary range
    is by loading a cmos memory map.

   +Make the internal s.timeval variable independent from external
    factors. This means providing a small set of time handling
    functions, contained in "iodev/utctime.h", which must work in
    any environment in which bochs compiles, accessing no external
    resource. This also means that after startup, s.timeval will only
    be changed internally, and no call to the OS time functions will
    be made.

   +Make the internal s.timeval variable timezone independent, to
    have a linear correlation between its values and valid CMOS
    settings. To make it easier, s.timeval is gonna be treated as
    if the current timezone was UTC: so,
     - if the user selects UTC as time0, s.timeval will become current
       time(NULL)
     - if the user selects localtime, s.timeval will be computed as
       the value which will display the same broken down time as
       localtime(&now)
     - if the user inputs a time formatted string the proper s.timeval
       to displayed will be easily calculated,
     - if the user inputs a starting time value, s.timeval will be
       computed as the value which will display the same broken down
       time as localtime(&user_input) to ensure the same operation as
       before.
    A "tz=utc" is displayed when bochs prints out the current time
    value, to warn users about the difference in meaning between the
    internally kept time value and the value they can set through
    the "time0=" parameter. This might be changed to communicate
    instead the time value they can input to get the same setting,
    but performing such calculation (except for the startup time)
    suffers from all the mktime()/localtime() problems listed above
    so I did not do it.
    The range of "time0" is automatically adjusted so all users in
    all time zones can set any legal value despite "time0=" having a
    local meaning.

  A thorough explanation of what I did and why can be found in the
  "iodev/utctime.h" library header.

---------

Co-authored-by: Stanislav Shwartsman <sshwarts@users.sourceforge.net>
Co-authored-by: Volker Ruppert <Volker.Ruppert@t-online.de>
2023-12-01 22:55:35 +01:00
..
bitmaps - deleted executable properties from source files 2011-04-03 10:29:19 +00:00
font - moved vga font to gui/font 2011-07-10 14:00:58 +00:00
keymaps Some work on the USB keyboard / keypad emulation. 2020-12-15 11:29:36 +00:00
amigagui.h - removed x/y tile size parameters from specific_init() since the tile dimensions 2012-03-03 12:41:24 +00:00
amigaos.cc remove trailing whitespace from source files 2022-08-23 21:46:04 +03:00
carbon.cc Changed bx_bool to bool type in the gui component of Bochs. 2021-01-30 18:32:52 +00:00
enh_dbg.cc move debug.h from bochs.h and include it only where required 2021-01-31 15:22:58 +00:00
enh_dbg.h Changed bx_bool to bool type in the gui component of Bochs. 2021-01-30 18:32:52 +00:00
gtk_enh_dbg_osdep.cc remove trailing whitespace from source files 2022-08-23 21:46:04 +03:00
gui.cc reset status bar items at reset (#142) 2023-11-21 08:58:21 +02:00
gui.h Attempt to fix some memory leaks in the plugins and gui code (discussion #144). 2023-11-25 18:15:47 +01:00
icon_bochs.h Adding Id and Rev property to all files 2011-02-24 22:05:47 +00:00
icon_bochs.xpm - fixed xpm-related warnings in 'x' and 'wx' 2011-02-10 23:00:56 +00:00
keymap.cc remove gui.h from bochs.h and include it only where required 2021-01-30 18:47:25 +00:00
keymap.h Changed bx_bool to bool type in the gui component of Bochs. 2021-01-30 18:32:52 +00:00
macintosh.cc Changed bx_bool to bool type in the gui component of Bochs. 2021-01-30 18:32:52 +00:00
Makefile.in Fixed gui DLL name. 2023-11-15 23:33:27 +01:00
nogui.cc Fixed nogui compilation. 2021-01-30 19:20:45 +00:00
paramtree.cc Fixed some memory leaks in the paramtree code (discussion #144). 2023-11-25 13:28:51 +01:00
paramtree.h Fixed some memory leaks in the paramtree code (discussion #144). 2023-11-25 13:28:51 +01:00
rfb.cc Added display library option for disabling the Bochs gui console - using system 2021-06-11 14:46:38 +00:00
rfb.h Prepare the RFB sources for the implementation of a new gui based on the 2013-05-30 09:31:21 +00:00
rfbkeys.h Some work on the new 'vncsrv' gui 2013-05-31 16:46:15 +00:00
scrollwin.cc Converted the win32config module to a plugin (using PLUGTYPE_CORE for now). 2021-03-26 19:12:09 +00:00
scrollwin.h initial implementation of scrollable dialog items on WIN32 2013-03-18 19:08:26 +00:00
sdl2.cc Modified error handling for display library option 'gui_debug'. 2023-11-19 16:16:09 +01:00
sdl.cc Modified error handling for display library option 'gui_debug'. 2023-11-19 16:16:09 +01:00
sdl.h Changing data type sdl fonts to "static const Bit8u" fixes conflict and 2017-01-01 19:37:26 +00:00
sdlkeys.h remove trailing whitespace from source files 2022-08-23 21:46:04 +03:00
siminterface.cc Some more memory leak fixes. 2023-11-26 15:44:38 +01:00
siminterface.h Some more memory leak fixes. 2023-11-26 15:44:38 +01:00
term.cc Changed bx_bool to bool type in the gui component of Bochs. 2021-01-30 18:32:52 +00:00
textconfig.cc Porting #SF patch #565 Real Time Clock /CMOS fix (#4) 2023-12-01 22:55:35 +01:00
vncsrv.cc Added display library option for disabling the Bochs gui console - using system 2021-06-11 14:46:38 +00:00
wenhdbg_res.h Added capability to use the gui debugger output window as a log viewer 2014-01-13 21:31:14 +00:00
win32_enh_dbg_osdep.cc move debug.h from bochs.h and include it only where required 2021-01-31 15:22:58 +00:00
win32.cc Memory leak fix in the win32 gui code. 2023-11-26 22:04:07 +01:00
win32config.cc In case of failure restore_config() resets the restore flag. 2023-11-04 15:09:44 +01:00
win32dialog.h Converted the win32config module to a plugin (using PLUGTYPE_CORE for now). 2021-03-26 19:12:09 +00:00
win32paramdlg.cc Converted the win32config module to a plugin (using PLUGTYPE_CORE for now). 2021-03-26 19:12:09 +00:00
win32paramdlg.h Added new symbol BX_USE_WIN32CONFIG in config.h and cleaned up related code 2014-06-20 09:31:56 +00:00
win32res.h Rewrite of the optional plugin control feature. 2021-01-21 18:10:40 +00:00
wx.cc Display lib options 'cmdmode' and 'gui_debug' are now ignored by the wxWidgets port. 2023-11-23 09:56:42 +01:00
wxdialog.cc Added modeless message box support for the wxWidgets port. 2023-11-05 19:05:24 +01:00
wxdialog.h Added modeless message box support for the wxWidgets port. 2023-11-05 19:05:24 +01:00
wxmain.cc Added modeless message box support for the wxWidgets port. 2023-11-05 19:05:24 +01:00
wxmain.h Small code cleanup. 2021-03-08 09:04:16 +00:00
x.cc Modified error handling for display library option 'gui_debug'. 2023-11-19 16:16:09 +01:00