Add a "this" style argument and a "void *private" so timecounters can

figure out which instance to wount with.
This commit is contained in:
phk 1998-06-07 08:40:53 +00:00
parent 2113d2ba5a
commit 19aada2084
11 changed files with 49 additions and 51 deletions

View File

@ -34,7 +34,7 @@
* SUCH DAMAGE.
*
* from: @(#)clock.c 7.2 (Berkeley) 5/12/91
* $Id: clock.c,v 1.120 1998/05/19 18:48:30 phk Exp $
* $Id: clock.c,v 1.121 1998/05/28 09:30:06 phk Exp $
*/
/*
@ -169,8 +169,8 @@ static u_char timer2_state;
static void (*timer_func) __P((struct clockframe *frame)) = hardclock;
static u_int tsc_present;
static unsigned i8254_get_timecount __P((void));
static unsigned tsc_get_timecount __P((void));
static unsigned i8254_get_timecount __P((struct timecounter *tc));
static unsigned tsc_get_timecount __P((struct timecounter *tc));
static void set_timer_freq(u_int freq, int intr_freq);
static struct timecounter tsc_timecounter[3] = {
@ -1130,7 +1130,7 @@ SYSCTL_PROC(_machdep, OID_AUTO, tsc_freq, CTLTYPE_INT | CTLFLAG_RW,
0, sizeof(u_int), sysctl_machdep_tsc_freq, "I", "");
static unsigned
i8254_get_timecount(void)
i8254_get_timecount(struct timecounter *tc)
{
u_int count;
u_long ef;
@ -1159,7 +1159,7 @@ i8254_get_timecount(void)
}
static unsigned
tsc_get_timecount(void)
tsc_get_timecount(struct timecounter *tc)
{
return (rdtsc());
}

View File

@ -34,7 +34,7 @@
* SUCH DAMAGE.
*
* from: @(#)clock.c 7.2 (Berkeley) 5/12/91
* $Id: clock.c,v 1.120 1998/05/19 18:48:30 phk Exp $
* $Id: clock.c,v 1.121 1998/05/28 09:30:06 phk Exp $
*/
/*
@ -169,8 +169,8 @@ static u_char timer2_state;
static void (*timer_func) __P((struct clockframe *frame)) = hardclock;
static u_int tsc_present;
static unsigned i8254_get_timecount __P((void));
static unsigned tsc_get_timecount __P((void));
static unsigned i8254_get_timecount __P((struct timecounter *tc));
static unsigned tsc_get_timecount __P((struct timecounter *tc));
static void set_timer_freq(u_int freq, int intr_freq);
static struct timecounter tsc_timecounter[3] = {
@ -1130,7 +1130,7 @@ SYSCTL_PROC(_machdep, OID_AUTO, tsc_freq, CTLTYPE_INT | CTLFLAG_RW,
0, sizeof(u_int), sysctl_machdep_tsc_freq, "I", "");
static unsigned
i8254_get_timecount(void)
i8254_get_timecount(struct timecounter *tc)
{
u_int count;
u_long ef;
@ -1159,7 +1159,7 @@ i8254_get_timecount(void)
}
static unsigned
tsc_get_timecount(void)
tsc_get_timecount(struct timecounter *tc)
{
return (rdtsc());
}

View File

@ -34,7 +34,7 @@
* SUCH DAMAGE.
*
* from: @(#)clock.c 7.2 (Berkeley) 5/12/91
* $Id: clock.c,v 1.120 1998/05/19 18:48:30 phk Exp $
* $Id: clock.c,v 1.121 1998/05/28 09:30:06 phk Exp $
*/
/*
@ -169,8 +169,8 @@ static u_char timer2_state;
static void (*timer_func) __P((struct clockframe *frame)) = hardclock;
static u_int tsc_present;
static unsigned i8254_get_timecount __P((void));
static unsigned tsc_get_timecount __P((void));
static unsigned i8254_get_timecount __P((struct timecounter *tc));
static unsigned tsc_get_timecount __P((struct timecounter *tc));
static void set_timer_freq(u_int freq, int intr_freq);
static struct timecounter tsc_timecounter[3] = {
@ -1130,7 +1130,7 @@ SYSCTL_PROC(_machdep, OID_AUTO, tsc_freq, CTLTYPE_INT | CTLFLAG_RW,
0, sizeof(u_int), sysctl_machdep_tsc_freq, "I", "");
static unsigned
i8254_get_timecount(void)
i8254_get_timecount(struct timecounter *tc)
{
u_int count;
u_long ef;
@ -1159,7 +1159,7 @@ i8254_get_timecount(void)
}
static unsigned
tsc_get_timecount(void)
tsc_get_timecount(struct timecounter *tc)
{
return (rdtsc());
}

View File

@ -34,7 +34,7 @@
* SUCH DAMAGE.
*
* from: @(#)clock.c 7.2 (Berkeley) 5/12/91
* $Id: clock.c,v 1.120 1998/05/19 18:48:30 phk Exp $
* $Id: clock.c,v 1.121 1998/05/28 09:30:06 phk Exp $
*/
/*
@ -169,8 +169,8 @@ static u_char timer2_state;
static void (*timer_func) __P((struct clockframe *frame)) = hardclock;
static u_int tsc_present;
static unsigned i8254_get_timecount __P((void));
static unsigned tsc_get_timecount __P((void));
static unsigned i8254_get_timecount __P((struct timecounter *tc));
static unsigned tsc_get_timecount __P((struct timecounter *tc));
static void set_timer_freq(u_int freq, int intr_freq);
static struct timecounter tsc_timecounter[3] = {
@ -1130,7 +1130,7 @@ SYSCTL_PROC(_machdep, OID_AUTO, tsc_freq, CTLTYPE_INT | CTLFLAG_RW,
0, sizeof(u_int), sysctl_machdep_tsc_freq, "I", "");
static unsigned
i8254_get_timecount(void)
i8254_get_timecount(struct timecounter *tc)
{
u_int count;
u_long ef;
@ -1159,7 +1159,7 @@ i8254_get_timecount(void)
}
static unsigned
tsc_get_timecount(void)
tsc_get_timecount(struct timecounter *tc)
{
return (rdtsc());
}

View File

@ -1,7 +1,7 @@
/*
* random_machdep.c -- A strong random number generator
*
* $Id: random_machdep.c,v 1.24 1998/04/06 09:30:32 phk Exp $
* $Id: random_machdep.c,v 1.25 1998/04/15 17:45:44 bde Exp $
*
* Version 0.95, last modified 18-Oct-95
*
@ -184,7 +184,7 @@ add_timer_randomness(struct random_bucket *r, struct timer_rand_state *state,
u_int nbits;
u_int32_t time;
num ^= timecounter->get_timecount() << 16;
num ^= timecounter->get_timecount(timecounter) << 16;
r->entropy_count += 2;
time = ticks;

View File

@ -34,7 +34,7 @@
* SUCH DAMAGE.
*
* from: @(#)clock.c 7.2 (Berkeley) 5/12/91
* $Id: clock.c,v 1.120 1998/05/19 18:48:30 phk Exp $
* $Id: clock.c,v 1.121 1998/05/28 09:30:06 phk Exp $
*/
/*
@ -169,8 +169,8 @@ static u_char timer2_state;
static void (*timer_func) __P((struct clockframe *frame)) = hardclock;
static u_int tsc_present;
static unsigned i8254_get_timecount __P((void));
static unsigned tsc_get_timecount __P((void));
static unsigned i8254_get_timecount __P((struct timecounter *tc));
static unsigned tsc_get_timecount __P((struct timecounter *tc));
static void set_timer_freq(u_int freq, int intr_freq);
static struct timecounter tsc_timecounter[3] = {
@ -1130,7 +1130,7 @@ SYSCTL_PROC(_machdep, OID_AUTO, tsc_freq, CTLTYPE_INT | CTLFLAG_RW,
0, sizeof(u_int), sysctl_machdep_tsc_freq, "I", "");
static unsigned
i8254_get_timecount(void)
i8254_get_timecount(struct timecounter *tc)
{
u_int count;
u_long ef;
@ -1159,7 +1159,7 @@ i8254_get_timecount(void)
}
static unsigned
tsc_get_timecount(void)
tsc_get_timecount(struct timecounter *tc)
{
return (rdtsc());
}

View File

@ -39,7 +39,7 @@ static volatile int print_tci = 1;
* SUCH DAMAGE.
*
* @(#)kern_clock.c 8.5 (Berkeley) 1/21/94
* $Id: kern_clock.c,v 1.69 1998/05/19 18:54:38 phk Exp $
* $Id: kern_clock.c,v 1.70 1998/05/28 09:30:16 phk Exp $
*/
#include <sys/param.h>
@ -498,7 +498,7 @@ static __inline unsigned
tco_getdelta(struct timecounter *tc)
{
return ((tc->get_timecount() - tc->offset_count) & tc->counter_mask);
return ((tc->get_timecount(tc) - tc->offset_count) & tc->counter_mask);
}
/*
@ -647,7 +647,7 @@ init_timecounter(struct timecounter *tc)
tc->adjustment = 0;
tco_setscales(tc);
tc->offset_count = tc->get_timecount();
tc->offset_count = tc->get_timecount(tc);
tc[0].tweak = &tc[0];
tc[2] = tc[1] = tc[0];
tc[1].other = &tc[2];
@ -661,7 +661,7 @@ init_timecounter(struct timecounter *tc)
*/
nanotime(&ts0);
for (i = 0; i < 256; i ++)
tc->get_timecount();
tc->get_timecount(tc);
nanotime(&ts1);
ts1.tv_sec -= ts0.tv_sec;
tc->cost = ts1.tv_sec * 1000000000 + ts1.tv_nsec - ts0.tv_nsec;
@ -671,7 +671,7 @@ init_timecounter(struct timecounter *tc)
tc->name, tc->frequency, tc->cost);
/* XXX: For now always start using the counter. */
tc->offset_count = tc->get_timecount();
tc->offset_count = tc->get_timecount(tc);
nanotime(&ts1);
tc->offset_nano = (u_int64_t)ts1.tv_nsec << 32;
tc->offset_micro = ts1.tv_nsec / 1000;
@ -714,7 +714,7 @@ switch_timecounter(struct timecounter *newtc)
newtc->offset_sec = ts.tv_sec;
newtc->offset_nano = (u_int64_t)ts.tv_nsec << 32;
newtc->offset_micro = ts.tv_nsec / 1000;
newtc->offset_count = newtc->get_timecount();
newtc->offset_count = newtc->get_timecount(newtc);
timecounter = newtc;
splx(s);
}
@ -805,7 +805,7 @@ SYSCTL_PROC(_kern_timecounter, OID_AUTO, adjustment, CTLTYPE_INT | CTLFLAG_RW,
*/
static unsigned
dummy_get_timecount(void)
dummy_get_timecount(void *tc)
{
static unsigned now;
return (++now);

View File

@ -1,7 +1,7 @@
/*
* random_machdep.c -- A strong random number generator
*
* $Id: random_machdep.c,v 1.24 1998/04/06 09:30:32 phk Exp $
* $Id: random_machdep.c,v 1.25 1998/04/15 17:45:44 bde Exp $
*
* Version 0.95, last modified 18-Oct-95
*
@ -184,7 +184,7 @@ add_timer_randomness(struct random_bucket *r, struct timer_rand_state *state,
u_int nbits;
u_int32_t time;
num ^= timecounter->get_timecount() << 16;
num ^= timecounter->get_timecount(timecounter) << 16;
r->entropy_count += 2;
time = ticks;

View File

@ -39,7 +39,7 @@ static volatile int print_tci = 1;
* SUCH DAMAGE.
*
* @(#)kern_clock.c 8.5 (Berkeley) 1/21/94
* $Id: kern_clock.c,v 1.69 1998/05/19 18:54:38 phk Exp $
* $Id: kern_clock.c,v 1.70 1998/05/28 09:30:16 phk Exp $
*/
#include <sys/param.h>
@ -498,7 +498,7 @@ static __inline unsigned
tco_getdelta(struct timecounter *tc)
{
return ((tc->get_timecount() - tc->offset_count) & tc->counter_mask);
return ((tc->get_timecount(tc) - tc->offset_count) & tc->counter_mask);
}
/*
@ -647,7 +647,7 @@ init_timecounter(struct timecounter *tc)
tc->adjustment = 0;
tco_setscales(tc);
tc->offset_count = tc->get_timecount();
tc->offset_count = tc->get_timecount(tc);
tc[0].tweak = &tc[0];
tc[2] = tc[1] = tc[0];
tc[1].other = &tc[2];
@ -661,7 +661,7 @@ init_timecounter(struct timecounter *tc)
*/
nanotime(&ts0);
for (i = 0; i < 256; i ++)
tc->get_timecount();
tc->get_timecount(tc);
nanotime(&ts1);
ts1.tv_sec -= ts0.tv_sec;
tc->cost = ts1.tv_sec * 1000000000 + ts1.tv_nsec - ts0.tv_nsec;
@ -671,7 +671,7 @@ init_timecounter(struct timecounter *tc)
tc->name, tc->frequency, tc->cost);
/* XXX: For now always start using the counter. */
tc->offset_count = tc->get_timecount();
tc->offset_count = tc->get_timecount(tc);
nanotime(&ts1);
tc->offset_nano = (u_int64_t)ts1.tv_nsec << 32;
tc->offset_micro = ts1.tv_nsec / 1000;
@ -714,7 +714,7 @@ switch_timecounter(struct timecounter *newtc)
newtc->offset_sec = ts.tv_sec;
newtc->offset_nano = (u_int64_t)ts.tv_nsec << 32;
newtc->offset_micro = ts.tv_nsec / 1000;
newtc->offset_count = newtc->get_timecount();
newtc->offset_count = newtc->get_timecount(newtc);
timecounter = newtc;
splx(s);
}
@ -805,7 +805,7 @@ SYSCTL_PROC(_kern_timecounter, OID_AUTO, adjustment, CTLTYPE_INT | CTLFLAG_RW,
*/
static unsigned
dummy_get_timecount(void)
dummy_get_timecount(void *tc)
{
static unsigned now;
return (++now);

View File

@ -31,7 +31,7 @@
* SUCH DAMAGE.
*
* @(#)time.h 8.5 (Berkeley) 5/4/95
* $Id: time.h,v 1.28 1998/05/19 18:55:02 phk Exp $
* $Id: time.h,v 1.29 1998/05/28 09:30:28 phk Exp $
*/
#ifndef _SYS_TIME_H_
@ -87,8 +87,6 @@ struct timezone {
* is expected to be less than 20 msec, but no hard data has been
* collected on this. 16 bit at 5 MHz (31 msec) is known to work.
*
* get_timedelta() returns difference between the counter now and offset_count.
*
* get_timecount() reads the counter.
*
* counter_mask removes unimplemented bits from the count value.
@ -129,7 +127,7 @@ struct timezone {
*/
struct timecounter;
typedef unsigned timecounter_get_t __P((void));
typedef unsigned timecounter_get_t __P((struct timecounter *));
struct timecounter {
/* These fields must be initialized by the driver. */
@ -137,6 +135,7 @@ struct timecounter {
unsigned counter_mask;
u_int32_t frequency;
char *name;
void *private;
/* These fields will be managed by the generic code. */
int cost;
int32_t adjustment;

View File

@ -31,7 +31,7 @@
* SUCH DAMAGE.
*
* @(#)time.h 8.5 (Berkeley) 5/4/95
* $Id: time.h,v 1.28 1998/05/19 18:55:02 phk Exp $
* $Id: time.h,v 1.29 1998/05/28 09:30:28 phk Exp $
*/
#ifndef _SYS_TIME_H_
@ -87,8 +87,6 @@ struct timezone {
* is expected to be less than 20 msec, but no hard data has been
* collected on this. 16 bit at 5 MHz (31 msec) is known to work.
*
* get_timedelta() returns difference between the counter now and offset_count.
*
* get_timecount() reads the counter.
*
* counter_mask removes unimplemented bits from the count value.
@ -129,7 +127,7 @@ struct timezone {
*/
struct timecounter;
typedef unsigned timecounter_get_t __P((void));
typedef unsigned timecounter_get_t __P((struct timecounter *));
struct timecounter {
/* These fields must be initialized by the driver. */
@ -137,6 +135,7 @@ struct timecounter {
unsigned counter_mask;
u_int32_t frequency;
char *name;
void *private;
/* These fields will be managed by the generic code. */
int cost;
int32_t adjustment;