History log of /openbsd-current/sys/arch/sh/sh/clock.c
Revision (<<< Hide revision tags) (Show revision tags >>>) Date Author Comments
# 1.17 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.16 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.15 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@.


# 1.14 10-Apr-2023 jsg

spelling


Revision tags: OPENBSD_7_3_BASE
# 1.13 12-Mar-2023 cheloha

sh, landisk: set HZ=64 again

The addition of HZ to sys/kernel.h in v1.26 overrides the default
definition of HZ in sh/clock.c, changing landisk from HZ=64 to HZ=100.

Explicitly set HZ=64 in the GENERIC and RAMDISK config(8) files to can
change it from 100 back to 64.

Not sure if this is the best thing, but it does fix the problem.

Problem confirmed by, and fix tested by, miod@.

ok miod@


# 1.12 06-Dec-2022 cheloha

sh, landisk: switch to clockintr

Patch review and testing by miod@.

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

ok mlarkin@, probably ok miod@


Revision tags: OPENBSD_6_9_BASE OPENBSD_7_0_BASE OPENBSD_7_1_BASE OPENBSD_7_2_BASE
# 1.11 20-Oct-2020 cheloha

alpha, loongson, sh, sparc64: recompute tick, tick_nsec when hz(9) is reset

Normally we set hz(9) at compile-time in sys/conf/param.c to the value
of HZ. HZ is one of the fundamental compilation options(4). However,
sometimes we need to reset hz(9) at runtime.

Whenever we reset hz(9) we need to recompute tick and tick_nsec.
Otherwise a variety of "time stuff" in the kernel will not work
correctly. For example, most timeouts will expire "too slow" or "too
fast". There are a bunch of other places we use tick and tick_nsec
that will exhibit similar problems.

Test-compiled by deraadt@.


Revision tags: OPENBSD_6_8_BASE
# 1.10 11-May-2020 kettenis

Use the same inittodr()/resettodr() implementation as on
amd64/arm64/armv7/hppa/i386/macppc/mips64/sparc64 and move it to the end
of sh_machdep.c. Wrap the existing sh_clock.rtc hooks into something
that can be used as a todr_handle.

ok mpi@


Revision tags: 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 OPENBSD_6_7_BASE
# 1.9 05-Mar-2016 tobiasu

Sync no-argument function declaration and definition by adding (void).
Covers all of landisk/sh, per naddy's suggestion.

ok on previous diff deraadt@ naddy@


# 1.8 26-Feb-2016 mmcc

Make alpha and sh 2038-safe. Now that we have 64-bit time_t, we don't
need to ignore the hardware clock when it reports a year > 2037. Irony
noted.

both ok millert, alpha ok deraadt


Revision tags: OPENBSD_5_3_BASE OPENBSD_5_4_BASE OPENBSD_5_5_BASE OPENBSD_5_6_BASE OPENBSD_5_7_BASE OPENBSD_5_8_BASE OPENBSD_5_9_BASE
# 1.7 08-Sep-2012 miod

Switch landisk to timecounters. Adapted from NetBSD.


Revision tags: OPENBSD_4_4_BASE OPENBSD_4_5_BASE OPENBSD_4_6_BASE OPENBSD_4_7_BASE OPENBSD_4_8_BASE OPENBSD_4_9_BASE OPENBSD_5_0_BASE OPENBSD_5_1_BASE OPENBSD_5_2_BASE
# 1.6 26-Jun-2008 ray

First pass at removing clauses 3 and 4 from NetBSD licenses.

Not sure what's more surprising: how long it took for NetBSD to
catch up to the rest of the BSDs (including UCB), or the amount of
code that NetBSD has claimed for itself without attributing to the
actual authors.

OK deraadt@


Revision tags: OPENBSD_4_3_BASE
# 1.5 02-Sep-2007 hshoexer

Fix typos in comments: soruce -> source


Revision tags: OPENBSD_4_2_BASE
# 1.4 21-Jun-2007 miod

Fix microtime to not lose clocik ticks, gives us among other things, real
ping times on slow links; from mickey


Revision tags: OPENBSD_4_1_BASE
# 1.3 04-Nov-2006 mickey

make compile w/ debug


# 1.2 07-Oct-2006 miod

More bits in progress, adapted from NetBSD.


# 1.1 06-Oct-2006 miod

branches: 1.1.1;
Initial revision


# 1.16 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.15 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@.


# 1.14 10-Apr-2023 jsg

spelling


Revision tags: OPENBSD_7_3_BASE
# 1.13 12-Mar-2023 cheloha

sh, landisk: set HZ=64 again

The addition of HZ to sys/kernel.h in v1.26 overrides the default
definition of HZ in sh/clock.c, changing landisk from HZ=64 to HZ=100.

Explicitly set HZ=64 in the GENERIC and RAMDISK config(8) files to can
change it from 100 back to 64.

Not sure if this is the best thing, but it does fix the problem.

Problem confirmed by, and fix tested by, miod@.

ok miod@


# 1.12 06-Dec-2022 cheloha

sh, landisk: switch to clockintr

Patch review and testing by miod@.

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

ok mlarkin@, probably ok miod@


Revision tags: OPENBSD_6_9_BASE OPENBSD_7_0_BASE OPENBSD_7_1_BASE OPENBSD_7_2_BASE
# 1.11 20-Oct-2020 cheloha

alpha, loongson, sh, sparc64: recompute tick, tick_nsec when hz(9) is reset

Normally we set hz(9) at compile-time in sys/conf/param.c to the value
of HZ. HZ is one of the fundamental compilation options(4). However,
sometimes we need to reset hz(9) at runtime.

Whenever we reset hz(9) we need to recompute tick and tick_nsec.
Otherwise a variety of "time stuff" in the kernel will not work
correctly. For example, most timeouts will expire "too slow" or "too
fast". There are a bunch of other places we use tick and tick_nsec
that will exhibit similar problems.

Test-compiled by deraadt@.


Revision tags: OPENBSD_6_8_BASE
# 1.10 11-May-2020 kettenis

Use the same inittodr()/resettodr() implementation as on
amd64/arm64/armv7/hppa/i386/macppc/mips64/sparc64 and move it to the end
of sh_machdep.c. Wrap the existing sh_clock.rtc hooks into something
that can be used as a todr_handle.

ok mpi@


Revision tags: 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 OPENBSD_6_7_BASE
# 1.9 05-Mar-2016 tobiasu

Sync no-argument function declaration and definition by adding (void).
Covers all of landisk/sh, per naddy's suggestion.

ok on previous diff deraadt@ naddy@


# 1.8 26-Feb-2016 mmcc

Make alpha and sh 2038-safe. Now that we have 64-bit time_t, we don't
need to ignore the hardware clock when it reports a year > 2037. Irony
noted.

both ok millert, alpha ok deraadt


Revision tags: OPENBSD_5_3_BASE OPENBSD_5_4_BASE OPENBSD_5_5_BASE OPENBSD_5_6_BASE OPENBSD_5_7_BASE OPENBSD_5_8_BASE OPENBSD_5_9_BASE
# 1.7 08-Sep-2012 miod

Switch landisk to timecounters. Adapted from NetBSD.


Revision tags: OPENBSD_4_4_BASE OPENBSD_4_5_BASE OPENBSD_4_6_BASE OPENBSD_4_7_BASE OPENBSD_4_8_BASE OPENBSD_4_9_BASE OPENBSD_5_0_BASE OPENBSD_5_1_BASE OPENBSD_5_2_BASE
# 1.6 26-Jun-2008 ray

First pass at removing clauses 3 and 4 from NetBSD licenses.

Not sure what's more surprising: how long it took for NetBSD to
catch up to the rest of the BSDs (including UCB), or the amount of
code that NetBSD has claimed for itself without attributing to the
actual authors.

OK deraadt@


Revision tags: OPENBSD_4_3_BASE
# 1.5 02-Sep-2007 hshoexer

Fix typos in comments: soruce -> source


Revision tags: OPENBSD_4_2_BASE
# 1.4 21-Jun-2007 miod

Fix microtime to not lose clocik ticks, gives us among other things, real
ping times on slow links; from mickey


Revision tags: OPENBSD_4_1_BASE
# 1.3 04-Nov-2006 mickey

make compile w/ debug


# 1.2 07-Oct-2006 miod

More bits in progress, adapted from NetBSD.


# 1.1 06-Oct-2006 miod

branches: 1.1.1;
Initial revision


# 1.15 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@.


# 1.14 10-Apr-2023 jsg

spelling


Revision tags: OPENBSD_7_3_BASE
# 1.13 12-Mar-2023 cheloha

sh, landisk: set HZ=64 again

The addition of HZ to sys/kernel.h in v1.26 overrides the default
definition of HZ in sh/clock.c, changing landisk from HZ=64 to HZ=100.

Explicitly set HZ=64 in the GENERIC and RAMDISK config(8) files to can
change it from 100 back to 64.

Not sure if this is the best thing, but it does fix the problem.

Problem confirmed by, and fix tested by, miod@.

ok miod@


# 1.12 06-Dec-2022 cheloha

sh, landisk: switch to clockintr

Patch review and testing by miod@.

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

ok mlarkin@, probably ok miod@


Revision tags: OPENBSD_6_9_BASE OPENBSD_7_0_BASE OPENBSD_7_1_BASE OPENBSD_7_2_BASE
# 1.11 20-Oct-2020 cheloha

alpha, loongson, sh, sparc64: recompute tick, tick_nsec when hz(9) is reset

Normally we set hz(9) at compile-time in sys/conf/param.c to the value
of HZ. HZ is one of the fundamental compilation options(4). However,
sometimes we need to reset hz(9) at runtime.

Whenever we reset hz(9) we need to recompute tick and tick_nsec.
Otherwise a variety of "time stuff" in the kernel will not work
correctly. For example, most timeouts will expire "too slow" or "too
fast". There are a bunch of other places we use tick and tick_nsec
that will exhibit similar problems.

Test-compiled by deraadt@.


Revision tags: OPENBSD_6_8_BASE
# 1.10 11-May-2020 kettenis

Use the same inittodr()/resettodr() implementation as on
amd64/arm64/armv7/hppa/i386/macppc/mips64/sparc64 and move it to the end
of sh_machdep.c. Wrap the existing sh_clock.rtc hooks into something
that can be used as a todr_handle.

ok mpi@


Revision tags: 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 OPENBSD_6_7_BASE
# 1.9 05-Mar-2016 tobiasu

Sync no-argument function declaration and definition by adding (void).
Covers all of landisk/sh, per naddy's suggestion.

ok on previous diff deraadt@ naddy@


# 1.8 26-Feb-2016 mmcc

Make alpha and sh 2038-safe. Now that we have 64-bit time_t, we don't
need to ignore the hardware clock when it reports a year > 2037. Irony
noted.

both ok millert, alpha ok deraadt


Revision tags: OPENBSD_5_3_BASE OPENBSD_5_4_BASE OPENBSD_5_5_BASE OPENBSD_5_6_BASE OPENBSD_5_7_BASE OPENBSD_5_8_BASE OPENBSD_5_9_BASE
# 1.7 08-Sep-2012 miod

Switch landisk to timecounters. Adapted from NetBSD.


Revision tags: OPENBSD_4_4_BASE OPENBSD_4_5_BASE OPENBSD_4_6_BASE OPENBSD_4_7_BASE OPENBSD_4_8_BASE OPENBSD_4_9_BASE OPENBSD_5_0_BASE OPENBSD_5_1_BASE OPENBSD_5_2_BASE
# 1.6 26-Jun-2008 ray

First pass at removing clauses 3 and 4 from NetBSD licenses.

Not sure what's more surprising: how long it took for NetBSD to
catch up to the rest of the BSDs (including UCB), or the amount of
code that NetBSD has claimed for itself without attributing to the
actual authors.

OK deraadt@


Revision tags: OPENBSD_4_3_BASE
# 1.5 02-Sep-2007 hshoexer

Fix typos in comments: soruce -> source


Revision tags: OPENBSD_4_2_BASE
# 1.4 21-Jun-2007 miod

Fix microtime to not lose clocik ticks, gives us among other things, real
ping times on slow links; from mickey


Revision tags: OPENBSD_4_1_BASE
# 1.3 04-Nov-2006 mickey

make compile w/ debug


# 1.2 07-Oct-2006 miod

More bits in progress, adapted from NetBSD.


# 1.1 06-Oct-2006 miod

branches: 1.1.1;
Initial revision


# 1.14 10-Apr-2023 jsg

spelling


Revision tags: OPENBSD_7_3_BASE
# 1.13 12-Mar-2023 cheloha

sh, landisk: set HZ=64 again

The addition of HZ to sys/kernel.h in v1.26 overrides the default
definition of HZ in sh/clock.c, changing landisk from HZ=64 to HZ=100.

Explicitly set HZ=64 in the GENERIC and RAMDISK config(8) files to can
change it from 100 back to 64.

Not sure if this is the best thing, but it does fix the problem.

Problem confirmed by, and fix tested by, miod@.

ok miod@


# 1.12 06-Dec-2022 cheloha

sh, landisk: switch to clockintr

Patch review and testing by miod@.

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

ok mlarkin@, probably ok miod@


Revision tags: OPENBSD_6_9_BASE OPENBSD_7_0_BASE OPENBSD_7_1_BASE OPENBSD_7_2_BASE
# 1.11 20-Oct-2020 cheloha

alpha, loongson, sh, sparc64: recompute tick, tick_nsec when hz(9) is reset

Normally we set hz(9) at compile-time in sys/conf/param.c to the value
of HZ. HZ is one of the fundamental compilation options(4). However,
sometimes we need to reset hz(9) at runtime.

Whenever we reset hz(9) we need to recompute tick and tick_nsec.
Otherwise a variety of "time stuff" in the kernel will not work
correctly. For example, most timeouts will expire "too slow" or "too
fast". There are a bunch of other places we use tick and tick_nsec
that will exhibit similar problems.

Test-compiled by deraadt@.


Revision tags: OPENBSD_6_8_BASE
# 1.10 11-May-2020 kettenis

Use the same inittodr()/resettodr() implementation as on
amd64/arm64/armv7/hppa/i386/macppc/mips64/sparc64 and move it to the end
of sh_machdep.c. Wrap the existing sh_clock.rtc hooks into something
that can be used as a todr_handle.

ok mpi@


Revision tags: 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 OPENBSD_6_7_BASE
# 1.9 05-Mar-2016 tobiasu

Sync no-argument function declaration and definition by adding (void).
Covers all of landisk/sh, per naddy's suggestion.

ok on previous diff deraadt@ naddy@


# 1.8 26-Feb-2016 mmcc

Make alpha and sh 2038-safe. Now that we have 64-bit time_t, we don't
need to ignore the hardware clock when it reports a year > 2037. Irony
noted.

both ok millert, alpha ok deraadt


Revision tags: OPENBSD_5_3_BASE OPENBSD_5_4_BASE OPENBSD_5_5_BASE OPENBSD_5_6_BASE OPENBSD_5_7_BASE OPENBSD_5_8_BASE OPENBSD_5_9_BASE
# 1.7 08-Sep-2012 miod

Switch landisk to timecounters. Adapted from NetBSD.


Revision tags: OPENBSD_4_4_BASE OPENBSD_4_5_BASE OPENBSD_4_6_BASE OPENBSD_4_7_BASE OPENBSD_4_8_BASE OPENBSD_4_9_BASE OPENBSD_5_0_BASE OPENBSD_5_1_BASE OPENBSD_5_2_BASE
# 1.6 26-Jun-2008 ray

First pass at removing clauses 3 and 4 from NetBSD licenses.

Not sure what's more surprising: how long it took for NetBSD to
catch up to the rest of the BSDs (including UCB), or the amount of
code that NetBSD has claimed for itself without attributing to the
actual authors.

OK deraadt@


Revision tags: OPENBSD_4_3_BASE
# 1.5 02-Sep-2007 hshoexer

Fix typos in comments: soruce -> source


Revision tags: OPENBSD_4_2_BASE
# 1.4 21-Jun-2007 miod

Fix microtime to not lose clocik ticks, gives us among other things, real
ping times on slow links; from mickey


Revision tags: OPENBSD_4_1_BASE
# 1.3 04-Nov-2006 mickey

make compile w/ debug


# 1.2 07-Oct-2006 miod

More bits in progress, adapted from NetBSD.


# 1.1 06-Oct-2006 miod

branches: 1.1.1;
Initial revision


# 1.13 12-Mar-2023 cheloha

sh, landisk: set HZ=64 again

The addition of HZ to sys/kernel.h in v1.26 overrides the default
definition of HZ in sh/clock.c, changing landisk from HZ=64 to HZ=100.

Explicitly set HZ=64 in the GENERIC and RAMDISK config(8) files to can
change it from 100 back to 64.

Not sure if this is the best thing, but it does fix the problem.

Problem confirmed by, and fix tested by, miod@.

ok miod@


# 1.12 06-Dec-2022 cheloha

sh, landisk: switch to clockintr

Patch review and testing by miod@.

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

ok mlarkin@, probably ok miod@


Revision tags: OPENBSD_6_9_BASE OPENBSD_7_0_BASE OPENBSD_7_1_BASE OPENBSD_7_2_BASE
# 1.11 20-Oct-2020 cheloha

alpha, loongson, sh, sparc64: recompute tick, tick_nsec when hz(9) is reset

Normally we set hz(9) at compile-time in sys/conf/param.c to the value
of HZ. HZ is one of the fundamental compilation options(4). However,
sometimes we need to reset hz(9) at runtime.

Whenever we reset hz(9) we need to recompute tick and tick_nsec.
Otherwise a variety of "time stuff" in the kernel will not work
correctly. For example, most timeouts will expire "too slow" or "too
fast". There are a bunch of other places we use tick and tick_nsec
that will exhibit similar problems.

Test-compiled by deraadt@.


Revision tags: OPENBSD_6_8_BASE
# 1.10 11-May-2020 kettenis

Use the same inittodr()/resettodr() implementation as on
amd64/arm64/armv7/hppa/i386/macppc/mips64/sparc64 and move it to the end
of sh_machdep.c. Wrap the existing sh_clock.rtc hooks into something
that can be used as a todr_handle.

ok mpi@


Revision tags: 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 OPENBSD_6_7_BASE
# 1.9 05-Mar-2016 tobiasu

Sync no-argument function declaration and definition by adding (void).
Covers all of landisk/sh, per naddy's suggestion.

ok on previous diff deraadt@ naddy@


# 1.8 26-Feb-2016 mmcc

Make alpha and sh 2038-safe. Now that we have 64-bit time_t, we don't
need to ignore the hardware clock when it reports a year > 2037. Irony
noted.

both ok millert, alpha ok deraadt


Revision tags: OPENBSD_5_3_BASE OPENBSD_5_4_BASE OPENBSD_5_5_BASE OPENBSD_5_6_BASE OPENBSD_5_7_BASE OPENBSD_5_8_BASE OPENBSD_5_9_BASE
# 1.7 08-Sep-2012 miod

Switch landisk to timecounters. Adapted from NetBSD.


Revision tags: OPENBSD_4_4_BASE OPENBSD_4_5_BASE OPENBSD_4_6_BASE OPENBSD_4_7_BASE OPENBSD_4_8_BASE OPENBSD_4_9_BASE OPENBSD_5_0_BASE OPENBSD_5_1_BASE OPENBSD_5_2_BASE
# 1.6 26-Jun-2008 ray

First pass at removing clauses 3 and 4 from NetBSD licenses.

Not sure what's more surprising: how long it took for NetBSD to
catch up to the rest of the BSDs (including UCB), or the amount of
code that NetBSD has claimed for itself without attributing to the
actual authors.

OK deraadt@


Revision tags: OPENBSD_4_3_BASE
# 1.5 02-Sep-2007 hshoexer

Fix typos in comments: soruce -> source


Revision tags: OPENBSD_4_2_BASE
# 1.4 21-Jun-2007 miod

Fix microtime to not lose clocik ticks, gives us among other things, real
ping times on slow links; from mickey


Revision tags: OPENBSD_4_1_BASE
# 1.3 04-Nov-2006 mickey

make compile w/ debug


# 1.2 07-Oct-2006 miod

More bits in progress, adapted from NetBSD.


# 1.1 06-Oct-2006 miod

branches: 1.1.1;
Initial revision


# 1.12 06-Dec-2022 cheloha

sh, landisk: switch to clockintr

Patch review and testing by miod@.

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

ok mlarkin@, probably ok miod@


Revision tags: OPENBSD_6_9_BASE OPENBSD_7_0_BASE OPENBSD_7_1_BASE OPENBSD_7_2_BASE
# 1.11 20-Oct-2020 cheloha

alpha, loongson, sh, sparc64: recompute tick, tick_nsec when hz(9) is reset

Normally we set hz(9) at compile-time in sys/conf/param.c to the value
of HZ. HZ is one of the fundamental compilation options(4). However,
sometimes we need to reset hz(9) at runtime.

Whenever we reset hz(9) we need to recompute tick and tick_nsec.
Otherwise a variety of "time stuff" in the kernel will not work
correctly. For example, most timeouts will expire "too slow" or "too
fast". There are a bunch of other places we use tick and tick_nsec
that will exhibit similar problems.

Test-compiled by deraadt@.


Revision tags: OPENBSD_6_8_BASE
# 1.10 11-May-2020 kettenis

Use the same inittodr()/resettodr() implementation as on
amd64/arm64/armv7/hppa/i386/macppc/mips64/sparc64 and move it to the end
of sh_machdep.c. Wrap the existing sh_clock.rtc hooks into something
that can be used as a todr_handle.

ok mpi@


Revision tags: 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 OPENBSD_6_7_BASE
# 1.9 05-Mar-2016 tobiasu

Sync no-argument function declaration and definition by adding (void).
Covers all of landisk/sh, per naddy's suggestion.

ok on previous diff deraadt@ naddy@


# 1.8 26-Feb-2016 mmcc

Make alpha and sh 2038-safe. Now that we have 64-bit time_t, we don't
need to ignore the hardware clock when it reports a year > 2037. Irony
noted.

both ok millert, alpha ok deraadt


Revision tags: OPENBSD_5_3_BASE OPENBSD_5_4_BASE OPENBSD_5_5_BASE OPENBSD_5_6_BASE OPENBSD_5_7_BASE OPENBSD_5_8_BASE OPENBSD_5_9_BASE
# 1.7 08-Sep-2012 miod

Switch landisk to timecounters. Adapted from NetBSD.


Revision tags: OPENBSD_4_4_BASE OPENBSD_4_5_BASE OPENBSD_4_6_BASE OPENBSD_4_7_BASE OPENBSD_4_8_BASE OPENBSD_4_9_BASE OPENBSD_5_0_BASE OPENBSD_5_1_BASE OPENBSD_5_2_BASE
# 1.6 26-Jun-2008 ray

First pass at removing clauses 3 and 4 from NetBSD licenses.

Not sure what's more surprising: how long it took for NetBSD to
catch up to the rest of the BSDs (including UCB), or the amount of
code that NetBSD has claimed for itself without attributing to the
actual authors.

OK deraadt@


Revision tags: OPENBSD_4_3_BASE
# 1.5 02-Sep-2007 hshoexer

Fix typos in comments: soruce -> source


Revision tags: OPENBSD_4_2_BASE
# 1.4 21-Jun-2007 miod

Fix microtime to not lose clocik ticks, gives us among other things, real
ping times on slow links; from mickey


Revision tags: OPENBSD_4_1_BASE
# 1.3 04-Nov-2006 mickey

make compile w/ debug


# 1.2 07-Oct-2006 miod

More bits in progress, adapted from NetBSD.


# 1.1 06-Oct-2006 miod

branches: 1.1.1;
Initial revision


# 1.11 20-Oct-2020 cheloha

alpha, loongson, sh, sparc64: recompute tick, tick_nsec when hz(9) is reset

Normally we set hz(9) at compile-time in sys/conf/param.c to the value
of HZ. HZ is one of the fundamental compilation options(4). However,
sometimes we need to reset hz(9) at runtime.

Whenever we reset hz(9) we need to recompute tick and tick_nsec.
Otherwise a variety of "time stuff" in the kernel will not work
correctly. For example, most timeouts will expire "too slow" or "too
fast". There are a bunch of other places we use tick and tick_nsec
that will exhibit similar problems.

Test-compiled by deraadt@.


Revision tags: OPENBSD_6_8_BASE
# 1.10 11-May-2020 kettenis

Use the same inittodr()/resettodr() implementation as on
amd64/arm64/armv7/hppa/i386/macppc/mips64/sparc64 and move it to the end
of sh_machdep.c. Wrap the existing sh_clock.rtc hooks into something
that can be used as a todr_handle.

ok mpi@


Revision tags: 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 OPENBSD_6_7_BASE
# 1.9 05-Mar-2016 tobiasu

Sync no-argument function declaration and definition by adding (void).
Covers all of landisk/sh, per naddy's suggestion.

ok on previous diff deraadt@ naddy@


# 1.8 26-Feb-2016 mmcc

Make alpha and sh 2038-safe. Now that we have 64-bit time_t, we don't
need to ignore the hardware clock when it reports a year > 2037. Irony
noted.

both ok millert, alpha ok deraadt


Revision tags: OPENBSD_5_3_BASE OPENBSD_5_4_BASE OPENBSD_5_5_BASE OPENBSD_5_6_BASE OPENBSD_5_7_BASE OPENBSD_5_8_BASE OPENBSD_5_9_BASE
# 1.7 08-Sep-2012 miod

Switch landisk to timecounters. Adapted from NetBSD.


Revision tags: OPENBSD_4_4_BASE OPENBSD_4_5_BASE OPENBSD_4_6_BASE OPENBSD_4_7_BASE OPENBSD_4_8_BASE OPENBSD_4_9_BASE OPENBSD_5_0_BASE OPENBSD_5_1_BASE OPENBSD_5_2_BASE
# 1.6 26-Jun-2008 ray

First pass at removing clauses 3 and 4 from NetBSD licenses.

Not sure what's more surprising: how long it took for NetBSD to
catch up to the rest of the BSDs (including UCB), or the amount of
code that NetBSD has claimed for itself without attributing to the
actual authors.

OK deraadt@


Revision tags: OPENBSD_4_3_BASE
# 1.5 02-Sep-2007 hshoexer

Fix typos in comments: soruce -> source


Revision tags: OPENBSD_4_2_BASE
# 1.4 21-Jun-2007 miod

Fix microtime to not lose clocik ticks, gives us among other things, real
ping times on slow links; from mickey


Revision tags: OPENBSD_4_1_BASE
# 1.3 04-Nov-2006 mickey

make compile w/ debug


# 1.2 07-Oct-2006 miod

More bits in progress, adapted from NetBSD.


# 1.1 06-Oct-2006 miod

branches: 1.1.1;
Initial revision


# 1.10 11-May-2020 kettenis

Use the same inittodr()/resettodr() implementation as on
amd64/arm64/armv7/hppa/i386/macppc/mips64/sparc64 and move it to the end
of sh_machdep.c. Wrap the existing sh_clock.rtc hooks into something
that can be used as a todr_handle.

ok mpi@


Revision tags: 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 OPENBSD_6_7_BASE
# 1.9 05-Mar-2016 tobiasu

Sync no-argument function declaration and definition by adding (void).
Covers all of landisk/sh, per naddy's suggestion.

ok on previous diff deraadt@ naddy@


# 1.8 26-Feb-2016 mmcc

Make alpha and sh 2038-safe. Now that we have 64-bit time_t, we don't
need to ignore the hardware clock when it reports a year > 2037. Irony
noted.

both ok millert, alpha ok deraadt


Revision tags: OPENBSD_5_3_BASE OPENBSD_5_4_BASE OPENBSD_5_5_BASE OPENBSD_5_6_BASE OPENBSD_5_7_BASE OPENBSD_5_8_BASE OPENBSD_5_9_BASE
# 1.7 08-Sep-2012 miod

Switch landisk to timecounters. Adapted from NetBSD.


Revision tags: OPENBSD_4_4_BASE OPENBSD_4_5_BASE OPENBSD_4_6_BASE OPENBSD_4_7_BASE OPENBSD_4_8_BASE OPENBSD_4_9_BASE OPENBSD_5_0_BASE OPENBSD_5_1_BASE OPENBSD_5_2_BASE
# 1.6 26-Jun-2008 ray

First pass at removing clauses 3 and 4 from NetBSD licenses.

Not sure what's more surprising: how long it took for NetBSD to
catch up to the rest of the BSDs (including UCB), or the amount of
code that NetBSD has claimed for itself without attributing to the
actual authors.

OK deraadt@


Revision tags: OPENBSD_4_3_BASE
# 1.5 02-Sep-2007 hshoexer

Fix typos in comments: soruce -> source


Revision tags: OPENBSD_4_2_BASE
# 1.4 21-Jun-2007 miod

Fix microtime to not lose clocik ticks, gives us among other things, real
ping times on slow links; from mickey


Revision tags: OPENBSD_4_1_BASE
# 1.3 04-Nov-2006 mickey

make compile w/ debug


# 1.2 07-Oct-2006 miod

More bits in progress, adapted from NetBSD.


# 1.1 06-Oct-2006 miod

branches: 1.1.1;
Initial revision


Revision tags: OPENBSD_6_0_BASE OPENBSD_6_1_BASE OPENBSD_6_2_BASE
# 1.9 05-Mar-2016 tobiasu

Sync no-argument function declaration and definition by adding (void).
Covers all of landisk/sh, per naddy's suggestion.

ok on previous diff deraadt@ naddy@


# 1.8 26-Feb-2016 mmcc

Make alpha and sh 2038-safe. Now that we have 64-bit time_t, we don't
need to ignore the hardware clock when it reports a year > 2037. Irony
noted.

both ok millert, alpha ok deraadt


Revision tags: OPENBSD_5_3_BASE OPENBSD_5_4_BASE OPENBSD_5_5_BASE OPENBSD_5_6_BASE OPENBSD_5_7_BASE OPENBSD_5_8_BASE OPENBSD_5_9_BASE
# 1.7 08-Sep-2012 miod

Switch landisk to timecounters. Adapted from NetBSD.


Revision tags: OPENBSD_4_4_BASE OPENBSD_4_5_BASE OPENBSD_4_6_BASE OPENBSD_4_7_BASE OPENBSD_4_8_BASE OPENBSD_4_9_BASE OPENBSD_5_0_BASE OPENBSD_5_1_BASE OPENBSD_5_2_BASE
# 1.6 26-Jun-2008 ray

First pass at removing clauses 3 and 4 from NetBSD licenses.

Not sure what's more surprising: how long it took for NetBSD to
catch up to the rest of the BSDs (including UCB), or the amount of
code that NetBSD has claimed for itself without attributing to the
actual authors.

OK deraadt@


Revision tags: OPENBSD_4_3_BASE
# 1.5 02-Sep-2007 hshoexer

Fix typos in comments: soruce -> source


Revision tags: OPENBSD_4_2_BASE
# 1.4 21-Jun-2007 miod

Fix microtime to not lose clocik ticks, gives us among other things, real
ping times on slow links; from mickey


Revision tags: OPENBSD_4_1_BASE
# 1.3 04-Nov-2006 mickey

make compile w/ debug


# 1.2 07-Oct-2006 miod

More bits in progress, adapted from NetBSD.


# 1.1 06-Oct-2006 miod

branches: 1.1.1;
Initial revision