From c67fc7b099186c4f67bf3cb820443beff33f3639 Mon Sep 17 00:00:00 2001 From: Wildan Mubarok Date: Thu, 31 Jul 2025 03:22:52 +0000 Subject: [PATCH] Backfill aarch64 serial log --- src/acpi/spcr.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/acpi/spcr.rs b/src/acpi/spcr.rs index 51cf179352..f65dcd6da5 100644 --- a/src/acpi/spcr.rs +++ b/src/acpi/spcr.rs @@ -6,6 +6,7 @@ use crate::{ serial::{SerialKind, COM1}, uart_pl011, }, + log::LOG, memory::{map_device_memory, PhysicalAddress, PAGE_SIZE}, }; @@ -62,6 +63,7 @@ impl Spcr { return; } + let serial_was_empty = !COM1.lock().is_some(); if spcr.header.revision >= 2 { match spcr.interface_type { 3 => { @@ -105,6 +107,18 @@ impl Spcr { } else { log::warn!("SPCR unsupported revision {}", spcr.header.revision); } + if serial_was_empty && let Some(ref mut serial_port) = *COM1.lock() { + // backfill logs since the heap is loaded + if let Some(ref mut early_log) = *LOG.lock() { + let (s1, s2) = early_log.read(); + if !s1.is_empty() { + serial_port.write(s1); + } + if !s2.is_empty() { + serial_port.write(s2); + } + } + } } pub fn new(sdt: &'static Sdt) -> Option<&'static Spcr> {