summaryrefslogtreecommitdiffstats
path: root/usr.bin/doscmd/timer.c
diff options
context:
space:
mode:
authortg <tg@FreeBSD.org>2001-08-14 11:54:37 +0000
committertg <tg@FreeBSD.org>2001-08-14 11:54:37 +0000
commit24059a36ee40d77d39e304cbb2c70e33d68c6c5f (patch)
treee62880a7da35ee071e19601635cc1d3d383500bb /usr.bin/doscmd/timer.c
parent24c7b0a61de73d3a99eea4c734e505e91acb7e7c (diff)
downloadFreeBSD-src-24059a36ee40d77d39e304cbb2c70e33d68c6c5f.zip
FreeBSD-src-24059a36ee40d77d39e304cbb2c70e33d68c6c5f.tar.gz
Move update of BIOS variable at 0x6c (time counter) completely to timer.c.
Suggested by: Igor Serikov <bt@turtle.pangeatech.com>
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