Searched hist:"862993757 a9c45a9c87b1c0b02a9513d44171601" (Results 1 – 2 of 2) sorted by relevance
/freebsd/sys/sys/ |
H A D | clock.h | diff 862993757a9c45a9c87b1c0b02a9513d44171601 Sun Jan 14 18:01:37 CET 2018 Ian Lepore <ian@FreeBSD.org> Add RTC clock conversions for BCD values, with non-panic validation.
RTC clock hardware frequently uses BCD numbers. Currently the low-level bcd2bin() and bin2bcd() functions will KASSERT if given out-of-range BCD values. Every RTC driver must implement its own code for validating the unreliable data coming from the hardware to avoid a potential kernel panic.
This change introduces two new functions, clock_bcd_to_ts() and clock_ts_to_bcd(). The former validates its inputs and returns EINVAL if any values are out of range. The latter guarantees the returned data will be valid BCD in a known format (4-digit years, etc).
A new bcd_clocktime structure is used with the new functions. It is similar to the original clocktime structure, but defines the fields holding BCD values as uint8_t (uint16_t for year), and adds a PM flag for handling hours using AM/PM mode.
PR: 224813 Differential Revision: https://reviews.freebsd.org/D13730 (no reviewers)
|
/freebsd/sys/kern/ |
H A D | subr_clock.c | diff 862993757a9c45a9c87b1c0b02a9513d44171601 Sun Jan 14 18:01:37 CET 2018 Ian Lepore <ian@FreeBSD.org> Add RTC clock conversions for BCD values, with non-panic validation.
RTC clock hardware frequently uses BCD numbers. Currently the low-level bcd2bin() and bin2bcd() functions will KASSERT if given out-of-range BCD values. Every RTC driver must implement its own code for validating the unreliable data coming from the hardware to avoid a potential kernel panic.
This change introduces two new functions, clock_bcd_to_ts() and clock_ts_to_bcd(). The former validates its inputs and returns EINVAL if any values are out of range. The latter guarantees the returned data will be valid BCD in a known format (4-digit years, etc).
A new bcd_clocktime structure is used with the new functions. It is similar to the original clocktime structure, but defines the fields holding BCD values as uint8_t (uint16_t for year), and adds a PM flag for handling hours using AM/PM mode.
PR: 224813 Differential Revision: https://reviews.freebsd.org/D13730 (no reviewers)
|