From feda905c3f13643adc352b3eef8bd3503bab69c4 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Fri, 12 Mar 2021 13:57:56 +0100 Subject: [PATCH] Kernel: Convert klog() => AK::Format in PCI --- Kernel/PCI/Access.cpp | 4 +--- Kernel/PCI/IOAccess.cpp | 2 +- Kernel/PCI/Initializer.cpp | 8 ++++---- Kernel/PCI/MMIOAccess.cpp | 17 ++++++----------- 4 files changed, 12 insertions(+), 19 deletions(-) diff --git a/Kernel/PCI/Access.cpp b/Kernel/PCI/Access.cpp index 8cdf758771..6197e6a7f1 100644 --- a/Kernel/PCI/Access.cpp +++ b/Kernel/PCI/Access.cpp @@ -107,9 +107,7 @@ void Access::enumerate_functions(int type, u8 bus, u8 device, u8 function, Funct callback(address, { early_read16_field(address, PCI_VENDOR_ID), early_read16_field(address, PCI_DEVICE_ID) }); if (early_read_type(address) == PCI_TYPE_BRIDGE && recursive) { u8 secondary_bus = early_read8_field(address, PCI_SECONDARY_BUS); -#if PCI_DEBUG - klog() << "PCI: Found secondary bus: " << secondary_bus; -#endif + dbgln_if(PCI_DEBUG, "PCI: Found secondary bus: {}", secondary_bus); VERIFY(secondary_bus != bus); enumerate_bus(type, secondary_bus, callback, recursive); } diff --git a/Kernel/PCI/IOAccess.cpp b/Kernel/PCI/IOAccess.cpp index b61f8cd86c..b327ca6f6b 100644 --- a/Kernel/PCI/IOAccess.cpp +++ b/Kernel/PCI/IOAccess.cpp @@ -41,7 +41,7 @@ UNMAP_AFTER_INIT void IOAccess::initialize() UNMAP_AFTER_INIT IOAccess::IOAccess() { - klog() << "PCI: Using I/O instructions for PCI configuration space access"; + dmesgln("PCI: Using I/O instructions for PCI configuration space access"); enumerate_hardware([&](const Address& address, ID id) { m_physical_ids.append({ address, id, get_capabilities(address) }); }); diff --git a/Kernel/PCI/Initializer.cpp b/Kernel/PCI/Initializer.cpp index ac33d6161a..d010c5fd09 100644 --- a/Kernel/PCI/Initializer.cpp +++ b/Kernel/PCI/Initializer.cpp @@ -57,22 +57,22 @@ UNMAP_AFTER_INIT void initialize() else IOAccess::initialize(); PCI::enumerate([&](const Address& address, ID id) { - klog() << address << " " << id; + dmesgln("{} {}", address, id); }); } UNMAP_AFTER_INIT bool test_pci_io() { - klog() << "Testing PCI via manual probing... "; + dmesgln("Testing PCI via manual probing..."); u32 tmp = 0x80000000; IO::out32(PCI_ADDRESS_PORT, tmp); tmp = IO::in32(PCI_ADDRESS_PORT); if (tmp == 0x80000000) { - klog() << "PCI IO Supported!"; + dmesgln("PCI IO supported"); return true; } - klog() << "PCI IO Not Supported!"; + dmesgln("PCI IO not supported"); return false; } diff --git a/Kernel/PCI/MMIOAccess.cpp b/Kernel/PCI/MMIOAccess.cpp index 9580a080c6..702f85aa87 100644 --- a/Kernel/PCI/MMIOAccess.cpp +++ b/Kernel/PCI/MMIOAccess.cpp @@ -83,27 +83,22 @@ UNMAP_AFTER_INIT void MMIOAccess::initialize(PhysicalAddress mcfg) { if (!Access::is_initialized()) { new MMIOAccess(mcfg); -#if PCI_DEBUG - dbgln("PCI: MMIO access initialised."); -#endif + dbgln_if(PCI_DEBUG, "PCI: MMIO access initialised."); } } UNMAP_AFTER_INIT MMIOAccess::MMIOAccess(PhysicalAddress p_mcfg) : m_mcfg(p_mcfg) { - klog() << "PCI: Using MMIO for PCI configuration space access"; + dmesgln("PCI: Using MMIO for PCI configuration space access"); auto checkup_region = MM.allocate_kernel_region(p_mcfg.page_base(), (PAGE_SIZE * 2), "PCI MCFG Checkup", Region::Access::Read | Region::Access::Write); -#if PCI_DEBUG - dbgln("PCI: Checking MCFG Table length to choose the correct mapping size"); -#endif - + dbgln_if(PCI_DEBUG, "PCI: Checking MCFG Table length to choose the correct mapping size"); auto* sdt = (ACPI::Structures::SDTHeader*)checkup_region->vaddr().offset(p_mcfg.offset_in_page()).as_ptr(); u32 length = sdt->length; u8 revision = sdt->revision; - klog() << "PCI: MCFG, length - " << length << ", revision " << revision; + dbgln("PCI: MCFG, length: {}, revision: {}", length, revision); checkup_region->unmap(); auto mcfg_region = MM.allocate_kernel_region(p_mcfg.page_base(), page_round_up(length) + PAGE_SIZE, "PCI Parsing MCFG", Region::Access::Read | Region::Access::Write); @@ -117,10 +112,10 @@ UNMAP_AFTER_INIT MMIOAccess::MMIOAccess(PhysicalAddress p_mcfg) u32 lower_addr = mcfg.descriptors[index].base_addr; m_segments.set(index, { PhysicalAddress(lower_addr), start_bus, end_bus }); - klog() << "PCI: New PCI segment @ " << PhysicalAddress(lower_addr) << ", PCI buses (" << start_bus << "-" << end_bus << ")"; + dmesgln("PCI: New PCI segment @ {}, PCI buses ({}-{})", PhysicalAddress { lower_addr }, start_bus, end_bus); } mcfg_region->unmap(); - klog() << "PCI: MMIO segments - " << m_segments.size(); + dmesgln("PCI: MMIO segments: {}", m_segments.size()); InterruptDisabler disabler;