Return to kern_time.c CVS log | Up to [local] / funnyos / kern |
File: [local] / funnyos / kern / kern_time.c (download)
Revision 1.1, Tue Nov 6 22:52:39 2007 UTC (16 years, 6 months ago) by init
System time functions/interface. rtc driver fills struct sysrtcops with its own callbacks, allowing to machine-independent time-related manipulations. sysclock_init() programms RTC hardware with HZ; sysclock() will be called by RTC intr handler (in IRQ mode) and update timedata with seconds past Epoch. Still more work to do; now it just prints system time from sysclock(). |
/* * $Id: kern_time.c,v 1.1 2007/11/06 22:52:39 init Exp $ */ #include <sys/types.h> #include <sys/kern_time.h> #include <libkern/printf.h> /* * Kernel time-related stuff. */ struct rtcops sysrtcops = {NULL, NULL, NULL}; /* system will use this to control rtc hardware */ struct timedata systimedata; void sysclock_init(void) { /* * Start system clock. */ /* panic if driver haven't configured rtcops for us */ if (sysrtcops.ro_sethz == NULL) panic("sysclock_init: clock init failed; can't find rtc driver entry points (sysrtcops is null)\n"); /* configure hardware */ sysrtcops.ro_sethz(HZ); } void sysclock(void) { /* * Process one system tick. * RTC interrupt handler will call us; remember that we are in interrupt mode here. */ /* update time data */ systimedata.td_seconds = sysrtcops.ro_getsec(); /* TODO kick scheduler */ printf("sysclock! td_seconds = %d\n", systimedata.td_seconds); }