History log of /openbsd-current/sys/arch/hppa/dev/clock.c
Revision (<<< Hide revision tags) (Show revision tags >>>) Date Author Comments
# 1.39 17-Sep-2023 cheloha

clockintr: remove clockintr_init(), clockintr_flags

All the state initialization once done in clockintr_init() has been
moved to other parts of the kernel. It's a dead function. Remove it.

Likewise, the clockintr_flags variable no longer sports any meaningful
flags. Remove it. This frees up the CL_* flag namespace, which might
be useful to the clockintr frontend if we ever need to add behavior
flags to any of those functions.


# 1.38 14-Sep-2023 cheloha

clockintr: replace CL_RNDSTAT with global variable statclock_is_randomized

In order to separate the statclock from the clock interrupt subsystem
we need to move all statclock state out into the broader kernel.

Start by replacing the CL_RNDSTAT flag with a new global variable,
"statclock_is_randomized", in kern_clock.c. Update all clockintr_init()
callers to set the boolean instead of passing the flag.

Thread: https://marc.info/?l=openbsd-tech&m=169428749720476&w=2


# 1.37 23-Aug-2023 cheloha

all platforms: separate cpu_initclocks() from cpu_startclock()

To give the primary CPU an opportunity to perform clock interrupt
preparation in a machine-independent manner we need to separate the
"initialization" parts of cpu_initclocks() from the "start the clock
interrupt" parts. Currently, cpu_initclocks() does everything all at
once, so there is no space for this MI setup.

Many platforms have more-or-less already done this separation by
implementing a separate routine named "cpu_startclock()". This patch
promotes cpu_startclock() from de facto standard to mandatory API.

- Prototype cpu_startclock() in sys/systm.h alongside cpu_initclocks().
The separation of responsibility between the two routines is a bit
fuzzy but the basic guidelines are as follows:

+ cpu_initclocks() must initialize hz, stathz, and profhz, and call
clockintr_init().

+ cpu_startclock() must call clockintr_cpu_init() and start the clock
interrupt cycle on the calling CPU.

These guidelines will shift in the future, but that's the way things
stand as of *this* commit.

- In initclocks(): first call cpu_initclocks(), then do MI setup, and
last call cpu_startclock().

- On platforms where cpu_startclock() already exists: don't call
cpu_startclock() from cpu_initclocks() anymore.

- On platforms where cpu_startclock() doesn't yet exist: implement it.
Usually this is as simple as dividing cpu_initclocks() in two.

Tested on amd64 (i8254, lapic), arm64, i386 (i8254, lapic), macppc,
mips64/octeon, and sparc64. Tested on arm/armv7 (agtimer(4)) by
phessler@ and jmatthew@. Tested on m88k/luna88k by aoyama@. Tested
on powerpc64 by gkoehler@ and mlarkin@. Tested on riscv64 by
jmatthew@.

Thread: https://marc.info/?l=openbsd-tech&m=169195251322149&w=2


# 1.36 25-Jul-2023 cheloha

statclock: move profil(2), GPROF code to profclock(), gmonclock()

This patch isolates profil(2) and GPROF from statclock(). Currently,
statclock() implements both profil(2) and GPROF through a complex
mechanism involving both platform code (setstatclockrate) and the
scheduler (pscnt, psdiv, and psratio). We have a machine-independent
interface to the clock interrupt hardware now, so we no longer need to
do it this way.

- Move profil(2)-specific code from statclock() to a new clock
interrupt callback, profclock(), in subr_prof.c. Each
schedstate_percpu has its own profclock handle. The profclock is
enabled/disabled for a given CPU when it is needed by the running
thread during mi_switch() and sched_exit().

- Move GPROF-specific code from statclock() to a new clock interrupt
callback, gmonclock(), in subr_prof.c. Where available, each cpu_info
has its own gmonclock handle . The gmonclock is enabled/disabled for
a given CPU via sysctl(2) in prof_state_toggle().

- Both profclock() and gmonclock() have a fixed period, profclock_period,
that is initialized during initclocks().

- Export clockintr_advance(), clockintr_cancel(), clockintr_establish(),
and clockintr_stagger() via <sys/clockintr.h>. They have external
callers now.

- Delete pscnt, psdiv, psratio. From schedstate_percpu, also delete
spc_pscnt and spc_psdiv. The statclock frequency is not dynamic
anymore so these variables are now useless.

- Delete code/state related to the dynamic statclock frequency from
kern_clockintr.c. The statclock frequency can still be pseudo-random,
so move the contents of clockintr_statvar_init() into clockintr_init().

With input from miod@, deraadt@, and claudio@. Early revisions
cleaned up by claudio. Early revisions tested by claudio@. Tested by
cheloha@ on amd64, arm64, macppc, octeon, and sparc64 (sun4v).
Compile- and boot- tested on i386 by mlarkin@. riscv64 compilation
bugs found by mlarkin@. Tested on riscv64 by jca@. Tested on
powerpc64 by gkoehler@.


Revision tags: OPENBSD_7_3_BASE
# 1.35 04-Feb-2023 cheloha

timecounting: remove incomplete PPS support

The timecounting code has had stubs for pulse-per-second (PPS) polling
since it was imported in 2004. At this point it seems unlikely that
anyone is going to finish adding PPS support, so let's remove the stubs:

- Delete the dead tc_poll_pps() call from tc_windup().
- Remove all tc_poll_pps symbols from the kernel.

Link: https://marc.info/?l=openbsd-tech&m=167519035723210&w=2

ok miod@


# 1.34 20-Jan-2023 cheloha

hppa: simplify itmr_rearm()

The nest of branches in itmr_rearm() can be simplified to:

if (cycles <= t1 - t0) {
/* we probably missed */
}

We're doing modular unsigned 32-bit, so the rollover case in the
current code is superfluous.

Tested by miod@.

"Works for me." miod@


# 1.33 06-Dec-2022 cheloha

hppa: switch to clockintr

- Remove hppa-specific clock interrupt scheduling bits from cpu_info.
- Rename cpu_hardclock() to itmr_intr(); it doesn't exclusively run
hardclock(9) anymore.
- Wire up itmr_intrclock.

hppa now has a randomized statclock(), stathz = hz.

Patch help, testing, and review from kettenis@ (B2000) and miod@ (C3650).
MP testing from guenther@ (dual-core J6700).

ok mlarkin@ kettenis@, "Ship it?" guenther@


Revision tags: OPENBSD_6_9_BASE OPENBSD_7_0_BASE OPENBSD_7_1_BASE OPENBSD_7_2_BASE
# 1.32 23-Feb-2021 cheloha

timecounting: use C99-style initialization for all timecounter structs

The timecounter struct is large and I think it may change in the
future. Changing it later will be easier if we use C99-style
initialization for all timecounter structs. It also makes reading the
code a bit easier.

For reasons I cannot explain, switching to C99-style initialization
sometimes changes the hash of the resulting object file, even though
the resulting struct should be the same. So there is a binary change
here, but only sometimes. No behavior should change in either case.

I can't compile-test this everywhere but I have been staring at the
diff for days now and I'm relatively confident this will not break
compilation. Fingers crossed.

ok gnezdo@


Revision tags: OPENBSD_6_8_BASE
# 1.31 06-Jul-2020 pirofti

Add support for timeconting in userland.

This diff exposes parts of clock_gettime(2) and gettimeofday(2) to
userland via libc eliberating processes from the need for a context
switch everytime they want to count the passage of time.

If a timecounter clock can be exposed to userland than it needs to set
its tc_user member to a non-zero value. Tested with one or multiple
counters per architecture.

The timing data is shared through a pointer found in the new ELF
auxiliary vector AUX_openbsd_timekeep containing timehands information
that is frequently updated by the kernel.

Timing differences between the last kernel update and the current time
are adjusted in userland by the tc_get_timecount() function inside the
MD usertc.c file.

This permits a much more responsive environment, quite visible in
browsers, office programs and gaming (apparently one is are able to fly
in Minecraft now).

Tested by robert@, sthen@, naddy@, kmos@, phessler@, and many others!

OK from at least kettenis@, cheloha@, naddy@, sthen@


Revision tags: OPENBSD_6_7_BASE
# 1.30 01-May-2020 kettenis

Use the same inittodr()/resettodr() implementation as on
amd64/arm64/armv7/i386/sparc64 and move it to the end of machdep.c. Rework the
actual implementation for the MC14818 compatible RTC into something that can
be used as a todr_handle just like on amd64.

ok mpi@


Revision tags: OPENBSD_5_6_BASE OPENBSD_5_7_BASE OPENBSD_5_8_BASE OPENBSD_5_9_BASE OPENBSD_6_0_BASE OPENBSD_6_1_BASE OPENBSD_6_2_BASE OPENBSD_6_3_BASE OPENBSD_6_4_BASE OPENBSD_6_5_BASE OPENBSD_6_6_BASE
# 1.29 29-Mar-2014 guenther

It's been a quarter century: we can assume volatile is present with that name.

ok dlg@ mpi@ deraadt@


Revision tags: OPENBSD_4_9_BASE OPENBSD_5_0_BASE OPENBSD_5_1_BASE OPENBSD_5_2_BASE OPENBSD_5_3_BASE OPENBSD_5_4_BASE OPENBSD_5_5_BASE
# 1.28 09-Jan-2011 jasper

Check in resettodr() if inittodr() has been called, otherwise we end up
resetting the clock when we don't need to. Found out with booting hppa64
kernels, and the problem also exists on hppa when booting with '-a' and hitting
'exit' when asked for the root filesystem.

help & ok jsing@
also ok kettenis@ (who suggested naming the variable like amd64/i386 to
prevent creating yet another variant of this code)


# 1.27 05-Jan-2011 jasper

- remove unused headers wrapped in #if defined(DDB)

ok jsing@ kettenis@


# 1.26 01-Jan-2011 jasper

Move setting cpu_hzticks to the clock initialization function, like
other ports (e.g. hppa64) do.

ok jsing@ kettenis@


Revision tags: OPENBSD_4_8_BASE
# 1.25 01-Aug-2010 kettenis

ANSIfy


# 1.24 29-Apr-2010 jsing

Store hardware timer information per CPU.

ok kettenis@


Revision tags: OPENBSD_4_5_BASE OPENBSD_4_6_BASE OPENBSD_4_7_BASE
# 1.23 08-Feb-2009 miod

Make sure than cpu_hardclock() never sets a ``next interrupt value'' which has
already been hit by the running timer; this happens very often on oosiop-based
machines, due to these machines being among the slowest hppa, and oosiop
being interrupt greedy. Unfortunately, when this happened, one had to wait
for the timer to wrap, which would take up to 128 seconds on the 33MHz
machines.

Also, invoke hardclock() as many times as necessary if it turns out that
we had to delay the interrupt 1/hz seconds to avoid the aforementioned
wrap problem.

With help from kettenis@; ok kettenis@


Revision tags: OPENBSD_4_2_BASE OPENBSD_4_3_BASE OPENBSD_4_4_BASE
# 1.22 22-Jul-2007 kettenis

Move hppa to __HAVE_TIMECOUNTERS.


Revision tags: OPENBSD_3_6_BASE OPENBSD_3_7_BASE OPENBSD_3_8_BASE OPENBSD_3_9_BASE OPENBSD_4_0_BASE OPENBSD_4_1_BASE SMP_SYNC_A SMP_SYNC_B
# 1.21 07-Apr-2004 mickey

update copyright; miod@ is fine w/ files where he holds it too


Revision tags: OPENBSD_3_5_BASE
# 1.20 12-Dec-2003 deraadt

typo


# 1.19 15-Oct-2003 mickey

less global name space pollution


# 1.18 05-Oct-2003 mickey

reload the itmr as soon as we get the intr to avoid lagging on slower machines


Revision tags: OPENBSD_3_3_BASE OPENBSD_3_4_BASE UBC_SYNC_A
# 1.17 27-Nov-2002 mickey

no wrapper arounf hardclock(), use CPU_CLOCKUPDATE, real microtime; miod ok


Revision tags: OPENBSD_3_2_BASE UBC_SYNC_B
# 1.16 15-Sep-2002 mickey

check for errors on tod pdc ops. say that bad time is before 82


# 1.15 20-May-2002 mickey

hardclock() is not called until clock has been initialized


# 1.14 14-May-2002 mickey

make resettodr() save the clock (per the pdc manual), tested


Revision tags: OPENBSD_3_1_BASE
# 1.13 14-Mar-2002 millert

First round of __P removal in sys


# 1.12 01-Feb-2002 mickey

long arg int format fix, from netbsd


Revision tags: UBC_BASE
# 1.11 06-Nov-2001 miod

branches: 1.11.2;
Replace inclusion of <vm/foo.h> with the correct <uvm/bar.h> when necessary.
(Look ma, I might have broken the tree)


Revision tags: OPENBSD_3_0_BASE
# 1.10 31-Aug-2001 mickey

some knf


Revision tags: OPENBSD_2_7_BASE OPENBSD_2_8_BASE OPENBSD_2_9_BASE
# 1.9 29-Mar-2000 mickey

timeout-driven heartbeat.
right thing would be to pass beat count as an argument to timeout
routine (casted to (void *)) avoiding static counter, but
doing timeout_set() every timeout_add() sounds kinda uncool.
well, pondering in the struct timeout guts would be even more ugly.


Revision tags: SMP_BASE
# 1.8 09-Feb-2000 mickey

branches: 1.8.2;
thinking it seems reduces heartbeat, boy


# 1.7 09-Feb-2000 mickey

heartbeat -- yeah we have a patch for that


Revision tags: OPENBSD_2_6_BASE kame_19991208
# 1.6 07-Sep-1999 mickey

make inittodr() whine some sane things


# 1.5 14-Aug-1999 mickey

clock_intr()


# 1.4 24-Jun-1999 mickey

manualy assign structures


# 1.3 12-Jun-1999 mickey

microtime() is moving to locore.S


Revision tags: OPENBSD_2_5_BASE
# 1.2 07-Feb-1999 mickey

missign extern cpu_hzticks


# 1.1 29-Dec-1998 mickey

no microtime() yet


# 1.38 14-Sep-2023 cheloha

clockintr: replace CL_RNDSTAT with global variable statclock_is_randomized

In order to separate the statclock from the clock interrupt subsystem
we need to move all statclock state out into the broader kernel.

Start by replacing the CL_RNDSTAT flag with a new global variable,
"statclock_is_randomized", in kern_clock.c. Update all clockintr_init()
callers to set the boolean instead of passing the flag.

Thread: https://marc.info/?l=openbsd-tech&m=169428749720476&w=2


# 1.37 23-Aug-2023 cheloha

all platforms: separate cpu_initclocks() from cpu_startclock()

To give the primary CPU an opportunity to perform clock interrupt
preparation in a machine-independent manner we need to separate the
"initialization" parts of cpu_initclocks() from the "start the clock
interrupt" parts. Currently, cpu_initclocks() does everything all at
once, so there is no space for this MI setup.

Many platforms have more-or-less already done this separation by
implementing a separate routine named "cpu_startclock()". This patch
promotes cpu_startclock() from de facto standard to mandatory API.

- Prototype cpu_startclock() in sys/systm.h alongside cpu_initclocks().
The separation of responsibility between the two routines is a bit
fuzzy but the basic guidelines are as follows:

+ cpu_initclocks() must initialize hz, stathz, and profhz, and call
clockintr_init().

+ cpu_startclock() must call clockintr_cpu_init() and start the clock
interrupt cycle on the calling CPU.

These guidelines will shift in the future, but that's the way things
stand as of *this* commit.

- In initclocks(): first call cpu_initclocks(), then do MI setup, and
last call cpu_startclock().

- On platforms where cpu_startclock() already exists: don't call
cpu_startclock() from cpu_initclocks() anymore.

- On platforms where cpu_startclock() doesn't yet exist: implement it.
Usually this is as simple as dividing cpu_initclocks() in two.

Tested on amd64 (i8254, lapic), arm64, i386 (i8254, lapic), macppc,
mips64/octeon, and sparc64. Tested on arm/armv7 (agtimer(4)) by
phessler@ and jmatthew@. Tested on m88k/luna88k by aoyama@. Tested
on powerpc64 by gkoehler@ and mlarkin@. Tested on riscv64 by
jmatthew@.

Thread: https://marc.info/?l=openbsd-tech&m=169195251322149&w=2


# 1.36 25-Jul-2023 cheloha

statclock: move profil(2), GPROF code to profclock(), gmonclock()

This patch isolates profil(2) and GPROF from statclock(). Currently,
statclock() implements both profil(2) and GPROF through a complex
mechanism involving both platform code (setstatclockrate) and the
scheduler (pscnt, psdiv, and psratio). We have a machine-independent
interface to the clock interrupt hardware now, so we no longer need to
do it this way.

- Move profil(2)-specific code from statclock() to a new clock
interrupt callback, profclock(), in subr_prof.c. Each
schedstate_percpu has its own profclock handle. The profclock is
enabled/disabled for a given CPU when it is needed by the running
thread during mi_switch() and sched_exit().

- Move GPROF-specific code from statclock() to a new clock interrupt
callback, gmonclock(), in subr_prof.c. Where available, each cpu_info
has its own gmonclock handle . The gmonclock is enabled/disabled for
a given CPU via sysctl(2) in prof_state_toggle().

- Both profclock() and gmonclock() have a fixed period, profclock_period,
that is initialized during initclocks().

- Export clockintr_advance(), clockintr_cancel(), clockintr_establish(),
and clockintr_stagger() via <sys/clockintr.h>. They have external
callers now.

- Delete pscnt, psdiv, psratio. From schedstate_percpu, also delete
spc_pscnt and spc_psdiv. The statclock frequency is not dynamic
anymore so these variables are now useless.

- Delete code/state related to the dynamic statclock frequency from
kern_clockintr.c. The statclock frequency can still be pseudo-random,
so move the contents of clockintr_statvar_init() into clockintr_init().

With input from miod@, deraadt@, and claudio@. Early revisions
cleaned up by claudio. Early revisions tested by claudio@. Tested by
cheloha@ on amd64, arm64, macppc, octeon, and sparc64 (sun4v).
Compile- and boot- tested on i386 by mlarkin@. riscv64 compilation
bugs found by mlarkin@. Tested on riscv64 by jca@. Tested on
powerpc64 by gkoehler@.


Revision tags: OPENBSD_7_3_BASE
# 1.35 04-Feb-2023 cheloha

timecounting: remove incomplete PPS support

The timecounting code has had stubs for pulse-per-second (PPS) polling
since it was imported in 2004. At this point it seems unlikely that
anyone is going to finish adding PPS support, so let's remove the stubs:

- Delete the dead tc_poll_pps() call from tc_windup().
- Remove all tc_poll_pps symbols from the kernel.

Link: https://marc.info/?l=openbsd-tech&m=167519035723210&w=2

ok miod@


# 1.34 20-Jan-2023 cheloha

hppa: simplify itmr_rearm()

The nest of branches in itmr_rearm() can be simplified to:

if (cycles <= t1 - t0) {
/* we probably missed */
}

We're doing modular unsigned 32-bit, so the rollover case in the
current code is superfluous.

Tested by miod@.

"Works for me." miod@


# 1.33 06-Dec-2022 cheloha

hppa: switch to clockintr

- Remove hppa-specific clock interrupt scheduling bits from cpu_info.
- Rename cpu_hardclock() to itmr_intr(); it doesn't exclusively run
hardclock(9) anymore.
- Wire up itmr_intrclock.

hppa now has a randomized statclock(), stathz = hz.

Patch help, testing, and review from kettenis@ (B2000) and miod@ (C3650).
MP testing from guenther@ (dual-core J6700).

ok mlarkin@ kettenis@, "Ship it?" guenther@


Revision tags: OPENBSD_6_9_BASE OPENBSD_7_0_BASE OPENBSD_7_1_BASE OPENBSD_7_2_BASE
# 1.32 23-Feb-2021 cheloha

timecounting: use C99-style initialization for all timecounter structs

The timecounter struct is large and I think it may change in the
future. Changing it later will be easier if we use C99-style
initialization for all timecounter structs. It also makes reading the
code a bit easier.

For reasons I cannot explain, switching to C99-style initialization
sometimes changes the hash of the resulting object file, even though
the resulting struct should be the same. So there is a binary change
here, but only sometimes. No behavior should change in either case.

I can't compile-test this everywhere but I have been staring at the
diff for days now and I'm relatively confident this will not break
compilation. Fingers crossed.

ok gnezdo@


Revision tags: OPENBSD_6_8_BASE
# 1.31 06-Jul-2020 pirofti

Add support for timeconting in userland.

This diff exposes parts of clock_gettime(2) and gettimeofday(2) to
userland via libc eliberating processes from the need for a context
switch everytime they want to count the passage of time.

If a timecounter clock can be exposed to userland than it needs to set
its tc_user member to a non-zero value. Tested with one or multiple
counters per architecture.

The timing data is shared through a pointer found in the new ELF
auxiliary vector AUX_openbsd_timekeep containing timehands information
that is frequently updated by the kernel.

Timing differences between the last kernel update and the current time
are adjusted in userland by the tc_get_timecount() function inside the
MD usertc.c file.

This permits a much more responsive environment, quite visible in
browsers, office programs and gaming (apparently one is are able to fly
in Minecraft now).

Tested by robert@, sthen@, naddy@, kmos@, phessler@, and many others!

OK from at least kettenis@, cheloha@, naddy@, sthen@


Revision tags: OPENBSD_6_7_BASE
# 1.30 01-May-2020 kettenis

Use the same inittodr()/resettodr() implementation as on
amd64/arm64/armv7/i386/sparc64 and move it to the end of machdep.c. Rework the
actual implementation for the MC14818 compatible RTC into something that can
be used as a todr_handle just like on amd64.

ok mpi@


Revision tags: OPENBSD_5_6_BASE OPENBSD_5_7_BASE OPENBSD_5_8_BASE OPENBSD_5_9_BASE OPENBSD_6_0_BASE OPENBSD_6_1_BASE OPENBSD_6_2_BASE OPENBSD_6_3_BASE OPENBSD_6_4_BASE OPENBSD_6_5_BASE OPENBSD_6_6_BASE
# 1.29 29-Mar-2014 guenther

It's been a quarter century: we can assume volatile is present with that name.

ok dlg@ mpi@ deraadt@


Revision tags: OPENBSD_4_9_BASE OPENBSD_5_0_BASE OPENBSD_5_1_BASE OPENBSD_5_2_BASE OPENBSD_5_3_BASE OPENBSD_5_4_BASE OPENBSD_5_5_BASE
# 1.28 09-Jan-2011 jasper

Check in resettodr() if inittodr() has been called, otherwise we end up
resetting the clock when we don't need to. Found out with booting hppa64
kernels, and the problem also exists on hppa when booting with '-a' and hitting
'exit' when asked for the root filesystem.

help & ok jsing@
also ok kettenis@ (who suggested naming the variable like amd64/i386 to
prevent creating yet another variant of this code)


# 1.27 05-Jan-2011 jasper

- remove unused headers wrapped in #if defined(DDB)

ok jsing@ kettenis@


# 1.26 01-Jan-2011 jasper

Move setting cpu_hzticks to the clock initialization function, like
other ports (e.g. hppa64) do.

ok jsing@ kettenis@


Revision tags: OPENBSD_4_8_BASE
# 1.25 01-Aug-2010 kettenis

ANSIfy


# 1.24 29-Apr-2010 jsing

Store hardware timer information per CPU.

ok kettenis@


Revision tags: OPENBSD_4_5_BASE OPENBSD_4_6_BASE OPENBSD_4_7_BASE
# 1.23 08-Feb-2009 miod

Make sure than cpu_hardclock() never sets a ``next interrupt value'' which has
already been hit by the running timer; this happens very often on oosiop-based
machines, due to these machines being among the slowest hppa, and oosiop
being interrupt greedy. Unfortunately, when this happened, one had to wait
for the timer to wrap, which would take up to 128 seconds on the 33MHz
machines.

Also, invoke hardclock() as many times as necessary if it turns out that
we had to delay the interrupt 1/hz seconds to avoid the aforementioned
wrap problem.

With help from kettenis@; ok kettenis@


Revision tags: OPENBSD_4_2_BASE OPENBSD_4_3_BASE OPENBSD_4_4_BASE
# 1.22 22-Jul-2007 kettenis

Move hppa to __HAVE_TIMECOUNTERS.


Revision tags: OPENBSD_3_6_BASE OPENBSD_3_7_BASE OPENBSD_3_8_BASE OPENBSD_3_9_BASE OPENBSD_4_0_BASE OPENBSD_4_1_BASE SMP_SYNC_A SMP_SYNC_B
# 1.21 07-Apr-2004 mickey

update copyright; miod@ is fine w/ files where he holds it too


Revision tags: OPENBSD_3_5_BASE
# 1.20 12-Dec-2003 deraadt

typo


# 1.19 15-Oct-2003 mickey

less global name space pollution


# 1.18 05-Oct-2003 mickey

reload the itmr as soon as we get the intr to avoid lagging on slower machines


Revision tags: OPENBSD_3_3_BASE OPENBSD_3_4_BASE UBC_SYNC_A
# 1.17 27-Nov-2002 mickey

no wrapper arounf hardclock(), use CPU_CLOCKUPDATE, real microtime; miod ok


Revision tags: OPENBSD_3_2_BASE UBC_SYNC_B
# 1.16 15-Sep-2002 mickey

check for errors on tod pdc ops. say that bad time is before 82


# 1.15 20-May-2002 mickey

hardclock() is not called until clock has been initialized


# 1.14 14-May-2002 mickey

make resettodr() save the clock (per the pdc manual), tested


Revision tags: OPENBSD_3_1_BASE
# 1.13 14-Mar-2002 millert

First round of __P removal in sys


# 1.12 01-Feb-2002 mickey

long arg int format fix, from netbsd


Revision tags: UBC_BASE
# 1.11 06-Nov-2001 miod

branches: 1.11.2;
Replace inclusion of <vm/foo.h> with the correct <uvm/bar.h> when necessary.
(Look ma, I might have broken the tree)


Revision tags: OPENBSD_3_0_BASE
# 1.10 31-Aug-2001 mickey

some knf


Revision tags: OPENBSD_2_7_BASE OPENBSD_2_8_BASE OPENBSD_2_9_BASE
# 1.9 29-Mar-2000 mickey

timeout-driven heartbeat.
right thing would be to pass beat count as an argument to timeout
routine (casted to (void *)) avoiding static counter, but
doing timeout_set() every timeout_add() sounds kinda uncool.
well, pondering in the struct timeout guts would be even more ugly.


Revision tags: SMP_BASE
# 1.8 09-Feb-2000 mickey

branches: 1.8.2;
thinking it seems reduces heartbeat, boy


# 1.7 09-Feb-2000 mickey

heartbeat -- yeah we have a patch for that


Revision tags: OPENBSD_2_6_BASE kame_19991208
# 1.6 07-Sep-1999 mickey

make inittodr() whine some sane things


# 1.5 14-Aug-1999 mickey

clock_intr()


# 1.4 24-Jun-1999 mickey

manualy assign structures


# 1.3 12-Jun-1999 mickey

microtime() is moving to locore.S


Revision tags: OPENBSD_2_5_BASE
# 1.2 07-Feb-1999 mickey

missign extern cpu_hzticks


# 1.1 29-Dec-1998 mickey

no microtime() yet


# 1.37 23-Aug-2023 cheloha

all platforms: separate cpu_initclocks() from cpu_startclock()

To give the primary CPU an opportunity to perform clock interrupt
preparation in a machine-independent manner we need to separate the
"initialization" parts of cpu_initclocks() from the "start the clock
interrupt" parts. Currently, cpu_initclocks() does everything all at
once, so there is no space for this MI setup.

Many platforms have more-or-less already done this separation by
implementing a separate routine named "cpu_startclock()". This patch
promotes cpu_startclock() from de facto standard to mandatory API.

- Prototype cpu_startclock() in sys/systm.h alongside cpu_initclocks().
The separation of responsibility between the two routines is a bit
fuzzy but the basic guidelines are as follows:

+ cpu_initclocks() must initialize hz, stathz, and profhz, and call
clockintr_init().

+ cpu_startclock() must call clockintr_cpu_init() and start the clock
interrupt cycle on the calling CPU.

These guidelines will shift in the future, but that's the way things
stand as of *this* commit.

- In initclocks(): first call cpu_initclocks(), then do MI setup, and
last call cpu_startclock().

- On platforms where cpu_startclock() already exists: don't call
cpu_startclock() from cpu_initclocks() anymore.

- On platforms where cpu_startclock() doesn't yet exist: implement it.
Usually this is as simple as dividing cpu_initclocks() in two.

Tested on amd64 (i8254, lapic), arm64, i386 (i8254, lapic), macppc,
mips64/octeon, and sparc64. Tested on arm/armv7 (agtimer(4)) by
phessler@ and jmatthew@. Tested on m88k/luna88k by aoyama@. Tested
on powerpc64 by gkoehler@ and mlarkin@. Tested on riscv64 by
jmatthew@.

Thread: https://marc.info/?l=openbsd-tech&m=169195251322149&w=2


# 1.36 25-Jul-2023 cheloha

statclock: move profil(2), GPROF code to profclock(), gmonclock()

This patch isolates profil(2) and GPROF from statclock(). Currently,
statclock() implements both profil(2) and GPROF through a complex
mechanism involving both platform code (setstatclockrate) and the
scheduler (pscnt, psdiv, and psratio). We have a machine-independent
interface to the clock interrupt hardware now, so we no longer need to
do it this way.

- Move profil(2)-specific code from statclock() to a new clock
interrupt callback, profclock(), in subr_prof.c. Each
schedstate_percpu has its own profclock handle. The profclock is
enabled/disabled for a given CPU when it is needed by the running
thread during mi_switch() and sched_exit().

- Move GPROF-specific code from statclock() to a new clock interrupt
callback, gmonclock(), in subr_prof.c. Where available, each cpu_info
has its own gmonclock handle . The gmonclock is enabled/disabled for
a given CPU via sysctl(2) in prof_state_toggle().

- Both profclock() and gmonclock() have a fixed period, profclock_period,
that is initialized during initclocks().

- Export clockintr_advance(), clockintr_cancel(), clockintr_establish(),
and clockintr_stagger() via <sys/clockintr.h>. They have external
callers now.

- Delete pscnt, psdiv, psratio. From schedstate_percpu, also delete
spc_pscnt and spc_psdiv. The statclock frequency is not dynamic
anymore so these variables are now useless.

- Delete code/state related to the dynamic statclock frequency from
kern_clockintr.c. The statclock frequency can still be pseudo-random,
so move the contents of clockintr_statvar_init() into clockintr_init().

With input from miod@, deraadt@, and claudio@. Early revisions
cleaned up by claudio. Early revisions tested by claudio@. Tested by
cheloha@ on amd64, arm64, macppc, octeon, and sparc64 (sun4v).
Compile- and boot- tested on i386 by mlarkin@. riscv64 compilation
bugs found by mlarkin@. Tested on riscv64 by jca@. Tested on
powerpc64 by gkoehler@.


Revision tags: OPENBSD_7_3_BASE
# 1.35 04-Feb-2023 cheloha

timecounting: remove incomplete PPS support

The timecounting code has had stubs for pulse-per-second (PPS) polling
since it was imported in 2004. At this point it seems unlikely that
anyone is going to finish adding PPS support, so let's remove the stubs:

- Delete the dead tc_poll_pps() call from tc_windup().
- Remove all tc_poll_pps symbols from the kernel.

Link: https://marc.info/?l=openbsd-tech&m=167519035723210&w=2

ok miod@


# 1.34 20-Jan-2023 cheloha

hppa: simplify itmr_rearm()

The nest of branches in itmr_rearm() can be simplified to:

if (cycles <= t1 - t0) {
/* we probably missed */
}

We're doing modular unsigned 32-bit, so the rollover case in the
current code is superfluous.

Tested by miod@.

"Works for me." miod@


# 1.33 06-Dec-2022 cheloha

hppa: switch to clockintr

- Remove hppa-specific clock interrupt scheduling bits from cpu_info.
- Rename cpu_hardclock() to itmr_intr(); it doesn't exclusively run
hardclock(9) anymore.
- Wire up itmr_intrclock.

hppa now has a randomized statclock(), stathz = hz.

Patch help, testing, and review from kettenis@ (B2000) and miod@ (C3650).
MP testing from guenther@ (dual-core J6700).

ok mlarkin@ kettenis@, "Ship it?" guenther@


Revision tags: OPENBSD_6_9_BASE OPENBSD_7_0_BASE OPENBSD_7_1_BASE OPENBSD_7_2_BASE
# 1.32 23-Feb-2021 cheloha

timecounting: use C99-style initialization for all timecounter structs

The timecounter struct is large and I think it may change in the
future. Changing it later will be easier if we use C99-style
initialization for all timecounter structs. It also makes reading the
code a bit easier.

For reasons I cannot explain, switching to C99-style initialization
sometimes changes the hash of the resulting object file, even though
the resulting struct should be the same. So there is a binary change
here, but only sometimes. No behavior should change in either case.

I can't compile-test this everywhere but I have been staring at the
diff for days now and I'm relatively confident this will not break
compilation. Fingers crossed.

ok gnezdo@


Revision tags: OPENBSD_6_8_BASE
# 1.31 06-Jul-2020 pirofti

Add support for timeconting in userland.

This diff exposes parts of clock_gettime(2) and gettimeofday(2) to
userland via libc eliberating processes from the need for a context
switch everytime they want to count the passage of time.

If a timecounter clock can be exposed to userland than it needs to set
its tc_user member to a non-zero value. Tested with one or multiple
counters per architecture.

The timing data is shared through a pointer found in the new ELF
auxiliary vector AUX_openbsd_timekeep containing timehands information
that is frequently updated by the kernel.

Timing differences between the last kernel update and the current time
are adjusted in userland by the tc_get_timecount() function inside the
MD usertc.c file.

This permits a much more responsive environment, quite visible in
browsers, office programs and gaming (apparently one is are able to fly
in Minecraft now).

Tested by robert@, sthen@, naddy@, kmos@, phessler@, and many others!

OK from at least kettenis@, cheloha@, naddy@, sthen@


Revision tags: OPENBSD_6_7_BASE
# 1.30 01-May-2020 kettenis

Use the same inittodr()/resettodr() implementation as on
amd64/arm64/armv7/i386/sparc64 and move it to the end of machdep.c. Rework the
actual implementation for the MC14818 compatible RTC into something that can
be used as a todr_handle just like on amd64.

ok mpi@


Revision tags: OPENBSD_5_6_BASE OPENBSD_5_7_BASE OPENBSD_5_8_BASE OPENBSD_5_9_BASE OPENBSD_6_0_BASE OPENBSD_6_1_BASE OPENBSD_6_2_BASE OPENBSD_6_3_BASE OPENBSD_6_4_BASE OPENBSD_6_5_BASE OPENBSD_6_6_BASE
# 1.29 29-Mar-2014 guenther

It's been a quarter century: we can assume volatile is present with that name.

ok dlg@ mpi@ deraadt@


Revision tags: OPENBSD_4_9_BASE OPENBSD_5_0_BASE OPENBSD_5_1_BASE OPENBSD_5_2_BASE OPENBSD_5_3_BASE OPENBSD_5_4_BASE OPENBSD_5_5_BASE
# 1.28 09-Jan-2011 jasper

Check in resettodr() if inittodr() has been called, otherwise we end up
resetting the clock when we don't need to. Found out with booting hppa64
kernels, and the problem also exists on hppa when booting with '-a' and hitting
'exit' when asked for the root filesystem.

help & ok jsing@
also ok kettenis@ (who suggested naming the variable like amd64/i386 to
prevent creating yet another variant of this code)


# 1.27 05-Jan-2011 jasper

- remove unused headers wrapped in #if defined(DDB)

ok jsing@ kettenis@


# 1.26 01-Jan-2011 jasper

Move setting cpu_hzticks to the clock initialization function, like
other ports (e.g. hppa64) do.

ok jsing@ kettenis@


Revision tags: OPENBSD_4_8_BASE
# 1.25 01-Aug-2010 kettenis

ANSIfy


# 1.24 29-Apr-2010 jsing

Store hardware timer information per CPU.

ok kettenis@


Revision tags: OPENBSD_4_5_BASE OPENBSD_4_6_BASE OPENBSD_4_7_BASE
# 1.23 08-Feb-2009 miod

Make sure than cpu_hardclock() never sets a ``next interrupt value'' which has
already been hit by the running timer; this happens very often on oosiop-based
machines, due to these machines being among the slowest hppa, and oosiop
being interrupt greedy. Unfortunately, when this happened, one had to wait
for the timer to wrap, which would take up to 128 seconds on the 33MHz
machines.

Also, invoke hardclock() as many times as necessary if it turns out that
we had to delay the interrupt 1/hz seconds to avoid the aforementioned
wrap problem.

With help from kettenis@; ok kettenis@


Revision tags: OPENBSD_4_2_BASE OPENBSD_4_3_BASE OPENBSD_4_4_BASE
# 1.22 22-Jul-2007 kettenis

Move hppa to __HAVE_TIMECOUNTERS.


Revision tags: OPENBSD_3_6_BASE OPENBSD_3_7_BASE OPENBSD_3_8_BASE OPENBSD_3_9_BASE OPENBSD_4_0_BASE OPENBSD_4_1_BASE SMP_SYNC_A SMP_SYNC_B
# 1.21 07-Apr-2004 mickey

update copyright; miod@ is fine w/ files where he holds it too


Revision tags: OPENBSD_3_5_BASE
# 1.20 12-Dec-2003 deraadt

typo


# 1.19 15-Oct-2003 mickey

less global name space pollution


# 1.18 05-Oct-2003 mickey

reload the itmr as soon as we get the intr to avoid lagging on slower machines


Revision tags: OPENBSD_3_3_BASE OPENBSD_3_4_BASE UBC_SYNC_A
# 1.17 27-Nov-2002 mickey

no wrapper arounf hardclock(), use CPU_CLOCKUPDATE, real microtime; miod ok


Revision tags: OPENBSD_3_2_BASE UBC_SYNC_B
# 1.16 15-Sep-2002 mickey

check for errors on tod pdc ops. say that bad time is before 82


# 1.15 20-May-2002 mickey

hardclock() is not called until clock has been initialized


# 1.14 14-May-2002 mickey

make resettodr() save the clock (per the pdc manual), tested


Revision tags: OPENBSD_3_1_BASE
# 1.13 14-Mar-2002 millert

First round of __P removal in sys


# 1.12 01-Feb-2002 mickey

long arg int format fix, from netbsd


Revision tags: UBC_BASE
# 1.11 06-Nov-2001 miod

branches: 1.11.2;
Replace inclusion of <vm/foo.h> with the correct <uvm/bar.h> when necessary.
(Look ma, I might have broken the tree)


Revision tags: OPENBSD_3_0_BASE
# 1.10 31-Aug-2001 mickey

some knf


Revision tags: OPENBSD_2_7_BASE OPENBSD_2_8_BASE OPENBSD_2_9_BASE
# 1.9 29-Mar-2000 mickey

timeout-driven heartbeat.
right thing would be to pass beat count as an argument to timeout
routine (casted to (void *)) avoiding static counter, but
doing timeout_set() every timeout_add() sounds kinda uncool.
well, pondering in the struct timeout guts would be even more ugly.


Revision tags: SMP_BASE
# 1.8 09-Feb-2000 mickey

branches: 1.8.2;
thinking it seems reduces heartbeat, boy


# 1.7 09-Feb-2000 mickey

heartbeat -- yeah we have a patch for that


Revision tags: OPENBSD_2_6_BASE kame_19991208
# 1.6 07-Sep-1999 mickey

make inittodr() whine some sane things


# 1.5 14-Aug-1999 mickey

clock_intr()


# 1.4 24-Jun-1999 mickey

manualy assign structures


# 1.3 12-Jun-1999 mickey

microtime() is moving to locore.S


Revision tags: OPENBSD_2_5_BASE
# 1.2 07-Feb-1999 mickey

missign extern cpu_hzticks


# 1.1 29-Dec-1998 mickey

no microtime() yet


# 1.36 25-Jul-2023 cheloha

statclock: move profil(2), GPROF code to profclock(), gmonclock()

This patch isolates profil(2) and GPROF from statclock(). Currently,
statclock() implements both profil(2) and GPROF through a complex
mechanism involving both platform code (setstatclockrate) and the
scheduler (pscnt, psdiv, and psratio). We have a machine-independent
interface to the clock interrupt hardware now, so we no longer need to
do it this way.

- Move profil(2)-specific code from statclock() to a new clock
interrupt callback, profclock(), in subr_prof.c. Each
schedstate_percpu has its own profclock handle. The profclock is
enabled/disabled for a given CPU when it is needed by the running
thread during mi_switch() and sched_exit().

- Move GPROF-specific code from statclock() to a new clock interrupt
callback, gmonclock(), in subr_prof.c. Where available, each cpu_info
has its own gmonclock handle . The gmonclock is enabled/disabled for
a given CPU via sysctl(2) in prof_state_toggle().

- Both profclock() and gmonclock() have a fixed period, profclock_period,
that is initialized during initclocks().

- Export clockintr_advance(), clockintr_cancel(), clockintr_establish(),
and clockintr_stagger() via <sys/clockintr.h>. They have external
callers now.

- Delete pscnt, psdiv, psratio. From schedstate_percpu, also delete
spc_pscnt and spc_psdiv. The statclock frequency is not dynamic
anymore so these variables are now useless.

- Delete code/state related to the dynamic statclock frequency from
kern_clockintr.c. The statclock frequency can still be pseudo-random,
so move the contents of clockintr_statvar_init() into clockintr_init().

With input from miod@, deraadt@, and claudio@. Early revisions
cleaned up by claudio. Early revisions tested by claudio@. Tested by
cheloha@ on amd64, arm64, macppc, octeon, and sparc64 (sun4v).
Compile- and boot- tested on i386 by mlarkin@. riscv64 compilation
bugs found by mlarkin@. Tested on riscv64 by jca@. Tested on
powerpc64 by gkoehler@.


Revision tags: OPENBSD_7_3_BASE
# 1.35 04-Feb-2023 cheloha

timecounting: remove incomplete PPS support

The timecounting code has had stubs for pulse-per-second (PPS) polling
since it was imported in 2004. At this point it seems unlikely that
anyone is going to finish adding PPS support, so let's remove the stubs:

- Delete the dead tc_poll_pps() call from tc_windup().
- Remove all tc_poll_pps symbols from the kernel.

Link: https://marc.info/?l=openbsd-tech&m=167519035723210&w=2

ok miod@


# 1.34 20-Jan-2023 cheloha

hppa: simplify itmr_rearm()

The nest of branches in itmr_rearm() can be simplified to:

if (cycles <= t1 - t0) {
/* we probably missed */
}

We're doing modular unsigned 32-bit, so the rollover case in the
current code is superfluous.

Tested by miod@.

"Works for me." miod@


# 1.33 06-Dec-2022 cheloha

hppa: switch to clockintr

- Remove hppa-specific clock interrupt scheduling bits from cpu_info.
- Rename cpu_hardclock() to itmr_intr(); it doesn't exclusively run
hardclock(9) anymore.
- Wire up itmr_intrclock.

hppa now has a randomized statclock(), stathz = hz.

Patch help, testing, and review from kettenis@ (B2000) and miod@ (C3650).
MP testing from guenther@ (dual-core J6700).

ok mlarkin@ kettenis@, "Ship it?" guenther@


Revision tags: OPENBSD_6_9_BASE OPENBSD_7_0_BASE OPENBSD_7_1_BASE OPENBSD_7_2_BASE
# 1.32 23-Feb-2021 cheloha

timecounting: use C99-style initialization for all timecounter structs

The timecounter struct is large and I think it may change in the
future. Changing it later will be easier if we use C99-style
initialization for all timecounter structs. It also makes reading the
code a bit easier.

For reasons I cannot explain, switching to C99-style initialization
sometimes changes the hash of the resulting object file, even though
the resulting struct should be the same. So there is a binary change
here, but only sometimes. No behavior should change in either case.

I can't compile-test this everywhere but I have been staring at the
diff for days now and I'm relatively confident this will not break
compilation. Fingers crossed.

ok gnezdo@


Revision tags: OPENBSD_6_8_BASE
# 1.31 06-Jul-2020 pirofti

Add support for timeconting in userland.

This diff exposes parts of clock_gettime(2) and gettimeofday(2) to
userland via libc eliberating processes from the need for a context
switch everytime they want to count the passage of time.

If a timecounter clock can be exposed to userland than it needs to set
its tc_user member to a non-zero value. Tested with one or multiple
counters per architecture.

The timing data is shared through a pointer found in the new ELF
auxiliary vector AUX_openbsd_timekeep containing timehands information
that is frequently updated by the kernel.

Timing differences between the last kernel update and the current time
are adjusted in userland by the tc_get_timecount() function inside the
MD usertc.c file.

This permits a much more responsive environment, quite visible in
browsers, office programs and gaming (apparently one is are able to fly
in Minecraft now).

Tested by robert@, sthen@, naddy@, kmos@, phessler@, and many others!

OK from at least kettenis@, cheloha@, naddy@, sthen@


Revision tags: OPENBSD_6_7_BASE
# 1.30 01-May-2020 kettenis

Use the same inittodr()/resettodr() implementation as on
amd64/arm64/armv7/i386/sparc64 and move it to the end of machdep.c. Rework the
actual implementation for the MC14818 compatible RTC into something that can
be used as a todr_handle just like on amd64.

ok mpi@


Revision tags: OPENBSD_5_6_BASE OPENBSD_5_7_BASE OPENBSD_5_8_BASE OPENBSD_5_9_BASE OPENBSD_6_0_BASE OPENBSD_6_1_BASE OPENBSD_6_2_BASE OPENBSD_6_3_BASE OPENBSD_6_4_BASE OPENBSD_6_5_BASE OPENBSD_6_6_BASE
# 1.29 29-Mar-2014 guenther

It's been a quarter century: we can assume volatile is present with that name.

ok dlg@ mpi@ deraadt@


Revision tags: OPENBSD_4_9_BASE OPENBSD_5_0_BASE OPENBSD_5_1_BASE OPENBSD_5_2_BASE OPENBSD_5_3_BASE OPENBSD_5_4_BASE OPENBSD_5_5_BASE
# 1.28 09-Jan-2011 jasper

Check in resettodr() if inittodr() has been called, otherwise we end up
resetting the clock when we don't need to. Found out with booting hppa64
kernels, and the problem also exists on hppa when booting with '-a' and hitting
'exit' when asked for the root filesystem.

help & ok jsing@
also ok kettenis@ (who suggested naming the variable like amd64/i386 to
prevent creating yet another variant of this code)


# 1.27 05-Jan-2011 jasper

- remove unused headers wrapped in #if defined(DDB)

ok jsing@ kettenis@


# 1.26 01-Jan-2011 jasper

Move setting cpu_hzticks to the clock initialization function, like
other ports (e.g. hppa64) do.

ok jsing@ kettenis@


Revision tags: OPENBSD_4_8_BASE
# 1.25 01-Aug-2010 kettenis

ANSIfy


# 1.24 29-Apr-2010 jsing

Store hardware timer information per CPU.

ok kettenis@


Revision tags: OPENBSD_4_5_BASE OPENBSD_4_6_BASE OPENBSD_4_7_BASE
# 1.23 08-Feb-2009 miod

Make sure than cpu_hardclock() never sets a ``next interrupt value'' which has
already been hit by the running timer; this happens very often on oosiop-based
machines, due to these machines being among the slowest hppa, and oosiop
being interrupt greedy. Unfortunately, when this happened, one had to wait
for the timer to wrap, which would take up to 128 seconds on the 33MHz
machines.

Also, invoke hardclock() as many times as necessary if it turns out that
we had to delay the interrupt 1/hz seconds to avoid the aforementioned
wrap problem.

With help from kettenis@; ok kettenis@


Revision tags: OPENBSD_4_2_BASE OPENBSD_4_3_BASE OPENBSD_4_4_BASE
# 1.22 22-Jul-2007 kettenis

Move hppa to __HAVE_TIMECOUNTERS.


Revision tags: OPENBSD_3_6_BASE OPENBSD_3_7_BASE OPENBSD_3_8_BASE OPENBSD_3_9_BASE OPENBSD_4_0_BASE OPENBSD_4_1_BASE SMP_SYNC_A SMP_SYNC_B
# 1.21 07-Apr-2004 mickey

update copyright; miod@ is fine w/ files where he holds it too


Revision tags: OPENBSD_3_5_BASE
# 1.20 12-Dec-2003 deraadt

typo


# 1.19 15-Oct-2003 mickey

less global name space pollution


# 1.18 05-Oct-2003 mickey

reload the itmr as soon as we get the intr to avoid lagging on slower machines


Revision tags: OPENBSD_3_3_BASE OPENBSD_3_4_BASE UBC_SYNC_A
# 1.17 27-Nov-2002 mickey

no wrapper arounf hardclock(), use CPU_CLOCKUPDATE, real microtime; miod ok


Revision tags: OPENBSD_3_2_BASE UBC_SYNC_B
# 1.16 15-Sep-2002 mickey

check for errors on tod pdc ops. say that bad time is before 82


# 1.15 20-May-2002 mickey

hardclock() is not called until clock has been initialized


# 1.14 14-May-2002 mickey

make resettodr() save the clock (per the pdc manual), tested


Revision tags: OPENBSD_3_1_BASE
# 1.13 14-Mar-2002 millert

First round of __P removal in sys


# 1.12 01-Feb-2002 mickey

long arg int format fix, from netbsd


Revision tags: UBC_BASE
# 1.11 06-Nov-2001 miod

branches: 1.11.2;
Replace inclusion of <vm/foo.h> with the correct <uvm/bar.h> when necessary.
(Look ma, I might have broken the tree)


Revision tags: OPENBSD_3_0_BASE
# 1.10 31-Aug-2001 mickey

some knf


Revision tags: OPENBSD_2_7_BASE OPENBSD_2_8_BASE OPENBSD_2_9_BASE
# 1.9 29-Mar-2000 mickey

timeout-driven heartbeat.
right thing would be to pass beat count as an argument to timeout
routine (casted to (void *)) avoiding static counter, but
doing timeout_set() every timeout_add() sounds kinda uncool.
well, pondering in the struct timeout guts would be even more ugly.


Revision tags: SMP_BASE
# 1.8 09-Feb-2000 mickey

branches: 1.8.2;
thinking it seems reduces heartbeat, boy


# 1.7 09-Feb-2000 mickey

heartbeat -- yeah we have a patch for that


Revision tags: OPENBSD_2_6_BASE kame_19991208
# 1.6 07-Sep-1999 mickey

make inittodr() whine some sane things


# 1.5 14-Aug-1999 mickey

clock_intr()


# 1.4 24-Jun-1999 mickey

manualy assign structures


# 1.3 12-Jun-1999 mickey

microtime() is moving to locore.S


Revision tags: OPENBSD_2_5_BASE
# 1.2 07-Feb-1999 mickey

missign extern cpu_hzticks


# 1.1 29-Dec-1998 mickey

no microtime() yet


# 1.35 04-Feb-2023 cheloha

timecounting: remove incomplete PPS support

The timecounting code has had stubs for pulse-per-second (PPS) polling
since it was imported in 2004. At this point it seems unlikely that
anyone is going to finish adding PPS support, so let's remove the stubs:

- Delete the dead tc_poll_pps() call from tc_windup().
- Remove all tc_poll_pps symbols from the kernel.

Link: https://marc.info/?l=openbsd-tech&m=167519035723210&w=2

ok miod@


# 1.34 20-Jan-2023 cheloha

hppa: simplify itmr_rearm()

The nest of branches in itmr_rearm() can be simplified to:

if (cycles <= t1 - t0) {
/* we probably missed */
}

We're doing modular unsigned 32-bit, so the rollover case in the
current code is superfluous.

Tested by miod@.

"Works for me." miod@


# 1.33 06-Dec-2022 cheloha

hppa: switch to clockintr

- Remove hppa-specific clock interrupt scheduling bits from cpu_info.
- Rename cpu_hardclock() to itmr_intr(); it doesn't exclusively run
hardclock(9) anymore.
- Wire up itmr_intrclock.

hppa now has a randomized statclock(), stathz = hz.

Patch help, testing, and review from kettenis@ (B2000) and miod@ (C3650).
MP testing from guenther@ (dual-core J6700).

ok mlarkin@ kettenis@, "Ship it?" guenther@


Revision tags: OPENBSD_6_9_BASE OPENBSD_7_0_BASE OPENBSD_7_1_BASE OPENBSD_7_2_BASE
# 1.32 23-Feb-2021 cheloha

timecounting: use C99-style initialization for all timecounter structs

The timecounter struct is large and I think it may change in the
future. Changing it later will be easier if we use C99-style
initialization for all timecounter structs. It also makes reading the
code a bit easier.

For reasons I cannot explain, switching to C99-style initialization
sometimes changes the hash of the resulting object file, even though
the resulting struct should be the same. So there is a binary change
here, but only sometimes. No behavior should change in either case.

I can't compile-test this everywhere but I have been staring at the
diff for days now and I'm relatively confident this will not break
compilation. Fingers crossed.

ok gnezdo@


Revision tags: OPENBSD_6_8_BASE
# 1.31 06-Jul-2020 pirofti

Add support for timeconting in userland.

This diff exposes parts of clock_gettime(2) and gettimeofday(2) to
userland via libc eliberating processes from the need for a context
switch everytime they want to count the passage of time.

If a timecounter clock can be exposed to userland than it needs to set
its tc_user member to a non-zero value. Tested with one or multiple
counters per architecture.

The timing data is shared through a pointer found in the new ELF
auxiliary vector AUX_openbsd_timekeep containing timehands information
that is frequently updated by the kernel.

Timing differences between the last kernel update and the current time
are adjusted in userland by the tc_get_timecount() function inside the
MD usertc.c file.

This permits a much more responsive environment, quite visible in
browsers, office programs and gaming (apparently one is are able to fly
in Minecraft now).

Tested by robert@, sthen@, naddy@, kmos@, phessler@, and many others!

OK from at least kettenis@, cheloha@, naddy@, sthen@


Revision tags: OPENBSD_6_7_BASE
# 1.30 01-May-2020 kettenis

Use the same inittodr()/resettodr() implementation as on
amd64/arm64/armv7/i386/sparc64 and move it to the end of machdep.c. Rework the
actual implementation for the MC14818 compatible RTC into something that can
be used as a todr_handle just like on amd64.

ok mpi@


Revision tags: OPENBSD_5_6_BASE OPENBSD_5_7_BASE OPENBSD_5_8_BASE OPENBSD_5_9_BASE OPENBSD_6_0_BASE OPENBSD_6_1_BASE OPENBSD_6_2_BASE OPENBSD_6_3_BASE OPENBSD_6_4_BASE OPENBSD_6_5_BASE OPENBSD_6_6_BASE
# 1.29 29-Mar-2014 guenther

It's been a quarter century: we can assume volatile is present with that name.

ok dlg@ mpi@ deraadt@


Revision tags: OPENBSD_4_9_BASE OPENBSD_5_0_BASE OPENBSD_5_1_BASE OPENBSD_5_2_BASE OPENBSD_5_3_BASE OPENBSD_5_4_BASE OPENBSD_5_5_BASE
# 1.28 09-Jan-2011 jasper

Check in resettodr() if inittodr() has been called, otherwise we end up
resetting the clock when we don't need to. Found out with booting hppa64
kernels, and the problem also exists on hppa when booting with '-a' and hitting
'exit' when asked for the root filesystem.

help & ok jsing@
also ok kettenis@ (who suggested naming the variable like amd64/i386 to
prevent creating yet another variant of this code)


# 1.27 05-Jan-2011 jasper

- remove unused headers wrapped in #if defined(DDB)

ok jsing@ kettenis@


# 1.26 01-Jan-2011 jasper

Move setting cpu_hzticks to the clock initialization function, like
other ports (e.g. hppa64) do.

ok jsing@ kettenis@


Revision tags: OPENBSD_4_8_BASE
# 1.25 01-Aug-2010 kettenis

ANSIfy


# 1.24 29-Apr-2010 jsing

Store hardware timer information per CPU.

ok kettenis@


Revision tags: OPENBSD_4_5_BASE OPENBSD_4_6_BASE OPENBSD_4_7_BASE
# 1.23 08-Feb-2009 miod

Make sure than cpu_hardclock() never sets a ``next interrupt value'' which has
already been hit by the running timer; this happens very often on oosiop-based
machines, due to these machines being among the slowest hppa, and oosiop
being interrupt greedy. Unfortunately, when this happened, one had to wait
for the timer to wrap, which would take up to 128 seconds on the 33MHz
machines.

Also, invoke hardclock() as many times as necessary if it turns out that
we had to delay the interrupt 1/hz seconds to avoid the aforementioned
wrap problem.

With help from kettenis@; ok kettenis@


Revision tags: OPENBSD_4_2_BASE OPENBSD_4_3_BASE OPENBSD_4_4_BASE
# 1.22 22-Jul-2007 kettenis

Move hppa to __HAVE_TIMECOUNTERS.


Revision tags: OPENBSD_3_6_BASE OPENBSD_3_7_BASE OPENBSD_3_8_BASE OPENBSD_3_9_BASE OPENBSD_4_0_BASE OPENBSD_4_1_BASE SMP_SYNC_A SMP_SYNC_B
# 1.21 07-Apr-2004 mickey

update copyright; miod@ is fine w/ files where he holds it too


Revision tags: OPENBSD_3_5_BASE
# 1.20 12-Dec-2003 deraadt

typo


# 1.19 15-Oct-2003 mickey

less global name space pollution


# 1.18 05-Oct-2003 mickey

reload the itmr as soon as we get the intr to avoid lagging on slower machines


Revision tags: OPENBSD_3_3_BASE OPENBSD_3_4_BASE UBC_SYNC_A
# 1.17 27-Nov-2002 mickey

no wrapper arounf hardclock(), use CPU_CLOCKUPDATE, real microtime; miod ok


Revision tags: OPENBSD_3_2_BASE UBC_SYNC_B
# 1.16 15-Sep-2002 mickey

check for errors on tod pdc ops. say that bad time is before 82


# 1.15 20-May-2002 mickey

hardclock() is not called until clock has been initialized


# 1.14 14-May-2002 mickey

make resettodr() save the clock (per the pdc manual), tested


Revision tags: OPENBSD_3_1_BASE
# 1.13 14-Mar-2002 millert

First round of __P removal in sys


# 1.12 01-Feb-2002 mickey

long arg int format fix, from netbsd


Revision tags: UBC_BASE
# 1.11 06-Nov-2001 miod

branches: 1.11.2;
Replace inclusion of <vm/foo.h> with the correct <uvm/bar.h> when necessary.
(Look ma, I might have broken the tree)


Revision tags: OPENBSD_3_0_BASE
# 1.10 31-Aug-2001 mickey

some knf


Revision tags: OPENBSD_2_7_BASE OPENBSD_2_8_BASE OPENBSD_2_9_BASE
# 1.9 29-Mar-2000 mickey

timeout-driven heartbeat.
right thing would be to pass beat count as an argument to timeout
routine (casted to (void *)) avoiding static counter, but
doing timeout_set() every timeout_add() sounds kinda uncool.
well, pondering in the struct timeout guts would be even more ugly.


Revision tags: SMP_BASE
# 1.8 09-Feb-2000 mickey

branches: 1.8.2;
thinking it seems reduces heartbeat, boy


# 1.7 09-Feb-2000 mickey

heartbeat -- yeah we have a patch for that


Revision tags: OPENBSD_2_6_BASE kame_19991208
# 1.6 07-Sep-1999 mickey

make inittodr() whine some sane things


# 1.5 14-Aug-1999 mickey

clock_intr()


# 1.4 24-Jun-1999 mickey

manualy assign structures


# 1.3 12-Jun-1999 mickey

microtime() is moving to locore.S


Revision tags: OPENBSD_2_5_BASE
# 1.2 07-Feb-1999 mickey

missign extern cpu_hzticks


# 1.1 29-Dec-1998 mickey

no microtime() yet


# 1.34 20-Jan-2023 cheloha

hppa: simplify itmr_rearm()

The nest of branches in itmr_rearm() can be simplified to:

if (cycles <= t1 - t0) {
/* we probably missed */
}

We're doing modular unsigned 32-bit, so the rollover case in the
current code is superfluous.

Tested by miod@.

"Works for me." miod@


# 1.33 06-Dec-2022 cheloha

hppa: switch to clockintr

- Remove hppa-specific clock interrupt scheduling bits from cpu_info.
- Rename cpu_hardclock() to itmr_intr(); it doesn't exclusively run
hardclock(9) anymore.
- Wire up itmr_intrclock.

hppa now has a randomized statclock(), stathz = hz.

Patch help, testing, and review from kettenis@ (B2000) and miod@ (C3650).
MP testing from guenther@ (dual-core J6700).

ok mlarkin@ kettenis@, "Ship it?" guenther@


Revision tags: OPENBSD_6_9_BASE OPENBSD_7_0_BASE OPENBSD_7_1_BASE OPENBSD_7_2_BASE
# 1.32 23-Feb-2021 cheloha

timecounting: use C99-style initialization for all timecounter structs

The timecounter struct is large and I think it may change in the
future. Changing it later will be easier if we use C99-style
initialization for all timecounter structs. It also makes reading the
code a bit easier.

For reasons I cannot explain, switching to C99-style initialization
sometimes changes the hash of the resulting object file, even though
the resulting struct should be the same. So there is a binary change
here, but only sometimes. No behavior should change in either case.

I can't compile-test this everywhere but I have been staring at the
diff for days now and I'm relatively confident this will not break
compilation. Fingers crossed.

ok gnezdo@


Revision tags: OPENBSD_6_8_BASE
# 1.31 06-Jul-2020 pirofti

Add support for timeconting in userland.

This diff exposes parts of clock_gettime(2) and gettimeofday(2) to
userland via libc eliberating processes from the need for a context
switch everytime they want to count the passage of time.

If a timecounter clock can be exposed to userland than it needs to set
its tc_user member to a non-zero value. Tested with one or multiple
counters per architecture.

The timing data is shared through a pointer found in the new ELF
auxiliary vector AUX_openbsd_timekeep containing timehands information
that is frequently updated by the kernel.

Timing differences between the last kernel update and the current time
are adjusted in userland by the tc_get_timecount() function inside the
MD usertc.c file.

This permits a much more responsive environment, quite visible in
browsers, office programs and gaming (apparently one is are able to fly
in Minecraft now).

Tested by robert@, sthen@, naddy@, kmos@, phessler@, and many others!

OK from at least kettenis@, cheloha@, naddy@, sthen@


Revision tags: OPENBSD_6_7_BASE
# 1.30 01-May-2020 kettenis

Use the same inittodr()/resettodr() implementation as on
amd64/arm64/armv7/i386/sparc64 and move it to the end of machdep.c. Rework the
actual implementation for the MC14818 compatible RTC into something that can
be used as a todr_handle just like on amd64.

ok mpi@


Revision tags: OPENBSD_5_6_BASE OPENBSD_5_7_BASE OPENBSD_5_8_BASE OPENBSD_5_9_BASE OPENBSD_6_0_BASE OPENBSD_6_1_BASE OPENBSD_6_2_BASE OPENBSD_6_3_BASE OPENBSD_6_4_BASE OPENBSD_6_5_BASE OPENBSD_6_6_BASE
# 1.29 29-Mar-2014 guenther

It's been a quarter century: we can assume volatile is present with that name.

ok dlg@ mpi@ deraadt@


Revision tags: OPENBSD_4_9_BASE OPENBSD_5_0_BASE OPENBSD_5_1_BASE OPENBSD_5_2_BASE OPENBSD_5_3_BASE OPENBSD_5_4_BASE OPENBSD_5_5_BASE
# 1.28 09-Jan-2011 jasper

Check in resettodr() if inittodr() has been called, otherwise we end up
resetting the clock when we don't need to. Found out with booting hppa64
kernels, and the problem also exists on hppa when booting with '-a' and hitting
'exit' when asked for the root filesystem.

help & ok jsing@
also ok kettenis@ (who suggested naming the variable like amd64/i386 to
prevent creating yet another variant of this code)


# 1.27 05-Jan-2011 jasper

- remove unused headers wrapped in #if defined(DDB)

ok jsing@ kettenis@


# 1.26 01-Jan-2011 jasper

Move setting cpu_hzticks to the clock initialization function, like
other ports (e.g. hppa64) do.

ok jsing@ kettenis@


Revision tags: OPENBSD_4_8_BASE
# 1.25 01-Aug-2010 kettenis

ANSIfy


# 1.24 29-Apr-2010 jsing

Store hardware timer information per CPU.

ok kettenis@


Revision tags: OPENBSD_4_5_BASE OPENBSD_4_6_BASE OPENBSD_4_7_BASE
# 1.23 08-Feb-2009 miod

Make sure than cpu_hardclock() never sets a ``next interrupt value'' which has
already been hit by the running timer; this happens very often on oosiop-based
machines, due to these machines being among the slowest hppa, and oosiop
being interrupt greedy. Unfortunately, when this happened, one had to wait
for the timer to wrap, which would take up to 128 seconds on the 33MHz
machines.

Also, invoke hardclock() as many times as necessary if it turns out that
we had to delay the interrupt 1/hz seconds to avoid the aforementioned
wrap problem.

With help from kettenis@; ok kettenis@


Revision tags: OPENBSD_4_2_BASE OPENBSD_4_3_BASE OPENBSD_4_4_BASE
# 1.22 22-Jul-2007 kettenis

Move hppa to __HAVE_TIMECOUNTERS.


Revision tags: OPENBSD_3_6_BASE OPENBSD_3_7_BASE OPENBSD_3_8_BASE OPENBSD_3_9_BASE OPENBSD_4_0_BASE OPENBSD_4_1_BASE SMP_SYNC_A SMP_SYNC_B
# 1.21 07-Apr-2004 mickey

update copyright; miod@ is fine w/ files where he holds it too


Revision tags: OPENBSD_3_5_BASE
# 1.20 12-Dec-2003 deraadt

typo


# 1.19 15-Oct-2003 mickey

less global name space pollution


# 1.18 05-Oct-2003 mickey

reload the itmr as soon as we get the intr to avoid lagging on slower machines


Revision tags: OPENBSD_3_3_BASE OPENBSD_3_4_BASE UBC_SYNC_A
# 1.17 27-Nov-2002 mickey

no wrapper arounf hardclock(), use CPU_CLOCKUPDATE, real microtime; miod ok


Revision tags: OPENBSD_3_2_BASE UBC_SYNC_B
# 1.16 15-Sep-2002 mickey

check for errors on tod pdc ops. say that bad time is before 82


# 1.15 20-May-2002 mickey

hardclock() is not called until clock has been initialized


# 1.14 14-May-2002 mickey

make resettodr() save the clock (per the pdc manual), tested


Revision tags: OPENBSD_3_1_BASE
# 1.13 14-Mar-2002 millert

First round of __P removal in sys


# 1.12 01-Feb-2002 mickey

long arg int format fix, from netbsd


Revision tags: UBC_BASE
# 1.11 06-Nov-2001 miod

branches: 1.11.2;
Replace inclusion of <vm/foo.h> with the correct <uvm/bar.h> when necessary.
(Look ma, I might have broken the tree)


Revision tags: OPENBSD_3_0_BASE
# 1.10 31-Aug-2001 mickey

some knf


Revision tags: OPENBSD_2_7_BASE OPENBSD_2_8_BASE OPENBSD_2_9_BASE
# 1.9 29-Mar-2000 mickey

timeout-driven heartbeat.
right thing would be to pass beat count as an argument to timeout
routine (casted to (void *)) avoiding static counter, but
doing timeout_set() every timeout_add() sounds kinda uncool.
well, pondering in the struct timeout guts would be even more ugly.


Revision tags: SMP_BASE
# 1.8 09-Feb-2000 mickey

branches: 1.8.2;
thinking it seems reduces heartbeat, boy


# 1.7 09-Feb-2000 mickey

heartbeat -- yeah we have a patch for that


Revision tags: OPENBSD_2_6_BASE kame_19991208
# 1.6 07-Sep-1999 mickey

make inittodr() whine some sane things


# 1.5 14-Aug-1999 mickey

clock_intr()


# 1.4 24-Jun-1999 mickey

manualy assign structures


# 1.3 12-Jun-1999 mickey

microtime() is moving to locore.S


Revision tags: OPENBSD_2_5_BASE
# 1.2 07-Feb-1999 mickey

missign extern cpu_hzticks


# 1.1 29-Dec-1998 mickey

no microtime() yet


# 1.33 06-Dec-2022 cheloha

hppa: switch to clockintr

- Remove hppa-specific clock interrupt scheduling bits from cpu_info.
- Rename cpu_hardclock() to itmr_intr(); it doesn't exclusively run
hardclock(9) anymore.
- Wire up itmr_intrclock.

hppa now has a randomized statclock(), stathz = hz.

Patch help, testing, and review from kettenis@ (B2000) and miod@ (C3650).
MP testing from guenther@ (dual-core J6700).

ok mlarkin@ kettenis@, "Ship it?" guenther@


Revision tags: OPENBSD_6_9_BASE OPENBSD_7_0_BASE OPENBSD_7_1_BASE OPENBSD_7_2_BASE
# 1.32 23-Feb-2021 cheloha

timecounting: use C99-style initialization for all timecounter structs

The timecounter struct is large and I think it may change in the
future. Changing it later will be easier if we use C99-style
initialization for all timecounter structs. It also makes reading the
code a bit easier.

For reasons I cannot explain, switching to C99-style initialization
sometimes changes the hash of the resulting object file, even though
the resulting struct should be the same. So there is a binary change
here, but only sometimes. No behavior should change in either case.

I can't compile-test this everywhere but I have been staring at the
diff for days now and I'm relatively confident this will not break
compilation. Fingers crossed.

ok gnezdo@


Revision tags: OPENBSD_6_8_BASE
# 1.31 06-Jul-2020 pirofti

Add support for timeconting in userland.

This diff exposes parts of clock_gettime(2) and gettimeofday(2) to
userland via libc eliberating processes from the need for a context
switch everytime they want to count the passage of time.

If a timecounter clock can be exposed to userland than it needs to set
its tc_user member to a non-zero value. Tested with one or multiple
counters per architecture.

The timing data is shared through a pointer found in the new ELF
auxiliary vector AUX_openbsd_timekeep containing timehands information
that is frequently updated by the kernel.

Timing differences between the last kernel update and the current time
are adjusted in userland by the tc_get_timecount() function inside the
MD usertc.c file.

This permits a much more responsive environment, quite visible in
browsers, office programs and gaming (apparently one is are able to fly
in Minecraft now).

Tested by robert@, sthen@, naddy@, kmos@, phessler@, and many others!

OK from at least kettenis@, cheloha@, naddy@, sthen@


Revision tags: OPENBSD_6_7_BASE
# 1.30 01-May-2020 kettenis

Use the same inittodr()/resettodr() implementation as on
amd64/arm64/armv7/i386/sparc64 and move it to the end of machdep.c. Rework the
actual implementation for the MC14818 compatible RTC into something that can
be used as a todr_handle just like on amd64.

ok mpi@


Revision tags: OPENBSD_5_6_BASE OPENBSD_5_7_BASE OPENBSD_5_8_BASE OPENBSD_5_9_BASE OPENBSD_6_0_BASE OPENBSD_6_1_BASE OPENBSD_6_2_BASE OPENBSD_6_3_BASE OPENBSD_6_4_BASE OPENBSD_6_5_BASE OPENBSD_6_6_BASE
# 1.29 29-Mar-2014 guenther

It's been a quarter century: we can assume volatile is present with that name.

ok dlg@ mpi@ deraadt@


Revision tags: OPENBSD_4_9_BASE OPENBSD_5_0_BASE OPENBSD_5_1_BASE OPENBSD_5_2_BASE OPENBSD_5_3_BASE OPENBSD_5_4_BASE OPENBSD_5_5_BASE
# 1.28 09-Jan-2011 jasper

Check in resettodr() if inittodr() has been called, otherwise we end up
resetting the clock when we don't need to. Found out with booting hppa64
kernels, and the problem also exists on hppa when booting with '-a' and hitting
'exit' when asked for the root filesystem.

help & ok jsing@
also ok kettenis@ (who suggested naming the variable like amd64/i386 to
prevent creating yet another variant of this code)


# 1.27 05-Jan-2011 jasper

- remove unused headers wrapped in #if defined(DDB)

ok jsing@ kettenis@


# 1.26 01-Jan-2011 jasper

Move setting cpu_hzticks to the clock initialization function, like
other ports (e.g. hppa64) do.

ok jsing@ kettenis@


Revision tags: OPENBSD_4_8_BASE
# 1.25 01-Aug-2010 kettenis

ANSIfy


# 1.24 29-Apr-2010 jsing

Store hardware timer information per CPU.

ok kettenis@


Revision tags: OPENBSD_4_5_BASE OPENBSD_4_6_BASE OPENBSD_4_7_BASE
# 1.23 08-Feb-2009 miod

Make sure than cpu_hardclock() never sets a ``next interrupt value'' which has
already been hit by the running timer; this happens very often on oosiop-based
machines, due to these machines being among the slowest hppa, and oosiop
being interrupt greedy. Unfortunately, when this happened, one had to wait
for the timer to wrap, which would take up to 128 seconds on the 33MHz
machines.

Also, invoke hardclock() as many times as necessary if it turns out that
we had to delay the interrupt 1/hz seconds to avoid the aforementioned
wrap problem.

With help from kettenis@; ok kettenis@


Revision tags: OPENBSD_4_2_BASE OPENBSD_4_3_BASE OPENBSD_4_4_BASE
# 1.22 22-Jul-2007 kettenis

Move hppa to __HAVE_TIMECOUNTERS.


Revision tags: OPENBSD_3_6_BASE OPENBSD_3_7_BASE OPENBSD_3_8_BASE OPENBSD_3_9_BASE OPENBSD_4_0_BASE OPENBSD_4_1_BASE SMP_SYNC_A SMP_SYNC_B
# 1.21 07-Apr-2004 mickey

update copyright; miod@ is fine w/ files where he holds it too


Revision tags: OPENBSD_3_5_BASE
# 1.20 12-Dec-2003 deraadt

typo


# 1.19 15-Oct-2003 mickey

less global name space pollution


# 1.18 05-Oct-2003 mickey

reload the itmr as soon as we get the intr to avoid lagging on slower machines


Revision tags: OPENBSD_3_3_BASE OPENBSD_3_4_BASE UBC_SYNC_A
# 1.17 27-Nov-2002 mickey

no wrapper arounf hardclock(), use CPU_CLOCKUPDATE, real microtime; miod ok


Revision tags: OPENBSD_3_2_BASE UBC_SYNC_B
# 1.16 15-Sep-2002 mickey

check for errors on tod pdc ops. say that bad time is before 82


# 1.15 20-May-2002 mickey

hardclock() is not called until clock has been initialized


# 1.14 14-May-2002 mickey

make resettodr() save the clock (per the pdc manual), tested


Revision tags: OPENBSD_3_1_BASE
# 1.13 14-Mar-2002 millert

First round of __P removal in sys


# 1.12 01-Feb-2002 mickey

long arg int format fix, from netbsd


Revision tags: UBC_BASE
# 1.11 06-Nov-2001 miod

branches: 1.11.2;
Replace inclusion of <vm/foo.h> with the correct <uvm/bar.h> when necessary.
(Look ma, I might have broken the tree)


Revision tags: OPENBSD_3_0_BASE
# 1.10 31-Aug-2001 mickey

some knf


Revision tags: OPENBSD_2_7_BASE OPENBSD_2_8_BASE OPENBSD_2_9_BASE
# 1.9 29-Mar-2000 mickey

timeout-driven heartbeat.
right thing would be to pass beat count as an argument to timeout
routine (casted to (void *)) avoiding static counter, but
doing timeout_set() every timeout_add() sounds kinda uncool.
well, pondering in the struct timeout guts would be even more ugly.


Revision tags: SMP_BASE
# 1.8 09-Feb-2000 mickey

branches: 1.8.2;
thinking it seems reduces heartbeat, boy


# 1.7 09-Feb-2000 mickey

heartbeat -- yeah we have a patch for that


Revision tags: OPENBSD_2_6_BASE kame_19991208
# 1.6 07-Sep-1999 mickey

make inittodr() whine some sane things


# 1.5 14-Aug-1999 mickey

clock_intr()


# 1.4 24-Jun-1999 mickey

manualy assign structures


# 1.3 12-Jun-1999 mickey

microtime() is moving to locore.S


Revision tags: OPENBSD_2_5_BASE
# 1.2 07-Feb-1999 mickey

missign extern cpu_hzticks


# 1.1 29-Dec-1998 mickey

no microtime() yet


# 1.32 23-Feb-2021 cheloha

timecounting: use C99-style initialization for all timecounter structs

The timecounter struct is large and I think it may change in the
future. Changing it later will be easier if we use C99-style
initialization for all timecounter structs. It also makes reading the
code a bit easier.

For reasons I cannot explain, switching to C99-style initialization
sometimes changes the hash of the resulting object file, even though
the resulting struct should be the same. So there is a binary change
here, but only sometimes. No behavior should change in either case.

I can't compile-test this everywhere but I have been staring at the
diff for days now and I'm relatively confident this will not break
compilation. Fingers crossed.

ok gnezdo@


Revision tags: OPENBSD_6_8_BASE
# 1.31 06-Jul-2020 pirofti

Add support for timeconting in userland.

This diff exposes parts of clock_gettime(2) and gettimeofday(2) to
userland via libc eliberating processes from the need for a context
switch everytime they want to count the passage of time.

If a timecounter clock can be exposed to userland than it needs to set
its tc_user member to a non-zero value. Tested with one or multiple
counters per architecture.

The timing data is shared through a pointer found in the new ELF
auxiliary vector AUX_openbsd_timekeep containing timehands information
that is frequently updated by the kernel.

Timing differences between the last kernel update and the current time
are adjusted in userland by the tc_get_timecount() function inside the
MD usertc.c file.

This permits a much more responsive environment, quite visible in
browsers, office programs and gaming (apparently one is are able to fly
in Minecraft now).

Tested by robert@, sthen@, naddy@, kmos@, phessler@, and many others!

OK from at least kettenis@, cheloha@, naddy@, sthen@


Revision tags: OPENBSD_6_7_BASE
# 1.30 01-May-2020 kettenis

Use the same inittodr()/resettodr() implementation as on
amd64/arm64/armv7/i386/sparc64 and move it to the end of machdep.c. Rework the
actual implementation for the MC14818 compatible RTC into something that can
be used as a todr_handle just like on amd64.

ok mpi@


Revision tags: OPENBSD_5_6_BASE OPENBSD_5_7_BASE OPENBSD_5_8_BASE OPENBSD_5_9_BASE OPENBSD_6_0_BASE OPENBSD_6_1_BASE OPENBSD_6_2_BASE OPENBSD_6_3_BASE OPENBSD_6_4_BASE OPENBSD_6_5_BASE OPENBSD_6_6_BASE
# 1.29 29-Mar-2014 guenther

It's been a quarter century: we can assume volatile is present with that name.

ok dlg@ mpi@ deraadt@


Revision tags: OPENBSD_4_9_BASE OPENBSD_5_0_BASE OPENBSD_5_1_BASE OPENBSD_5_2_BASE OPENBSD_5_3_BASE OPENBSD_5_4_BASE OPENBSD_5_5_BASE
# 1.28 09-Jan-2011 jasper

Check in resettodr() if inittodr() has been called, otherwise we end up
resetting the clock when we don't need to. Found out with booting hppa64
kernels, and the problem also exists on hppa when booting with '-a' and hitting
'exit' when asked for the root filesystem.

help & ok jsing@
also ok kettenis@ (who suggested naming the variable like amd64/i386 to
prevent creating yet another variant of this code)


# 1.27 05-Jan-2011 jasper

- remove unused headers wrapped in #if defined(DDB)

ok jsing@ kettenis@


# 1.26 01-Jan-2011 jasper

Move setting cpu_hzticks to the clock initialization function, like
other ports (e.g. hppa64) do.

ok jsing@ kettenis@


Revision tags: OPENBSD_4_8_BASE
# 1.25 01-Aug-2010 kettenis

ANSIfy


# 1.24 29-Apr-2010 jsing

Store hardware timer information per CPU.

ok kettenis@


Revision tags: OPENBSD_4_5_BASE OPENBSD_4_6_BASE OPENBSD_4_7_BASE
# 1.23 08-Feb-2009 miod

Make sure than cpu_hardclock() never sets a ``next interrupt value'' which has
already been hit by the running timer; this happens very often on oosiop-based
machines, due to these machines being among the slowest hppa, and oosiop
being interrupt greedy. Unfortunately, when this happened, one had to wait
for the timer to wrap, which would take up to 128 seconds on the 33MHz
machines.

Also, invoke hardclock() as many times as necessary if it turns out that
we had to delay the interrupt 1/hz seconds to avoid the aforementioned
wrap problem.

With help from kettenis@; ok kettenis@


Revision tags: OPENBSD_4_2_BASE OPENBSD_4_3_BASE OPENBSD_4_4_BASE
# 1.22 22-Jul-2007 kettenis

Move hppa to __HAVE_TIMECOUNTERS.


Revision tags: OPENBSD_3_6_BASE OPENBSD_3_7_BASE OPENBSD_3_8_BASE OPENBSD_3_9_BASE OPENBSD_4_0_BASE OPENBSD_4_1_BASE SMP_SYNC_A SMP_SYNC_B
# 1.21 07-Apr-2004 mickey

update copyright; miod@ is fine w/ files where he holds it too


Revision tags: OPENBSD_3_5_BASE
# 1.20 12-Dec-2003 deraadt

typo


# 1.19 15-Oct-2003 mickey

less global name space pollution


# 1.18 05-Oct-2003 mickey

reload the itmr as soon as we get the intr to avoid lagging on slower machines


Revision tags: OPENBSD_3_3_BASE OPENBSD_3_4_BASE UBC_SYNC_A
# 1.17 27-Nov-2002 mickey

no wrapper arounf hardclock(), use CPU_CLOCKUPDATE, real microtime; miod ok


Revision tags: OPENBSD_3_2_BASE UBC_SYNC_B
# 1.16 15-Sep-2002 mickey

check for errors on tod pdc ops. say that bad time is before 82


# 1.15 20-May-2002 mickey

hardclock() is not called until clock has been initialized


# 1.14 14-May-2002 mickey

make resettodr() save the clock (per the pdc manual), tested


Revision tags: OPENBSD_3_1_BASE
# 1.13 14-Mar-2002 millert

First round of __P removal in sys


# 1.12 01-Feb-2002 mickey

long arg int format fix, from netbsd


Revision tags: UBC_BASE
# 1.11 06-Nov-2001 miod

branches: 1.11.2;
Replace inclusion of <vm/foo.h> with the correct <uvm/bar.h> when necessary.
(Look ma, I might have broken the tree)


Revision tags: OPENBSD_3_0_BASE
# 1.10 31-Aug-2001 mickey

some knf


Revision tags: OPENBSD_2_7_BASE OPENBSD_2_8_BASE OPENBSD_2_9_BASE
# 1.9 29-Mar-2000 mickey

timeout-driven heartbeat.
right thing would be to pass beat count as an argument to timeout
routine (casted to (void *)) avoiding static counter, but
doing timeout_set() every timeout_add() sounds kinda uncool.
well, pondering in the struct timeout guts would be even more ugly.


Revision tags: SMP_BASE
# 1.8 09-Feb-2000 mickey

branches: 1.8.2;
thinking it seems reduces heartbeat, boy


# 1.7 09-Feb-2000 mickey

heartbeat -- yeah we have a patch for that


Revision tags: OPENBSD_2_6_BASE kame_19991208
# 1.6 07-Sep-1999 mickey

make inittodr() whine some sane things


# 1.5 14-Aug-1999 mickey

clock_intr()


# 1.4 24-Jun-1999 mickey

manualy assign structures


# 1.3 12-Jun-1999 mickey

microtime() is moving to locore.S


Revision tags: OPENBSD_2_5_BASE
# 1.2 07-Feb-1999 mickey

missign extern cpu_hzticks


# 1.1 29-Dec-1998 mickey

no microtime() yet


# 1.31 06-Jul-2020 pirofti

Add support for timeconting in userland.

This diff exposes parts of clock_gettime(2) and gettimeofday(2) to
userland via libc eliberating processes from the need for a context
switch everytime they want to count the passage of time.

If a timecounter clock can be exposed to userland than it needs to set
its tc_user member to a non-zero value. Tested with one or multiple
counters per architecture.

The timing data is shared through a pointer found in the new ELF
auxiliary vector AUX_openbsd_timekeep containing timehands information
that is frequently updated by the kernel.

Timing differences between the last kernel update and the current time
are adjusted in userland by the tc_get_timecount() function inside the
MD usertc.c file.

This permits a much more responsive environment, quite visible in
browsers, office programs and gaming (apparently one is are able to fly
in Minecraft now).

Tested by robert@, sthen@, naddy@, kmos@, phessler@, and many others!

OK from at least kettenis@, cheloha@, naddy@, sthen@


Revision tags: OPENBSD_6_7_BASE
# 1.30 01-May-2020 kettenis

Use the same inittodr()/resettodr() implementation as on
amd64/arm64/armv7/i386/sparc64 and move it to the end of machdep.c. Rework the
actual implementation for the MC14818 compatible RTC into something that can
be used as a todr_handle just like on amd64.

ok mpi@


Revision tags: OPENBSD_5_6_BASE OPENBSD_5_7_BASE OPENBSD_5_8_BASE OPENBSD_5_9_BASE OPENBSD_6_0_BASE OPENBSD_6_1_BASE OPENBSD_6_2_BASE OPENBSD_6_3_BASE OPENBSD_6_4_BASE OPENBSD_6_5_BASE OPENBSD_6_6_BASE
# 1.29 29-Mar-2014 guenther

It's been a quarter century: we can assume volatile is present with that name.

ok dlg@ mpi@ deraadt@


Revision tags: OPENBSD_4_9_BASE OPENBSD_5_0_BASE OPENBSD_5_1_BASE OPENBSD_5_2_BASE OPENBSD_5_3_BASE OPENBSD_5_4_BASE OPENBSD_5_5_BASE
# 1.28 09-Jan-2011 jasper

Check in resettodr() if inittodr() has been called, otherwise we end up
resetting the clock when we don't need to. Found out with booting hppa64
kernels, and the problem also exists on hppa when booting with '-a' and hitting
'exit' when asked for the root filesystem.

help & ok jsing@
also ok kettenis@ (who suggested naming the variable like amd64/i386 to
prevent creating yet another variant of this code)


# 1.27 05-Jan-2011 jasper

- remove unused headers wrapped in #if defined(DDB)

ok jsing@ kettenis@


# 1.26 01-Jan-2011 jasper

Move setting cpu_hzticks to the clock initialization function, like
other ports (e.g. hppa64) do.

ok jsing@ kettenis@


Revision tags: OPENBSD_4_8_BASE
# 1.25 01-Aug-2010 kettenis

ANSIfy


# 1.24 29-Apr-2010 jsing

Store hardware timer information per CPU.

ok kettenis@


Revision tags: OPENBSD_4_5_BASE OPENBSD_4_6_BASE OPENBSD_4_7_BASE
# 1.23 08-Feb-2009 miod

Make sure than cpu_hardclock() never sets a ``next interrupt value'' which has
already been hit by the running timer; this happens very often on oosiop-based
machines, due to these machines being among the slowest hppa, and oosiop
being interrupt greedy. Unfortunately, when this happened, one had to wait
for the timer to wrap, which would take up to 128 seconds on the 33MHz
machines.

Also, invoke hardclock() as many times as necessary if it turns out that
we had to delay the interrupt 1/hz seconds to avoid the aforementioned
wrap problem.

With help from kettenis@; ok kettenis@


Revision tags: OPENBSD_4_2_BASE OPENBSD_4_3_BASE OPENBSD_4_4_BASE
# 1.22 22-Jul-2007 kettenis

Move hppa to __HAVE_TIMECOUNTERS.


Revision tags: OPENBSD_3_6_BASE OPENBSD_3_7_BASE OPENBSD_3_8_BASE OPENBSD_3_9_BASE OPENBSD_4_0_BASE OPENBSD_4_1_BASE SMP_SYNC_A SMP_SYNC_B
# 1.21 07-Apr-2004 mickey

update copyright; miod@ is fine w/ files where he holds it too


Revision tags: OPENBSD_3_5_BASE
# 1.20 12-Dec-2003 deraadt

typo


# 1.19 15-Oct-2003 mickey

less global name space pollution


# 1.18 05-Oct-2003 mickey

reload the itmr as soon as we get the intr to avoid lagging on slower machines


Revision tags: OPENBSD_3_3_BASE OPENBSD_3_4_BASE UBC_SYNC_A
# 1.17 27-Nov-2002 mickey

no wrapper arounf hardclock(), use CPU_CLOCKUPDATE, real microtime; miod ok


Revision tags: OPENBSD_3_2_BASE UBC_SYNC_B
# 1.16 15-Sep-2002 mickey

check for errors on tod pdc ops. say that bad time is before 82


# 1.15 20-May-2002 mickey

hardclock() is not called until clock has been initialized


# 1.14 14-May-2002 mickey

make resettodr() save the clock (per the pdc manual), tested


Revision tags: OPENBSD_3_1_BASE
# 1.13 14-Mar-2002 millert

First round of __P removal in sys


# 1.12 01-Feb-2002 mickey

long arg int format fix, from netbsd


Revision tags: UBC_BASE
# 1.11 06-Nov-2001 miod

branches: 1.11.2;
Replace inclusion of <vm/foo.h> with the correct <uvm/bar.h> when necessary.
(Look ma, I might have broken the tree)


Revision tags: OPENBSD_3_0_BASE
# 1.10 31-Aug-2001 mickey

some knf


Revision tags: OPENBSD_2_7_BASE OPENBSD_2_8_BASE OPENBSD_2_9_BASE
# 1.9 29-Mar-2000 mickey

timeout-driven heartbeat.
right thing would be to pass beat count as an argument to timeout
routine (casted to (void *)) avoiding static counter, but
doing timeout_set() every timeout_add() sounds kinda uncool.
well, pondering in the struct timeout guts would be even more ugly.


Revision tags: SMP_BASE
# 1.8 09-Feb-2000 mickey

branches: 1.8.2;
thinking it seems reduces heartbeat, boy


# 1.7 09-Feb-2000 mickey

heartbeat -- yeah we have a patch for that


Revision tags: OPENBSD_2_6_BASE kame_19991208
# 1.6 07-Sep-1999 mickey

make inittodr() whine some sane things


# 1.5 14-Aug-1999 mickey

clock_intr()


# 1.4 24-Jun-1999 mickey

manualy assign structures


# 1.3 12-Jun-1999 mickey

microtime() is moving to locore.S


Revision tags: OPENBSD_2_5_BASE
# 1.2 07-Feb-1999 mickey

missign extern cpu_hzticks


# 1.1 29-Dec-1998 mickey

no microtime() yet


# 1.30 01-May-2020 kettenis

Use the same inittodr()/resettodr() implementation as on
amd64/arm64/armv7/i386/sparc64 and move it to the end of machdep.c. Rework the
actual implementation for the MC14818 compatible RTC into something that can
be used as a todr_handle just like on amd64.

ok mpi@


Revision tags: OPENBSD_5_6_BASE OPENBSD_5_7_BASE OPENBSD_5_8_BASE OPENBSD_5_9_BASE OPENBSD_6_0_BASE OPENBSD_6_1_BASE OPENBSD_6_2_BASE OPENBSD_6_3_BASE OPENBSD_6_4_BASE OPENBSD_6_5_BASE OPENBSD_6_6_BASE
# 1.29 29-Mar-2014 guenther

It's been a quarter century: we can assume volatile is present with that name.

ok dlg@ mpi@ deraadt@


Revision tags: OPENBSD_4_9_BASE OPENBSD_5_0_BASE OPENBSD_5_1_BASE OPENBSD_5_2_BASE OPENBSD_5_3_BASE OPENBSD_5_4_BASE OPENBSD_5_5_BASE
# 1.28 09-Jan-2011 jasper

Check in resettodr() if inittodr() has been called, otherwise we end up
resetting the clock when we don't need to. Found out with booting hppa64
kernels, and the problem also exists on hppa when booting with '-a' and hitting
'exit' when asked for the root filesystem.

help & ok jsing@
also ok kettenis@ (who suggested naming the variable like amd64/i386 to
prevent creating yet another variant of this code)


# 1.27 05-Jan-2011 jasper

- remove unused headers wrapped in #if defined(DDB)

ok jsing@ kettenis@


# 1.26 01-Jan-2011 jasper

Move setting cpu_hzticks to the clock initialization function, like
other ports (e.g. hppa64) do.

ok jsing@ kettenis@


Revision tags: OPENBSD_4_8_BASE
# 1.25 01-Aug-2010 kettenis

ANSIfy


# 1.24 29-Apr-2010 jsing

Store hardware timer information per CPU.

ok kettenis@


Revision tags: OPENBSD_4_5_BASE OPENBSD_4_6_BASE OPENBSD_4_7_BASE
# 1.23 08-Feb-2009 miod

Make sure than cpu_hardclock() never sets a ``next interrupt value'' which has
already been hit by the running timer; this happens very often on oosiop-based
machines, due to these machines being among the slowest hppa, and oosiop
being interrupt greedy. Unfortunately, when this happened, one had to wait
for the timer to wrap, which would take up to 128 seconds on the 33MHz
machines.

Also, invoke hardclock() as many times as necessary if it turns out that
we had to delay the interrupt 1/hz seconds to avoid the aforementioned
wrap problem.

With help from kettenis@; ok kettenis@


Revision tags: OPENBSD_4_2_BASE OPENBSD_4_3_BASE OPENBSD_4_4_BASE
# 1.22 22-Jul-2007 kettenis

Move hppa to __HAVE_TIMECOUNTERS.


Revision tags: OPENBSD_3_6_BASE OPENBSD_3_7_BASE OPENBSD_3_8_BASE OPENBSD_3_9_BASE OPENBSD_4_0_BASE OPENBSD_4_1_BASE SMP_SYNC_A SMP_SYNC_B
# 1.21 07-Apr-2004 mickey

update copyright; miod@ is fine w/ files where he holds it too


Revision tags: OPENBSD_3_5_BASE
# 1.20 12-Dec-2003 deraadt

typo


# 1.19 15-Oct-2003 mickey

less global name space pollution


# 1.18 05-Oct-2003 mickey

reload the itmr as soon as we get the intr to avoid lagging on slower machines


Revision tags: OPENBSD_3_3_BASE OPENBSD_3_4_BASE UBC_SYNC_A
# 1.17 27-Nov-2002 mickey

no wrapper arounf hardclock(), use CPU_CLOCKUPDATE, real microtime; miod ok


Revision tags: OPENBSD_3_2_BASE UBC_SYNC_B
# 1.16 15-Sep-2002 mickey

check for errors on tod pdc ops. say that bad time is before 82


# 1.15 20-May-2002 mickey

hardclock() is not called until clock has been initialized


# 1.14 14-May-2002 mickey

make resettodr() save the clock (per the pdc manual), tested


Revision tags: OPENBSD_3_1_BASE
# 1.13 14-Mar-2002 millert

First round of __P removal in sys


# 1.12 01-Feb-2002 mickey

long arg int format fix, from netbsd


Revision tags: UBC_BASE
# 1.11 06-Nov-2001 miod

branches: 1.11.2;
Replace inclusion of <vm/foo.h> with the correct <uvm/bar.h> when necessary.
(Look ma, I might have broken the tree)


Revision tags: OPENBSD_3_0_BASE
# 1.10 31-Aug-2001 mickey

some knf


Revision tags: OPENBSD_2_7_BASE OPENBSD_2_8_BASE OPENBSD_2_9_BASE
# 1.9 29-Mar-2000 mickey

timeout-driven heartbeat.
right thing would be to pass beat count as an argument to timeout
routine (casted to (void *)) avoiding static counter, but
doing timeout_set() every timeout_add() sounds kinda uncool.
well, pondering in the struct timeout guts would be even more ugly.


Revision tags: SMP_BASE
# 1.8 09-Feb-2000 mickey

branches: 1.8.2;
thinking it seems reduces heartbeat, boy


# 1.7 09-Feb-2000 mickey

heartbeat -- yeah we have a patch for that


Revision tags: OPENBSD_2_6_BASE kame_19991208
# 1.6 07-Sep-1999 mickey

make inittodr() whine some sane things


# 1.5 14-Aug-1999 mickey

clock_intr()


# 1.4 24-Jun-1999 mickey

manualy assign structures


# 1.3 12-Jun-1999 mickey

microtime() is moving to locore.S


Revision tags: OPENBSD_2_5_BASE
# 1.2 07-Feb-1999 mickey

missign extern cpu_hzticks


# 1.1 29-Dec-1998 mickey

no microtime() yet


Revision tags: OPENBSD_5_6_BASE OPENBSD_5_7_BASE OPENBSD_5_8_BASE OPENBSD_5_9_BASE OPENBSD_6_0_BASE OPENBSD_6_1_BASE OPENBSD_6_2_BASE
# 1.29 29-Mar-2014 guenther

It's been a quarter century: we can assume volatile is present with that name.

ok dlg@ mpi@ deraadt@


Revision tags: OPENBSD_4_9_BASE OPENBSD_5_0_BASE OPENBSD_5_1_BASE OPENBSD_5_2_BASE OPENBSD_5_3_BASE OPENBSD_5_4_BASE OPENBSD_5_5_BASE
# 1.28 09-Jan-2011 jasper

Check in resettodr() if inittodr() has been called, otherwise we end up
resetting the clock when we don't need to. Found out with booting hppa64
kernels, and the problem also exists on hppa when booting with '-a' and hitting
'exit' when asked for the root filesystem.

help & ok jsing@
also ok kettenis@ (who suggested naming the variable like amd64/i386 to
prevent creating yet another variant of this code)


# 1.27 05-Jan-2011 jasper

- remove unused headers wrapped in #if defined(DDB)

ok jsing@ kettenis@


# 1.26 01-Jan-2011 jasper

Move setting cpu_hzticks to the clock initialization function, like
other ports (e.g. hppa64) do.

ok jsing@ kettenis@


Revision tags: OPENBSD_4_8_BASE
# 1.25 01-Aug-2010 kettenis

ANSIfy


# 1.24 29-Apr-2010 jsing

Store hardware timer information per CPU.

ok kettenis@


Revision tags: OPENBSD_4_5_BASE OPENBSD_4_6_BASE OPENBSD_4_7_BASE
# 1.23 08-Feb-2009 miod

Make sure than cpu_hardclock() never sets a ``next interrupt value'' which has
already been hit by the running timer; this happens very often on oosiop-based
machines, due to these machines being among the slowest hppa, and oosiop
being interrupt greedy. Unfortunately, when this happened, one had to wait
for the timer to wrap, which would take up to 128 seconds on the 33MHz
machines.

Also, invoke hardclock() as many times as necessary if it turns out that
we had to delay the interrupt 1/hz seconds to avoid the aforementioned
wrap problem.

With help from kettenis@; ok kettenis@


Revision tags: OPENBSD_4_2_BASE OPENBSD_4_3_BASE OPENBSD_4_4_BASE
# 1.22 22-Jul-2007 kettenis

Move hppa to __HAVE_TIMECOUNTERS.


Revision tags: OPENBSD_3_6_BASE OPENBSD_3_7_BASE OPENBSD_3_8_BASE OPENBSD_3_9_BASE OPENBSD_4_0_BASE OPENBSD_4_1_BASE SMP_SYNC_A SMP_SYNC_B
# 1.21 07-Apr-2004 mickey

update copyright; miod@ is fine w/ files where he holds it too


Revision tags: OPENBSD_3_5_BASE
# 1.20 12-Dec-2003 deraadt

typo


# 1.19 15-Oct-2003 mickey

less global name space pollution


# 1.18 05-Oct-2003 mickey

reload the itmr as soon as we get the intr to avoid lagging on slower machines


Revision tags: OPENBSD_3_3_BASE OPENBSD_3_4_BASE UBC_SYNC_A
# 1.17 27-Nov-2002 mickey

no wrapper arounf hardclock(), use CPU_CLOCKUPDATE, real microtime; miod ok


Revision tags: OPENBSD_3_2_BASE UBC_SYNC_B
# 1.16 15-Sep-2002 mickey

check for errors on tod pdc ops. say that bad time is before 82


# 1.15 20-May-2002 mickey

hardclock() is not called until clock has been initialized


# 1.14 14-May-2002 mickey

make resettodr() save the clock (per the pdc manual), tested


Revision tags: OPENBSD_3_1_BASE
# 1.13 14-Mar-2002 millert

First round of __P removal in sys


# 1.12 01-Feb-2002 mickey

long arg int format fix, from netbsd


Revision tags: UBC_BASE
# 1.11 06-Nov-2001 miod

branches: 1.11.2;
Replace inclusion of <vm/foo.h> with the correct <uvm/bar.h> when necessary.
(Look ma, I might have broken the tree)


Revision tags: OPENBSD_3_0_BASE
# 1.10 31-Aug-2001 mickey

some knf


Revision tags: OPENBSD_2_7_BASE OPENBSD_2_8_BASE OPENBSD_2_9_BASE
# 1.9 29-Mar-2000 mickey

timeout-driven heartbeat.
right thing would be to pass beat count as an argument to timeout
routine (casted to (void *)) avoiding static counter, but
doing timeout_set() every timeout_add() sounds kinda uncool.
well, pondering in the struct timeout guts would be even more ugly.


Revision tags: SMP_BASE
# 1.8 09-Feb-2000 mickey

branches: 1.8.2;
thinking it seems reduces heartbeat, boy


# 1.7 09-Feb-2000 mickey

heartbeat -- yeah we have a patch for that


Revision tags: OPENBSD_2_6_BASE kame_19991208
# 1.6 07-Sep-1999 mickey

make inittodr() whine some sane things


# 1.5 14-Aug-1999 mickey

clock_intr()


# 1.4 24-Jun-1999 mickey

manualy assign structures


# 1.3 12-Jun-1999 mickey

microtime() is moving to locore.S


Revision tags: OPENBSD_2_5_BASE
# 1.2 07-Feb-1999 mickey

missign extern cpu_hzticks


# 1.1 29-Dec-1998 mickey

no microtime() yet