From fe468aa1ab7470df27525391bc37da9343732786 Mon Sep 17 00:00:00 2001 From: Jeremy Soller Date: Tue, 1 Mar 2022 16:25:15 -0700 Subject: [PATCH] Improvements for graphical debug and system76 EC debug --- src/arch/x86_64/graphical_debug/debug.rs | 10 +--------- src/arch/x86_64/graphical_debug/display.rs | 7 +++---- src/arch/x86_64/rmm.rs | 2 +- src/arch/x86_64/start.rs | 10 +++++----- 4 files changed, 10 insertions(+), 19 deletions(-) diff --git a/src/arch/x86_64/graphical_debug/debug.rs b/src/arch/x86_64/graphical_debug/debug.rs index 052f1bb..0716fda 100644 --- a/src/arch/x86_64/graphical_debug/debug.rs +++ b/src/arch/x86_64/graphical_debug/debug.rs @@ -1,7 +1,7 @@ use super::Display; pub struct DebugDisplay { - display: Display, + pub (crate) display: Display, x: usize, y: usize, w: usize, @@ -21,14 +21,6 @@ impl DebugDisplay { } } - pub fn as_display(&self) -> &Display { - &self.display - } - - pub fn into_display(self) -> Display { - self.display - } - pub fn write_char(&mut self, c: char) { if self.x >= self.w || c == '\n' { self.x = 0; diff --git a/src/arch/x86_64/graphical_debug/display.rs b/src/arch/x86_64/graphical_debug/display.rs index 4f3ff0b..58ba0c2 100644 --- a/src/arch/x86_64/graphical_debug/display.rs +++ b/src/arch/x86_64/graphical_debug/display.rs @@ -48,10 +48,9 @@ impl Display { let offset = cmp::min(self.height, lines) * self.width; let size = self.data.len() - offset; unsafe { - let src = self.data.as_ptr(); - let dst = self.data.as_mut_ptr().add(offset); - ptr::copy(src, dst, size); - ptr::write_bytes(dst, 0, offset); + let ptr = self.data.as_mut_ptr(); + ptr::copy(ptr.add(offset), ptr, size); + ptr::write_bytes(ptr.add(size), 0, offset); } } } diff --git a/src/arch/x86_64/rmm.rs b/src/arch/x86_64/rmm.rs index f09af95..6d376aa 100644 --- a/src/arch/x86_64/rmm.rs +++ b/src/arch/x86_64/rmm.rs @@ -183,7 +183,7 @@ unsafe fn inner( use super::paging::entry::EntryFlags; let (base, size) = if let Some(debug_display) = &*DEBUG_DISPLAY.lock() { - let data = &debug_display.as_display().data; + let data = &debug_display.display.data; ( data.as_ptr() as usize - crate::PHYS_OFFSET, data.len() * 4 diff --git a/src/arch/x86_64/start.rs b/src/arch/x86_64/start.rs index 41e8fb8..37715a3 100644 --- a/src/arch/x86_64/start.rs +++ b/src/arch/x86_64/start.rs @@ -91,9 +91,12 @@ pub unsafe extern fn kstart(args_ptr: *const KernelArgs) -> ! { let env = slice::from_raw_parts((env_base + crate::PHYS_OFFSET) as *const u8, env_size); // Set up graphical debug - #[cfg(feature="graphical_debug")] + #[cfg(feature = "graphical_debug")] graphical_debug::init(env); + #[cfg(feature = "system76_ec_debug")] + device::system76_ec::init(); + // Initialize logger log::init_logger(|r| { use core::fmt::Write; @@ -163,9 +166,6 @@ pub unsafe extern fn kstart(args_ptr: *const KernelArgs) -> ! { // Activate memory logging log::init(); - #[cfg(feature = "system76_ec_debug")] - device::system76_ec::init(); - // Initialize devices device::init(&mut active_table); @@ -184,7 +184,7 @@ pub unsafe extern fn kstart(args_ptr: *const KernelArgs) -> ! { device::init_noncore(); // Stop graphical debug - #[cfg(feature="graphical_debug")] + #[cfg(feature = "graphical_debug")] graphical_debug::fini(); BSP_READY.store(true, Ordering::SeqCst);