summaryrefslogtreecommitdiffstats
path: root/usr.bin/doscmd/timer.c
diff options
context:
space:
mode:
Diffstat (limited to 'usr.bin/doscmd/timer.c')
-rw-r--r--usr.bin/doscmd/timer.c26
1 files changed, 16 insertions, 10 deletions
diff --git a/usr.bin/doscmd/timer.c b/usr.bin/doscmd/timer.c
index a91c8d1..7f40725 100644
--- a/usr.bin/doscmd/timer.c
+++ b/usr.bin/doscmd/timer.c
@@ -8,16 +8,11 @@
static void
int08(regcontext_t *REGS)
{
- struct timeval tv;
- time_t tv_sec;
- struct timezone tz;
- struct tm tm;
-
- gettimeofday(&tv, &tz);
- tv_sec = tv.tv_sec;
- tm = *localtime(&tv_sec);
- *(u_long *)&BIOSDATA[0x6c] =
- (((tm.tm_hour * 60 + tm.tm_min) * 60) + tm.tm_sec) * 182 / 10;
+ *(u_long *)&BIOSDATA[0x6c] += 1; /* ticks since midnight */
+ while (*(u_long *)&BIOSDATA[0x6c] >= 24*60*6*182) {
+ *(u_long *)&BIOSDATA[0x6c] -= 24*60*6*182;
+ BIOSDATA[0x70]++; /* # times past mn */
+ }
softint(0x1c);
}
@@ -40,6 +35,10 @@ timer_init(void)
{
u_long vec;
struct itimerval itv;
+ struct timeval tv;
+ time_t tv_sec;
+ struct timezone tz;
+ struct tm tm;
vec = insert_hardint_trampoline();
ivec[0x08] = vec;
@@ -52,6 +51,13 @@ timer_init(void)
define_input_port_handler(0x42, inb_timer);
define_input_port_handler(0x40, inb_timer);
+ /* Initialize time counter BIOS variable. */
+ gettimeofday(&tv, &tz);
+ tv_sec = tv.tv_sec;
+ tm = *localtime(&tv_sec);
+ *(u_long *)&BIOSDATA[0x6c] =
+ (((tm.tm_hour * 60 + tm.tm_min) * 60) + tm.tm_sec) * 182 / 10;
+
itv.it_interval.tv_sec = 0;
itv.it_interval.tv_usec = 54925; /* 1193182/65536 times per second */
itv.it_value.tv_sec = 0;
OpenPOWER on IntegriCloud