From 8aa08e1e3da2f2b0d44e6e0c209eef0af3eb7307 Mon Sep 17 00:00:00 2001 From: bjorn3 <17426603+bjorn3@users.noreply.github.com> Date: Fri, 12 Sep 2025 18:59:48 +0200 Subject: [PATCH] Unconditionally enable serial_debug on arm64 and riscv64 --- src/arch/aarch64/debug.rs | 20 +++++++------------- src/arch/riscv64/debug.rs | 19 +++++++------------ src/arch/riscv64/start.rs | 1 - src/arch/x86_shared/debug.rs | 5 ----- src/arch/x86_shared/device/serial.rs | 6 ++++++ src/arch/x86_shared/start.rs | 1 - 6 files changed, 20 insertions(+), 32 deletions(-) diff --git a/src/arch/aarch64/debug.rs b/src/arch/aarch64/debug.rs index ad591311b9..ac9f64c11f 100644 --- a/src/arch/aarch64/debug.rs +++ b/src/arch/aarch64/debug.rs @@ -2,19 +2,17 @@ use core::fmt; use spin::MutexGuard; use crate::{ - devices::graphical_debug::{DebugDisplay, DEBUG_DISPLAY}, + device::serial::COM1, + devices::{ + graphical_debug::{DebugDisplay, DEBUG_DISPLAY}, + serial::SerialKind, + }, log::{Log, LOG}, }; -#[cfg(feature = "serial_debug")] -use super::device::serial::COM1; -#[cfg(feature = "serial_debug")] -use crate::devices::serial::SerialKind; - pub struct Writer<'a> { log: MutexGuard<'a, Option>, display: MutexGuard<'a, Option>, - #[cfg(feature = "serial_debug")] serial: MutexGuard<'a, Option>, } @@ -23,7 +21,6 @@ impl<'a> Writer<'a> { Writer { log: LOG.lock(), display: DEBUG_DISPLAY.lock(), - #[cfg(feature = "serial_debug")] serial: COM1.lock(), } } @@ -39,11 +36,8 @@ impl<'a> Writer<'a> { let _ = display.write(buf); } - #[cfg(feature = "serial_debug")] - { - if let Some(ref mut serial) = *self.serial { - serial.write(buf); - } + if let Some(ref mut serial) = *self.serial { + serial.write(buf); } } } diff --git a/src/arch/riscv64/debug.rs b/src/arch/riscv64/debug.rs index 3a89bfd70b..58cdd0eb7f 100644 --- a/src/arch/riscv64/debug.rs +++ b/src/arch/riscv64/debug.rs @@ -1,18 +1,17 @@ use core::fmt; use spin::MutexGuard; -#[cfg(feature = "serial_debug")] -use super::device::serial::COM1; -#[cfg(feature = "serial_debug")] -use crate::devices::serial::SerialKind; use crate::{ - devices::graphical_debug::{DebugDisplay, DEBUG_DISPLAY}, + device::serial::COM1, + devices::{ + graphical_debug::{DebugDisplay, DEBUG_DISPLAY}, + serial::SerialKind, + }, log::{Log, LOG}, }; pub struct Writer<'a> { log: MutexGuard<'a, Option>, - #[cfg(feature = "serial_debug")] serial: MutexGuard<'a, Option>, display: MutexGuard<'a, Option>, } @@ -22,7 +21,6 @@ impl<'a> Writer<'a> { Writer { log: LOG.lock(), display: DEBUG_DISPLAY.lock(), - #[cfg(feature = "serial_debug")] serial: COM1.lock(), } } @@ -38,11 +36,8 @@ impl<'a> Writer<'a> { let _ = display.write(buf); } - #[cfg(feature = "serial_debug")] - { - if let Some(ref mut serial) = *self.serial { - serial.write(buf); - } + if let Some(ref mut serial) = *self.serial { + serial.write(buf); } } } diff --git a/src/arch/riscv64/start.rs b/src/arch/riscv64/start.rs index 46d8ce6797..88f2b5925b 100644 --- a/src/arch/riscv64/start.rs +++ b/src/arch/riscv64/start.rs @@ -101,7 +101,6 @@ pub unsafe extern "C" fn kstart(args_ptr: *const KernelArgs) -> ! { graphical_debug::init(env); - #[cfg(feature = "serial_debug")] if let Some(dtb) = &dtb { init_early(dtb); } diff --git a/src/arch/x86_shared/debug.rs b/src/arch/x86_shared/debug.rs index 513d65e7e5..fa7d6ef809 100644 --- a/src/arch/x86_shared/debug.rs +++ b/src/arch/x86_shared/debug.rs @@ -3,7 +3,6 @@ use core::fmt; use spin::Mutex; use spin::MutexGuard; -#[cfg(feature = "serial_debug")] use crate::devices::serial::SerialKind; #[cfg(feature = "lpss_debug")] use crate::devices::uart_16550::SerialPort; @@ -18,7 +17,6 @@ use crate::{ #[cfg(feature = "qemu_debug")] use syscall::io::Io; -#[cfg(feature = "serial_debug")] use super::device::serial::COM1; #[cfg(feature = "lpss_debug")] use super::device::serial::LPSS; @@ -35,7 +33,6 @@ pub struct Writer<'a> { lpss: MutexGuard<'a, Option>, #[cfg(feature = "qemu_debug")] qemu: MutexGuard<'a, Pio>, - #[cfg(feature = "serial_debug")] serial: MutexGuard<'a, Option>, #[cfg(feature = "system76_ec_debug")] system76_ec: MutexGuard<'a, Option>, @@ -50,7 +47,6 @@ impl<'a> Writer<'a> { lpss: LPSS.lock(), #[cfg(feature = "qemu_debug")] qemu: QEMU.lock(), - #[cfg(feature = "serial_debug")] serial: COM1.lock(), #[cfg(feature = "system76_ec_debug")] system76_ec: SYSTEM76_EC.lock(), @@ -82,7 +78,6 @@ impl<'a> Writer<'a> { } } - #[cfg(feature = "serial_debug")] if let Some(serial) = &mut *self.serial { serial.write(buf) } diff --git a/src/arch/x86_shared/device/serial.rs b/src/arch/x86_shared/device/serial.rs index 64e074f09d..5608784f9c 100644 --- a/src/arch/x86_shared/device/serial.rs +++ b/src/arch/x86_shared/device/serial.rs @@ -13,6 +13,11 @@ pub static COM2: Mutex> = Mutex::new(None); pub static LPSS: Mutex> = Mutex::new(None); pub unsafe fn init() { + if cfg!(not(feature = "serial_debug")) { + // FIXME remove serial_debug feature once ACPI SPCR is respected on UEFI boots. + return; + } + let mut com1 = SerialPort::>::new(0x3F8); com1.init(); *COM1.lock() = Some(SerialKind::Ns16550Pio(com1)); @@ -20,6 +25,7 @@ pub unsafe fn init() { com2.init(); *COM2.lock() = Some(SerialKind::Ns16550Pio(com2)); + // FIXME remove explicit LPSS handling once ACPI SPCR is supported #[cfg(feature = "lpss_debug")] { // TODO: Make this configurable diff --git a/src/arch/x86_shared/start.rs b/src/arch/x86_shared/start.rs index 2f5eee9b2f..60b0256816 100644 --- a/src/arch/x86_shared/start.rs +++ b/src/arch/x86_shared/start.rs @@ -87,7 +87,6 @@ pub unsafe extern "C" fn kstart(args_ptr: *const KernelArgs) -> ! { ); // Set up serial debug - #[cfg(feature = "serial_debug")] device::serial::init(); // Set up graphical debug