1
0
mirror of https://github.com/rcore-os/rCore.git synced 2024-11-22 16:16:16 +04:00

add syscall: sys_times partial implementation

This commit is contained in:
chyyuu 2019-04-21 17:07:40 +08:00
parent 96e393ecd4
commit 144090e42d
3 changed files with 34 additions and 3 deletions

View File

@ -106,7 +106,7 @@ impl Drop for KernelStack {
/// Handle page fault at `addr`.
/// Return true to continue, false to halt.
pub fn handle_page_fault(addr: usize) -> bool {
debug!("page fault @ {:#x}", addr);
// debug!("page fault @ {:#x}", addr);
// This is safe as long as page fault never happens in page fault handler
unsafe { process_unsafe().vm.handle_page_fault(addr) }

View File

@ -59,8 +59,8 @@ pub fn syscall(id: usize, args: [usize; 6], tf: &mut TrapFrame) -> isize {
SYS_MPROTECT => sys_mprotect(args[0], args[1], args[2]),
SYS_MUNMAP => sys_munmap(args[0], args[1]),
SYS_BRK => {
warn!("sys_brk is unimplemented");
Ok(0)
warn!("sys_brk is unimplemented, return -1");
Err(SysError::ENOMEM)
}
SYS_RT_SIGACTION => {
warn!("sys_sigaction is unimplemented");
@ -174,6 +174,7 @@ pub fn syscall(id: usize, args: [usize; 6], tf: &mut TrapFrame) -> isize {
// SYS_GETRLIMIT => sys_getrlimit(),
SYS_GETRUSAGE => sys_getrusage(args[0], args[1] as *mut RUsage),
SYS_SYSINFO => sys_sysinfo(args[0] as *mut SysInfo),
SYS_TIMES => sys_times(args[0] as *mut Tms),
SYS_GETUID => {
warn!("sys_getuid is unimplemented");
Ok(0)

View File

@ -146,3 +146,33 @@ pub fn sys_getrusage(who: usize, rusage: *mut RUsage) -> SysResult {
unsafe { *rusage = new_rusage };
Ok(0)
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct Tms {
tms_utime: u64, /* user time */
tms_stime: u64, /* system time */
tms_cutime: u64, /* user time of children */
tms_cstime: u64, /* system time of children */
}
pub fn sys_times(buf:*mut Tms)-> SysResult {
info!("times: buf: {:?}", buf);
let proc = process();
proc.vm.check_write_ptr(buf)?;
let tick_base = *TICK_BASE;
let tick = unsafe { crate::trap::TICK as u64 };
let new_buf = Tms {
tms_utime: 0,
tms_stime: 0,
tms_cutime: 0,
tms_cstime: 0,
};
unsafe { *buf = new_buf };
Ok(tick as usize)
}