From 91b835d29fae864c5b073e550f33ffcb738bb469 Mon Sep 17 00:00:00 2001 From: Jeremy Soller Date: Sat, 1 Nov 2025 20:24:11 -0600 Subject: [PATCH] Reduce logging significantly --- src/acpi/hpet.rs | 2 +- src/acpi/madt/arch/aarch64.rs | 2 +- src/acpi/madt/arch/other.rs | 2 +- src/acpi/madt/arch/x86.rs | 20 ++++---------------- src/acpi/madt/mod.rs | 2 +- src/acpi/mod.rs | 11 +++-------- src/arch/x86_64/alternative.rs | 2 +- src/arch/x86_shared/device/hpet.rs | 2 +- src/arch/x86_shared/device/local_apic.rs | 4 ++-- src/arch/x86_shared/device/mod.rs | 10 +++++----- src/arch/x86_shared/device/tsc.rs | 2 +- src/main.rs | 4 ++-- src/memory/mod.rs | 2 +- src/startup/mod.rs | 10 +++++----- src/syscall/process.rs | 2 +- 15 files changed, 30 insertions(+), 47 deletions(-) diff --git a/src/acpi/hpet.rs b/src/acpi/hpet.rs index 50446eea12..0d1a4b7b0f 100644 --- a/src/acpi/hpet.rs +++ b/src/acpi/hpet.rs @@ -30,7 +30,7 @@ impl Hpet { let hpet = Hpet::new(find_one_sdt!("HPET")); if let Some(hpet) = hpet { - println!(" HPET: {:X}", hpet.hpet_number); + debug!(" HPET: {:X}", hpet.hpet_number); let mut hpet_t = ACPI_TABLE.hpet.write(); *hpet_t = Some(hpet); diff --git a/src/acpi/madt/arch/aarch64.rs b/src/acpi/madt/arch/aarch64.rs index ecf0bd3666..4222cc9f26 100644 --- a/src/acpi/madt/arch/aarch64.rs +++ b/src/acpi/madt/arch/aarch64.rs @@ -14,7 +14,7 @@ pub(super) fn init(madt: Madt) { let mut gicd_opt = None; let mut giccs = Vec::new(); for madt_entry in madt.iter() { - println!(" {:#x?}", madt_entry); + debug!(" {:#x?}", madt_entry); match madt_entry { MadtEntry::Gicc(gicc) => { giccs.push(gicc); diff --git a/src/acpi/madt/arch/other.rs b/src/acpi/madt/arch/other.rs index 09a4a2df14..6400e09afb 100644 --- a/src/acpi/madt/arch/other.rs +++ b/src/acpi/madt/arch/other.rs @@ -2,7 +2,7 @@ use super::Madt; pub(super) fn init(madt: Madt) { for madt_entry in madt.iter() { - println!(" {:#x?}", madt_entry); + debug!(" {:#x?}", madt_entry); } warn!("MADT not yet handled on this platform"); diff --git a/src/acpi/madt/arch/x86.rs b/src/acpi/madt/arch/x86.rs index 9cdb550521..63ba505476 100644 --- a/src/acpi/madt/arch/x86.rs +++ b/src/acpi/madt/arch/x86.rs @@ -22,9 +22,9 @@ pub(super) fn init(madt: Madt) { let me = local_apic.id(); if local_apic.x2 { - println!(" X2APIC {}", me.get()); + debug!(" X2APIC {}", me.get()); } else { - println!(" XAPIC {}: {:>08X}", me.get(), local_apic.address); + debug!(" XAPIC {}: {:>08X}", me.get(), local_apic.address); } if cfg!(not(feature = "multi_core")) { @@ -62,10 +62,10 @@ pub(super) fn init(madt: Madt) { } for madt_entry in madt.iter() { - println!(" {:x?}", madt_entry); + debug!(" {:x?}", madt_entry); if let MadtEntry::LocalApic(ap_local_apic) = madt_entry { if u32::from(ap_local_apic.id) == me.get() { - println!(" This is my local APIC"); + debug!(" This is my local APIC"); } else if ap_local_apic.flags & 1 == 1 { let cpu_id = LogicalCpuId::next(); @@ -105,11 +105,6 @@ pub(super) fn init(madt: Madt) { }; AP_READY.store(false, Ordering::SeqCst); - print!( - " AP {} APIC {}:", - ap_local_apic.processor, ap_local_apic.id - ); - // Send INIT IPI { let mut icr = 0x4500; @@ -118,7 +113,6 @@ pub(super) fn init(madt: Madt) { } else { icr |= u64::from(ap_local_apic.id) << 56; } - print!(" IPI..."); local_apic.set_icr(icr); } @@ -133,26 +127,20 @@ pub(super) fn init(madt: Madt) { icr |= u64::from(ap_local_apic.id) << 56; } - print!(" SIPI..."); local_apic.set_icr(icr); } // Wait for trampoline ready - print!(" Wait..."); while unsafe { (*ap_ready.cast::()).load(Ordering::SeqCst) } == 0 { hint::spin_loop(); } - print!(" Trampoline..."); while !AP_READY.load(Ordering::SeqCst) { hint::spin_loop(); } - println!(" Ready"); unsafe { RmmA::invalidate_all(); } - } else { - println!(" CPU Disabled"); } } } diff --git a/src/acpi/madt/mod.rs b/src/acpi/madt/mod.rs index aa1ed192e9..052eaefd5d 100644 --- a/src/acpi/madt/mod.rs +++ b/src/acpi/madt/mod.rs @@ -37,7 +37,7 @@ impl Madt { // safe because no APs have been started yet. unsafe { MADT.get().write(Some(madt)) }; - println!(" APIC: {:>08X}: {}", madt.local_address, madt.flags); + debug!(" APIC: {:>08X}: {}", madt.local_address, madt.flags); arch::init(madt); } diff --git a/src/acpi/mod.rs b/src/acpi/mod.rs index 30638e005f..bbd5121720 100644 --- a/src/acpi/mod.rs +++ b/src/acpi/mod.rs @@ -103,14 +103,9 @@ pub unsafe fn init(already_supplied_rsdp: Option<*const u8>) { let rsdp_opt = Rsdp::get_rsdp(&mut KernelMapper::lock(), already_supplied_rsdp); if let Some(rsdp) = rsdp_opt { - info!("SDT address: {:#x}", rsdp.sdt_address()); + debug!("SDT address: {:#x}", rsdp.sdt_address()); let rxsdt = get_sdt(rsdp.sdt_address(), &mut KernelMapper::lock()); - for &c in rxsdt.signature.iter() { - print!("{}", c as char); - } - println!(":"); - let rxsdt = if let Some(rsdt) = Rsdt::new(rxsdt) { let mut initialized = false; @@ -139,7 +134,7 @@ pub unsafe fn init(already_supplied_rsdp: Option<*const u8>) { xsdt } else { - println!("UNKNOWN RSDT OR XSDT SIGNATURE"); + warn!("UNKNOWN RSDT OR XSDT SIGNATURE"); return; }; @@ -170,7 +165,7 @@ pub unsafe fn init(already_supplied_rsdp: Option<*const u8>) { #[cfg(target_arch = "aarch64")] gtdt::Gtdt::init(); } else { - println!("NO RSDP FOUND"); + error!("NO RSDP FOUND"); } } } diff --git a/src/arch/x86_64/alternative.rs b/src/arch/x86_64/alternative.rs index 2769d9891b..b1683f524c 100644 --- a/src/arch/x86_64/alternative.rs +++ b/src/arch/x86_64/alternative.rs @@ -147,7 +147,7 @@ unsafe fn overwrite(relocs: &[AltReloc], enable: KcpuFeatures) { return; } - info!("self-modifying features: {:?}", enable); + debug!("self-modifying features: {:?}", enable); let mut mapper = KernelMapper::lock(); for reloc in relocs.iter().copied() { diff --git a/src/arch/x86_shared/device/hpet.rs b/src/arch/x86_shared/device/hpet.rs index d8b787cd1d..62a2f69fb7 100644 --- a/src/arch/x86_shared/device/hpet.rs +++ b/src/arch/x86_shared/device/hpet.rs @@ -24,7 +24,7 @@ const PER_INT_CAP: u64 = 0x10; pub unsafe fn init(hpet: &mut Hpet) -> bool { unsafe { - info!("HPET @ {:#x}", { hpet.base_address.address }); + debug!("HPET @ {:#x}", { hpet.base_address.address }); debug_caps(hpet); trace!("HPET Before Init"); diff --git a/src/arch/x86_shared/device/local_apic.rs b/src/arch/x86_shared/device/local_apic.rs index f4b1269d70..87e602b65b 100644 --- a/src/arch/x86_shared/device/local_apic.rs +++ b/src/arch/x86_shared/device/local_apic.rs @@ -73,7 +73,7 @@ impl LocalApic { .is_some_and(|feature_info| feature_info.has_x2apic()); if !self.x2 { - info!("Detected xAPIC at {:#x}", physaddr.data()); + debug!("Detected xAPIC at {:#x}", physaddr.data()); if let Some((_entry, _, flush)) = mapper.unmap_phys(virtaddr, true) { // Unmap xAPIC page if already mapped flush.flush(); @@ -83,7 +83,7 @@ impl LocalApic { .expect("failed to map local APIC memory") .flush(); } else { - info!("Detected x2APIC"); + debug!("Detected x2APIC"); } self.init_ap(); diff --git a/src/arch/x86_shared/device/mod.rs b/src/arch/x86_shared/device/mod.rs index 0f3446c3d8..a99f513a88 100644 --- a/src/arch/x86_shared/device/mod.rs +++ b/src/arch/x86_shared/device/mod.rs @@ -54,21 +54,21 @@ unsafe fn init_hpet() -> bool { pub unsafe fn init_noncore() { unsafe { - info!("Initializing system timer"); + debug!("Initializing system timer"); #[cfg(feature = "x86_kvm_pv")] if tsc::init() { - info!("TSC used as system clock source"); + debug!("TSC used as system clock source"); } if init_hpet() { - info!("HPET used as system timer"); + debug!("HPET used as system timer"); } else { pit::init(); - info!("PIT used as system timer"); + debug!("PIT used as system timer"); } - info!("Finished initializing devices"); + debug!("Finished initializing devices"); } } diff --git a/src/arch/x86_shared/device/tsc.rs b/src/arch/x86_shared/device/tsc.rs index 1b6717c890..26fda60739 100644 --- a/src/arch/x86_shared/device/tsc.rs +++ b/src/arch/x86_shared/device/tsc.rs @@ -111,7 +111,7 @@ pub fn get_kvm_support() -> &'static Option { let supp_feats = KvmFeatureBits::from_bits_retain(res.eax); - info!("Detected KVM paravirtualization support, features {supp_feats:?}"); + debug!("Detected KVM paravirtualization support, features {supp_feats:?}"); Some(KvmSupport { max_leaf, diff --git a/src/main.rs b/src/main.rs index c2e4adcb30..78f58d0dba 100644 --- a/src/main.rs +++ b/src/main.rs @@ -184,8 +184,8 @@ fn kmain(bootstrap: Bootstrap) -> ! { //Initialize global schemes, such as `acpi:`. scheme::init_globals(); - info!("BSP: {}", cpu_count()); - info!("Env: {:?}", ::core::str::from_utf8(bootstrap.env)); + info!("BSP: {} CPUs", cpu_count()); + debug!("Env: {:?}", ::core::str::from_utf8(bootstrap.env)); BOOTSTRAP.call_once(|| bootstrap); diff --git a/src/memory/mod.rs b/src/memory/mod.rs index 0d15acd22c..379d4e4f6a 100644 --- a/src/memory/mod.rs +++ b/src/memory/mod.rs @@ -735,7 +735,7 @@ fn init_sections(mut allocator: BumpAllocator) { FREELIST.lock().for_orders = first_pages.map(|pair| pair.map(|(frame, _)| frame)); //debug_freelist(); - info!("Initial freelist consistent"); + debug!("Initial freelist consistent"); } #[cold] diff --git a/src/startup/mod.rs b/src/startup/mod.rs index 1499ddde94..7b1c2e96cb 100644 --- a/src/startup/mod.rs +++ b/src/startup/mod.rs @@ -35,27 +35,27 @@ pub(crate) struct KernelArgs { impl KernelArgs { pub(crate) fn print(&self) { - info!( + debug!( "Kernel: {:X}:{:X}", { self.kernel_base }, self.kernel_base + self.kernel_size ); - info!( + debug!( "Env: {:X}:{:X}", { self.env_base }, self.env_base + self.env_size ); - info!( + debug!( "HWDESC: {:X}:{:X}", { self.hwdesc_base }, self.hwdesc_base + self.hwdesc_size ); - info!( + debug!( "Areas: {:X}:{:X}", { self.areas_base }, self.areas_base + self.areas_size ); - info!( + debug!( "Bootstrap: {:X}:{:X}", { self.bootstrap_base }, self.bootstrap_base + self.bootstrap_size diff --git a/src/syscall/process.rs b/src/syscall/process.rs index 0d222556e3..52b8a11bf4 100644 --- a/src/syscall/process.rs +++ b/src/syscall/process.rs @@ -123,7 +123,7 @@ pub unsafe fn usermode_bootstrap(bootstrap: &Bootstrap, token: &mut CleanLockTok .expect("failed to copy memory to bootstrap"); let bootstrap_entry = u64::from_le_bytes(bootstrap_slice[0x1a..0x22].try_into().unwrap()); - info!("Bootstrap entry point: {:X}", bootstrap_entry); + debug!("Bootstrap entry point: {:X}", bootstrap_entry); assert_ne!(bootstrap_entry, 0); println!("\n");