Unconditionally enable serial_debug on arm64 and riscv64

This commit is contained in:
bjorn3
2025-09-12 18:59:48 +02:00
parent 520453f779
commit 8aa08e1e3d
6 changed files with 20 additions and 32 deletions
+7 -13
View File
@@ -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<Log>>,
display: MutexGuard<'a, Option<DebugDisplay>>,
#[cfg(feature = "serial_debug")]
serial: MutexGuard<'a, Option<SerialKind>>,
}
@@ -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);
}
}
}
+7 -12
View File
@@ -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<Log>>,
#[cfg(feature = "serial_debug")]
serial: MutexGuard<'a, Option<SerialKind>>,
display: MutexGuard<'a, Option<DebugDisplay>>,
}
@@ -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);
}
}
}
-1
View File
@@ -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);
}
-5
View File
@@ -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<SerialKind>>,
#[cfg(feature = "qemu_debug")]
qemu: MutexGuard<'a, Pio<u8>>,
#[cfg(feature = "serial_debug")]
serial: MutexGuard<'a, Option<SerialKind>>,
#[cfg(feature = "system76_ec_debug")]
system76_ec: MutexGuard<'a, Option<System76Ec>>,
@@ -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)
}
+6
View File
@@ -13,6 +13,11 @@ pub static COM2: Mutex<Option<SerialKind>> = Mutex::new(None);
pub static LPSS: Mutex<Option<SerialKind>> = 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::<Pio<u8>>::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
-1
View File
@@ -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