kernel: replace more unimplemented!() with UnhandledSyscall

This should prevent pacnics when calling unhandled functions.

Signed-off-by: Sean Cross <sean@xobs.io>
This commit is contained in:
Sean Cross 2020-07-04 11:58:18 +08:00
parent acfe8e5076
commit e1a92e929c
6 changed files with 16 additions and 48 deletions

View file

@ -12,8 +12,8 @@ pub fn enable_irq(_irq_no: usize) {
unimplemented!();
}
pub fn disable_irq(_irq_no: usize) {
unimplemented!();
pub fn disable_irq(_irq_no: usize) -> Result<(), xous::Error> {
Err(xous::Error::UnhandledSyscall)
}
pub unsafe fn take_isr_return_pair() -> Option<(PID, CtxID)> {

View file

@ -167,7 +167,6 @@ impl Process {
}
pub fn destroy(pid: PID) -> Result<(), xous::Error> {
println!("KERNEL: Destroying PID {}", pid);
PROCESS_TABLE.with(|pt| {
let mut process_table = pt.borrow_mut();
let pid_idx = pid.get() as usize - 1;
@ -191,39 +190,3 @@ impl Process {
}
impl Context {}
// pub struct ProcessHandle {
// inner: RefCell<ProcessTable>,
// }
// /// Wraps the MemoryManager in a safe mutex. Because of this, accesses
// /// to the Memory Manager should only be made during interrupt contexts.
// impl ProcessHandle {
// /// Get the singleton Process.
// pub fn get() -> ProcessHandle {
// ProcessHandle {
// inner: *PROCESS_TABLE.with(|pt| pt.clone()),
// }
// }
// }
// // impl<'a> Drop for ProcessHandle<'a> {
// // fn drop(&mut self) {
// // println!("<<< Dropping ProcessHandle");
// // }
// // }
// use core::ops::{Deref, DerefMut};
// impl Deref for ProcessHandle {
// type Target = Process;
// fn deref(&self) -> &Process {
// &self.inner.table[self.inner.current]
// }
// }
// impl DerefMut for ProcessHandle {
// fn deref_mut(&mut self) -> &mut Process {
// let current = self.inner.current;
// &mut self.inner.table[current]
// }
// }

View file

@ -30,8 +30,9 @@ pub fn enable_irq(irq_no: usize) {
sim::write(sim::read() | (1 << irq_no));
}
pub fn disable_irq(irq_no: usize) {
pub fn disable_irq(irq_no: usize) -> Result<(), xous::Error> {
sim::write(sim::read() & !(1 << irq_no));
Ok(())
}
static mut PREVIOUS_PAIR: Option<(PID, CtxID)> = None;

View file

@ -4,6 +4,7 @@ use xous::{MemoryAddress, PID};
static mut IRQ_HANDLERS: [Option<(PID, MemoryAddress, Option<MemoryAddress>)>; 32] = [None; 32];
#[allow(dead_code)]
pub fn handle(irqs_pending: usize) -> Result<xous::Result, xous::Error> {
// Unsafe is required here because we're accessing a static
// mutable value, and it could be modified from various threads.
@ -32,8 +33,7 @@ pub fn handle(irqs_pending: usize) -> Result<xous::Result, xous::Error> {
// If there is no handler, mask this interrupt
// to prevent an IRQ storm. This is considered
// an error.
// println!("Shutting it up");
arch::irq::disable_irq(irq_no);
arch::irq::disable_irq(irq_no)?;
}
}
}

View file

@ -222,7 +222,10 @@ impl Server {
}
}
}
x => (),
// For "Scalar" and "Move" messages, this memory has already
// been moved into this process, so memory will be reclaimed
// when the process terminates.
_ => (),
}
}
}

View file

@ -361,6 +361,7 @@ impl SystemServices {
/// 1. Pause the current process and switch to the new one
/// 2. Save the process state, if it hasn't already been saved
/// 3. Run the new process, returning to an illegal instruction
#[allow(dead_code)]
pub fn finish_callback_and_resume(
&mut self,
pid: PID,
@ -412,12 +413,12 @@ impl SystemServices {
/// 3. Run the new process, returning to an illegal instruction
pub fn make_callback_to(
&mut self,
pid: PID,
pc: *const usize,
irq_no: usize,
arg: *mut usize,
_pid: PID,
_pc: *const usize,
_irq_no: usize,
_arg: *mut usize,
) -> Result<(), xous::Error> {
unimplemented!()
Err(xous::Error::UnhandledSyscall)
// // Get the current process (which was just interrupted) and mark it as
// // "ready to run". If this function is called when the current process
// // isn't running, that means the system has gotten into an invalid