1997-08-09 01:43:15 +00:00
|
|
|
/*
|
|
|
|
** No copyright?!
|
|
|
|
*/
|
2002-03-07 12:52:27 +00:00
|
|
|
|
|
|
|
#include <sys/cdefs.h>
|
|
|
|
__FBSDID("$FreeBSD$");
|
|
|
|
|
1997-08-09 01:43:15 +00:00
|
|
|
#include "doscmd.h"
|
|
|
|
|
|
|
|
static void
|
2001-12-02 13:48:40 +00:00
|
|
|
int08(regcontext_t *REGS __unused)
|
1997-08-09 01:43:15 +00:00
|
|
|
{
|
2001-08-14 11:54:37 +00:00
|
|
|
*(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 */
|
|
|
|
}
|
2001-10-02 11:28:59 +00:00
|
|
|
/* What is the real BIOS' sequence? */
|
|
|
|
send_eoi();
|
1997-08-09 01:43:15 +00:00
|
|
|
softint(0x1c);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2001-12-02 13:48:40 +00:00
|
|
|
int1c(regcontext_t *REGS __unused)
|
1997-08-09 01:43:15 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
unsigned char timer;
|
|
|
|
|
|
|
|
static u_char
|
2001-12-02 13:48:40 +00:00
|
|
|
inb_timer(int port __unused)
|
1997-08-09 01:43:15 +00:00
|
|
|
{
|
|
|
|
return (--timer);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
timer_init(void)
|
|
|
|
{
|
|
|
|
u_long vec;
|
|
|
|
struct itimerval itv;
|
2001-08-14 11:54:37 +00:00
|
|
|
struct timeval tv;
|
|
|
|
time_t tv_sec;
|
|
|
|
struct timezone tz;
|
|
|
|
struct tm tm;
|
1997-08-09 01:43:15 +00:00
|
|
|
|
|
|
|
vec = insert_hardint_trampoline();
|
|
|
|
ivec[0x08] = vec;
|
|
|
|
register_callback(vec, int08, "int 08");
|
|
|
|
|
|
|
|
vec = insert_softint_trampoline();
|
|
|
|
ivec[0x1c] = vec;
|
|
|
|
register_callback(vec, int1c, "int 1c");
|
|
|
|
|
|
|
|
define_input_port_handler(0x42, inb_timer);
|
|
|
|
define_input_port_handler(0x40, inb_timer);
|
|
|
|
|
2001-08-14 11:54:37 +00:00
|
|
|
/* 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;
|
|
|
|
|
1997-08-09 01:43:15 +00:00
|
|
|
itv.it_interval.tv_sec = 0;
|
2001-10-12 10:31:00 +00:00
|
|
|
itv.it_interval.tv_usec = 54925; /* 1193182/65536 times per second */
|
1997-08-09 01:43:15 +00:00
|
|
|
itv.it_value.tv_sec = 0;
|
2001-10-12 10:31:00 +00:00
|
|
|
itv.it_value.tv_usec = 54925; /* 1193182/65536 times per second */
|
1997-08-09 01:43:15 +00:00
|
|
|
if (! timer_disable)
|
|
|
|
setitimer(ITIMER_REAL, &itv, 0);
|
|
|
|
}
|