add syscall: sys_getrandom for python3, etc.

master
chyyuu 6 years ago
parent 88b54fdacd
commit 1974cc5853

@ -201,3 +201,18 @@ pub struct RLimit {
cur: u64, // soft limit
max: u64, // hard limit
}
pub fn sys_getrandom( buf: *mut u8, len: usize, flag: u32) -> SysResult {
//info!("getrandom: buf: {:?}, len: {:?}, falg {:?}", buf, len,flag);
let mut proc = process();
proc.vm.check_write_array(buf, len)?;
let slice = unsafe { slice::from_raw_parts_mut(buf, len) };
let mut i=0;
for elm in slice {
unsafe{ *elm=i+ crate::trap::TICK as u8;}
i+=1;
}
Ok(len)
}

@ -230,7 +230,9 @@ pub fn syscall(id: usize, args: [usize; 6], tf: &mut TrapFrame) -> isize {
// custom
SYS_MAP_PCI_DEVICE => sys_map_pci_device(args[0], args[1]),
SYS_GET_PADDR => sys_get_paddr(args[0] as *const u64, args[1] as *mut u64, args[2]),
//SYS_GETRANDOM => unimplemented("getrandom", Err(SysError::EINVAL)),
SYS_GETRANDOM =>sys_getrandom( args[0] as *mut u8, args[1] as usize, args[2] as u32),
SYS_TKILL => unimplemented("tkill", Ok(0)),
_ => {
let ret = match () {
#[cfg(target_arch = "x86_64")]

Loading…
Cancel
Save