The manual
ginnOS
The reference: libc, the libraries and the kernel
Loading...
Searching...
No Matches
clock.c File Reference

Functions

void clock_init (void)
 read the wall-clock time from the RTC.
uint32_t clock_realtime_seconds (void)
 the wall-clock time in seconds since 1970 (0 if the RTC gave none).
void clock_ticks_to_timespec (uint64_t ticks, struct ktimespec *out)
 a timespec from a number of timer ticks.
void clock_realtime (struct ktimespec *out)
 the realtime clock as a timespec: the boot time plus the ticks since.
void clock_init_sleep (void)
 set up the queue nanosleep sleeps on.
syscall_ret_t sys_clock_settime (struct registers *regs)
 SYS_clock_settime: set the realtime clock (root only).
syscall_ret_t sys_clock_gettime (struct registers *regs)
 SYS_clock_gettime: read a clock.
uint64_t clock_timespec_to_ticks (const struct ktimespec *span)
 the timer ticks that cover at least a time span (rounded up).
syscall_ret_t sys_nanosleep (struct registers *regs)
 SYS_nanosleep: sleep for a time span.
syscall_ret_t sys_times (struct registers *regs)
 SYS_times: the CPU time of the calling process and its reaped children.

Function Documentation

◆ clock_init()

void clock_init ( void )

read the wall-clock time from the RTC.

call once at boot.

◆ clock_realtime_seconds()

uint32_t clock_realtime_seconds ( void )

the wall-clock time in seconds since 1970 (0 if the RTC gave none).

◆ clock_ticks_to_timespec()

void clock_ticks_to_timespec ( uint64_t ticks,
struct ktimespec * out )

a timespec from a number of timer ticks.

◆ clock_realtime()

void clock_realtime ( struct ktimespec * out)

the realtime clock as a timespec: the boot time plus the ticks since.

the wall-clock time as a timespec.

the realtime clock as a timespec: the boot time plus the ticks since.

◆ clock_init_sleep()

void clock_init_sleep ( void )

set up the queue nanosleep sleeps on.

call once at boot, before the first nanosleep.

◆ sys_clock_settime()

syscall_ret_t sys_clock_settime ( struct registers * regs)

SYS_clock_settime: set the realtime clock (root only).

args: clock id (CLOCK_REALTIME only), struct timespec *. the clock keeps whole seconds; the battery-backed clock (RTC) is not written, so the next boot reads its old time again. returns 0, or -EPERM, -EINVAL (another clock, a bad time), -EFAULT.

◆ sys_clock_gettime()

syscall_ret_t sys_clock_gettime ( struct registers * regs)

SYS_clock_gettime: read a clock.

args: EBX = clock id (CLOCK_*), ECX = struct timespec * out. returns 0, or -EINVAL for an unknown clock, -EFAULT.

◆ clock_timespec_to_ticks()

uint64_t clock_timespec_to_ticks ( const struct ktimespec * span)

the timer ticks that cover at least a time span (rounded up).

◆ sys_nanosleep()

syscall_ret_t sys_nanosleep ( struct registers * regs)

SYS_nanosleep: sleep for a time span.

args: EBX = const struct timespec * span, ECX = struct timespec * left (may be NULL). the sleep ends at the first timer tick after the span (10 ms steps). a signal ends it early: -EINTR, with the time left in *left. returns 0, or -EINTR, -EINVAL (a negative span or nanoseconds out of range), -EFAULT.

◆ sys_times()

syscall_ret_t sys_times ( struct registers * regs)

SYS_times: the CPU time of the calling process and its reaped children.

args: EBX = struct tms * out (may be NULL). returns the ticks since boot (clock_t, TIMER_HZ per second).