add trampoline to return from swapper

This commit is contained in:
bunnie 2024-03-08 04:10:11 +08:00
parent daf4d9a93e
commit 6f18a0ed21

View file

@ -10,8 +10,9 @@ use crate::arch::current_pid;
use crate::arch::exception::RiscvException;
use crate::arch::mem::MemoryMapping;
use crate::arch::process::{Process as ArchProcess, RETURN_FROM_EXCEPTION_HANDLER};
use crate::arch::process::{Thread, EXIT_THREAD, RETURN_FROM_ISR};
use crate::arch::process::{Thread, EXIT_THREAD, RETURN_FROM_ISR, RETURN_FROM_SWAPPER};
use crate::services::SystemServices;
use crate::swap::Swap;
extern "Rust" {
fn _xous_syscall_return_result(result: &xous_kernel::Result, context: &Thread) -> !;
@ -307,6 +308,22 @@ pub extern "C" fn trap_handler(
});
}
RiscvException::InstructionPageFault(RETURN_FROM_SWAPPER, _offset) => {
// Cleanup after the swapper
let response =
Swap::with_mut(|s| s.exit_blocking_call()).unwrap_or_else(xous_kernel::Result::Error);
// Resume like we're returning from a syscall.
enable_all_irqs();
ArchProcess::with_current_mut(|p| {
let thread = p.current_thread();
if response == xous_kernel::Result::ResumeProcess {
crate::arch::syscall::resume(current_pid().get() == 1, thread);
} else {
unsafe { _xous_syscall_return_result(&response, thread) };
}
});
}
#[cfg(feature = "gdb-stub")]
RiscvException::Breakpoint(_address) => {
let insn_lo = crate::arch::mem::peek_memory(epc as *mut u16).unwrap_or(0xffff);