mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-18 08:52:45 +00:00
add trampoline to return from swapper
This commit is contained in:
parent
daf4d9a93e
commit
6f18a0ed21
1 changed files with 18 additions and 1 deletions
|
|
@ -10,8 +10,9 @@ use crate::arch::current_pid;
|
||||||
use crate::arch::exception::RiscvException;
|
use crate::arch::exception::RiscvException;
|
||||||
use crate::arch::mem::MemoryMapping;
|
use crate::arch::mem::MemoryMapping;
|
||||||
use crate::arch::process::{Process as ArchProcess, RETURN_FROM_EXCEPTION_HANDLER};
|
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::services::SystemServices;
|
||||||
|
use crate::swap::Swap;
|
||||||
|
|
||||||
extern "Rust" {
|
extern "Rust" {
|
||||||
fn _xous_syscall_return_result(result: &xous_kernel::Result, context: &Thread) -> !;
|
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")]
|
#[cfg(feature = "gdb-stub")]
|
||||||
RiscvException::Breakpoint(_address) => {
|
RiscvException::Breakpoint(_address) => {
|
||||||
let insn_lo = crate::arch::mem::peek_memory(epc as *mut u16).unwrap_or(0xffff);
|
let insn_lo = crate::arch::mem::peek_memory(epc as *mut u16).unwrap_or(0xffff);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue