diff --git a/bochs/config.h.in b/bochs/config.h.in index 7245bfb78..3f4b60029 100644 --- a/bochs/config.h.in +++ b/bochs/config.h.in @@ -196,7 +196,7 @@ #define BX_HAVE_SOCKLEN_T 0 #define BX_HAVE_SOCKADDR_IN_SIN_LEN 0 #define BX_HAVE_GETTIMEOFDAY 0 -#define BX_HAVE_REALTIME_USEC BX_HAVE_GETTIMEOFDAY +#define BX_HAVE_REALTIME_USEC (BX_HAVE_GETTIMEOFDAY || BX_WITH_WIN32) // This turns on Roland Mainz's idle hack. Presently it is specific to the X11 // gui. If people try to enable it elsewhere, give a compile error after the diff --git a/bochs/iodev/pit_wrap.cc b/bochs/iodev/pit_wrap.cc index 3fa7225b9..70fc8b51e 100644 --- a/bochs/iodev/pit_wrap.cc +++ b/bochs/iodev/pit_wrap.cc @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////// -// $Id: pit_wrap.cc,v 1.37 2002-10-30 23:54:29 yakovlev Exp $ +// $Id: pit_wrap.cc,v 1.38 2002-12-04 19:51:51 yakovlev Exp $ ///////////////////////////////////////////////////////////////////////// // // Copyright (C) 2002 MandrakeSoft S.A. @@ -523,12 +523,15 @@ bx_pit_c::periodic( Bit32u usec_delta ) if(ticks_delta) { # if DEBUG_REALTIME_WITH_PRINTF if(((BX_PIT_THIS s.last_time + real_time_delta) / USEC_PER_SECOND) > (BX_PIT_THIS s.last_time / USEC_PER_SECOND)) { - printf("useconds: %lld, expected ticks: %lld, ticks: %lld, diff: %lld\n", - (Bit64u) BX_PIT_THIS s.total_sec, - (Bit64u)REAL_USEC_TO_TICKS(BX_PIT_THIS s.total_sec), - (Bit64u)BX_PIT_THIS s.total_ticks, - (Bit64u)(REAL_USEC_TO_TICKS(BX_PIT_THIS s.total_sec) - BX_PIT_THIS s.total_ticks) - ); + Bit64u temp1, temp2, temp3, temp4; + temp1 = (Bit64u) BX_PIT_THIS s.total_sec; + temp2 = REAL_USEC_TO_TICKS(BX_PIT_THIS s.total_sec); + temp3 = (Bit64u)BX_PIT_THIS s.total_ticks; + temp4 = (Bit64u)(REAL_USEC_TO_TICKS(BX_PIT_THIS s.total_sec) - BX_PIT_THIS s.total_ticks); + printf("useconds: %llu, ",temp1); + printf("expect ticks: %llu, ",temp2); + printf("ticks: %llu, ",temp3); + printf("diff: %llu\n",temp4); } # endif BX_PIT_THIS s.last_time += real_time_delta; @@ -543,8 +546,11 @@ bx_pit_c::periodic( Bit32u usec_delta ) Bit64u a,b; a=(BX_PIT_THIS s.usec_per_second); - b=((Bit64u)USEC_PER_SECOND * em_time_delta / real_time_delta); - + if(real_time_delta) { + b=((Bit64u)USEC_PER_SECOND * em_time_delta / real_time_delta); + } else { + b=a; + } BX_PIT_THIS s.usec_per_second = ALPHA_LOWER(a,b); #else ticks_delta=(Bit32u)(USEC_TO_TICKS(usec_delta)); diff --git a/bochs/osdep.cc b/bochs/osdep.cc index 2914f3a93..2f95beb02 100644 --- a/bochs/osdep.cc +++ b/bochs/osdep.cc @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////// -// $Id: osdep.cc,v 1.8 2002-09-25 19:24:26 cbothamy Exp $ +// $Id: osdep.cc,v 1.9 2002-12-04 19:51:51 yakovlev Exp $ ///////////////////////////////////////////////////////////////////////// // // Copyright (C) 2001 MandrakeSoft S.A. @@ -289,5 +289,21 @@ Bit64u bx_get_realtime64_usec (void) { mytime=(Bit64u)thetime.tv_sec*(Bit64u)1000000+(Bit64u)thetime.tv_usec; return mytime; } +# else +# if BX_WITH_WIN32 +Bit64u last_realtime64_top = 0; +Bit64u last_realtime64_bottom = 0; +Bit64u bx_get_realtime64_usec (void) { + Bit64u new_bottom = ((Bit64u) GetTickCount()) & 0x0FFFFFFFFll; + if(new_bottom < last_realtime64_bottom) { + last_realtime64_top += 0x0000000100000000ll; + } + last_realtime64_bottom = new_bottom; + Bit64u interim_realtime64 = + (last_realtime64_top & 0xFFFFFFFF00000000ll) | + (new_bottom & 0x00000000FFFFFFFFll); + return interim_realtime64*((Bit64u)1000ll); +} +# endif # endif #endif