|
ginnOS
The reference: libc, the libraries and the kernel
|
#include "clock.h"#include "common/div64.h"#include "drivers/rtc/rtc.h"#include "kernel/klog/klog.h"#include "kernel/time/timer.h"#include "arch/arch.h"#include "kernel/errno.h"#include "kernel/process/process.h"#include "kernel/syscall/syscall_internal.h"#include "kernel/usermode/uaccess.h"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. | |
| void clock_init | ( | void | ) |
read the wall-clock time from the RTC.
call once at boot.
| uint32_t clock_realtime_seconds | ( | void | ) |
the wall-clock time in seconds since 1970 (0 if the RTC gave none).
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.
the wall-clock time as a timespec.
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.
call once at boot, before the first nanosleep.
| 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.
| 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.
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.
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.
| 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).