X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?p=dosdemo;a=blobdiff_plain;f=src%2Fdos%2Ftimer.c;h=d6c3b520cf600c2cd0caf795ae50b9ecbbacdb46;hp=dcf790cfc0b494e11c9fe6f6ec13605e6252d3ee;hb=7cffbf057545fb303ad8f53e432ef42f7708e16d;hpb=68f89fa06ae5cfacde9cf8310e97220e5fc05260 diff --git a/src/dos/timer.c b/src/dos/timer.c index dcf790c..d6c3b52 100644 --- a/src/dos/timer.c +++ b/src/dos/timer.c @@ -16,6 +16,7 @@ #include "pit8254.h" #include "inttypes.h" +#include "util.h" #define PIT_TIMER_INTR 8 #define DOS_TIMER_INTR 0x1c @@ -45,7 +46,7 @@ static _go32_dpmi_seginfo intr, prev_intr; static void INTERRUPT timer_irq(); -static unsigned long ticks; +static volatile unsigned long ticks; static unsigned long tick_interval, ticks_per_dos_intr; static int inum; @@ -123,6 +124,16 @@ unsigned long get_msec(void) return ticks * tick_interval; } +void sleep_msec(unsigned long msec) +{ + unsigned long wakeup_time = ticks + msec / tick_interval; + while(ticks < wakeup_time) { +#ifdef USE_HLT + halt(); +#endif + } +} + static void set_timer_reload(int reload_val) { outp(PORT_CMD, CMD_CHAN0 | CMD_ACCESS_BOTH | CMD_OP_SQWAVE);