diff --git a/src/arch/aarch64/start.rs b/src/arch/aarch64/start.rs index a9d7a94b41..f5820e5a61 100644 --- a/src/arch/aarch64/start.rs +++ b/src/arch/aarch64/start.rs @@ -186,10 +186,6 @@ pub unsafe extern "C" fn kstart(args_ptr: *const KernelArgs) -> ! { // Initialize all of the non-core devices not otherwise needed to complete initialization device::init_noncore(); - // Stop graphical debug - #[cfg(feature = "graphical_debug")] - graphical_debug::fini(); - BSP_READY.store(true, Ordering::SeqCst); crate::Bootstrap { diff --git a/src/arch/x86/start.rs b/src/arch/x86/start.rs index 3c88349c61..aa431452f7 100644 --- a/src/arch/x86/start.rs +++ b/src/arch/x86/start.rs @@ -201,10 +201,6 @@ pub unsafe extern "C" fn kstart(args_ptr: *const KernelArgs) -> ! { // Initialize all of the non-core devices not otherwise needed to complete initialization device::init_noncore(); - // Stop graphical debug - #[cfg(feature = "graphical_debug")] - graphical_debug::fini(); - BSP_READY.store(true, Ordering::SeqCst); crate::Bootstrap { diff --git a/src/arch/x86_64/start.rs b/src/arch/x86_64/start.rs index fd8579a34f..68116d6af2 100644 --- a/src/arch/x86_64/start.rs +++ b/src/arch/x86_64/start.rs @@ -211,10 +211,6 @@ pub unsafe extern "C" fn kstart(args_ptr: *const KernelArgs) -> ! { // Initialize all of the non-core devices not otherwise needed to complete initialization device::init_noncore(); - // Stop graphical debug - #[cfg(feature = "graphical_debug")] - graphical_debug::fini(); - BSP_READY.store(true, Ordering::SeqCst); crate::Bootstrap { diff --git a/src/scheme/debug.rs b/src/scheme/debug.rs index 72caaadfa8..8b8c8bbae9 100644 --- a/src/scheme/debug.rs +++ b/src/scheme/debug.rs @@ -3,6 +3,7 @@ use spin::RwLock; use crate::{ arch::debug::Writer, + devices::graphical_debug, event, scheme::*, sync::WaitQueue, @@ -48,6 +49,13 @@ impl KernelScheme for DebugScheme { let num = match path { "" => !0, + "disable-graphical-debug" => { + #[cfg(feature = "graphical_debug")] + graphical_debug::fini(); + + !0 - 1 + } + #[cfg(feature = "profiling")] p if p.starts_with("profiling-") => { path[10..].parse().map_err(|_| Error::new(ENOENT))? @@ -90,11 +98,15 @@ impl KernelScheme for DebugScheme { Ok(()) } fn kread(&self, id: usize, buf: UserSliceWo, flags: u32, _stored_flags: u32) -> Result { - let _handle = { + let handle = { let handles = HANDLES.read(); *handles.get(&id).ok_or(Error::new(EBADF))? }; + if handle.num == !0 - 1 { + return Err(Error::new(EINVAL)); + } + #[cfg(feature = "profiling")] if handle.num != !0 { return crate::profiling::drain_buffer( @@ -118,7 +130,7 @@ impl KernelScheme for DebugScheme { *handles.get(&id).ok_or(Error::new(EBADF))? }; if handle.num != !0 { - return Err(Error::new(EBADF)); + return Err(Error::new(EINVAL)); } let mut tmp = [0_u8; 512]; @@ -141,7 +153,7 @@ impl KernelScheme for DebugScheme { *handles.get(&id).ok_or(Error::new(EBADF))? }; if handle.num != !0 { - return Err(Error::new(EBADF)); + return Err(Error::new(EINVAL)); } // TODO: Copy elsewhere in the kernel?