make retrievepage a re-entrant syscall: syscall abi

This commit is contained in:
bunnie 2024-05-28 02:49:00 +08:00
parent 747e07c90f
commit ed73dfb401

View file

@ -1021,7 +1021,10 @@ pub fn handle_inner(pid: PID, tid: TID, in_irq: bool, call: SysCall) -> SysCallR
if pid.get() != xous_kernel::SWAPPER_PID {
return Err(xous_kernel::Error::AccessDenied);
} else {
Swap::with_mut(|swap| swap.hard_oom_syscall())
Swap::with_mut(|swap| {
swap.clearmem_stop_irq();
swap.hard_oom_syscall()
})
}
}
SwapAbi::GetFreePages => {
@ -1030,7 +1033,6 @@ pub fn handle_inner(pid: PID, tid: TID, in_irq: bool, call: SysCall) -> SysCallR
}
Swap::with(|swap| swap.get_free_mem())
}
// SwapAbi::SetOomThresh => Swap::with_mut(|swap| swap.set_oom_thresh(a1, a2)),
SwapAbi::StealPage => {
if pid.get() != xous_kernel::SWAPPER_PID {
return Err(xous_kernel::Error::AccessDenied);
@ -1083,6 +1085,16 @@ pub fn handle_inner(pid: PID, tid: TID, in_irq: bool, call: SysCall) -> SysCallR
Err(xous_kernel::Error::AccessDenied)
}
}
SwapAbi::RetrievePage => {
if riscv::register::sstatus::read().spp() == riscv::register::sstatus::SPP::Supervisor {
// any process can invoke RetrievePage, but only from within the kernel
let target_vaddr_in_pid = a1;
let paddr = a2;
Swap::with_mut(|swap| swap.retrieve_page_syscall(target_vaddr_in_pid, paddr))
} else {
Err(xous_kernel::Error::AccessDenied)
}
}
SwapAbi::Invalid => {
println!(
"Invalid SwapOp: {:x} {:x} {:x} {:x} {:x} {:x} {:x}",