diff options
author | Evan Smal <evan.smal@hotmail.com> | 2022-12-28 17:55:04 -0500 |
---|---|---|
committer | Jelle Raaijmakers <jelle@gmta.nl> | 2023-01-05 01:44:19 +0100 |
commit | 288a73ea0e21ab1f98dba68e6b71d37da87b5591 (patch) | |
tree | 5d0d6e511155b5e23face6f3440a1a8aaec75f19 /Kernel/Bus/PCI | |
parent | 6a5be5f1c555fa880822d988e52058b50a3eea84 (diff) | |
download | serenity-288a73ea0e21ab1f98dba68e6b71d37da87b5591.zip |
Kernel: Add dmesgln_pci logging for Kernel::PCI
A virtual method named device_name() was added to
Kernel::PCI to support logging the PCI::Device name
and address using dmesgln_pci. Previously, PCI::Device
did not store the device name.
All devices inheriting from PCI::Device now use dmesgln_pci where
they previously used dmesgln.
Diffstat (limited to 'Kernel/Bus/PCI')
-rw-r--r-- | Kernel/Bus/PCI/Device.h | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/Kernel/Bus/PCI/Device.h b/Kernel/Bus/PCI/Device.h index f167e192e1..9c1d1fa92e 100644 --- a/Kernel/Bus/PCI/Device.h +++ b/Kernel/Bus/PCI/Device.h @@ -6,6 +6,8 @@ #pragma once +#include <AK/Format.h> +#include <AK/StringBuilder.h> #include <AK/Types.h> #include <Kernel/Bus/PCI/Definitions.h> @@ -16,6 +18,9 @@ public: Address pci_address() const { return m_pci_address; }; virtual ~Device() = default; + + virtual StringView device_name() const = 0; + void enable_pin_based_interrupts() const; void disable_pin_based_interrupts() const; @@ -35,4 +40,16 @@ private: Address m_pci_address; }; +template<typename... Parameters> +void dmesgln_pci(Device const& device, AK::CheckedFormatString<Parameters...>&& fmt, Parameters const&... parameters) +{ + AK::StringBuilder builder; + if (builder.try_append("{}: {}: "sv).is_error()) + return; + if (builder.try_append(fmt.view()).is_error()) + return; + AK::VariadicFormatParams variadic_format_params { device.device_name(), device.pci_address(), parameters... }; + vdmesgln(builder.string_view(), variadic_format_params); +} + } |