mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-19 09:00:54 +00:00
kernel: add in_irq parameter to syscall::handle()
This parameter will determine whether a syscall is being handled from within an interrupt context. This is because certain calls cannot be called from such a context. Signed-off-by: Sean Cross <sean@xobs.io>
This commit is contained in:
parent
bb304d412a
commit
7ab2338ff3
3 changed files with 17 additions and 11 deletions
|
|
@ -544,14 +544,14 @@ pub fn idle() -> bool {
|
||||||
"Unable to send response to process: {:?} -- terminating",
|
"Unable to send response to process: {:?} -- terminating",
|
||||||
_e
|
_e
|
||||||
);
|
);
|
||||||
crate::syscall::handle(pid, thread_id, SysCall::TerminateProcess).ok();
|
crate::syscall::handle(pid, thread_id, false, SysCall::TerminateProcess).ok();
|
||||||
});
|
});
|
||||||
// println!("KERNEL: Done sending");
|
// println!("KERNEL: Done sending");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Handle the syscall within the Xous kernel
|
// Handle the syscall within the Xous kernel
|
||||||
let response =
|
let response =
|
||||||
crate::syscall::handle(pid, thread_id, call).unwrap_or_else(Result::Error);
|
crate::syscall::handle(pid, thread_id, false, call).unwrap_or_else(Result::Error);
|
||||||
|
|
||||||
// println!("KERNEL({}): Syscall response {:?}", pid, response);
|
// println!("KERNEL({}): Syscall response {:?}", pid, response);
|
||||||
// There's a response if it wasn't a blocked process and we're not terminating.
|
// There's a response if it wasn't a blocked process and we're not terminating.
|
||||||
|
|
@ -580,7 +580,7 @@ pub fn idle() -> bool {
|
||||||
"KERNEL({}): Unable to send response to process: {:?} -- terminating",
|
"KERNEL({}): Unable to send response to process: {:?} -- terminating",
|
||||||
pid, _e
|
pid, _e
|
||||||
);
|
);
|
||||||
crate::syscall::handle(pid, thread_id, SysCall::TerminateProcess).ok();
|
crate::syscall::handle(pid, thread_id, false, SysCall::TerminateProcess).ok();
|
||||||
});
|
});
|
||||||
crate::arch::process::set_current_pid(existing_pid);
|
crate::arch::process::set_current_pid(existing_pid);
|
||||||
// SystemServices::with_mut(|ss| {
|
// SystemServices::with_mut(|ss| {
|
||||||
|
|
|
||||||
|
|
@ -96,8 +96,8 @@ pub extern "C" fn trap_handler(
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
|
||||||
let response =
|
let response = crate::syscall::handle(pid, tid, unsafe { PREVIOUS_PAIR.is_some() }, call)
|
||||||
crate::syscall::handle(pid, tid, call).unwrap_or_else(|e| xous_kernel::Result::Error(e));
|
.unwrap_or_else(|e| xous_kernel::Result::Error(e));
|
||||||
|
|
||||||
// println!("Syscall Result: {:?}", response);
|
// println!("Syscall Result: {:?}", response);
|
||||||
ArchProcess::with_current_mut(|p| {
|
ArchProcess::with_current_mut(|p| {
|
||||||
|
|
@ -122,7 +122,10 @@ pub extern "C" fn trap_handler(
|
||||||
match ex {
|
match ex {
|
||||||
RiscvException::StorePageFault(pc, addr) | RiscvException::LoadPageFault(pc, addr) => {
|
RiscvException::StorePageFault(pc, addr) | RiscvException::LoadPageFault(pc, addr) => {
|
||||||
#[cfg(any(feature = "debug-print", feature = "print-panics"))]
|
#[cfg(any(feature = "debug-print", feature = "print-panics"))]
|
||||||
println!("KERNEL({}): RISC-V fault: {} @ {:08x}, addr {:08x}", pid, ex, pc, addr);
|
println!(
|
||||||
|
"KERNEL({}): RISC-V fault: {} @ {:08x}, addr {:08x}",
|
||||||
|
pid, ex, pc, addr
|
||||||
|
);
|
||||||
let entry = crate::arch::mem::pagetable_entry(addr).unwrap_or_else(|x| {
|
let entry = crate::arch::mem::pagetable_entry(addr).unwrap_or_else(|x| {
|
||||||
// MemoryManagerHandle::get().print_ownership();
|
// MemoryManagerHandle::get().print_ownership();
|
||||||
MemoryMapping::current().print_map();
|
MemoryMapping::current().print_map();
|
||||||
|
|
@ -212,9 +215,6 @@ pub extern "C" fn trap_handler(
|
||||||
if PREVIOUS_PAIR.is_none() {
|
if PREVIOUS_PAIR.is_none() {
|
||||||
let tid = crate::arch::process::current_tid();
|
let tid = crate::arch::process::current_tid();
|
||||||
PREVIOUS_PAIR = Some((pid, tid));
|
PREVIOUS_PAIR = Some((pid, tid));
|
||||||
// println!("ISR: Setting previous pair to ({}, {})", pid, tid);
|
|
||||||
// } else {
|
|
||||||
// println!("ISR: Previous pair is not None");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
crate::irq::handle(irqs_pending).expect("Couldn't handle IRQ");
|
crate::irq::handle(irqs_pending).expect("Couldn't handle IRQ");
|
||||||
|
|
|
||||||
|
|
@ -514,10 +514,16 @@ fn receive_message(pid: PID, tid: TID, sid: SID) -> SysCallResult {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn handle(pid: PID, tid: TID, call: SysCall) -> SysCallResult {
|
pub fn handle(pid: PID, tid: TID, irq: bool, call: SysCall) -> SysCallResult {
|
||||||
#[cfg(feature = "debug-print")]
|
#[cfg(feature = "debug-print")]
|
||||||
print!("KERNEL({}:{}): Syscall {:x?}", pid, tid, call);
|
print!("KERNEL({}:{}): Syscall {:x?}", pid, tid, call);
|
||||||
let result = handle_inner(pid, tid, call);
|
|
||||||
|
let result = if irq && !call.can_call_from_interrupt() {
|
||||||
|
Err(xous_kernel::Error::InvalidSyscall)
|
||||||
|
} else {
|
||||||
|
handle_inner(pid, tid, call)
|
||||||
|
};
|
||||||
|
|
||||||
#[cfg(feature = "debug-print")]
|
#[cfg(feature = "debug-print")]
|
||||||
println!(
|
println!(
|
||||||
" -> ({}:{}) {:?}",
|
" -> ({}:{}) {:?}",
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue