From a3493d16fdd26b7422282b7b07b30db74089cb56 Mon Sep 17 00:00:00 2001 From: Jeremy Soller Date: Mon, 10 Jul 2017 20:28:10 -0600 Subject: [PATCH] Allow simple signal delivery to PID 1 (the kernel idle process) --- src/context/context.rs | 2 +- src/context/switch.rs | 15 ++++----------- 2 files changed, 5 insertions(+), 12 deletions(-) diff --git a/src/context/context.rs b/src/context/context.rs index bae447e..d971cee 100644 --- a/src/context/context.rs +++ b/src/context/context.rs @@ -66,7 +66,7 @@ pub struct Context { /// Kernel stack pub kstack: Option>, /// Kernel signal backup - pub ksig: Option<(arch::Context, Box<[u8]>, Box<[u8]>)>, + pub ksig: Option<(arch::Context, Option>, Option>)>, /// Restore ksig context on next switch pub ksig_restore: bool, /// Executable image diff --git a/src/context/switch.rs b/src/context/switch.rs index 4706a11..d231eed 100644 --- a/src/context/switch.rs +++ b/src/context/switch.rs @@ -53,12 +53,12 @@ pub unsafe fn switch() -> bool { let ksig = context.ksig.take().expect("context::switch: ksig not set with ksig_restore"); context.arch = ksig.0; if let Some(ref mut kfx) = context.kfx { - kfx.clone_from_slice(&ksig.1); + kfx.clone_from_slice(&ksig.1.expect("context::switch: ksig kfx not set with ksig_restore")); } else { panic!("context::switch: kfx not set with ksig_restore"); } if let Some(ref mut kstack) = context.kstack { - kstack.clone_from_slice(&ksig.2); + kstack.clone_from_slice(&ksig.2.expect("context::switch: ksig kstack not set with ksig_restore")); } else { panic!("context::switch: kstack not set with ksig_restore"); } @@ -139,15 +139,8 @@ pub unsafe fn switch() -> bool { assert!((&mut *to_ptr).ksig.is_none()); let arch = (&mut *to_ptr).arch.clone(); - let kfx = match (&mut *to_ptr).kfx { - Some(ref kfx) => kfx.clone(), - None => panic!("context::switch: no kfx during signal") - }; - let kstack = match (&mut *to_ptr).kstack { - Some(ref kstack) => kstack.clone(), - None => panic!("context::switch: no kstack during signal") - }; - + let kfx = (&mut *to_ptr).kfx.clone(); + let kstack = (&mut *to_ptr).kstack.clone(); (&mut *to_ptr).ksig = Some((arch, kfx, kstack)); (&mut *to_ptr).arch.signal_stack(signal_handler, sig); }