From 3989477669b025cb989977c4d167f14c5fd19df8 Mon Sep 17 00:00:00 2001 From: 4lDO2 <4lDO2@protonmail.com> Date: Thu, 11 Mar 2021 17:50:17 +0100 Subject: [PATCH] Also open a file descriptor in `debug:`. This is to allow the shutdown logs to reach serial output before the system shuts down, which is especially useful on QEMU. --- acpid/src/acpi.rs | 2 ++ acpid/src/aml/namespace.rs | 3 +++ acpid/src/main.rs | 8 ++++++++ 3 files changed, 13 insertions(+) diff --git a/acpid/src/acpi.rs b/acpid/src/acpi.rs index 4d08cfe919..7e24025997 100644 --- a/acpid/src/acpi.rs +++ b/acpid/src/acpi.rs @@ -393,6 +393,7 @@ pub struct FadtAcpi2Struct { } unsafe impl plain::Plain for FadtAcpi2Struct {} +#[derive(Clone)] pub struct Fadt(Sdt); impl Fadt { @@ -456,6 +457,7 @@ impl Fadt { } }; + context.fadt = Some(fadt.clone()); context.dsdt = Some(Dsdt(dsdt_sdt.clone())); context.tables.push(dsdt_sdt); diff --git a/acpid/src/aml/namespace.rs b/acpid/src/aml/namespace.rs index 600a253a56..4dfd18516f 100644 --- a/acpid/src/aml/namespace.rs +++ b/acpid/src/aml/namespace.rs @@ -129,7 +129,10 @@ pub enum AmlValue { String(String), PowerResource(PowerResource), Processor(Processor), + + #[allow(dead_code)] RawDataBuffer(Vec), + ThermalZone(ThermalZone) } diff --git a/acpid/src/main.rs b/acpid/src/main.rs index 83ea52b090..bc1e10afc5 100644 --- a/acpid/src/main.rs +++ b/acpid/src/main.rs @@ -36,6 +36,7 @@ fn monotonic() -> (u64, u64) { fn setup_logging() -> Option<&'static RedoxLogger> { use redox_log::OutputBuilder; + #[allow(unused_mut)] let mut logger = RedoxLogger::new() .with_output( OutputBuilder::stderr() @@ -45,6 +46,12 @@ fn setup_logging() -> Option<&'static RedoxLogger> { .build() ); + #[cfg(target_os = "redox")] + match File::open("debug:") { + Ok(d) => logger = logger.with_output(OutputBuilder::with_endpoint(d).flush_on_newline(true).with_filter(log::LevelFilter::Info).build()), + Err(error) => eprintln!("Failed to open `debug:` scheme: {}", error), + } + #[cfg(target_os = "redox")] match OutputBuilder::in_redox_logging_scheme("misc", "acpi", "acpid.log") { Ok(b) => logger = logger.with_output( @@ -231,6 +238,7 @@ fn main() { let _ = event_queue.read(&mut event).expect("acpid: failed to read from event queue"); if event.flags.contains(EventFlags::EVENT_READ) && event.id == shutdown_pipe.as_raw_fd() as usize { + log::info!("Received shutdown request from kernel."); break 'events; } if !event.flags.contains(EventFlags::EVENT_READ) || event.id != scheme_socket.as_raw_fd() as usize {