Message type for SYS_SETTIME
Change-Id: I10c2c27c0c9749b49d70735175e530b4341440dc
This commit is contained in:
parent
9d1ed02a04
commit
c59c5caceb
4 changed files with 28 additions and 22 deletions
|
@ -338,12 +338,6 @@
|
||||||
# define GET_REGS 24 /* get general process registers */
|
# define GET_REGS 24 /* get general process registers */
|
||||||
# define GET_RUSAGE 25 /* get resource usage */
|
# define GET_RUSAGE 25 /* get resource usage */
|
||||||
|
|
||||||
/* Field names for SYS_SETTIME. */
|
|
||||||
#define T_SETTIME_NOW m4_l2 /* non-zero for immediate, 0 for adjtime */
|
|
||||||
#define T_CLOCK_ID m4_l3 /* clock to adjust */
|
|
||||||
#define T_TIME_SEC m4_ll1 /* time in seconds since 1970 */
|
|
||||||
#define T_TIME_NSEC m4_l5 /* number of nano seconds */
|
|
||||||
|
|
||||||
/* Field names for SYS_TRACE, SYS_PRIVCTL, SYS_STATECTL. */
|
/* Field names for SYS_TRACE, SYS_PRIVCTL, SYS_STATECTL. */
|
||||||
#define CTL_ENDPT m2_i1 /* process number of the caller */
|
#define CTL_ENDPT m2_i1 /* process number of the caller */
|
||||||
#define CTL_REQUEST m2_i2 /* server control request */
|
#define CTL_REQUEST m2_i2 /* server control request */
|
||||||
|
|
|
@ -791,6 +791,16 @@ typedef struct {
|
||||||
} mess_lsys_krn_sys_stime;
|
} mess_lsys_krn_sys_stime;
|
||||||
_ASSERT_MSG_SIZE(mess_lsys_krn_sys_stime);
|
_ASSERT_MSG_SIZE(mess_lsys_krn_sys_stime);
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
time_t sec; /* time in seconds since 1970 */
|
||||||
|
long int nsec;
|
||||||
|
int now; /* non-zero for immediate, 0 for adjtime */
|
||||||
|
clockid_t clock_id;
|
||||||
|
|
||||||
|
uint8_t padding[36];
|
||||||
|
} mess_lsys_krn_sys_settime;
|
||||||
|
_ASSERT_MSG_SIZE(mess_lsys_krn_sys_settime);
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
endpoint_t endpt;
|
endpoint_t endpt;
|
||||||
|
|
||||||
|
@ -1603,6 +1613,7 @@ typedef struct {
|
||||||
mess_lsys_krn_sys_sdevio m_lsys_krn_sys_sdevio;
|
mess_lsys_krn_sys_sdevio m_lsys_krn_sys_sdevio;
|
||||||
mess_lsys_krn_sys_setalarm m_lsys_krn_sys_setalarm;
|
mess_lsys_krn_sys_setalarm m_lsys_krn_sys_setalarm;
|
||||||
mess_lsys_krn_sys_stime m_lsys_krn_sys_stime;
|
mess_lsys_krn_sys_stime m_lsys_krn_sys_stime;
|
||||||
|
mess_lsys_krn_sys_settime m_lsys_krn_sys_settime;
|
||||||
mess_lsys_krn_sys_times m_lsys_krn_sys_times;
|
mess_lsys_krn_sys_times m_lsys_krn_sys_times;
|
||||||
mess_lsys_krn_sys_umap m_lsys_krn_sys_umap;
|
mess_lsys_krn_sys_umap m_lsys_krn_sys_umap;
|
||||||
mess_lsys_krn_sys_vdevio m_lsys_krn_sys_vdevio;
|
mess_lsys_krn_sys_vdevio m_lsys_krn_sys_vdevio;
|
||||||
|
|
|
@ -2,10 +2,10 @@
|
||||||
* m_type: SYS_SETTIME
|
* m_type: SYS_SETTIME
|
||||||
*
|
*
|
||||||
* The parameters for this kernel call are:
|
* The parameters for this kernel call are:
|
||||||
* m4_l2: T_SETTIME_NOW
|
* m_lsys_krn_sys_settime.now
|
||||||
* m4_l3: T_CLOCK_ID
|
* m_lsys_krn_sys_settime.clock_id
|
||||||
* m4_ll1: T_TIME_SEC
|
* m_lsys_krn_sys_settime.sec
|
||||||
* m4_l5: T_TIME_NSEC
|
* m_lsys_krn_sys_settime.nsec
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "kernel/system.h"
|
#include "kernel/system.h"
|
||||||
|
@ -21,31 +21,32 @@ int do_settime(struct proc * caller, message * m_ptr)
|
||||||
int32_t ticks;
|
int32_t ticks;
|
||||||
time_t timediff, timediff_ticks;
|
time_t timediff, timediff_ticks;
|
||||||
|
|
||||||
if (m_ptr->T_CLOCK_ID != CLOCK_REALTIME) /* only realtime can change */
|
if (m_ptr->m_lsys_krn_sys_settime.clock_id != CLOCK_REALTIME) /* only realtime can change */
|
||||||
return EINVAL;
|
return EINVAL;
|
||||||
|
|
||||||
if (m_ptr->T_SETTIME_NOW == 0) { /* user just wants to adjtime() */
|
if (m_ptr->m_lsys_krn_sys_settime.now == 0) { /* user just wants to adjtime() */
|
||||||
/* convert delta value from seconds and nseconds to ticks */
|
/* convert delta value from seconds and nseconds to ticks */
|
||||||
ticks = (m_ptr->T_TIME_SEC * system_hz) +
|
ticks = (m_ptr->m_lsys_krn_sys_settime.sec * system_hz) +
|
||||||
(m_ptr->T_TIME_NSEC/(1000000000/system_hz));
|
(m_ptr->m_lsys_krn_sys_settime.nsec/(1000000000/system_hz));
|
||||||
set_adjtime_delta(ticks);
|
set_adjtime_delta(ticks);
|
||||||
return(OK);
|
return(OK);
|
||||||
} /* else user wants to set the time */
|
} /* else user wants to set the time */
|
||||||
|
|
||||||
timediff = m_ptr->T_TIME_SEC - boottime;
|
timediff = m_ptr->m_lsys_krn_sys_settime.sec - boottime;
|
||||||
timediff_ticks = timediff * system_hz;
|
timediff_ticks = timediff * system_hz;
|
||||||
|
|
||||||
/* prevent a negative value for realtime */
|
/* prevent a negative value for realtime */
|
||||||
if (m_ptr->T_TIME_SEC <= boottime ||
|
if (m_ptr->m_lsys_krn_sys_settime.sec <= boottime ||
|
||||||
timediff_ticks < LONG_MIN/2 || timediff_ticks > LONG_MAX/2) {
|
timediff_ticks < LONG_MIN/2 || timediff_ticks > LONG_MAX/2) {
|
||||||
/* boottime was likely wrong, try to correct it. */
|
/* boottime was likely wrong, try to correct it. */
|
||||||
boottime = m_ptr->T_TIME_SEC;
|
boottime = m_ptr->m_lsys_krn_sys_settime.sec;
|
||||||
set_realtime(1);
|
set_realtime(1);
|
||||||
return(OK);
|
return(OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* calculate the new value of realtime in ticks */
|
/* calculate the new value of realtime in ticks */
|
||||||
newclock = timediff_ticks + (m_ptr->T_TIME_NSEC/(1000000000/system_hz));
|
newclock = timediff_ticks +
|
||||||
|
(m_ptr->m_lsys_krn_sys_settime.nsec/(1000000000/system_hz));
|
||||||
|
|
||||||
set_realtime(newclock);
|
set_realtime(newclock);
|
||||||
|
|
||||||
|
|
|
@ -6,10 +6,10 @@ int sys_settime(int now, clockid_t clk_id, time_t sec, long nsec)
|
||||||
message m;
|
message m;
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
m.T_SETTIME_NOW = now;
|
m.m_lsys_krn_sys_settime.now = now;
|
||||||
m.T_CLOCK_ID = clk_id;
|
m.m_lsys_krn_sys_settime.clock_id = clk_id;
|
||||||
m.T_TIME_SEC = sec;
|
m.m_lsys_krn_sys_settime.sec = sec;
|
||||||
m.T_TIME_NSEC = nsec;
|
m.m_lsys_krn_sys_settime.nsec = nsec;
|
||||||
|
|
||||||
r = _kernel_call(SYS_SETTIME, &m);
|
r = _kernel_call(SYS_SETTIME, &m);
|
||||||
return r;
|
return r;
|
||||||
|
|
Loading…
Reference in a new issue