Home | History | Annotate | Download | only in dev
History log of /src/sys/dev/clock_subr.h
RevisionDateAuthorComments
 1.33  09-Sep-2025  christos use device_if.h for device_t not device.h as the latter include prop/proplib.h
which fails for standalone code.
 1.32  07-Sep-2025  thorpej Change todr_chip_handle::cookie -> todr_chip_handle::todr_dev, and
make it a device_t. Upcoming functional changes will require the
device_t associated with a TODR device.

Change todr_chip_handle::bus_cookie -> todr_chip_handle::todr_devaux.
Nothing was using the old field, but I decided to keep it around just
in cause something needs it in the future.

And with these largely mechanical yet semantically meaningful changes,
thus spake the Oracle: "Welcome to NetBSD 11.99.2."
 1.31  07-Sep-2025  thorpej todr_chip_handle::base_time -> todr_chip_handle::todr_base_time

NFCI
 1.30  01-Jan-2020  thorpej Pull in <sys/stdbool.h>.
 1.29  01-Jan-2020  thorpej First steps towards properly serializing access to the TOD clock.
- Add a mutex around the TODR, and provide lock/unlock/lock-owned
functions to manipulate it.
- Rename inittodr() to todr_set_systime() and resettodr() to
todr_save_systime() to better reflect what they do. These functions
are intended to be called with the TODR lock held, which will allow
for a pattern like:
-> todr_lock()
-> todr_save_systime()
-> [do machine-dependent stuff to sleep/suspend]
-> [magically awaken]
-> todr_set_systime(...)
-> todr_unlock()
- Provide historically-named wrappers inittodr() and resettodr() that
do the dance of acquiring / releasing the lock around the actual
substance.

NOTE: resettodr()'s use of the TODR lock is currently disabled (and
todr_save_systime() does not assert it's held) until such time as
issues around shutdown / reboot under duress can be addressed.
 1.28  01-Jan-2020  thorpej Fix some issues around todr_wenable():
- As previously defined, it was not possible to return an error from the
back-end RTC driver. Make it a real function so that it can do so.
- Only the mc146818 and mk48txx drivers used it (for historical reasons).
Centralize the logic for how it's used in kern_todr.c (and make it private
to that file) for consistency.
 1.27  01-Jan-2020  thorpej todr_gettime() and todr_settime() are not referenced outside of kern_todr.c,
so make them private to that file.
 1.26  19-Apr-2018  christos branches: 1.26.2;
s/static inline/static __inline/g for consistency.
 1.25  20-Nov-2014  christos branches: 1.25.18;
kill the macros that called the inlines bcdtobin and bintobcd and define
them directly here.
 1.24  20-Nov-2014  christos provide forward declaration for struct timeval;
 1.23  17-Nov-2014  christos PR/49207: Kamil Rytarowski: Add sys/clock.h with generic time macros
(derived from clock_subr.h). Keep clock_subr.h with the kernel structures
and functions to reduce diffs, and have clock.h only include standalone
constants and macros.
 1.22  07-Sep-2014  martin Avoid overflowing the "year" value by making the field uint64_t. Adapt
arguments and local variables accordingly.
This now fixes PR 49144 for real.
 1.21  12-Dec-2009  tsutsui branches: 1.21.22; 1.21.38;
Remove `volatile' qualifier from argument types of
struct timeval passed to todr_gettime(9) and todr_settime(9).
We no longer have an ancient and volatile struct timeval `time'
global since we have switched to MI timercounter(9) on all port.

XXX1: some of these RTC drivers still assume 32bit time_t
XXX2: some of these should be rewritten to use todr_[gs]ettime_ymdhms()
XXX3: todr(9) man page doesn't mention todr_[gs]ettime_ymdhms()
 1.20  28-Apr-2008  martin Remove clause 3 and 4 from TNF licenses
 1.19  16-Sep-2006  gdamore branches: 1.19.50; 1.19.52; 1.19.54;
Pass the filesystem time to clock drivers in the todr_chip_handle, so that
vax, and pmax can use it.
 1.18  10-Sep-2006  gavan dsrtc_settime already takes a volatile struct timeval *, also qualify
with volatile for dsrtc_gettime.
 1.17  07-Sep-2006  uwe branches: 1.17.2;
Make timeval argument to todr_settime volatile to keep non-timecounter
ports happy.
 1.16  07-Sep-2006  gdamore Add support for new todr entry points for drivers- todr_gettime_ymdhms and
todr_settime_ymdhms. This allows drivers to avoid repeated conversions, and
allows us to centralize check for Y2038 overflow. As discussed on
tech-kern.
 1.15  04-Sep-2006  gdamore Remove unused todr_setcal/todr_getcal and all the assorted stub
implementations.
 1.14  11-Mar-2006  kleink Provide BCD<->binary conversion in libkern and turn <dev/clock_subr.h>'s
FROMBCD()/TOBCD() macros into wrappers around it, resulting in both
smaller code footprint and elimination of possible issues due to
multiple evaluation of macro arguments.

Suggested by Simon Burge and Anders Gavare on tech-kern.
 1.13  11-Dec-2005  christos branches: 1.13.4; 1.13.6; 1.13.8; 1.13.10;
merge ktrace-lwp.
 1.12  04-Jun-2005  he branches: 1.12.2;
Fix the various todr_gettime() and todr_settime() fallouts from
-Wcast-qual differently, by instead changing the signatore of those
"functions" to take a "volatile struct timeval*" instead of a
"struct timeval*". Many places, these functions are called with
&time, and time is declared as volatile in <sys/kernel.h>. This
way we can get rid of all the ugly casts which now also triggered
warnings, and caused more code to be added to work around the
problem.

Reviewed by thorpej.
 1.11  04-Feb-2005  perry de-__P
 1.10  18-Jul-2003  thorpej branches: 1.10.8; 1.10.10;
Rename clock_rtc_config() to todr_attach().
 1.9  18-Jul-2003  thorpej Move the prototype of clock_rtc_config() into <dev/clock_subr.h>.
 1.8  06-Jan-2003  matt branches: 1.8.2;
Add multiple inclusion protection.
 1.7  03-Oct-2000  tsutsui branches: 1.7.2;
Move #define POSIX_BASE_YEAR to clock_subr.h.
 1.6  03-Oct-2000  tsutsui For SECDAY, use "24 * 60 * 60" rather than "86400".
 1.5  01-Sep-2000  eeh Add support for write protecting clock registers.
 1.4  26-Jul-2000  pk No point in forcing SECDAY to be a long int.
 1.3  25-Jul-2000  pk Define the todr(9) interface.
 1.2  15-Mar-1997  is branches: 1.2.22;
New ARP system, supports IPv4 over any hardware link.

Some of the stuff (e.g., rarpd, bootpd, dhcpd etc., libsa) still will
only support Ethernet. Tcpdump itself should be ok, but libpcap needs
lot of work.

For the detailed change history, look at the commit log entries for
the is-newarp branch.
 1.1  19-Feb-1997  gwr branches: 1.1.2;
Shared functions to convert between year/month/day/hour/minute/second
and "seconds since 1970" (POSIX time_t). See sys/arch/sun3/sun3/clock.c
for an example of how these can be used.
 1.1.2.2  12-Mar-1997  is Merge in changes from Trunk
 1.1.2.1  19-Feb-1997  is file clock_subr.h was added on branch is-newarp on 1997-03-12 21:21:50 +0000
 1.2.22.1  20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.7.2.1  07-Jan-2003  thorpej Sync with HEAD.
 1.8.2.5  10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.8.2.4  04-Feb-2005  skrll Sync with HEAD.
 1.8.2.3  21-Sep-2004  skrll Fix the sync with head I botched.
 1.8.2.2  18-Sep-2004  skrll Sync with HEAD.
 1.8.2.1  03-Aug-2004  skrll Sync with HEAD
 1.10.10.1  12-Feb-2005  yamt sync with head.
 1.10.8.1  29-Apr-2005  kent sync with -current
 1.12.2.2  30-Dec-2006  yamt sync with head.
 1.12.2.1  21-Jun-2006  yamt sync with head.
 1.13.10.1  19-Apr-2006  elad sync with head.
 1.13.8.2  14-Sep-2006  yamt sync with head.
 1.13.8.1  13-Mar-2006  yamt sync with head.
 1.13.6.1  22-Apr-2006  simonb Sync with head.
 1.13.4.1  09-Sep-2006  rpaulo sync with head
 1.17.2.1  18-Nov-2006  ad Sync with head.
 1.19.54.2  11-Mar-2010  yamt sync with head
 1.19.54.1  16-May-2008  yamt sync with head.
 1.19.52.1  18-May-2008  yamt sync with head.
 1.19.50.1  02-Jun-2008  mjf Sync with HEAD.
 1.21.38.1  12-Nov-2014  snj Pull up following revision(s) (requested by martin in ticket #216):
share/man/man9/todr.9: revision 1.17
sys/arch/sh3/dev/rtc.c: revision 1.9
sys/dev/clock_subr.c: revision 1.17-1.22
sys/dev/clock_subr.h: revision 1.22
sys/fs/msdosfs/msdosfs_conv.c: revision 1.10
tools/compat/compat_defs.h: revision 1.98
tools/compat/dev/clock_subr.h: revision 1.1-1.2
usr.sbin/makefs/msdos/Makefile.inc: revision 1.6
clock_secs_to_ymdhms(9) takes seconds as a time_t, not int.
--
Make this compile- and usable from userland as well.
--
Add a slightly stripped down version of sys/dev/clock/clock_subr.h to make
this code available for tools.
--
Reformulate an overflow test so it can be used in tool builds (i.e. does
not depend on netbsd specific macros).
--
Make msdosfs time conversion use the y/m/d/h/m/s conversion functions
from clock_subr.c and compile that into the userland (and tools)
makefs as well.
--
Copy definitions of __type_min(t), __type_max(t), and some related macros,
from <sys/cdefs.h>, for use when building tools.
--
Revert previous; test secs > __type_max(time_t) again, now
that __type_max is available in tools/compat/compat_defs.h.
--
If HAVE_NBTOOL_CONFIG_H is set, then include "nbtool_config.h",
because this file is compiled as part of tools/makefs.
--
Counting leap years was fine while we had 32bit time_t - but now it
is not a good idea for dates far away in the future.
For dates in the year 2000 or later, use arithmetic instead (since the
repeating periods are well aligned). Should fix PR 49144.
--
Avoid overflowing the "year" value by making the field uint64_t. Adapt
arguments and local variables accordingly.
This now fixes PR 49144 for real.
--
Adapt formats for debug printfs to clock_subr type changes.
 1.21.22.1  03-Dec-2017  jdolecek update from HEAD
 1.25.18.1  22-Apr-2018  pgoyette Sync with HEAD
 1.26.2.1  08-Apr-2020  martin Merge changes from current as of 20200406

RSS XML Feed