1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 16:17:45 +00:00

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.
This commit is contained in:
Evan Smal 2022-12-28 17:55:04 -05:00 committed by Jelle Raaijmakers
parent 6a5be5f1c5
commit 288a73ea0e
24 changed files with 90 additions and 52 deletions

View file

@ -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);
}
}

View file

@ -75,9 +75,9 @@ ErrorOr<NonnullLockRefPtr<UHCIController>> UHCIController::try_to_initialize(PCI
ErrorOr<void> UHCIController::initialize()
{
dmesgln("UHCI: Controller found {} @ {}", PCI::get_hardware_id(pci_address()), pci_address());
dmesgln("UHCI: I/O base {}", m_registers_io_window);
dmesgln("UHCI: Interrupt line: {}", interrupt_number());
dmesgln_pci(*this, "Controller found {} @ {}", PCI::get_hardware_id(pci_address()), pci_address());
dmesgln_pci(*this, "I/O base {}", m_registers_io_window);
dmesgln_pci(*this, "Interrupt line: {}", interrupt_number());
TRY(spawn_async_poll_process());
TRY(spawn_port_process());

View file

@ -38,6 +38,7 @@ public:
virtual ~UHCIController() override;
virtual StringView purpose() const override { return "UHCI"sv; }
virtual StringView device_name() const override { return purpose(); }
virtual ErrorOr<void> initialize() override;
virtual ErrorOr<void> reset() override;

View file

@ -22,6 +22,7 @@ public:
virtual ~Console() override = default;
virtual StringView purpose() const override { return class_name(); }
virtual StringView device_name() const override { return class_name(); }
unsigned device_id() const
{

View file

@ -21,6 +21,7 @@ class RNG final
public:
static NonnullLockRefPtr<RNG> must_create(PCI::DeviceIdentifier const&);
virtual StringView purpose() const override { return class_name(); }
virtual StringView device_name() const override { return class_name(); }
virtual ~RNG() override = default;
virtual void initialize() override;