Skip to main content

Module real_time_clock

Module real_time_clock 

Source
Expand description

Real-time clock device contract (/devices/time/real_time_clock, kind b'r').

A real-time clock (RTC) stores wall-clock time (UTC) across resets and, on chips with a battery-backed domain, across power-off. Like Linux, Xila keeps RTC drivers separate from clocksource drivers: the RTC only supplies and stores UTC; timers, deadlines and uptime stay on the monotonic clock of the time subsystem and never read this device.

The upper half (drivers_peripherals::real_time_clock) adapts a peripherals::real_time_clock::RealTimeClockController lower half to this contract. Plain read and write on the node fail with Unsupported: the clock is only reachable through the control commands below.

§Control commands (kind b'r')

NumberCommandDirectionInputOutputEffect
0x00GET_TIMEReadRealTimeClockTimeAbiRealTimeClockTimeAbiReturns the time the clock holds and its validity.
0x01SET_TIMEWriteRealTimeClockTimeAbiRealTimeClockTimeAbiSets the clock, then returns the time it now holds.

Both commands carry the same versioned payload. In a GET_TIME input only version and reserved are checked; the time fields are ignored. A wrong version, a non-zero reserved or, for SET_TIME, valid != 1 or nanoseconds >= 1_000_000_000 fails with InvalidArgument. In a GET_TIME output valid is 1 when the clock holds a valid time and 0 when it does not (for example after power-off on a chip without a battery-backed domain); then seconds and nanoseconds are zero. A clock that cannot be read or written fails with InputOutput.

Structs§

GET_TIME
RealTimeClockTimeAbi
UTC wall-clock time held by a real-time clock, plus its ABI version and validity. Field order keeps the struct free of padding on 32-bit and 64-bit targets: 16 bytes everywhere.
SET_TIME

Constants§

ABI_VERSION
Version of the real-time clock control ABI payload.
MAX_NANOSECONDS
Largest accepted value of nanoseconds (exclusive).
NOT_VALID
valid value of a clock that holds no valid time.
REAL_TIME_CLOCK_PATH
Path of the real-time clock device node in the virtual file system.
VALID
valid value of a clock that holds a valid time.