Let userspace control when graphical_debug gets disabled

Rather than disabling it right before entering userspace. This allows
showing debug messages while the graphics subsystem hasn't initialized
yet.
This commit is contained in:
bjorn3
2024-07-24 20:59:40 +02:00
parent 34cab9edba
commit e7a46c3422
4 changed files with 15 additions and 15 deletions
-4
View File
@@ -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 {
-4
View File
@@ -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 {
-4
View File
@@ -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 {
+15 -3
View File
@@ -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<usize> {
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?