- usually the realtime synchronization keeps the PIT-based system clock in sync

with the host time. After using a runtime config dialog or save and restore
  simulation, this behaviour makes the PIT clock and the VGA update timer
  running way too fast until it's back in sync. Now the elapsed time is stored
  in the variable 'real_time_delay' and it is used to let the PIT clock run at
  realtime speed, even if it is out of sync.
This commit is contained in:
Volker Ruppert 2011-08-15 10:37:41 +00:00
parent 83f0e388c5
commit 7bbfee58a2
4 changed files with 19 additions and 8 deletions

View File

@ -26,6 +26,7 @@
#include "param_names.h"
#include "iodev.h"
#include "virt_timer.h"
bx_simulator_interface_c *SIM = NULL;
logfunctions *siminterface_log = NULL;
@ -835,6 +836,7 @@ void bx_real_sim_c::update_runtime_options()
temp = temp->next;
}
bx_gui->update_drive_status_buttons();
bx_virt_timer.set_realtime_delay();
}
bx_bool bx_real_sim_c::is_sim_thread()

View File

@ -427,6 +427,7 @@ void bx_devices_c::register_state()
void bx_devices_c::after_restore_state()
{
bx_slowdown_timer.after_restore_state();
bx_virt_timer.set_realtime_delay();
#if BX_SUPPORT_PCI
if (SIM->get_param_bool(BXPN_I440FX_SUPPORT)->get()) {
pluginPciBridge->after_restore_state();

View File

@ -93,13 +93,8 @@
//Debug with printf options.
#define DEBUG_REALTIME_WITH_PRINTF 0
//Use to test execution at multiples of real time.
#define TIME_DIVIDER (1)
#define TIME_MULTIPLIER (1)
#define TIME_HEADSTART (0)
#define GET_VIRT_REALTIME64_USEC() (((bx_get_realtime64_usec()*(Bit64u)TIME_MULTIPLIER/(Bit64u)TIME_DIVIDER)))
#define GET_VIRT_REALTIME64_USEC() (bx_get_realtime64_usec())
//Set up Logging.
#define LOG_THIS bx_virt_timer.
@ -398,10 +393,11 @@ void bx_virt_timer_c::init(void)
//Real time variables:
#if BX_HAVE_REALTIME_USEC
last_real_time = GET_VIRT_REALTIME64_USEC()+(Bit64u)TIME_HEADSTART*(Bit64u)USEC_PER_SECOND;
last_real_time = GET_VIRT_REALTIME64_USEC();
#endif
total_real_usec = 0;
last_realtime_delta = 0;
real_time_delay = 0;
//System time variables:
last_usec = 0;
usec_per_second = USEC_PER_SECOND;
@ -474,7 +470,7 @@ void bx_virt_timer_c::timer_handler(void)
if (usec_delta) {
#if BX_HAVE_REALTIME_USEC
Bit64u ticks_delta = 0;
Bit64u real_time_delta = GET_VIRT_REALTIME64_USEC() - last_real_time;
Bit64u real_time_delta = GET_VIRT_REALTIME64_USEC() - last_real_time - real_time_delay;
Bit64u real_time_total = real_time_delta + total_real_usec;
Bit64u system_time_delta = (Bit64u)usec_delta + (Bit64u)stored_delta;
if(real_time_delta) {
@ -563,3 +559,10 @@ void bx_virt_timer_c::pc_system_timer_handler(void* this_ptr)
{
((bx_virt_timer_c *)this_ptr)->timer_handler();
}
void bx_virt_timer_c::set_realtime_delay()
{
if (virtual_timers_realtime) {
real_time_delay = GET_VIRT_REALTIME64_USEC() - last_real_time;
}
}

View File

@ -62,6 +62,7 @@ private:
Bit64u last_real_time;
Bit64u total_real_usec;
Bit64u last_realtime_delta;
Bit64u real_time_delay;
//System time variables:
Bit64u last_usec;
Bit64u usec_per_second;
@ -147,6 +148,10 @@ public:
void init(void);
void register_state(void);
//Determine the real time elapsed during runtime config or between save and
//restore.
void set_realtime_delay(void);
};
BOCHSAPI extern bx_virt_timer_c bx_virt_timer;