From 059fc188507224c424c6c450565f11cad3954b08 Mon Sep 17 00:00:00 2001 From: Sean Cross Date: Fri, 6 Aug 2021 10:02:32 +0800 Subject: [PATCH] services: add exception handler routines Add a function to set and one to clear the current exception handler. Signed-off-by: Sean Cross --- kernel/src/services.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/kernel/src/services.rs b/kernel/src/services.rs index bf4b98806..2a5b85d2d 100644 --- a/kernel/src/services.rs +++ b/kernel/src/services.rs @@ -2131,6 +2131,14 @@ impl SystemServices { Ok(()) } + /// Sets the exception handler for the given process ID. If an exception handler + /// exists, it will be silently overridden. + pub fn set_exception_handler(&mut self, pid: PID, pc: usize, sp: usize) -> Result<(), xous_kernel::Error> { + let process = self.get_process_mut(pid)?; + process.exception_handler = Some(ExceptionHandler { pc, sp }); + Ok(()) + } + /// Causes the provided process to go into an exception state. This will fail /// if any of the following are true: /// 1. The process does not exist