4 * $FreeBSD: src/usr.bin/doscmd/timer.c,v 1.2.2.2 2002/04/25 11:04:51 tg Exp $
5 * $DragonFly: src/usr.bin/doscmd/timer.c,v 1.2 2003/06/17 04:29:26 dillon Exp $
10 int08(regcontext_t
*REGS __unused
)
12 *(u_long
*)&BIOSDATA
[0x6c] += 1; /* ticks since midnight */
13 while (*(u_long
*)&BIOSDATA
[0x6c] >= 24*60*6*182) {
14 *(u_long
*)&BIOSDATA
[0x6c] -= 24*60*6*182;
15 BIOSDATA
[0x70]++; /* # times past mn */
17 /* What is the real BIOS' sequence? */
23 int1c(regcontext_t
*REGS __unused
)
30 inb_timer(int port __unused
)
45 vec
= insert_hardint_trampoline();
47 register_callback(vec
, int08
, "int 08");
49 vec
= insert_softint_trampoline();
51 register_callback(vec
, int1c
, "int 1c");
53 define_input_port_handler(0x42, inb_timer
);
54 define_input_port_handler(0x40, inb_timer
);
56 /* Initialize time counter BIOS variable. */
57 gettimeofday(&tv
, &tz
);
59 tm
= *localtime(&tv_sec
);
60 *(u_long
*)&BIOSDATA
[0x6c] =
61 (((tm
.tm_hour
* 60 + tm
.tm_min
) * 60) + tm
.tm_sec
) * 182 / 10;
63 itv
.it_interval
.tv_sec
= 0;
64 itv
.it_interval
.tv_usec
= 54925; /* 1193182/65536 times per second */
65 itv
.it_value
.tv_sec
= 0;
66 itv
.it_value
.tv_usec
= 54925; /* 1193182/65536 times per second */
68 setitimer(ITIMER_REAL
, &itv
, 0);