rc.8: Fix description of fsck durig startup
[dragonfly.git] / usr.bin / doscmd / timer.c
blobbaba43dc8a01c36a90a1a4e6d8b1f90ac558912e
1 /*
2 * No copyright?!
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 $
6 */
7 #include "doscmd.h"
9 static void
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? */
18 send_eoi();
19 softint(0x1c);
22 static void
23 int1c(regcontext_t *REGS __unused)
27 unsigned char timer;
29 static u_char
30 inb_timer(int port __unused)
32 return (--timer);
35 void
36 timer_init(void)
38 u_long vec;
39 struct itimerval itv;
40 struct timeval tv;
41 time_t tv_sec;
42 struct timezone tz;
43 struct tm tm;
45 vec = insert_hardint_trampoline();
46 ivec[0x08] = vec;
47 register_callback(vec, int08, "int 08");
49 vec = insert_softint_trampoline();
50 ivec[0x1c] = vec;
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);
58 tv_sec = tv.tv_sec;
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 */
67 if (! timer_disable)
68 setitimer(ITIMER_REAL, &itv, 0);