Add statclock and todr function arguments to the systemsw.

Add a system_set_todrfns() function.
This commit is contained in:
simonb 2002-06-01 14:38:27 +00:00
parent e8aaf3c28b
commit 9f6638d8c1
2 changed files with 30 additions and 10 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: systemsw.h,v 1.2 2002/03/06 07:35:13 simonb Exp $ */
/* $NetBSD: systemsw.h,v 1.3 2002/06/01 14:38:27 simonb Exp $ */
/*
* Copyright 2000, 2001
@ -49,9 +49,11 @@ struct systemsw {
void *s_clock_arg;
void (*s_clock_init)(void *);
void *s_statclock_arg;
void (*s_statclock_init)(void *);
void (*s_statclock_setrate)(void *, int);
void *s_todr_arg;
void (*s_inittodr)(void *, time_t);
void (*s_resettodr)(void *);
@ -60,7 +62,8 @@ struct systemsw {
};
extern struct systemsw systemsw;
int system_set_clockfns(void *, void (*init)(void *));
int system_set_clockfns(void *, void (*)(void *));
int system_set_todrfns(void *, void (*)(void *, time_t), void (*)(void *));
#define delay(n) ((*systemsw.s_delay)(n))
#define DELAY(n) ((*systemsw.s_delay)(n))

View File

@ -1,4 +1,4 @@
/* $NetBSD: systemsw.c,v 1.4 2002/05/03 03:36:51 simonb Exp $ */
/* $NetBSD: systemsw.c,v 1.5 2002/06/01 14:38:28 simonb Exp $ */
/*
* Copyright 2000, 2001
@ -51,8 +51,6 @@ static void inittodr_triv(void *, time_t);
static void microtime_triv(struct timeval *);
static void resettodr_triv(void *);
#define XXXNULL NULL
/* system function switch */
struct systemsw systemsw = {
cpu_intr_triv,
@ -64,12 +62,14 @@ struct systemsw systemsw = {
NULL, /* clock intr arg */
clock_init_triv,
NULL, /* statclock arg */
NULL, /* s_statclock_init: dflt no-op */
NULL, /* s_statclock_setrate: dflt no-op */
NULL, /* todr functions arg */
inittodr_triv,
resettodr_triv,
NULL, /* XXX: s_intr_establish */
NULL, /* intr_establish */
};
int
@ -83,6 +83,21 @@ system_set_clockfns(void *arg, void (*init)(void *))
return 0;
}
int
system_set_todrfns(void *arg, void (*init)(void *, time_t),
void (*reset)(void *))
{
if (systemsw.s_inittodr != inittodr_triv ||
systemsw.s_resettodr != resettodr_triv)
return 1;
systemsw.s_todr_arg = arg;
systemsw.s_inittodr = init;
systemsw.s_resettodr = reset;
return 0;
}
/* trivial microtime() implementation */
static void
microtime_triv(struct timeval *tvp)
@ -168,6 +183,7 @@ microtime(struct timeval *tvp)
static void
clock_init_triv(void *arg)
{
panic("clock_init_triv");
}
@ -192,7 +208,7 @@ cpu_initclocks(void)
(*systemsw.s_clock_init)(systemsw.s_clock_arg);
if (systemsw.s_statclock_init != NULL)
(*systemsw.s_statclock_init)(XXXNULL);
(*systemsw.s_statclock_init)(systemsw.s_statclock_arg);
/*
* ``Disable'' the compare interrupt by setting it to it's largest
@ -208,19 +224,20 @@ setstatclockrate(int hzrate)
{
if (systemsw.s_statclock_setrate != NULL)
(*systemsw.s_statclock_setrate)(XXXNULL, hzrate);
(*systemsw.s_statclock_setrate)(systemsw.s_statclock_arg,
hzrate);
}
void
inittodr(time_t t)
{
(*systemsw.s_inittodr)(XXXNULL, t);
(*systemsw.s_inittodr)(systemsw.s_todr_arg, t);
}
void
resettodr(void)
{
(*systemsw.s_resettodr)(XXXNULL);
(*systemsw.s_resettodr)(systemsw.s_todr_arg);
}