History log of /openbsd-current/sys/sys/kernel.h
Revision (<<< Hide revision tags) (Show revision tags >>>) Date Author Comments
# 1.26 03-Mar-2023 cheloha

initclocks: don't reinitialize ticks, jiffies at runtime

Various drivers use ticks/jiffies before initclocks(). It isn't
generally safe to reinitialize them at runtime. Hoist the conditional
definition of HZ from param.c into sys/kernel.h so we can see it from
kern_clock.c and statically initialize ticks/jiffies to the desired
offset.

With this change, timeouts scheduled before initclocks() do not all
fire immediately during the first softclock().

With input from kettenis@.

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


Revision tags: OPENBSD_6_9_BASE OPENBSD_7_0_BASE OPENBSD_7_1_BASE OPENBSD_7_2_BASE
# 1.25 13-Jan-2021 cheloha

kernel, sysctl(8): remove dead variable: tickadj

The global "tickadj" variable is a remnant of the old NTP adjustment
code we used in the kernel before the current timecounter subsystem
was imported from FreeBSD circa 2004 or 2005.

Fifteen years hence it is completely vestigial and we can remove it.
We probably should have removed it long ago but I guess it slipped
through the cracks. FreeBSD removed it in 2002:

https://cgit.freebsd.org/src/commit/?id=e1d970f1811e5e1e9c912c032acdcec6521b2a6d

NetBSD and DragonflyBSD can probably remove it, too.

We export tickadj via the kern.clockrate sysctl(2), so update sysctl.2
and sysctl(8) accordingly. Hypothetically this change could break
someone's sysctl(8) parsing script. I don't think that's very likely.

ok mvs@


# 1.24 15-Oct-2020 cheloha

sys/kernel.h: remove dead externs: tickfix, tixfixinterval, tickdelta, ...

miod@ removed several time-related globals from the kernel with the
commit "unifdef -d __HAVE_TIMECOUNTER" (see sys/kern/kern_clock.c v1.76).
He neglected to remove their externs from sys/kernel.h, though.

Remove the externs.

With help from jsg@.

ok jsg@


Revision tags: OPENBSD_6_8_BASE
# 1.23 20-May-2020 cheloha

kernel.h: remove global declaration for naptime

naptime is now a member of the timehands, th_naptime.


Revision tags: OPENBSD_6_6_BASE OPENBSD_6_7_BASE
# 1.22 07-Sep-2019 cheloha

Remove tz, the kernel timezone.

After removing timezone support from date(1), msdosfs, gettimeofday(2),
settimeofday(2), boot_config(8), config(8), and introducing kern.utc_offset
sysctl(2) to replace the DST/TIMEZONE options(4) to support running the RTC
at an offset from UTC, the kernel timezone is unused and we can delete it.

With this commit the kernel timezone now appears to be extinct in
upstream BSD, though it does survive in XNU:

https://github.com/opensource-apple/xnu/blob/0a798f6738bc1db01281fc08ae024145e84df927/bsd/conf/param.c#L83

Prompted by tedu@ some time back, and inspired by NetBSD and FreeBSD's
work in this area.

ok deraadt@


# 1.21 21-Aug-2019 cheloha

sysctl(2): add kern.utc_offset: successor to the DST/TIMEZONE options(4)

The DST and TIMEZONE options(4) are incompatible with KARL, so we need
some other way to compensate for an RTC running with a known offset.

Enter kern.utc_offset, an offset in minutes East of UTC. TIMEZONE has
always been minutes West, but this is inconsistent with how everyone
else talks about timezones, hence the flip.

TIMEZONE has the advantage of being compiled into the binary. Our new
sysctl(2) has no such luck, so it needs to be set as early as possible
in boot, from sysctl.conf(5), so we can correct the kernel clock from
the RTC's local time to UTC before daemons like ntpd(8) and cron(8)
start. To encourage this, kern.utc_offset is made immutable after the
securelevel(7) is raised to 1.

Prompted by yasuoka@. Discussed with deraadt@, kettenis@, yasuoka@.
Additional testing by yasuoka@.

ok deraadt@, yasuoka@


# 1.20 02-Aug-2019 cheloha

per-process itimers: itimerval -> itimerspec

Loongson runs at 128hz. 128 doesn't divide evenly into a million,
but it does divide evenly into a billion. So if we do the per-process
itimer bookkeeping with itimerspec structs we can have error-free
virtual itimers on loongson just as we do on most other platforms.

This change doesn't fix the virtual itimer error alpha, as 1024 does not
divide evenly into a billion. But this doesn't make the situation any
worse, either.

ok deraadt@


Revision tags: OPENBSD_6_5_BASE
# 1.19 10-Mar-2019 cheloha

Move adjtimedelta from kern_time.c to kern_tc.c.

This will simplify upcoming MP-safety diffs for the timecounting layer.

adjtimedelta is now accessed nowhere outside of kern_tc.c, so we can
remove its extern declaration from kernel.h. Zeroing adjtimedelta
within timecounter_mtx before we jump the real-time clock is also a
bit safer than what we do now, as we are not racing a simultaneous
tc_windup() call from hardclock(), which itself can modify adjtimedelta
via ntp_update_second().

Discussed with visa@ and mpi@.

ok visa@


# 1.18 19-Jan-2019 cheloha

Move boottime into the timehands.

To protect the timehands we first need to protect the basis for all UTC
time in the kernel: the boottime.

Because the boottime can be changed at any time it needs to be versioned
along with the other members of the timehands to enable safe lockless reads
when using it for anything. So the global boottime timespec goes away and
the static boottimebin becomes a member of the timehands. Instead of reading
the global boottime you use one of two interfaces: binboottime(9) or
microboottime(9). nanoboottime(9) can trivially be added later, though there
are no consumers for it at the moment.

This introduces one small change in behavior. We used to advance the
reported boottime just before launching kernel threads from main().
This makes it look to userland like we "booted" moments before those
threads were launched. Because there is no longer a boottime global we
can no longer trivially do this from main(), so the boottime we report
to userspace via e.g. kern.boottime will now reflect whatever the time
was when we bootstrapped the timehands via inittodr(9). This is usually
no more than a minute before the kernel threads are launched from main().
The prior behavior can be restored by adding a new interface to the
timecounter layer in a future commit.

Based on FreeBSD r303387.

Discussed with mpi@ and visa@.

ok visa@


Revision tags: 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
# 1.17 20-Jul-2015 uebayasi

Move `ticks' declaration to sys/kernel.h.


Revision tags: OPENBSD_5_5_BASE OPENBSD_5_6_BASE OPENBSD_5_7_BASE
# 1.16 30-Jan-2014 kettenis

Simplyfy adjtime(2) by keeping track of the adjustment as a number of
microsecond in a 64-bit integer. Fixes the issue where ntpd loses sync
because the struct timeval currently used to hold the adjustment is not
properly normalized after the changes guenther@ made.

ok guenther@, millert@


# 1.15 06-Oct-2013 guenther

Add CLOCK_UPTIME, a clock which measures time-running-not-suspended, so
that mlarkin@ can fix programs that report rates-over-uptime.

ok kettenis@
manpage corrections jmc@ (which I've probably broken again)


Revision tags: OPENBSD_5_4_BASE
# 1.14 03-Jun-2013 guenther

Convert some internal APIs to use timespecs instead of timevals

ok matthew@ deraadt@


Revision tags: OPENBSD_5_3_BASE
# 1.13 05-Nov-2012 miod

unifdef -D __HAVE_TIMECOUNTER


Revision tags: OPENBSD_4_2_BASE OPENBSD_4_3_BASE 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.12 16-May-2007 art

The world of __HAVEs and __HAVE_NOTs is reducing. All architectures
have cpu_info now, so kill the option.

eyeballed by jsg@ and grange@


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
# 1.11 28-Jul-2004 tholo

This touches only MI code, and adds new time keeping code. The
code is all conditionalized on __HAVE_TIMECOUNTER, and not
enabled on any platforms.

adjtime(2) support exists, courtesy of nordin@, sysctl(2) support
and a concept of quality for each time source attached exists.

High quality time sources exists for PIIX4 ACPI timer as well as
some AMD power management chips. This will have to be redone
once we actually add ACPI support (at that time we need to use
the ACPI interfaces to get at these clocks).

ok art@ ken@ miod@ jmc@ and many more


# 1.10 13-Jun-2004 niklas

debranch SMP, have fun


Revision tags: SMP_SYNC_A SMP_SYNC_B
# 1.9 09-Jun-2004 art

Merge in a piece of the SMP branch into HEAD.

Introduce the cpu_info structure, p_cpu field in struct proc and global
scheduling context and various changed code to deal with this. At the
moment no architecture uses this stuff yet, but it will allow us slow and
controlled migration to the new APIs.

All new code is ifdef:ed out.

ok deraadt@ niklas@


Revision tags: OPENBSD_3_4_BASE OPENBSD_3_5_BASE
# 1.8 02-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


Revision tags: OPENBSD_2_7_BASE OPENBSD_2_8_BASE OPENBSD_2_9_BASE OPENBSD_3_0_BASE OPENBSD_3_1_BASE OPENBSD_3_2_BASE OPENBSD_3_3_BASE UBC_BASE UBC_SYNC_A UBC_SYNC_B
# 1.7 19-Apr-2000 art

Remove roundrobin_attempts.


# 1.6 03-Mar-2000 art

Keep track of the number of times we trigger a reschedule before the
context switch actually happens.


Revision tags: OPENBSD_2_0_BASE OPENBSD_2_1_BASE OPENBSD_2_2_BASE OPENBSD_2_3_BASE OPENBSD_2_4_BASE OPENBSD_2_5_BASE OPENBSD_2_6_BASE SMP_BASE kame_19991208
# 1.5 11-Aug-1996 niklas

branches: 1.5.16;
Move MD5 protos to a more sensible place


# 1.4 17-Apr-1996 mickey

Add prototypes for MD5 routines.


# 1.3 03-Mar-1996 niklas

From NetBSD: 960217 merge


# 1.2 30-Jan-1996 tholo

Add extern declarations of new globals used by kernel PLL clock


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision


# 1.25 13-Jan-2021 cheloha

kernel, sysctl(8): remove dead variable: tickadj

The global "tickadj" variable is a remnant of the old NTP adjustment
code we used in the kernel before the current timecounter subsystem
was imported from FreeBSD circa 2004 or 2005.

Fifteen years hence it is completely vestigial and we can remove it.
We probably should have removed it long ago but I guess it slipped
through the cracks. FreeBSD removed it in 2002:

https://cgit.freebsd.org/src/commit/?id=e1d970f1811e5e1e9c912c032acdcec6521b2a6d

NetBSD and DragonflyBSD can probably remove it, too.

We export tickadj via the kern.clockrate sysctl(2), so update sysctl.2
and sysctl(8) accordingly. Hypothetically this change could break
someone's sysctl(8) parsing script. I don't think that's very likely.

ok mvs@


# 1.24 15-Oct-2020 cheloha

sys/kernel.h: remove dead externs: tickfix, tixfixinterval, tickdelta, ...

miod@ removed several time-related globals from the kernel with the
commit "unifdef -d __HAVE_TIMECOUNTER" (see sys/kern/kern_clock.c v1.76).
He neglected to remove their externs from sys/kernel.h, though.

Remove the externs.

With help from jsg@.

ok jsg@


Revision tags: OPENBSD_6_8_BASE
# 1.23 20-May-2020 cheloha

kernel.h: remove global declaration for naptime

naptime is now a member of the timehands, th_naptime.


Revision tags: OPENBSD_6_6_BASE OPENBSD_6_7_BASE
# 1.22 07-Sep-2019 cheloha

Remove tz, the kernel timezone.

After removing timezone support from date(1), msdosfs, gettimeofday(2),
settimeofday(2), boot_config(8), config(8), and introducing kern.utc_offset
sysctl(2) to replace the DST/TIMEZONE options(4) to support running the RTC
at an offset from UTC, the kernel timezone is unused and we can delete it.

With this commit the kernel timezone now appears to be extinct in
upstream BSD, though it does survive in XNU:

https://github.com/opensource-apple/xnu/blob/0a798f6738bc1db01281fc08ae024145e84df927/bsd/conf/param.c#L83

Prompted by tedu@ some time back, and inspired by NetBSD and FreeBSD's
work in this area.

ok deraadt@


# 1.21 21-Aug-2019 cheloha

sysctl(2): add kern.utc_offset: successor to the DST/TIMEZONE options(4)

The DST and TIMEZONE options(4) are incompatible with KARL, so we need
some other way to compensate for an RTC running with a known offset.

Enter kern.utc_offset, an offset in minutes East of UTC. TIMEZONE has
always been minutes West, but this is inconsistent with how everyone
else talks about timezones, hence the flip.

TIMEZONE has the advantage of being compiled into the binary. Our new
sysctl(2) has no such luck, so it needs to be set as early as possible
in boot, from sysctl.conf(5), so we can correct the kernel clock from
the RTC's local time to UTC before daemons like ntpd(8) and cron(8)
start. To encourage this, kern.utc_offset is made immutable after the
securelevel(7) is raised to 1.

Prompted by yasuoka@. Discussed with deraadt@, kettenis@, yasuoka@.
Additional testing by yasuoka@.

ok deraadt@, yasuoka@


# 1.20 02-Aug-2019 cheloha

per-process itimers: itimerval -> itimerspec

Loongson runs at 128hz. 128 doesn't divide evenly into a million,
but it does divide evenly into a billion. So if we do the per-process
itimer bookkeeping with itimerspec structs we can have error-free
virtual itimers on loongson just as we do on most other platforms.

This change doesn't fix the virtual itimer error alpha, as 1024 does not
divide evenly into a billion. But this doesn't make the situation any
worse, either.

ok deraadt@


Revision tags: OPENBSD_6_5_BASE
# 1.19 10-Mar-2019 cheloha

Move adjtimedelta from kern_time.c to kern_tc.c.

This will simplify upcoming MP-safety diffs for the timecounting layer.

adjtimedelta is now accessed nowhere outside of kern_tc.c, so we can
remove its extern declaration from kernel.h. Zeroing adjtimedelta
within timecounter_mtx before we jump the real-time clock is also a
bit safer than what we do now, as we are not racing a simultaneous
tc_windup() call from hardclock(), which itself can modify adjtimedelta
via ntp_update_second().

Discussed with visa@ and mpi@.

ok visa@


# 1.18 19-Jan-2019 cheloha

Move boottime into the timehands.

To protect the timehands we first need to protect the basis for all UTC
time in the kernel: the boottime.

Because the boottime can be changed at any time it needs to be versioned
along with the other members of the timehands to enable safe lockless reads
when using it for anything. So the global boottime timespec goes away and
the static boottimebin becomes a member of the timehands. Instead of reading
the global boottime you use one of two interfaces: binboottime(9) or
microboottime(9). nanoboottime(9) can trivially be added later, though there
are no consumers for it at the moment.

This introduces one small change in behavior. We used to advance the
reported boottime just before launching kernel threads from main().
This makes it look to userland like we "booted" moments before those
threads were launched. Because there is no longer a boottime global we
can no longer trivially do this from main(), so the boottime we report
to userspace via e.g. kern.boottime will now reflect whatever the time
was when we bootstrapped the timehands via inittodr(9). This is usually
no more than a minute before the kernel threads are launched from main().
The prior behavior can be restored by adding a new interface to the
timecounter layer in a future commit.

Based on FreeBSD r303387.

Discussed with mpi@ and visa@.

ok visa@


Revision tags: 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
# 1.17 20-Jul-2015 uebayasi

Move `ticks' declaration to sys/kernel.h.


Revision tags: OPENBSD_5_5_BASE OPENBSD_5_6_BASE OPENBSD_5_7_BASE
# 1.16 30-Jan-2014 kettenis

Simplyfy adjtime(2) by keeping track of the adjustment as a number of
microsecond in a 64-bit integer. Fixes the issue where ntpd loses sync
because the struct timeval currently used to hold the adjustment is not
properly normalized after the changes guenther@ made.

ok guenther@, millert@


# 1.15 06-Oct-2013 guenther

Add CLOCK_UPTIME, a clock which measures time-running-not-suspended, so
that mlarkin@ can fix programs that report rates-over-uptime.

ok kettenis@
manpage corrections jmc@ (which I've probably broken again)


Revision tags: OPENBSD_5_4_BASE
# 1.14 03-Jun-2013 guenther

Convert some internal APIs to use timespecs instead of timevals

ok matthew@ deraadt@


Revision tags: OPENBSD_5_3_BASE
# 1.13 05-Nov-2012 miod

unifdef -D __HAVE_TIMECOUNTER


Revision tags: OPENBSD_4_2_BASE OPENBSD_4_3_BASE 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.12 16-May-2007 art

The world of __HAVEs and __HAVE_NOTs is reducing. All architectures
have cpu_info now, so kill the option.

eyeballed by jsg@ and grange@


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
# 1.11 28-Jul-2004 tholo

This touches only MI code, and adds new time keeping code. The
code is all conditionalized on __HAVE_TIMECOUNTER, and not
enabled on any platforms.

adjtime(2) support exists, courtesy of nordin@, sysctl(2) support
and a concept of quality for each time source attached exists.

High quality time sources exists for PIIX4 ACPI timer as well as
some AMD power management chips. This will have to be redone
once we actually add ACPI support (at that time we need to use
the ACPI interfaces to get at these clocks).

ok art@ ken@ miod@ jmc@ and many more


# 1.10 13-Jun-2004 niklas

debranch SMP, have fun


Revision tags: SMP_SYNC_A SMP_SYNC_B
# 1.9 09-Jun-2004 art

Merge in a piece of the SMP branch into HEAD.

Introduce the cpu_info structure, p_cpu field in struct proc and global
scheduling context and various changed code to deal with this. At the
moment no architecture uses this stuff yet, but it will allow us slow and
controlled migration to the new APIs.

All new code is ifdef:ed out.

ok deraadt@ niklas@


Revision tags: OPENBSD_3_4_BASE OPENBSD_3_5_BASE
# 1.8 02-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


Revision tags: OPENBSD_2_7_BASE OPENBSD_2_8_BASE OPENBSD_2_9_BASE OPENBSD_3_0_BASE OPENBSD_3_1_BASE OPENBSD_3_2_BASE OPENBSD_3_3_BASE UBC_BASE UBC_SYNC_A UBC_SYNC_B
# 1.7 19-Apr-2000 art

Remove roundrobin_attempts.


# 1.6 03-Mar-2000 art

Keep track of the number of times we trigger a reschedule before the
context switch actually happens.


Revision tags: OPENBSD_2_0_BASE OPENBSD_2_1_BASE OPENBSD_2_2_BASE OPENBSD_2_3_BASE OPENBSD_2_4_BASE OPENBSD_2_5_BASE OPENBSD_2_6_BASE SMP_BASE kame_19991208
# 1.5 11-Aug-1996 niklas

branches: 1.5.16;
Move MD5 protos to a more sensible place


# 1.4 17-Apr-1996 mickey

Add prototypes for MD5 routines.


# 1.3 03-Mar-1996 niklas

From NetBSD: 960217 merge


# 1.2 30-Jan-1996 tholo

Add extern declarations of new globals used by kernel PLL clock


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision


# 1.24 15-Oct-2020 cheloha

sys/kernel.h: remove dead externs: tickfix, tixfixinterval, tickdelta, ...

miod@ removed several time-related globals from the kernel with the
commit "unifdef -d __HAVE_TIMECOUNTER" (see sys/kern/kern_clock.c v1.76).
He neglected to remove their externs from sys/kernel.h, though.

Remove the externs.

With help from jsg@.

ok jsg@


Revision tags: OPENBSD_6_8_BASE
# 1.23 20-May-2020 cheloha

kernel.h: remove global declaration for naptime

naptime is now a member of the timehands, th_naptime.


Revision tags: OPENBSD_6_6_BASE OPENBSD_6_7_BASE
# 1.22 07-Sep-2019 cheloha

Remove tz, the kernel timezone.

After removing timezone support from date(1), msdosfs, gettimeofday(2),
settimeofday(2), boot_config(8), config(8), and introducing kern.utc_offset
sysctl(2) to replace the DST/TIMEZONE options(4) to support running the RTC
at an offset from UTC, the kernel timezone is unused and we can delete it.

With this commit the kernel timezone now appears to be extinct in
upstream BSD, though it does survive in XNU:

https://github.com/opensource-apple/xnu/blob/0a798f6738bc1db01281fc08ae024145e84df927/bsd/conf/param.c#L83

Prompted by tedu@ some time back, and inspired by NetBSD and FreeBSD's
work in this area.

ok deraadt@


# 1.21 21-Aug-2019 cheloha

sysctl(2): add kern.utc_offset: successor to the DST/TIMEZONE options(4)

The DST and TIMEZONE options(4) are incompatible with KARL, so we need
some other way to compensate for an RTC running with a known offset.

Enter kern.utc_offset, an offset in minutes East of UTC. TIMEZONE has
always been minutes West, but this is inconsistent with how everyone
else talks about timezones, hence the flip.

TIMEZONE has the advantage of being compiled into the binary. Our new
sysctl(2) has no such luck, so it needs to be set as early as possible
in boot, from sysctl.conf(5), so we can correct the kernel clock from
the RTC's local time to UTC before daemons like ntpd(8) and cron(8)
start. To encourage this, kern.utc_offset is made immutable after the
securelevel(7) is raised to 1.

Prompted by yasuoka@. Discussed with deraadt@, kettenis@, yasuoka@.
Additional testing by yasuoka@.

ok deraadt@, yasuoka@


# 1.20 02-Aug-2019 cheloha

per-process itimers: itimerval -> itimerspec

Loongson runs at 128hz. 128 doesn't divide evenly into a million,
but it does divide evenly into a billion. So if we do the per-process
itimer bookkeeping with itimerspec structs we can have error-free
virtual itimers on loongson just as we do on most other platforms.

This change doesn't fix the virtual itimer error alpha, as 1024 does not
divide evenly into a billion. But this doesn't make the situation any
worse, either.

ok deraadt@


Revision tags: OPENBSD_6_5_BASE
# 1.19 10-Mar-2019 cheloha

Move adjtimedelta from kern_time.c to kern_tc.c.

This will simplify upcoming MP-safety diffs for the timecounting layer.

adjtimedelta is now accessed nowhere outside of kern_tc.c, so we can
remove its extern declaration from kernel.h. Zeroing adjtimedelta
within timecounter_mtx before we jump the real-time clock is also a
bit safer than what we do now, as we are not racing a simultaneous
tc_windup() call from hardclock(), which itself can modify adjtimedelta
via ntp_update_second().

Discussed with visa@ and mpi@.

ok visa@


# 1.18 19-Jan-2019 cheloha

Move boottime into the timehands.

To protect the timehands we first need to protect the basis for all UTC
time in the kernel: the boottime.

Because the boottime can be changed at any time it needs to be versioned
along with the other members of the timehands to enable safe lockless reads
when using it for anything. So the global boottime timespec goes away and
the static boottimebin becomes a member of the timehands. Instead of reading
the global boottime you use one of two interfaces: binboottime(9) or
microboottime(9). nanoboottime(9) can trivially be added later, though there
are no consumers for it at the moment.

This introduces one small change in behavior. We used to advance the
reported boottime just before launching kernel threads from main().
This makes it look to userland like we "booted" moments before those
threads were launched. Because there is no longer a boottime global we
can no longer trivially do this from main(), so the boottime we report
to userspace via e.g. kern.boottime will now reflect whatever the time
was when we bootstrapped the timehands via inittodr(9). This is usually
no more than a minute before the kernel threads are launched from main().
The prior behavior can be restored by adding a new interface to the
timecounter layer in a future commit.

Based on FreeBSD r303387.

Discussed with mpi@ and visa@.

ok visa@


Revision tags: 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
# 1.17 20-Jul-2015 uebayasi

Move `ticks' declaration to sys/kernel.h.


Revision tags: OPENBSD_5_5_BASE OPENBSD_5_6_BASE OPENBSD_5_7_BASE
# 1.16 30-Jan-2014 kettenis

Simplyfy adjtime(2) by keeping track of the adjustment as a number of
microsecond in a 64-bit integer. Fixes the issue where ntpd loses sync
because the struct timeval currently used to hold the adjustment is not
properly normalized after the changes guenther@ made.

ok guenther@, millert@


# 1.15 06-Oct-2013 guenther

Add CLOCK_UPTIME, a clock which measures time-running-not-suspended, so
that mlarkin@ can fix programs that report rates-over-uptime.

ok kettenis@
manpage corrections jmc@ (which I've probably broken again)


Revision tags: OPENBSD_5_4_BASE
# 1.14 03-Jun-2013 guenther

Convert some internal APIs to use timespecs instead of timevals

ok matthew@ deraadt@


Revision tags: OPENBSD_5_3_BASE
# 1.13 05-Nov-2012 miod

unifdef -D __HAVE_TIMECOUNTER


Revision tags: OPENBSD_4_2_BASE OPENBSD_4_3_BASE 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.12 16-May-2007 art

The world of __HAVEs and __HAVE_NOTs is reducing. All architectures
have cpu_info now, so kill the option.

eyeballed by jsg@ and grange@


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
# 1.11 28-Jul-2004 tholo

This touches only MI code, and adds new time keeping code. The
code is all conditionalized on __HAVE_TIMECOUNTER, and not
enabled on any platforms.

adjtime(2) support exists, courtesy of nordin@, sysctl(2) support
and a concept of quality for each time source attached exists.

High quality time sources exists for PIIX4 ACPI timer as well as
some AMD power management chips. This will have to be redone
once we actually add ACPI support (at that time we need to use
the ACPI interfaces to get at these clocks).

ok art@ ken@ miod@ jmc@ and many more


# 1.10 13-Jun-2004 niklas

debranch SMP, have fun


Revision tags: SMP_SYNC_A SMP_SYNC_B
# 1.9 09-Jun-2004 art

Merge in a piece of the SMP branch into HEAD.

Introduce the cpu_info structure, p_cpu field in struct proc and global
scheduling context and various changed code to deal with this. At the
moment no architecture uses this stuff yet, but it will allow us slow and
controlled migration to the new APIs.

All new code is ifdef:ed out.

ok deraadt@ niklas@


Revision tags: OPENBSD_3_4_BASE OPENBSD_3_5_BASE
# 1.8 02-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


Revision tags: OPENBSD_2_7_BASE OPENBSD_2_8_BASE OPENBSD_2_9_BASE OPENBSD_3_0_BASE OPENBSD_3_1_BASE OPENBSD_3_2_BASE OPENBSD_3_3_BASE UBC_BASE UBC_SYNC_A UBC_SYNC_B
# 1.7 19-Apr-2000 art

Remove roundrobin_attempts.


# 1.6 03-Mar-2000 art

Keep track of the number of times we trigger a reschedule before the
context switch actually happens.


Revision tags: OPENBSD_2_0_BASE OPENBSD_2_1_BASE OPENBSD_2_2_BASE OPENBSD_2_3_BASE OPENBSD_2_4_BASE OPENBSD_2_5_BASE OPENBSD_2_6_BASE SMP_BASE kame_19991208
# 1.5 11-Aug-1996 niklas

branches: 1.5.16;
Move MD5 protos to a more sensible place


# 1.4 17-Apr-1996 mickey

Add prototypes for MD5 routines.


# 1.3 03-Mar-1996 niklas

From NetBSD: 960217 merge


# 1.2 30-Jan-1996 tholo

Add extern declarations of new globals used by kernel PLL clock


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision


# 1.23 20-May-2020 cheloha

kernel.h: remove global declaration for naptime

naptime is now a member of the timehands, th_naptime.


Revision tags: OPENBSD_6_6_BASE OPENBSD_6_7_BASE
# 1.22 07-Sep-2019 cheloha

Remove tz, the kernel timezone.

After removing timezone support from date(1), msdosfs, gettimeofday(2),
settimeofday(2), boot_config(8), config(8), and introducing kern.utc_offset
sysctl(2) to replace the DST/TIMEZONE options(4) to support running the RTC
at an offset from UTC, the kernel timezone is unused and we can delete it.

With this commit the kernel timezone now appears to be extinct in
upstream BSD, though it does survive in XNU:

https://github.com/opensource-apple/xnu/blob/0a798f6738bc1db01281fc08ae024145e84df927/bsd/conf/param.c#L83

Prompted by tedu@ some time back, and inspired by NetBSD and FreeBSD's
work in this area.

ok deraadt@


# 1.21 21-Aug-2019 cheloha

sysctl(2): add kern.utc_offset: successor to the DST/TIMEZONE options(4)

The DST and TIMEZONE options(4) are incompatible with KARL, so we need
some other way to compensate for an RTC running with a known offset.

Enter kern.utc_offset, an offset in minutes East of UTC. TIMEZONE has
always been minutes West, but this is inconsistent with how everyone
else talks about timezones, hence the flip.

TIMEZONE has the advantage of being compiled into the binary. Our new
sysctl(2) has no such luck, so it needs to be set as early as possible
in boot, from sysctl.conf(5), so we can correct the kernel clock from
the RTC's local time to UTC before daemons like ntpd(8) and cron(8)
start. To encourage this, kern.utc_offset is made immutable after the
securelevel(7) is raised to 1.

Prompted by yasuoka@. Discussed with deraadt@, kettenis@, yasuoka@.
Additional testing by yasuoka@.

ok deraadt@, yasuoka@


# 1.20 02-Aug-2019 cheloha

per-process itimers: itimerval -> itimerspec

Loongson runs at 128hz. 128 doesn't divide evenly into a million,
but it does divide evenly into a billion. So if we do the per-process
itimer bookkeeping with itimerspec structs we can have error-free
virtual itimers on loongson just as we do on most other platforms.

This change doesn't fix the virtual itimer error alpha, as 1024 does not
divide evenly into a billion. But this doesn't make the situation any
worse, either.

ok deraadt@


Revision tags: OPENBSD_6_5_BASE
# 1.19 10-Mar-2019 cheloha

Move adjtimedelta from kern_time.c to kern_tc.c.

This will simplify upcoming MP-safety diffs for the timecounting layer.

adjtimedelta is now accessed nowhere outside of kern_tc.c, so we can
remove its extern declaration from kernel.h. Zeroing adjtimedelta
within timecounter_mtx before we jump the real-time clock is also a
bit safer than what we do now, as we are not racing a simultaneous
tc_windup() call from hardclock(), which itself can modify adjtimedelta
via ntp_update_second().

Discussed with visa@ and mpi@.

ok visa@


# 1.18 19-Jan-2019 cheloha

Move boottime into the timehands.

To protect the timehands we first need to protect the basis for all UTC
time in the kernel: the boottime.

Because the boottime can be changed at any time it needs to be versioned
along with the other members of the timehands to enable safe lockless reads
when using it for anything. So the global boottime timespec goes away and
the static boottimebin becomes a member of the timehands. Instead of reading
the global boottime you use one of two interfaces: binboottime(9) or
microboottime(9). nanoboottime(9) can trivially be added later, though there
are no consumers for it at the moment.

This introduces one small change in behavior. We used to advance the
reported boottime just before launching kernel threads from main().
This makes it look to userland like we "booted" moments before those
threads were launched. Because there is no longer a boottime global we
can no longer trivially do this from main(), so the boottime we report
to userspace via e.g. kern.boottime will now reflect whatever the time
was when we bootstrapped the timehands via inittodr(9). This is usually
no more than a minute before the kernel threads are launched from main().
The prior behavior can be restored by adding a new interface to the
timecounter layer in a future commit.

Based on FreeBSD r303387.

Discussed with mpi@ and visa@.

ok visa@


Revision tags: 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
# 1.17 20-Jul-2015 uebayasi

Move `ticks' declaration to sys/kernel.h.


Revision tags: OPENBSD_5_5_BASE OPENBSD_5_6_BASE OPENBSD_5_7_BASE
# 1.16 30-Jan-2014 kettenis

Simplyfy adjtime(2) by keeping track of the adjustment as a number of
microsecond in a 64-bit integer. Fixes the issue where ntpd loses sync
because the struct timeval currently used to hold the adjustment is not
properly normalized after the changes guenther@ made.

ok guenther@, millert@


# 1.15 06-Oct-2013 guenther

Add CLOCK_UPTIME, a clock which measures time-running-not-suspended, so
that mlarkin@ can fix programs that report rates-over-uptime.

ok kettenis@
manpage corrections jmc@ (which I've probably broken again)


Revision tags: OPENBSD_5_4_BASE
# 1.14 03-Jun-2013 guenther

Convert some internal APIs to use timespecs instead of timevals

ok matthew@ deraadt@


Revision tags: OPENBSD_5_3_BASE
# 1.13 05-Nov-2012 miod

unifdef -D __HAVE_TIMECOUNTER


Revision tags: OPENBSD_4_2_BASE OPENBSD_4_3_BASE 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.12 16-May-2007 art

The world of __HAVEs and __HAVE_NOTs is reducing. All architectures
have cpu_info now, so kill the option.

eyeballed by jsg@ and grange@


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
# 1.11 28-Jul-2004 tholo

This touches only MI code, and adds new time keeping code. The
code is all conditionalized on __HAVE_TIMECOUNTER, and not
enabled on any platforms.

adjtime(2) support exists, courtesy of nordin@, sysctl(2) support
and a concept of quality for each time source attached exists.

High quality time sources exists for PIIX4 ACPI timer as well as
some AMD power management chips. This will have to be redone
once we actually add ACPI support (at that time we need to use
the ACPI interfaces to get at these clocks).

ok art@ ken@ miod@ jmc@ and many more


# 1.10 13-Jun-2004 niklas

debranch SMP, have fun


Revision tags: SMP_SYNC_A SMP_SYNC_B
# 1.9 09-Jun-2004 art

Merge in a piece of the SMP branch into HEAD.

Introduce the cpu_info structure, p_cpu field in struct proc and global
scheduling context and various changed code to deal with this. At the
moment no architecture uses this stuff yet, but it will allow us slow and
controlled migration to the new APIs.

All new code is ifdef:ed out.

ok deraadt@ niklas@


Revision tags: OPENBSD_3_4_BASE OPENBSD_3_5_BASE
# 1.8 02-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


Revision tags: OPENBSD_2_7_BASE OPENBSD_2_8_BASE OPENBSD_2_9_BASE OPENBSD_3_0_BASE OPENBSD_3_1_BASE OPENBSD_3_2_BASE OPENBSD_3_3_BASE UBC_BASE UBC_SYNC_A UBC_SYNC_B
# 1.7 19-Apr-2000 art

Remove roundrobin_attempts.


# 1.6 03-Mar-2000 art

Keep track of the number of times we trigger a reschedule before the
context switch actually happens.


Revision tags: OPENBSD_2_0_BASE OPENBSD_2_1_BASE OPENBSD_2_2_BASE OPENBSD_2_3_BASE OPENBSD_2_4_BASE OPENBSD_2_5_BASE OPENBSD_2_6_BASE SMP_BASE kame_19991208
# 1.5 11-Aug-1996 niklas

branches: 1.5.16;
Move MD5 protos to a more sensible place


# 1.4 17-Apr-1996 mickey

Add prototypes for MD5 routines.


# 1.3 03-Mar-1996 niklas

From NetBSD: 960217 merge


# 1.2 30-Jan-1996 tholo

Add extern declarations of new globals used by kernel PLL clock


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision


# 1.22 07-Sep-2019 cheloha

Remove tz, the kernel timezone.

After removing timezone support from date(1), msdosfs, gettimeofday(2),
settimeofday(2), boot_config(8), config(8), and introducing kern.utc_offset
sysctl(2) to replace the DST/TIMEZONE options(4) to support running the RTC
at an offset from UTC, the kernel timezone is unused and we can delete it.

With this commit the kernel timezone now appears to be extinct in
upstream BSD, though it does survive in XNU:

https://github.com/opensource-apple/xnu/blob/0a798f6738bc1db01281fc08ae024145e84df927/bsd/conf/param.c#L83

Prompted by tedu@ some time back, and inspired by NetBSD and FreeBSD's
work in this area.

ok deraadt@


# 1.21 21-Aug-2019 cheloha

sysctl(2): add kern.utc_offset: successor to the DST/TIMEZONE options(4)

The DST and TIMEZONE options(4) are incompatible with KARL, so we need
some other way to compensate for an RTC running with a known offset.

Enter kern.utc_offset, an offset in minutes East of UTC. TIMEZONE has
always been minutes West, but this is inconsistent with how everyone
else talks about timezones, hence the flip.

TIMEZONE has the advantage of being compiled into the binary. Our new
sysctl(2) has no such luck, so it needs to be set as early as possible
in boot, from sysctl.conf(5), so we can correct the kernel clock from
the RTC's local time to UTC before daemons like ntpd(8) and cron(8)
start. To encourage this, kern.utc_offset is made immutable after the
securelevel(7) is raised to 1.

Prompted by yasuoka@. Discussed with deraadt@, kettenis@, yasuoka@.
Additional testing by yasuoka@.

ok deraadt@, yasuoka@


# 1.20 02-Aug-2019 cheloha

per-process itimers: itimerval -> itimerspec

Loongson runs at 128hz. 128 doesn't divide evenly into a million,
but it does divide evenly into a billion. So if we do the per-process
itimer bookkeeping with itimerspec structs we can have error-free
virtual itimers on loongson just as we do on most other platforms.

This change doesn't fix the virtual itimer error alpha, as 1024 does not
divide evenly into a billion. But this doesn't make the situation any
worse, either.

ok deraadt@


Revision tags: OPENBSD_6_5_BASE
# 1.19 10-Mar-2019 cheloha

Move adjtimedelta from kern_time.c to kern_tc.c.

This will simplify upcoming MP-safety diffs for the timecounting layer.

adjtimedelta is now accessed nowhere outside of kern_tc.c, so we can
remove its extern declaration from kernel.h. Zeroing adjtimedelta
within timecounter_mtx before we jump the real-time clock is also a
bit safer than what we do now, as we are not racing a simultaneous
tc_windup() call from hardclock(), which itself can modify adjtimedelta
via ntp_update_second().

Discussed with visa@ and mpi@.

ok visa@


# 1.18 19-Jan-2019 cheloha

Move boottime into the timehands.

To protect the timehands we first need to protect the basis for all UTC
time in the kernel: the boottime.

Because the boottime can be changed at any time it needs to be versioned
along with the other members of the timehands to enable safe lockless reads
when using it for anything. So the global boottime timespec goes away and
the static boottimebin becomes a member of the timehands. Instead of reading
the global boottime you use one of two interfaces: binboottime(9) or
microboottime(9). nanoboottime(9) can trivially be added later, though there
are no consumers for it at the moment.

This introduces one small change in behavior. We used to advance the
reported boottime just before launching kernel threads from main().
This makes it look to userland like we "booted" moments before those
threads were launched. Because there is no longer a boottime global we
can no longer trivially do this from main(), so the boottime we report
to userspace via e.g. kern.boottime will now reflect whatever the time
was when we bootstrapped the timehands via inittodr(9). This is usually
no more than a minute before the kernel threads are launched from main().
The prior behavior can be restored by adding a new interface to the
timecounter layer in a future commit.

Based on FreeBSD r303387.

Discussed with mpi@ and visa@.

ok visa@


Revision tags: 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
# 1.17 20-Jul-2015 uebayasi

Move `ticks' declaration to sys/kernel.h.


Revision tags: OPENBSD_5_5_BASE OPENBSD_5_6_BASE OPENBSD_5_7_BASE
# 1.16 30-Jan-2014 kettenis

Simplyfy adjtime(2) by keeping track of the adjustment as a number of
microsecond in a 64-bit integer. Fixes the issue where ntpd loses sync
because the struct timeval currently used to hold the adjustment is not
properly normalized after the changes guenther@ made.

ok guenther@, millert@


# 1.15 06-Oct-2013 guenther

Add CLOCK_UPTIME, a clock which measures time-running-not-suspended, so
that mlarkin@ can fix programs that report rates-over-uptime.

ok kettenis@
manpage corrections jmc@ (which I've probably broken again)


Revision tags: OPENBSD_5_4_BASE
# 1.14 03-Jun-2013 guenther

Convert some internal APIs to use timespecs instead of timevals

ok matthew@ deraadt@


Revision tags: OPENBSD_5_3_BASE
# 1.13 05-Nov-2012 miod

unifdef -D __HAVE_TIMECOUNTER


Revision tags: OPENBSD_4_2_BASE OPENBSD_4_3_BASE 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.12 16-May-2007 art

The world of __HAVEs and __HAVE_NOTs is reducing. All architectures
have cpu_info now, so kill the option.

eyeballed by jsg@ and grange@


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
# 1.11 28-Jul-2004 tholo

This touches only MI code, and adds new time keeping code. The
code is all conditionalized on __HAVE_TIMECOUNTER, and not
enabled on any platforms.

adjtime(2) support exists, courtesy of nordin@, sysctl(2) support
and a concept of quality for each time source attached exists.

High quality time sources exists for PIIX4 ACPI timer as well as
some AMD power management chips. This will have to be redone
once we actually add ACPI support (at that time we need to use
the ACPI interfaces to get at these clocks).

ok art@ ken@ miod@ jmc@ and many more


# 1.10 13-Jun-2004 niklas

debranch SMP, have fun


Revision tags: SMP_SYNC_A SMP_SYNC_B
# 1.9 09-Jun-2004 art

Merge in a piece of the SMP branch into HEAD.

Introduce the cpu_info structure, p_cpu field in struct proc and global
scheduling context and various changed code to deal with this. At the
moment no architecture uses this stuff yet, but it will allow us slow and
controlled migration to the new APIs.

All new code is ifdef:ed out.

ok deraadt@ niklas@


Revision tags: OPENBSD_3_4_BASE OPENBSD_3_5_BASE
# 1.8 02-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


Revision tags: OPENBSD_2_7_BASE OPENBSD_2_8_BASE OPENBSD_2_9_BASE OPENBSD_3_0_BASE OPENBSD_3_1_BASE OPENBSD_3_2_BASE OPENBSD_3_3_BASE UBC_BASE UBC_SYNC_A UBC_SYNC_B
# 1.7 19-Apr-2000 art

Remove roundrobin_attempts.


# 1.6 03-Mar-2000 art

Keep track of the number of times we trigger a reschedule before the
context switch actually happens.


Revision tags: OPENBSD_2_0_BASE OPENBSD_2_1_BASE OPENBSD_2_2_BASE OPENBSD_2_3_BASE OPENBSD_2_4_BASE OPENBSD_2_5_BASE OPENBSD_2_6_BASE SMP_BASE kame_19991208
# 1.5 11-Aug-1996 niklas

branches: 1.5.16;
Move MD5 protos to a more sensible place


# 1.4 17-Apr-1996 mickey

Add prototypes for MD5 routines.


# 1.3 03-Mar-1996 niklas

From NetBSD: 960217 merge


# 1.2 30-Jan-1996 tholo

Add extern declarations of new globals used by kernel PLL clock


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision


# 1.21 21-Aug-2019 cheloha

sysctl(2): add kern.utc_offset: successor to the DST/TIMEZONE options(4)

The DST and TIMEZONE options(4) are incompatible with KARL, so we need
some other way to compensate for an RTC running with a known offset.

Enter kern.utc_offset, an offset in minutes East of UTC. TIMEZONE has
always been minutes West, but this is inconsistent with how everyone
else talks about timezones, hence the flip.

TIMEZONE has the advantage of being compiled into the binary. Our new
sysctl(2) has no such luck, so it needs to be set as early as possible
in boot, from sysctl.conf(5), so we can correct the kernel clock from
the RTC's local time to UTC before daemons like ntpd(8) and cron(8)
start. To encourage this, kern.utc_offset is made immutable after the
securelevel(7) is raised to 1.

Prompted by yasuoka@. Discussed with deraadt@, kettenis@, yasuoka@.
Additional testing by yasuoka@.

ok deraadt@, yasuoka@


# 1.20 02-Aug-2019 cheloha

per-process itimers: itimerval -> itimerspec

Loongson runs at 128hz. 128 doesn't divide evenly into a million,
but it does divide evenly into a billion. So if we do the per-process
itimer bookkeeping with itimerspec structs we can have error-free
virtual itimers on loongson just as we do on most other platforms.

This change doesn't fix the virtual itimer error alpha, as 1024 does not
divide evenly into a billion. But this doesn't make the situation any
worse, either.

ok deraadt@


Revision tags: OPENBSD_6_5_BASE
# 1.19 10-Mar-2019 cheloha

Move adjtimedelta from kern_time.c to kern_tc.c.

This will simplify upcoming MP-safety diffs for the timecounting layer.

adjtimedelta is now accessed nowhere outside of kern_tc.c, so we can
remove its extern declaration from kernel.h. Zeroing adjtimedelta
within timecounter_mtx before we jump the real-time clock is also a
bit safer than what we do now, as we are not racing a simultaneous
tc_windup() call from hardclock(), which itself can modify adjtimedelta
via ntp_update_second().

Discussed with visa@ and mpi@.

ok visa@


# 1.18 19-Jan-2019 cheloha

Move boottime into the timehands.

To protect the timehands we first need to protect the basis for all UTC
time in the kernel: the boottime.

Because the boottime can be changed at any time it needs to be versioned
along with the other members of the timehands to enable safe lockless reads
when using it for anything. So the global boottime timespec goes away and
the static boottimebin becomes a member of the timehands. Instead of reading
the global boottime you use one of two interfaces: binboottime(9) or
microboottime(9). nanoboottime(9) can trivially be added later, though there
are no consumers for it at the moment.

This introduces one small change in behavior. We used to advance the
reported boottime just before launching kernel threads from main().
This makes it look to userland like we "booted" moments before those
threads were launched. Because there is no longer a boottime global we
can no longer trivially do this from main(), so the boottime we report
to userspace via e.g. kern.boottime will now reflect whatever the time
was when we bootstrapped the timehands via inittodr(9). This is usually
no more than a minute before the kernel threads are launched from main().
The prior behavior can be restored by adding a new interface to the
timecounter layer in a future commit.

Based on FreeBSD r303387.

Discussed with mpi@ and visa@.

ok visa@


Revision tags: 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
# 1.17 20-Jul-2015 uebayasi

Move `ticks' declaration to sys/kernel.h.


Revision tags: OPENBSD_5_5_BASE OPENBSD_5_6_BASE OPENBSD_5_7_BASE
# 1.16 30-Jan-2014 kettenis

Simplyfy adjtime(2) by keeping track of the adjustment as a number of
microsecond in a 64-bit integer. Fixes the issue where ntpd loses sync
because the struct timeval currently used to hold the adjustment is not
properly normalized after the changes guenther@ made.

ok guenther@, millert@


# 1.15 06-Oct-2013 guenther

Add CLOCK_UPTIME, a clock which measures time-running-not-suspended, so
that mlarkin@ can fix programs that report rates-over-uptime.

ok kettenis@
manpage corrections jmc@ (which I've probably broken again)


Revision tags: OPENBSD_5_4_BASE
# 1.14 03-Jun-2013 guenther

Convert some internal APIs to use timespecs instead of timevals

ok matthew@ deraadt@


Revision tags: OPENBSD_5_3_BASE
# 1.13 05-Nov-2012 miod

unifdef -D __HAVE_TIMECOUNTER


Revision tags: OPENBSD_4_2_BASE OPENBSD_4_3_BASE 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.12 16-May-2007 art

The world of __HAVEs and __HAVE_NOTs is reducing. All architectures
have cpu_info now, so kill the option.

eyeballed by jsg@ and grange@


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
# 1.11 28-Jul-2004 tholo

This touches only MI code, and adds new time keeping code. The
code is all conditionalized on __HAVE_TIMECOUNTER, and not
enabled on any platforms.

adjtime(2) support exists, courtesy of nordin@, sysctl(2) support
and a concept of quality for each time source attached exists.

High quality time sources exists for PIIX4 ACPI timer as well as
some AMD power management chips. This will have to be redone
once we actually add ACPI support (at that time we need to use
the ACPI interfaces to get at these clocks).

ok art@ ken@ miod@ jmc@ and many more


# 1.10 13-Jun-2004 niklas

debranch SMP, have fun


Revision tags: SMP_SYNC_A SMP_SYNC_B
# 1.9 09-Jun-2004 art

Merge in a piece of the SMP branch into HEAD.

Introduce the cpu_info structure, p_cpu field in struct proc and global
scheduling context and various changed code to deal with this. At the
moment no architecture uses this stuff yet, but it will allow us slow and
controlled migration to the new APIs.

All new code is ifdef:ed out.

ok deraadt@ niklas@


Revision tags: OPENBSD_3_4_BASE OPENBSD_3_5_BASE
# 1.8 02-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


Revision tags: OPENBSD_2_7_BASE OPENBSD_2_8_BASE OPENBSD_2_9_BASE OPENBSD_3_0_BASE OPENBSD_3_1_BASE OPENBSD_3_2_BASE OPENBSD_3_3_BASE UBC_BASE UBC_SYNC_A UBC_SYNC_B
# 1.7 19-Apr-2000 art

Remove roundrobin_attempts.


# 1.6 03-Mar-2000 art

Keep track of the number of times we trigger a reschedule before the
context switch actually happens.


Revision tags: OPENBSD_2_0_BASE OPENBSD_2_1_BASE OPENBSD_2_2_BASE OPENBSD_2_3_BASE OPENBSD_2_4_BASE OPENBSD_2_5_BASE OPENBSD_2_6_BASE SMP_BASE kame_19991208
# 1.5 11-Aug-1996 niklas

branches: 1.5.16;
Move MD5 protos to a more sensible place


# 1.4 17-Apr-1996 mickey

Add prototypes for MD5 routines.


# 1.3 03-Mar-1996 niklas

From NetBSD: 960217 merge


# 1.2 30-Jan-1996 tholo

Add extern declarations of new globals used by kernel PLL clock


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision


# 1.20 02-Aug-2019 cheloha

per-process itimers: itimerval -> itimerspec

Loongson runs at 128hz. 128 doesn't divide evenly into a million,
but it does divide evenly into a billion. So if we do the per-process
itimer bookkeeping with itimerspec structs we can have error-free
virtual itimers on loongson just as we do on most other platforms.

This change doesn't fix the virtual itimer error alpha, as 1024 does not
divide evenly into a billion. But this doesn't make the situation any
worse, either.

ok deraadt@


Revision tags: OPENBSD_6_5_BASE
# 1.19 10-Mar-2019 cheloha

Move adjtimedelta from kern_time.c to kern_tc.c.

This will simplify upcoming MP-safety diffs for the timecounting layer.

adjtimedelta is now accessed nowhere outside of kern_tc.c, so we can
remove its extern declaration from kernel.h. Zeroing adjtimedelta
within timecounter_mtx before we jump the real-time clock is also a
bit safer than what we do now, as we are not racing a simultaneous
tc_windup() call from hardclock(), which itself can modify adjtimedelta
via ntp_update_second().

Discussed with visa@ and mpi@.

ok visa@


# 1.18 19-Jan-2019 cheloha

Move boottime into the timehands.

To protect the timehands we first need to protect the basis for all UTC
time in the kernel: the boottime.

Because the boottime can be changed at any time it needs to be versioned
along with the other members of the timehands to enable safe lockless reads
when using it for anything. So the global boottime timespec goes away and
the static boottimebin becomes a member of the timehands. Instead of reading
the global boottime you use one of two interfaces: binboottime(9) or
microboottime(9). nanoboottime(9) can trivially be added later, though there
are no consumers for it at the moment.

This introduces one small change in behavior. We used to advance the
reported boottime just before launching kernel threads from main().
This makes it look to userland like we "booted" moments before those
threads were launched. Because there is no longer a boottime global we
can no longer trivially do this from main(), so the boottime we report
to userspace via e.g. kern.boottime will now reflect whatever the time
was when we bootstrapped the timehands via inittodr(9). This is usually
no more than a minute before the kernel threads are launched from main().
The prior behavior can be restored by adding a new interface to the
timecounter layer in a future commit.

Based on FreeBSD r303387.

Discussed with mpi@ and visa@.

ok visa@


Revision tags: 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
# 1.17 20-Jul-2015 uebayasi

Move `ticks' declaration to sys/kernel.h.


Revision tags: OPENBSD_5_5_BASE OPENBSD_5_6_BASE OPENBSD_5_7_BASE
# 1.16 30-Jan-2014 kettenis

Simplyfy adjtime(2) by keeping track of the adjustment as a number of
microsecond in a 64-bit integer. Fixes the issue where ntpd loses sync
because the struct timeval currently used to hold the adjustment is not
properly normalized after the changes guenther@ made.

ok guenther@, millert@


# 1.15 06-Oct-2013 guenther

Add CLOCK_UPTIME, a clock which measures time-running-not-suspended, so
that mlarkin@ can fix programs that report rates-over-uptime.

ok kettenis@
manpage corrections jmc@ (which I've probably broken again)


Revision tags: OPENBSD_5_4_BASE
# 1.14 03-Jun-2013 guenther

Convert some internal APIs to use timespecs instead of timevals

ok matthew@ deraadt@


Revision tags: OPENBSD_5_3_BASE
# 1.13 05-Nov-2012 miod

unifdef -D __HAVE_TIMECOUNTER


Revision tags: OPENBSD_4_2_BASE OPENBSD_4_3_BASE 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.12 16-May-2007 art

The world of __HAVEs and __HAVE_NOTs is reducing. All architectures
have cpu_info now, so kill the option.

eyeballed by jsg@ and grange@


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
# 1.11 28-Jul-2004 tholo

This touches only MI code, and adds new time keeping code. The
code is all conditionalized on __HAVE_TIMECOUNTER, and not
enabled on any platforms.

adjtime(2) support exists, courtesy of nordin@, sysctl(2) support
and a concept of quality for each time source attached exists.

High quality time sources exists for PIIX4 ACPI timer as well as
some AMD power management chips. This will have to be redone
once we actually add ACPI support (at that time we need to use
the ACPI interfaces to get at these clocks).

ok art@ ken@ miod@ jmc@ and many more


# 1.10 13-Jun-2004 niklas

debranch SMP, have fun


Revision tags: SMP_SYNC_A SMP_SYNC_B
# 1.9 09-Jun-2004 art

Merge in a piece of the SMP branch into HEAD.

Introduce the cpu_info structure, p_cpu field in struct proc and global
scheduling context and various changed code to deal with this. At the
moment no architecture uses this stuff yet, but it will allow us slow and
controlled migration to the new APIs.

All new code is ifdef:ed out.

ok deraadt@ niklas@


Revision tags: OPENBSD_3_4_BASE OPENBSD_3_5_BASE
# 1.8 02-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


Revision tags: OPENBSD_2_7_BASE OPENBSD_2_8_BASE OPENBSD_2_9_BASE OPENBSD_3_0_BASE OPENBSD_3_1_BASE OPENBSD_3_2_BASE OPENBSD_3_3_BASE UBC_BASE UBC_SYNC_A UBC_SYNC_B
# 1.7 19-Apr-2000 art

Remove roundrobin_attempts.


# 1.6 03-Mar-2000 art

Keep track of the number of times we trigger a reschedule before the
context switch actually happens.


Revision tags: OPENBSD_2_0_BASE OPENBSD_2_1_BASE OPENBSD_2_2_BASE OPENBSD_2_3_BASE OPENBSD_2_4_BASE OPENBSD_2_5_BASE OPENBSD_2_6_BASE SMP_BASE kame_19991208
# 1.5 11-Aug-1996 niklas

branches: 1.5.16;
Move MD5 protos to a more sensible place


# 1.4 17-Apr-1996 mickey

Add prototypes for MD5 routines.


# 1.3 03-Mar-1996 niklas

From NetBSD: 960217 merge


# 1.2 30-Jan-1996 tholo

Add extern declarations of new globals used by kernel PLL clock


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision


Revision tags: OPENBSD_6_5_BASE
# 1.19 10-Mar-2019 cheloha

Move adjtimedelta from kern_time.c to kern_tc.c.

This will simplify upcoming MP-safety diffs for the timecounting layer.

adjtimedelta is now accessed nowhere outside of kern_tc.c, so we can
remove its extern declaration from kernel.h. Zeroing adjtimedelta
within timecounter_mtx before we jump the real-time clock is also a
bit safer than what we do now, as we are not racing a simultaneous
tc_windup() call from hardclock(), which itself can modify adjtimedelta
via ntp_update_second().

Discussed with visa@ and mpi@.

ok visa@


# 1.18 19-Jan-2019 cheloha

Move boottime into the timehands.

To protect the timehands we first need to protect the basis for all UTC
time in the kernel: the boottime.

Because the boottime can be changed at any time it needs to be versioned
along with the other members of the timehands to enable safe lockless reads
when using it for anything. So the global boottime timespec goes away and
the static boottimebin becomes a member of the timehands. Instead of reading
the global boottime you use one of two interfaces: binboottime(9) or
microboottime(9). nanoboottime(9) can trivially be added later, though there
are no consumers for it at the moment.

This introduces one small change in behavior. We used to advance the
reported boottime just before launching kernel threads from main().
This makes it look to userland like we "booted" moments before those
threads were launched. Because there is no longer a boottime global we
can no longer trivially do this from main(), so the boottime we report
to userspace via e.g. kern.boottime will now reflect whatever the time
was when we bootstrapped the timehands via inittodr(9). This is usually
no more than a minute before the kernel threads are launched from main().
The prior behavior can be restored by adding a new interface to the
timecounter layer in a future commit.

Based on FreeBSD r303387.

Discussed with mpi@ and visa@.

ok visa@


Revision tags: 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
# 1.17 20-Jul-2015 uebayasi

Move `ticks' declaration to sys/kernel.h.


Revision tags: OPENBSD_5_5_BASE OPENBSD_5_6_BASE OPENBSD_5_7_BASE
# 1.16 30-Jan-2014 kettenis

Simplyfy adjtime(2) by keeping track of the adjustment as a number of
microsecond in a 64-bit integer. Fixes the issue where ntpd loses sync
because the struct timeval currently used to hold the adjustment is not
properly normalized after the changes guenther@ made.

ok guenther@, millert@


# 1.15 06-Oct-2013 guenther

Add CLOCK_UPTIME, a clock which measures time-running-not-suspended, so
that mlarkin@ can fix programs that report rates-over-uptime.

ok kettenis@
manpage corrections jmc@ (which I've probably broken again)


Revision tags: OPENBSD_5_4_BASE
# 1.14 03-Jun-2013 guenther

Convert some internal APIs to use timespecs instead of timevals

ok matthew@ deraadt@


Revision tags: OPENBSD_5_3_BASE
# 1.13 05-Nov-2012 miod

unifdef -D __HAVE_TIMECOUNTER


Revision tags: OPENBSD_4_2_BASE OPENBSD_4_3_BASE 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.12 16-May-2007 art

The world of __HAVEs and __HAVE_NOTs is reducing. All architectures
have cpu_info now, so kill the option.

eyeballed by jsg@ and grange@


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
# 1.11 28-Jul-2004 tholo

This touches only MI code, and adds new time keeping code. The
code is all conditionalized on __HAVE_TIMECOUNTER, and not
enabled on any platforms.

adjtime(2) support exists, courtesy of nordin@, sysctl(2) support
and a concept of quality for each time source attached exists.

High quality time sources exists for PIIX4 ACPI timer as well as
some AMD power management chips. This will have to be redone
once we actually add ACPI support (at that time we need to use
the ACPI interfaces to get at these clocks).

ok art@ ken@ miod@ jmc@ and many more


# 1.10 13-Jun-2004 niklas

debranch SMP, have fun


Revision tags: SMP_SYNC_A SMP_SYNC_B
# 1.9 09-Jun-2004 art

Merge in a piece of the SMP branch into HEAD.

Introduce the cpu_info structure, p_cpu field in struct proc and global
scheduling context and various changed code to deal with this. At the
moment no architecture uses this stuff yet, but it will allow us slow and
controlled migration to the new APIs.

All new code is ifdef:ed out.

ok deraadt@ niklas@


Revision tags: OPENBSD_3_4_BASE OPENBSD_3_5_BASE
# 1.8 02-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


Revision tags: OPENBSD_2_7_BASE OPENBSD_2_8_BASE OPENBSD_2_9_BASE OPENBSD_3_0_BASE OPENBSD_3_1_BASE OPENBSD_3_2_BASE OPENBSD_3_3_BASE UBC_BASE UBC_SYNC_A UBC_SYNC_B
# 1.7 19-Apr-2000 art

Remove roundrobin_attempts.


# 1.6 03-Mar-2000 art

Keep track of the number of times we trigger a reschedule before the
context switch actually happens.


Revision tags: OPENBSD_2_0_BASE OPENBSD_2_1_BASE OPENBSD_2_2_BASE OPENBSD_2_3_BASE OPENBSD_2_4_BASE OPENBSD_2_5_BASE OPENBSD_2_6_BASE SMP_BASE kame_19991208
# 1.5 11-Aug-1996 niklas

branches: 1.5.16;
Move MD5 protos to a more sensible place


# 1.4 17-Apr-1996 mickey

Add prototypes for MD5 routines.


# 1.3 03-Mar-1996 niklas

From NetBSD: 960217 merge


# 1.2 30-Jan-1996 tholo

Add extern declarations of new globals used by kernel PLL clock


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision


# 1.18 19-Jan-2019 cheloha

Move boottime into the timehands.

To protect the timehands we first need to protect the basis for all UTC
time in the kernel: the boottime.

Because the boottime can be changed at any time it needs to be versioned
along with the other members of the timehands to enable safe lockless reads
when using it for anything. So the global boottime timespec goes away and
the static boottimebin becomes a member of the timehands. Instead of reading
the global boottime you use one of two interfaces: binboottime(9) or
microboottime(9). nanoboottime(9) can trivially be added later, though there
are no consumers for it at the moment.

This introduces one small change in behavior. We used to advance the
reported boottime just before launching kernel threads from main().
This makes it look to userland like we "booted" moments before those
threads were launched. Because there is no longer a boottime global we
can no longer trivially do this from main(), so the boottime we report
to userspace via e.g. kern.boottime will now reflect whatever the time
was when we bootstrapped the timehands via inittodr(9). This is usually
no more than a minute before the kernel threads are launched from main().
The prior behavior can be restored by adding a new interface to the
timecounter layer in a future commit.

Based on FreeBSD r303387.

Discussed with mpi@ and visa@.

ok visa@


Revision tags: 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
# 1.17 20-Jul-2015 uebayasi

Move `ticks' declaration to sys/kernel.h.


Revision tags: OPENBSD_5_5_BASE OPENBSD_5_6_BASE OPENBSD_5_7_BASE
# 1.16 30-Jan-2014 kettenis

Simplyfy adjtime(2) by keeping track of the adjustment as a number of
microsecond in a 64-bit integer. Fixes the issue where ntpd loses sync
because the struct timeval currently used to hold the adjustment is not
properly normalized after the changes guenther@ made.

ok guenther@, millert@


# 1.15 06-Oct-2013 guenther

Add CLOCK_UPTIME, a clock which measures time-running-not-suspended, so
that mlarkin@ can fix programs that report rates-over-uptime.

ok kettenis@
manpage corrections jmc@ (which I've probably broken again)


Revision tags: OPENBSD_5_4_BASE
# 1.14 03-Jun-2013 guenther

Convert some internal APIs to use timespecs instead of timevals

ok matthew@ deraadt@


Revision tags: OPENBSD_5_3_BASE
# 1.13 05-Nov-2012 miod

unifdef -D __HAVE_TIMECOUNTER


Revision tags: OPENBSD_4_2_BASE OPENBSD_4_3_BASE 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.12 16-May-2007 art

The world of __HAVEs and __HAVE_NOTs is reducing. All architectures
have cpu_info now, so kill the option.

eyeballed by jsg@ and grange@


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
# 1.11 28-Jul-2004 tholo

This touches only MI code, and adds new time keeping code. The
code is all conditionalized on __HAVE_TIMECOUNTER, and not
enabled on any platforms.

adjtime(2) support exists, courtesy of nordin@, sysctl(2) support
and a concept of quality for each time source attached exists.

High quality time sources exists for PIIX4 ACPI timer as well as
some AMD power management chips. This will have to be redone
once we actually add ACPI support (at that time we need to use
the ACPI interfaces to get at these clocks).

ok art@ ken@ miod@ jmc@ and many more


# 1.10 13-Jun-2004 niklas

debranch SMP, have fun


Revision tags: SMP_SYNC_A SMP_SYNC_B
# 1.9 09-Jun-2004 art

Merge in a piece of the SMP branch into HEAD.

Introduce the cpu_info structure, p_cpu field in struct proc and global
scheduling context and various changed code to deal with this. At the
moment no architecture uses this stuff yet, but it will allow us slow and
controlled migration to the new APIs.

All new code is ifdef:ed out.

ok deraadt@ niklas@


Revision tags: OPENBSD_3_4_BASE OPENBSD_3_5_BASE
# 1.8 02-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


Revision tags: OPENBSD_2_7_BASE OPENBSD_2_8_BASE OPENBSD_2_9_BASE OPENBSD_3_0_BASE OPENBSD_3_1_BASE OPENBSD_3_2_BASE OPENBSD_3_3_BASE UBC_BASE UBC_SYNC_A UBC_SYNC_B
# 1.7 19-Apr-2000 art

Remove roundrobin_attempts.


# 1.6 03-Mar-2000 art

Keep track of the number of times we trigger a reschedule before the
context switch actually happens.


Revision tags: OPENBSD_2_0_BASE OPENBSD_2_1_BASE OPENBSD_2_2_BASE OPENBSD_2_3_BASE OPENBSD_2_4_BASE OPENBSD_2_5_BASE OPENBSD_2_6_BASE SMP_BASE kame_19991208
# 1.5 11-Aug-1996 niklas

branches: 1.5.16;
Move MD5 protos to a more sensible place


# 1.4 17-Apr-1996 mickey

Add prototypes for MD5 routines.


# 1.3 03-Mar-1996 niklas

From NetBSD: 960217 merge


# 1.2 30-Jan-1996 tholo

Add extern declarations of new globals used by kernel PLL clock


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision


Revision tags: OPENBSD_5_8_BASE OPENBSD_5_9_BASE OPENBSD_6_0_BASE OPENBSD_6_1_BASE OPENBSD_6_2_BASE
# 1.17 20-Jul-2015 uebayasi

Move `ticks' declaration to sys/kernel.h.


Revision tags: OPENBSD_5_5_BASE OPENBSD_5_6_BASE OPENBSD_5_7_BASE
# 1.16 30-Jan-2014 kettenis

Simplyfy adjtime(2) by keeping track of the adjustment as a number of
microsecond in a 64-bit integer. Fixes the issue where ntpd loses sync
because the struct timeval currently used to hold the adjustment is not
properly normalized after the changes guenther@ made.

ok guenther@, millert@


# 1.15 06-Oct-2013 guenther

Add CLOCK_UPTIME, a clock which measures time-running-not-suspended, so
that mlarkin@ can fix programs that report rates-over-uptime.

ok kettenis@
manpage corrections jmc@ (which I've probably broken again)


Revision tags: OPENBSD_5_4_BASE
# 1.14 03-Jun-2013 guenther

Convert some internal APIs to use timespecs instead of timevals

ok matthew@ deraadt@


Revision tags: OPENBSD_5_3_BASE
# 1.13 05-Nov-2012 miod

unifdef -D __HAVE_TIMECOUNTER


Revision tags: OPENBSD_4_2_BASE OPENBSD_4_3_BASE 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.12 16-May-2007 art

The world of __HAVEs and __HAVE_NOTs is reducing. All architectures
have cpu_info now, so kill the option.

eyeballed by jsg@ and grange@


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
# 1.11 28-Jul-2004 tholo

This touches only MI code, and adds new time keeping code. The
code is all conditionalized on __HAVE_TIMECOUNTER, and not
enabled on any platforms.

adjtime(2) support exists, courtesy of nordin@, sysctl(2) support
and a concept of quality for each time source attached exists.

High quality time sources exists for PIIX4 ACPI timer as well as
some AMD power management chips. This will have to be redone
once we actually add ACPI support (at that time we need to use
the ACPI interfaces to get at these clocks).

ok art@ ken@ miod@ jmc@ and many more


# 1.10 13-Jun-2004 niklas

debranch SMP, have fun


Revision tags: SMP_SYNC_A SMP_SYNC_B
# 1.9 09-Jun-2004 art

Merge in a piece of the SMP branch into HEAD.

Introduce the cpu_info structure, p_cpu field in struct proc and global
scheduling context and various changed code to deal with this. At the
moment no architecture uses this stuff yet, but it will allow us slow and
controlled migration to the new APIs.

All new code is ifdef:ed out.

ok deraadt@ niklas@


Revision tags: OPENBSD_3_4_BASE OPENBSD_3_5_BASE
# 1.8 02-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


Revision tags: OPENBSD_2_7_BASE OPENBSD_2_8_BASE OPENBSD_2_9_BASE OPENBSD_3_0_BASE OPENBSD_3_1_BASE OPENBSD_3_2_BASE OPENBSD_3_3_BASE UBC_BASE UBC_SYNC_A UBC_SYNC_B
# 1.7 19-Apr-2000 art

Remove roundrobin_attempts.


# 1.6 03-Mar-2000 art

Keep track of the number of times we trigger a reschedule before the
context switch actually happens.


Revision tags: OPENBSD_2_0_BASE OPENBSD_2_1_BASE OPENBSD_2_2_BASE OPENBSD_2_3_BASE OPENBSD_2_4_BASE OPENBSD_2_5_BASE OPENBSD_2_6_BASE SMP_BASE kame_19991208
# 1.5 11-Aug-1996 niklas

branches: 1.5.16;
Move MD5 protos to a more sensible place


# 1.4 17-Apr-1996 mickey

Add prototypes for MD5 routines.


# 1.3 03-Mar-1996 niklas

From NetBSD: 960217 merge


# 1.2 30-Jan-1996 tholo

Add extern declarations of new globals used by kernel PLL clock


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision