diff --git a/bochs/pc_system.cc b/bochs/pc_system.cc index 20e7556e0..791239e0b 100644 --- a/bochs/pc_system.cc +++ b/bochs/pc_system.cc @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////// -// $Id: pc_system.cc,v 1.31 2002-10-25 11:44:33 bdenney Exp $ +// $Id: pc_system.cc,v 1.32 2003-02-14 04:22:16 yakovlev Exp $ ///////////////////////////////////////////////////////////////////////// // // Copyright (C) 2002 MandrakeSoft S.A. @@ -78,6 +78,8 @@ bx_pc_system_c::bx_pc_system_c(void) currCountdown = NullTimerInterval; currCountdownPeriod = NullTimerInterval; numTimers = 1; // So far, only the nullTimer. + lastTimeUsec = 0; + usecSinceLast = 0; } void @@ -419,6 +421,21 @@ bx_pc_system_c::timebp_handler(void* this_ptr) } #endif // BX_DEBUGGER + Bit64u +bx_pc_system_c::time_usec_sequential() { + Bit64u this_time_usec = time_usec(); + if(this_time_usec != lastTimeUsec) { + Bit64u diff_usec = this_time_usec-lastTimeUsec; + lastTimeUsec = this_time_usec; + if(diff_usec >= usecSinceLast) { + usecSinceLast = 0; + } else { + usecSinceLast -= diff_usec; + } + } + usecSinceLast++; + return (this_time_usec+usecSinceLast); +} Bit64u bx_pc_system_c::time_usec() { return (Bit64u) (((double)(Bit64s)time_ticks()) / m_ips ); diff --git a/bochs/pc_system.h b/bochs/pc_system.h index 0ad25f260..7e23099f9 100644 --- a/bochs/pc_system.h +++ b/bochs/pc_system.h @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////// -// $Id: pc_system.h,v 1.23 2002-12-15 16:00:41 bdenney Exp $ +// $Id: pc_system.h,v 1.24 2003-02-14 04:22:16 yakovlev Exp $ ///////////////////////////////////////////////////////////////////////// // // Copyright (C) 2002 MandrakeSoft S.A. @@ -70,6 +70,8 @@ private: Bit32u currCountdown; // Current countdown ticks value (decrements to 0). Bit32u currCountdownPeriod; // Length of current countdown period. Bit64u ticksTotal; // Num ticks total since start of emulator execution. + Bit64u lastTimeUsec; // Last sequentially read time in usec. + Bit64u usecSinceLast; // Number of useconds claimed since then. // A special null timer is always inserted in the timer[0] slot. This // make sure that at least one timer is always active, and that the @@ -137,6 +139,7 @@ public: void activate_timer_ticks(unsigned index, Bit64u instructions, bx_bool continuous); Bit64u time_usec(); + Bit64u time_usec_sequential(); static BX_CPP_INLINE Bit64u time_ticks() { return bx_pc_system.ticksTotal + Bit64u(bx_pc_system.currCountdownPeriod - bx_pc_system.currCountdown);