mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-16 08:38:26 +00:00
kernel: implement SetExceptionHandler routine
Signed-off-by: Sean Cross <sean@xobs.io>
This commit is contained in:
parent
76953985fe
commit
5b2ac0df68
1 changed files with 15 additions and 17 deletions
|
|
@ -672,8 +672,8 @@ pub fn handle_inner(pid: PID, tid: TID, in_irq: bool, call: SysCall) -> SysCallR
|
|||
};
|
||||
// println!("Done zeroing out");
|
||||
}
|
||||
for offset in
|
||||
(range.as_ptr() as usize..(range.as_ptr() as usize + range.len())).step_by(PAGE_SIZE)
|
||||
for offset in (range.as_ptr() as usize..(range.as_ptr() as usize + range.len()))
|
||||
.step_by(PAGE_SIZE)
|
||||
{
|
||||
// println!("Handing page to user");
|
||||
crate::arch::mem::hand_page_to_user(offset as *mut u8)
|
||||
|
|
@ -688,10 +688,8 @@ pub fn handle_inner(pid: PID, tid: TID, in_irq: bool, call: SysCall) -> SysCallR
|
|||
let mut result = Ok(xous_kernel::Result::Ok);
|
||||
let virt = range.as_ptr() as usize;
|
||||
let size = range.len();
|
||||
if cfg!(baremetal) {
|
||||
if virt & 0xfff != 0 {
|
||||
return Err(xous_kernel::Error::BadAlignment);
|
||||
}
|
||||
if cfg!(baremetal) && virt & 0xfff != 0 {
|
||||
return Err(xous_kernel::Error::BadAlignment);
|
||||
}
|
||||
for addr in (virt..(virt + size)).step_by(PAGE_SIZE) {
|
||||
if let Err(e) = mm.unmap_page(addr as *mut usize) {
|
||||
|
|
@ -757,11 +755,8 @@ pub fn handle_inner(pid: PID, tid: TID, in_irq: bool, call: SysCall) -> SysCallR
|
|||
// "Activating process thread {} in pid {} coming from pid {} thread {}",
|
||||
// new_context, new_pid, pid, tid
|
||||
// );
|
||||
let result = ss
|
||||
.activate_process_thread(tid, new_pid, new_context, true)
|
||||
.map(|_ctx| xous_kernel::Result::ResumeProcess);
|
||||
// println!("Done activating process thread: {:?}", result);
|
||||
result
|
||||
ss.activate_process_thread(tid, new_pid, new_context, true)
|
||||
.map(|_ctx| xous_kernel::Result::ResumeProcess)
|
||||
}),
|
||||
SysCall::ClaimInterrupt(no, callback, arg) => {
|
||||
interrupt_claim(no, pid as definitions::PID, callback, arg)
|
||||
|
|
@ -770,9 +765,9 @@ pub fn handle_inner(pid: PID, tid: TID, in_irq: bool, call: SysCall) -> SysCallR
|
|||
SysCall::Yield => do_yield(pid, tid),
|
||||
SysCall::ReturnToParent(_pid, _cpuid) => {
|
||||
unsafe {
|
||||
SWITCHTO_CALLER.take().map(|(parent_pid, parent_ctx)| {
|
||||
if let Some((parent_pid, parent_ctx)) = SWITCHTO_CALLER.take() {
|
||||
crate::arch::irq::set_isr_return_pair(parent_pid, parent_ctx)
|
||||
});
|
||||
}
|
||||
};
|
||||
Ok(xous_kernel::Result::ResumeProcess)
|
||||
}
|
||||
|
|
@ -814,10 +809,9 @@ pub fn handle_inner(pid: PID, tid: TID, in_irq: bool, call: SysCall) -> SysCallR
|
|||
ss.create_server(pid)
|
||||
.map(|(sid, cid)| xous_kernel::Result::NewServerID(sid, cid))
|
||||
}),
|
||||
SysCall::CreateServerId => SystemServices::with_mut(|ss| {
|
||||
ss.create_server_id()
|
||||
.map(|sid| xous_kernel::Result::ServerID(sid))
|
||||
}),
|
||||
SysCall::CreateServerId => {
|
||||
SystemServices::with_mut(|ss| ss.create_server_id().map(xous_kernel::Result::ServerID))
|
||||
}
|
||||
SysCall::TryConnect(sid) => SystemServices::with_mut(|ss| {
|
||||
ss.connect_to_server(sid)
|
||||
.map(xous_kernel::Result::ConnectionID)
|
||||
|
|
@ -886,6 +880,10 @@ pub fn handle_inner(pid: PID, tid: TID, in_irq: bool, call: SysCall) -> SysCallR
|
|||
ret
|
||||
})
|
||||
}
|
||||
SysCall::SetExceptionHandler(pc, sp) => SystemServices::with_mut(|ss| {
|
||||
ss.set_exception_handler(pid, pc, sp)
|
||||
.and(Ok(xous_kernel::Result::Ok))
|
||||
}),
|
||||
_ => Err(xous_kernel::Error::UnhandledSyscall),
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue