PatchworkOS  28a9544
A non-POSIX operating system.
Loading...
Searching...
No Matches
sys_time.c File Reference
#include <kernel/sched/sys_time.h>
#include <kernel/cpu/cpu.h>
#include <kernel/cpu/interrupt.h>
#include <kernel/cpu/syscalls.h>
#include <kernel/drivers/apic.h>
#include <kernel/drivers/rtc.h>
#include <kernel/log/log.h>
#include <kernel/log/panic.h>
#include <kernel/module/symbol.h>
#include <kernel/sched/thread.h>
#include <kernel/sched/timer.h>
#include <kernel/sync/rwlock.h>
#include <stdbool.h>
#include <stdint.h>
#include <sys/math.h>

Go to the source code of this file.

Functions

static void timer_boot_epoch_init (void)
 
uint64_t sys_time_register_source (const sys_time_source_t *source)
 Register a system timer source.
 
void sys_time_unregister_source (const sys_time_source_t *source)
 Unregister a system timer source.
 
clock_t sys_time_uptime (void)
 Time since boot.
 
time_t sys_time_unix_epoch (void)
 The unix epoch.
 
void sys_time_wait (clock_t nanoseconds)
 Wait for a specified number of nanoseconds.
 
 SYSCALL_DEFINE (SYS_UPTIME, clock_t)
 
 SYSCALL_DEFINE (SYS_UNIX_EPOCH, time_t, time_t *timePtr)
 

Variables

static time_t bootEpoch = 0
 
static bool bootEpochInitialized = false
 
static sys_time_source_tsources [SYS_TIME_MAX_SOURCES]
 
static uint32_t sourceCount = 0
 
static sys_time_source_tbestSource = NULL
 
static rwlock_t sourcesLock = RWLOCK_CREATE
 

Function Documentation

◆ SYSCALL_DEFINE() [1/2]

SYSCALL_DEFINE ( SYS_UNIX_EPOCH  ,
time_t  ,
time_t timePtr 
)

Definition at line 151 of file sys_time.c.

References ERR, NULL, sched_thread(), sys_time_unix_epoch(), and thread_copy_to_user().

◆ SYSCALL_DEFINE() [2/2]

SYSCALL_DEFINE ( SYS_UPTIME  ,
clock_t   
)

Definition at line 146 of file sys_time.c.

References sys_time_uptime().

◆ timer_boot_epoch_init()

static void timer_boot_epoch_init ( void  )
static

Definition at line 27 of file sys_time.c.

References bootEpoch, bootEpochInitialized, mktime(), rtc_read(), and time().

Referenced by sys_time_unix_epoch().

Variable Documentation

◆ bestSource

sys_time_source_t* bestSource = NULL
static

◆ bootEpoch

time_t bootEpoch = 0
static

Definition at line 19 of file sys_time.c.

Referenced by sys_time_unix_epoch(), and timer_boot_epoch_init().

◆ bootEpochInitialized

bool bootEpochInitialized = false
static

Definition at line 20 of file sys_time.c.

Referenced by sys_time_unix_epoch(), and timer_boot_epoch_init().

◆ sourceCount

uint32_t sourceCount = 0
static

Definition at line 23 of file sys_time.c.

Referenced by sys_time_register_source(), and sys_time_unregister_source().

◆ sources

Definition at line 22 of file sys_time.c.

Referenced by sys_time_register_source(), and sys_time_unregister_source().

◆ sourcesLock

rwlock_t sourcesLock = RWLOCK_CREATE
static