1
0
mirror of https://github.com/rcore-os/rCore.git synced 2024-11-27 02:03:29 +04:00
rCore/kernel/src/syscall/time.rs

29 lines
620 B
Rust
Raw Normal View History

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)
}
pub fn sys_time(time: *mut u64) -> SysResult {
2019-03-04 12:25:57 +04:00
let t = rtc_cmos::read_epoch();
if time as usize != 0 {
let mut proc = process();
proc.memory_set.check_mut_ptr(time)?;
unsafe {
time.write(t as u64);
}
}
Ok(t as isize)
}