Kernel: export clock information on kernel page
Please note that this information is for use by system services only! The clock facility is not ready to be used directly by userland, and thus, this kernel page extension is NOT part of the userland ABI. For service programmers' convenience, change the prototype of the getticks(3) to return the uptime clock value directly, since the call can no longer fail. Correct the sys_times(2) reply message to use the right field type for the boot time. Restructure the kernel internals a bit so as to have all the clock stuff closer together. Change-Id: Ifc050b7bd253aecbe46e3bd7d7cc75bd86e45555
This commit is contained in:
@@ -19,19 +19,23 @@ int do_settime(struct proc * caller, message * m_ptr)
|
||||
{
|
||||
clock_t newclock;
|
||||
int32_t ticks;
|
||||
time_t timediff, timediff_ticks;
|
||||
time_t boottime, timediff, timediff_ticks;
|
||||
|
||||
if (m_ptr->m_lsys_krn_sys_settime.clock_id != CLOCK_REALTIME) /* only realtime can change */
|
||||
/* only realtime can change */
|
||||
if (m_ptr->m_lsys_krn_sys_settime.clock_id != CLOCK_REALTIME)
|
||||
return EINVAL;
|
||||
|
||||
if (m_ptr->m_lsys_krn_sys_settime.now == 0) { /* user just wants to adjtime() */
|
||||
/* user just wants to adjtime() */
|
||||
if (m_ptr->m_lsys_krn_sys_settime.now == 0) {
|
||||
/* convert delta value from seconds and nseconds to ticks */
|
||||
ticks = (m_ptr->m_lsys_krn_sys_settime.sec * system_hz) +
|
||||
(m_ptr->m_lsys_krn_sys_settime.nsec/(1000000000/system_hz));
|
||||
(m_ptr->m_lsys_krn_sys_settime.nsec/(1000000000/system_hz));
|
||||
set_adjtime_delta(ticks);
|
||||
return(OK);
|
||||
} /* else user wants to set the time */
|
||||
|
||||
boottime = get_boottime();
|
||||
|
||||
timediff = m_ptr->m_lsys_krn_sys_settime.sec - boottime;
|
||||
timediff_ticks = timediff * system_hz;
|
||||
|
||||
@@ -39,7 +43,7 @@ int do_settime(struct proc * caller, message * m_ptr)
|
||||
if (m_ptr->m_lsys_krn_sys_settime.sec <= boottime ||
|
||||
timediff_ticks < LONG_MIN/2 || timediff_ticks > LONG_MAX/2) {
|
||||
/* boottime was likely wrong, try to correct it. */
|
||||
boottime = m_ptr->m_lsys_krn_sys_settime.sec;
|
||||
set_boottime(m_ptr->m_lsys_krn_sys_settime.sec);
|
||||
set_realtime(1);
|
||||
return(OK);
|
||||
}
|
||||
|
||||
@@ -14,6 +14,6 @@
|
||||
*===========================================================================*/
|
||||
int do_stime(struct proc * caller, message * m_ptr)
|
||||
{
|
||||
boottime = m_ptr->m_lsys_krn_sys_stime.boot_time;
|
||||
set_boottime(m_ptr->m_lsys_krn_sys_stime.boot_time);
|
||||
return(OK);
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@ int do_times(struct proc * caller, message * m_ptr)
|
||||
}
|
||||
m_ptr->m_krn_lsys_sys_times.boot_ticks = get_monotonic();
|
||||
m_ptr->m_krn_lsys_sys_times.real_ticks = get_realtime();
|
||||
m_ptr->m_krn_lsys_sys_times.boot_time = boottime;
|
||||
m_ptr->m_krn_lsys_sys_times.boot_time = get_boottime();
|
||||
return(OK);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user