2019-02-22 10:10:24 +04:00
|
|
|
//! Syscalls for time
|
|
|
|
|
|
|
|
use super::*;
|
2019-03-04 12:25:57 +04:00
|
|
|
use crate::arch::driver::rtc_cmos;
|
2019-02-22 10:10:24 +04:00
|
|
|
|
2019-03-04 12:25:57 +04:00
|
|
|
pub fn sys_gettimeofday(tv: *mut u64, tz: *const u8) -> SysResult {
|
|
|
|
if tz as usize != 0 {
|
|
|
|
return Err(SysError::EINVAL);
|
|
|
|
}
|
|
|
|
|
|
|
|
let mut proc = process();
|
|
|
|
proc.memory_set.check_mut_ptr(tv)?;
|
|
|
|
|
|
|
|
unsafe { *tv = rtc_cmos::read_epoch() };
|
|
|
|
Ok(0)
|
2019-03-02 16:15:55 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
pub fn sys_time(time: *mut u64) -> SysResult {
|
2019-03-04 12:25:57 +04:00
|
|
|
let t = rtc_cmos::read_epoch();
|
2019-03-02 16:15:55 +04:00
|
|
|
if time as usize != 0 {
|
|
|
|
let mut proc = process();
|
2019-03-02 21:27:30 +04:00
|
|
|
proc.memory_set.check_mut_ptr(time)?;
|
2019-03-02 16:15:55 +04:00
|
|
|
unsafe {
|
|
|
|
time.write(t as u64);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Ok(t as isize)
|
|
|
|
}
|